mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Remove unused code
This commit is contained in:
parent
11d4e8cfdb
commit
22232e378c
@ -41,9 +41,6 @@ import static org.kiwix.kiwixmobile.utils.StandardActions.enterHelp;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class DownloadTest {
|
||||
|
||||
@Inject KiwixIdlingResource kiwixIdlingResource;
|
||||
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<SplashActivity> mActivityTestRule = new ActivityTestRule<>(
|
||||
SplashActivity.class);
|
||||
|
@ -56,7 +56,6 @@ import static org.kiwix.kiwixmobile.utils.StandardActions.enterHelp;
|
||||
|
||||
public class NetworkTest {
|
||||
|
||||
@Inject OkHttpClient okHttpClient;
|
||||
@Inject MockWebServer mockWebServer;
|
||||
|
||||
|
||||
|
@ -154,23 +154,6 @@ public class ZimContentProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getArticleCount() {
|
||||
if (jniKiwix == null || zimFileName == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return jniKiwix.getArticleCount();
|
||||
|
||||
}
|
||||
}
|
||||
public static int getMediaCount() {
|
||||
if (jniKiwix == null || zimFileName == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return jniKiwix.getMediaCount();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCreator() {
|
||||
if (jniKiwix == null || zimFileName == null) {
|
||||
return null;
|
||||
@ -443,8 +426,6 @@ public class ZimContentProvider extends ContentProvider {
|
||||
|
||||
static class TransferThread extends Thread {
|
||||
|
||||
Uri articleUri;
|
||||
|
||||
String articleZimUrl;
|
||||
|
||||
OutputStream out;
|
||||
@ -452,7 +433,6 @@ public class ZimContentProvider extends ContentProvider {
|
||||
JNIKiwix jniKiwix;
|
||||
|
||||
TransferThread(JNIKiwix jniKiwix, Uri articleUri, OutputStream out) throws IOException {
|
||||
this.articleUri = articleUri;
|
||||
this.jniKiwix = jniKiwix;
|
||||
Log.d(TAG_KIWIX, "Retrieving: " + articleUri.toString());
|
||||
|
||||
|
@ -183,13 +183,6 @@ public class BookmarksActivity extends BaseActivity
|
||||
setNoBookmarksState();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateAdapter() {
|
||||
adapter.notifyDataSetChanged();
|
||||
setNoBookmarksState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popDeleteBookmarksSnackbar() {
|
||||
Snackbar bookmarkDeleteSnackbar =
|
||||
|
@ -11,7 +11,5 @@ import java.util.ArrayList;
|
||||
public interface BookmarksViewCallback extends ViewCallback {
|
||||
void showBookmarks(ArrayList<String> bookmarks, ArrayList<String> bookmarkUrls);
|
||||
|
||||
void updateAdapter();
|
||||
|
||||
void popDeleteBookmarksSnackbar();
|
||||
}
|
||||
|
@ -77,9 +77,4 @@ public class BookmarksDao {
|
||||
mDb.deleteWhere(Bookmarks.class, Bookmarks.BOOKMARK_URL.eq(favArticle).and(Bookmarks.ZIM_ID.eq(ZimId).or(Bookmarks.ZIM_NAME.eq(ZimName))) );
|
||||
}
|
||||
|
||||
|
||||
public void deleteAll(){
|
||||
mDb.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -268,17 +268,6 @@ public class DownloadFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Download {
|
||||
public String title;
|
||||
public int progress;
|
||||
|
||||
public Download(String title) {
|
||||
this.title = title;
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addDownload(int position, LibraryNetworkEntity.Book book, String fileName) {
|
||||
mDownloads.put(position, book);
|
||||
mDownloadFiles.put(position, fileName);
|
||||
|
@ -84,12 +84,8 @@ public class KiwixSettingsActivity extends AppCompatActivity {
|
||||
|
||||
public static final String PREF_NIGHTMODE = "pref_nightmode";
|
||||
|
||||
public static final String PREF_HIDETOOLBAR = "pref_hidetoolbar";
|
||||
|
||||
public static final String PREF_WIFI_ONLY = "pref_wifi_only";
|
||||
|
||||
public static String zimFile;
|
||||
|
||||
public static boolean allHistoryCleared = false;
|
||||
|
||||
|
||||
@ -107,7 +103,6 @@ public class KiwixSettingsActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.settings);
|
||||
|
||||
allHistoryCleared = false;
|
||||
zimFile = getIntent().getStringExtra("zim_file");
|
||||
|
||||
getFragmentManager()
|
||||
.beginTransaction().
|
||||
|
@ -36,18 +36,4 @@ public class DimenUtils {
|
||||
return DimenUtils.getToolbarHeight(context) +
|
||||
DimenUtils.getTranslucentStatusBarHeight(context);
|
||||
}
|
||||
|
||||
public static void resizeToolbar(Context context, Toolbar toolbar, ViewGroup toolbarContainer) {
|
||||
int statusBarHeight = DimenUtils.getTranslucentStatusBarHeight(context);
|
||||
|
||||
ViewGroup.LayoutParams toolbarContainerParams = toolbarContainer.getLayoutParams();
|
||||
toolbarContainerParams.height += statusBarHeight;
|
||||
toolbarContainer.setLayoutParams(toolbarContainerParams);
|
||||
|
||||
ViewGroup.LayoutParams toolbarParams = toolbar.getLayoutParams();
|
||||
toolbarParams.height += statusBarHeight;
|
||||
toolbar.setLayoutParams(toolbarParams);
|
||||
|
||||
toolbar.setPadding(0, statusBarHeight, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,6 @@ public class RateAppCounter {
|
||||
CounterEditor.apply();
|
||||
}
|
||||
|
||||
public SharedPreferences.Editor getEditor() {
|
||||
return visitCounter.edit();
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return visitCounter.getInt("count", 0);
|
||||
}
|
||||
|
@ -12,94 +12,9 @@ import java.util.UUID;
|
||||
|
||||
public class StorageUtils {
|
||||
|
||||
private static final String SDCARD_ROOT =
|
||||
Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
|
||||
public static final String FILE_ROOT = SDCARD_ROOT + "/kiwix/";
|
||||
|
||||
private static final long LOW_STORAGE_THRESHOLD = 1024 * 1024 * 10;
|
||||
|
||||
public static boolean isSdCardWritable() {
|
||||
return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
|
||||
}
|
||||
|
||||
public static long getAvailableStorage(File path) {
|
||||
|
||||
String storageDirectory;
|
||||
storageDirectory = path.getPath();
|
||||
try {
|
||||
StatFs stat = new StatFs(storageDirectory);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
return (stat.getAvailableBlocksLong() * stat.getBlockSizeLong());
|
||||
}
|
||||
return ((long) stat.getAvailableBlocks() * (long) stat.getBlockSize());
|
||||
} catch (RuntimeException ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkAvailableStorage(File path) {
|
||||
return getAvailableStorage(path) >= LOW_STORAGE_THRESHOLD;
|
||||
}
|
||||
|
||||
public static boolean isSDCardAvailable() {
|
||||
return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
|
||||
}
|
||||
|
||||
public static boolean createKiwixRootDir() throws IOException {
|
||||
File file = new File(FILE_ROOT);
|
||||
return (!file.exists() || !file.isDirectory()) && file.mkdir();
|
||||
}
|
||||
|
||||
public static String size(long size) {
|
||||
if (size / (1024 * 1024) > 0) {
|
||||
float tmpSize = (float) (size) / (float) (1024 * 1024);
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
return "" + df.format(tmpSize) + "MB";
|
||||
} else if (size / 1024 > 0) {
|
||||
return "" + (size / (1024)) + "KB";
|
||||
} else {
|
||||
return "" + size + "B";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean delete(File path) {
|
||||
boolean result = true;
|
||||
if (path.exists()) {
|
||||
if (path.isDirectory()) {
|
||||
for (File child : path.listFiles()) {
|
||||
result &= delete(child);
|
||||
}
|
||||
result &= path.delete(); // Delete empty directory.
|
||||
}
|
||||
if (path.isFile()) {
|
||||
result &= path.delete();
|
||||
}
|
||||
if (!result) {
|
||||
Log.e(null, "Delete failed;");
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
Log.e(null, "File does not exist.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFileNameFromUrl(String url) {
|
||||
|
||||
int index = url.lastIndexOf('?');
|
||||
String filename;
|
||||
if (index > 1) {
|
||||
filename = url.substring(url.lastIndexOf('/') + 1, index);
|
||||
} else {
|
||||
filename = url.substring(url.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
if ("".equals(filename.trim())) {
|
||||
filename = String.valueOf(UUID.randomUUID());
|
||||
}
|
||||
String filename = NetworkUtils.getFileNameFromUrl(url);
|
||||
filename = filename.replace(".meta4","");
|
||||
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
@ -62,10 +62,6 @@ public class AutoCompleteAdapter extends ArrayAdapter<String> implements Filtera
|
||||
} else return a;
|
||||
}
|
||||
|
||||
public String getItemRaw(int index) {
|
||||
return mData.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return mFilter;
|
||||
|
@ -50,8 +50,6 @@ public class CompatFindActionModeCallback
|
||||
|
||||
private InputMethodManager mInput;
|
||||
|
||||
private boolean mMatchesFound;
|
||||
|
||||
private ActionMode mActionMode;
|
||||
|
||||
public CompatFindActionModeCallback(Context context) {
|
||||
@ -87,7 +85,6 @@ public class CompatFindActionModeCallback
|
||||
// Necessary each time we set the text, so that this will watch
|
||||
// changes to it.
|
||||
span.setSpan(this, 0, length, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
mMatchesFound = false;
|
||||
}
|
||||
|
||||
// Set the WebView to search. Must be non null, and set before calling startActionMode.
|
||||
@ -119,10 +116,8 @@ public class CompatFindActionModeCallback
|
||||
CharSequence find = mEditText.getText();
|
||||
if (find.length() == 0) {
|
||||
mWebView.clearMatches();
|
||||
mMatchesFound = false;
|
||||
mWebView.findAll(null);
|
||||
} else {
|
||||
mMatchesFound = true;
|
||||
mWebView.findAll(find.toString());
|
||||
|
||||
// Enable word highlighting with reflection
|
||||
@ -164,7 +159,6 @@ public class CompatFindActionModeCallback
|
||||
mActionMode = mode;
|
||||
Editable edit = mEditText.getText();
|
||||
Selection.setSelection(edit, edit.length());
|
||||
mMatchesFound = false;
|
||||
mEditText.requestFocus();
|
||||
return true;
|
||||
}
|
||||
|
@ -92,10 +92,6 @@ public class SliderPreference extends DialogPreference {
|
||||
}
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return mSeekBarValue;
|
||||
}
|
||||
|
||||
public void setValue(float value) {
|
||||
if (shouldPersist()) {
|
||||
persistFloat(value);
|
||||
|
@ -60,8 +60,6 @@ public class ZimManageActivity extends AppCompatActivity {
|
||||
*/
|
||||
private ViewPager mViewPager;
|
||||
|
||||
public boolean downloading = false;
|
||||
|
||||
public Toolbar toolbar;
|
||||
|
||||
public MenuItem refeshItem;
|
||||
@ -159,15 +157,10 @@ public class ZimManageActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
public void displayDownloadInterface() {
|
||||
downloading = true;
|
||||
mSectionsPagerAdapter.notifyDataSetChanged();
|
||||
mViewPager.setCurrentItem(2);
|
||||
}
|
||||
|
||||
public void displayLocalTab() {
|
||||
mViewPager.setCurrentItem(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
int value = Settings.System.getInt(getContentResolver(), Settings.System.ALWAYS_FINISH_ACTIVITIES, 0);
|
||||
|
@ -158,11 +158,6 @@ public class ZimFileSelectFragment extends Fragment
|
||||
checkPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFilesAdapter() {
|
||||
|
||||
}
|
||||
|
||||
public void refreshFragment(){
|
||||
if (mZimFileList == null)
|
||||
return;
|
||||
|
@ -10,9 +10,4 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public interface ZimFileSelectViewCallback extends ViewCallback {
|
||||
void showFiles(ArrayList<LibraryNetworkEntity.Book> books);
|
||||
|
||||
void updateFilesAdapter();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -83,8 +83,6 @@ public class LibraryFragment extends Fragment
|
||||
|
||||
private boolean mBound;
|
||||
|
||||
private boolean active;
|
||||
|
||||
public LibraryAdapter libraryAdapter;
|
||||
|
||||
private DownloadServiceConnection mConnection = new DownloadServiceConnection();
|
||||
@ -148,7 +146,6 @@ public class LibraryFragment extends Fragment
|
||||
|
||||
@Override
|
||||
public void showBooks(LinkedList<Book> books) {
|
||||
active = true;
|
||||
libraryAdapter.setAllBooks(books);
|
||||
if (faActivity.searchView != null) {
|
||||
libraryAdapter.getFilter().filter(
|
||||
@ -196,7 +193,6 @@ public class LibraryFragment extends Fragment
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
active = false;
|
||||
if (mBound) {
|
||||
super.getActivity().unbindService(mConnection.downloadServiceInterface);
|
||||
mBound = false;
|
||||
@ -252,22 +248,6 @@ public class LibraryFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void mobileDownloadDialog(int position, AdapterView<?> parent) {
|
||||
new AlertDialog.Builder(super.getActivity(), dialogStyle())
|
||||
.setMessage(getString(R.string.download_over_network))
|
||||
.setPositiveButton(getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
downloadFile((Book) parent.getAdapter().getItem(position));
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadFile(Book book) {
|
||||
downloadingBooks.add(book);
|
||||
@ -311,7 +291,6 @@ public class LibraryFragment extends Fragment
|
||||
|
||||
public class DownloadServiceConnection {
|
||||
public DownloadServiceInterface downloadServiceInterface;
|
||||
public boolean bound;
|
||||
|
||||
public DownloadServiceConnection() {
|
||||
downloadServiceInterface = new DownloadServiceInterface();
|
||||
@ -328,9 +307,7 @@ public class LibraryFragment extends Fragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName arg0) {
|
||||
bound = false;
|
||||
}
|
||||
public void onServiceDisconnected(ComponentName arg0) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.kiwix.kiwixlib;
|
||||
|
||||
public class JNIKiwixBool {
|
||||
|
||||
public boolean value;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user