mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 18:51:49 +01:00
Remove cache size setting. Add advanced settings section. Other minor changes.
This commit is contained in:
parent
77d2e6643a
commit
453a187938
@ -15,25 +15,25 @@ import java.io.OutputStream;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
|
||||||
import eu.kanade.mangafeed.data.source.model.Page;
|
import eu.kanade.mangafeed.data.source.model.Page;
|
||||||
import eu.kanade.mangafeed.util.DiskUtils;
|
import eu.kanade.mangafeed.util.DiskUtils;
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
import okio.Okio;
|
import okio.Okio;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|
||||||
public class CacheManager {
|
public class ChapterCache {
|
||||||
|
|
||||||
private static final String PARAMETER_CACHE_DIRECTORY = "chapter_disk_cache";
|
private static final String PARAMETER_CACHE_DIRECTORY = "chapter_disk_cache";
|
||||||
private static final int PARAMETER_APP_VERSION = 1;
|
private static final int PARAMETER_APP_VERSION = 1;
|
||||||
private static final int PARAMETER_VALUE_COUNT = 1;
|
private static final int PARAMETER_VALUE_COUNT = 1;
|
||||||
|
private static final int PARAMETER_CACHE_SIZE = 75 * 1024 * 1024;
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
|
|
||||||
private DiskLruCache diskCache;
|
private DiskLruCache diskCache;
|
||||||
|
|
||||||
public CacheManager(Context context, PreferencesHelper preferences) {
|
public ChapterCache(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
gson = new Gson();
|
gson = new Gson();
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class CacheManager {
|
|||||||
new File(context.getCacheDir(), PARAMETER_CACHE_DIRECTORY),
|
new File(context.getCacheDir(), PARAMETER_CACHE_DIRECTORY),
|
||||||
PARAMETER_APP_VERSION,
|
PARAMETER_APP_VERSION,
|
||||||
PARAMETER_VALUE_COUNT,
|
PARAMETER_VALUE_COUNT,
|
||||||
preferences.cacheSize() * 1024 * 1024
|
PARAMETER_CACHE_SIZE
|
||||||
);
|
);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Do Nothing.
|
// Do Nothing.
|
@ -136,6 +136,16 @@ public class DatabaseHelper {
|
|||||||
.prepare();
|
.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PreparedDeleteByQuery deleteMangasNotInLibrary() {
|
||||||
|
return db.delete()
|
||||||
|
.byQuery(DeleteQuery.builder()
|
||||||
|
.table(MangaTable.TABLE)
|
||||||
|
.where(MangaTable.COLUMN_FAVORITE + "=?")
|
||||||
|
.whereArgs(0)
|
||||||
|
.build())
|
||||||
|
.prepare();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Chapters related queries
|
// Chapters related queries
|
||||||
|
|
||||||
|
@ -56,10 +56,6 @@ public class PreferencesHelper {
|
|||||||
prefs.edit().clear().apply();
|
prefs.edit().clear().apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int cacheSize() {
|
|
||||||
return prefs.getInt(getKey(R.string.pref_chapter_cache_size_key), 75);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Preference<Boolean> lockOrientation() {
|
public Preference<Boolean> lockOrientation() {
|
||||||
return rxPrefs.getBoolean(getKey(R.string.pref_lock_orientation_key), true);
|
return rxPrefs.getBoolean(getKey(R.string.pref_lock_orientation_key), true);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import java.util.Map;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.App;
|
import eu.kanade.mangafeed.App;
|
||||||
import eu.kanade.mangafeed.data.cache.CacheManager;
|
import eu.kanade.mangafeed.data.cache.ChapterCache;
|
||||||
import eu.kanade.mangafeed.data.database.models.Chapter;
|
import eu.kanade.mangafeed.data.database.models.Chapter;
|
||||||
import eu.kanade.mangafeed.data.database.models.Manga;
|
import eu.kanade.mangafeed.data.database.models.Manga;
|
||||||
import eu.kanade.mangafeed.data.network.NetworkHelper;
|
import eu.kanade.mangafeed.data.network.NetworkHelper;
|
||||||
@ -29,7 +29,7 @@ import rx.schedulers.Schedulers;
|
|||||||
public abstract class Source extends BaseSource {
|
public abstract class Source extends BaseSource {
|
||||||
|
|
||||||
@Inject protected NetworkHelper networkService;
|
@Inject protected NetworkHelper networkService;
|
||||||
@Inject protected CacheManager cacheManager;
|
@Inject protected ChapterCache chapterCache;
|
||||||
@Inject protected PreferencesHelper prefs;
|
@Inject protected PreferencesHelper prefs;
|
||||||
protected Headers requestHeaders;
|
protected Headers requestHeaders;
|
||||||
protected LazyHeaders glideHeaders;
|
protected LazyHeaders glideHeaders;
|
||||||
@ -89,7 +89,7 @@ public abstract class Source extends BaseSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Observable<List<Page>> getCachedPageListOrPullFromNetwork(final String chapterUrl) {
|
public Observable<List<Page>> getCachedPageListOrPullFromNetwork(final String chapterUrl) {
|
||||||
return cacheManager.getPageUrlsFromDiskCache(getChapterCacheKey(chapterUrl))
|
return chapterCache.getPageUrlsFromDiskCache(getChapterCacheKey(chapterUrl))
|
||||||
.onErrorResumeNext(throwable -> {
|
.onErrorResumeNext(throwable -> {
|
||||||
return pullPageListFromNetwork(chapterUrl);
|
return pullPageListFromNetwork(chapterUrl);
|
||||||
})
|
})
|
||||||
@ -141,13 +141,13 @@ public abstract class Source extends BaseSource {
|
|||||||
|
|
||||||
return pageObservable
|
return pageObservable
|
||||||
.flatMap(p -> {
|
.flatMap(p -> {
|
||||||
if (!cacheManager.isImageInCache(page.getImageUrl())) {
|
if (!chapterCache.isImageInCache(page.getImageUrl())) {
|
||||||
return cacheImage(page);
|
return cacheImage(page);
|
||||||
}
|
}
|
||||||
return Observable.just(page);
|
return Observable.just(page);
|
||||||
})
|
})
|
||||||
.flatMap(p -> {
|
.flatMap(p -> {
|
||||||
page.setImagePath(cacheManager.getImagePath(page.getImageUrl()));
|
page.setImagePath(chapterCache.getImagePath(page.getImageUrl()));
|
||||||
page.setStatus(Page.READY);
|
page.setStatus(Page.READY);
|
||||||
return Observable.just(page);
|
return Observable.just(page);
|
||||||
})
|
})
|
||||||
@ -162,7 +162,7 @@ public abstract class Source extends BaseSource {
|
|||||||
return getImageProgressResponse(page)
|
return getImageProgressResponse(page)
|
||||||
.flatMap(resp -> {
|
.flatMap(resp -> {
|
||||||
try {
|
try {
|
||||||
cacheManager.putImageToDiskCache(page.getImageUrl(), resp);
|
chapterCache.putImageToDiskCache(page.getImageUrl(), resp);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return Observable.error(e);
|
return Observable.error(e);
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ public abstract class Source extends BaseSource {
|
|||||||
|
|
||||||
public void savePageList(String chapterUrl, List<Page> pages) {
|
public void savePageList(String chapterUrl, List<Page> pages) {
|
||||||
if (pages != null)
|
if (pages != null)
|
||||||
cacheManager.putPageUrlsToDiskCache(getChapterCacheKey(chapterUrl), pages);
|
chapterCache.putPageUrlsToDiskCache(getChapterCacheKey(chapterUrl), pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Page> convertToPages(List<String> pageUrls) {
|
protected List<Page> convertToPages(List<String> pageUrls) {
|
||||||
|
@ -6,7 +6,7 @@ import javax.inject.Singleton;
|
|||||||
|
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
import eu.kanade.mangafeed.data.cache.CacheManager;
|
import eu.kanade.mangafeed.data.cache.ChapterCache;
|
||||||
import eu.kanade.mangafeed.data.cache.CoverCache;
|
import eu.kanade.mangafeed.data.cache.CoverCache;
|
||||||
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
||||||
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
||||||
@ -35,8 +35,8 @@ public class DataModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
CacheManager provideCacheManager(Application app, PreferencesHelper preferences) {
|
ChapterCache provideChapterCache(Application app) {
|
||||||
return new CacheManager(app, preferences);
|
return new ChapterCache(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -87,8 +87,7 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
readerMenu.show(false);
|
readerMenu.show(false);
|
||||||
|
|
||||||
readerTheme = preferences.getReaderTheme();
|
readerTheme = preferences.getReaderTheme();
|
||||||
if (readerTheme == BLACK_THEME)
|
applyTheme();
|
||||||
setBlackTheme();
|
|
||||||
|
|
||||||
initializeSettings();
|
initializeSettings();
|
||||||
|
|
||||||
@ -265,10 +264,15 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
recreate();
|
recreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBlackTheme() {
|
private void applyTheme() {
|
||||||
getWindow().getDecorView().getRootView().setBackgroundColor(Color.BLACK);
|
View rootView = getWindow().getDecorView().getRootView();
|
||||||
|
if (readerTheme == BLACK_THEME) {
|
||||||
|
rootView.setBackgroundColor(Color.BLACK);
|
||||||
pageNumber.setTextColor(ContextCompat.getColor(this, R.color.light_grey));
|
pageNumber.setTextColor(ContextCompat.getColor(this, R.color.light_grey));
|
||||||
pageNumber.setBackgroundColor(ContextCompat.getColor(this, R.color.page_number_background_black));
|
pageNumber.setBackgroundColor(ContextCompat.getColor(this, R.color.page_number_background_black));
|
||||||
|
} else {
|
||||||
|
rootView.setBackgroundColor(Color.WHITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getReaderTheme() {
|
public int getReaderTheme() {
|
||||||
|
@ -10,14 +10,16 @@ import butterknife.Bind;
|
|||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import eu.kanade.mangafeed.App;
|
import eu.kanade.mangafeed.App;
|
||||||
import eu.kanade.mangafeed.R;
|
import eu.kanade.mangafeed.R;
|
||||||
import eu.kanade.mangafeed.data.cache.CacheManager;
|
import eu.kanade.mangafeed.data.cache.ChapterCache;
|
||||||
|
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
||||||
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
||||||
import eu.kanade.mangafeed.ui.base.activity.BaseActivity;
|
import eu.kanade.mangafeed.ui.base.activity.BaseActivity;
|
||||||
|
|
||||||
public class SettingsActivity extends BaseActivity {
|
public class SettingsActivity extends BaseActivity {
|
||||||
|
|
||||||
@Inject PreferencesHelper preferences;
|
@Inject PreferencesHelper preferences;
|
||||||
@Inject CacheManager cacheManager;
|
@Inject ChapterCache chapterCache;
|
||||||
|
@Inject DatabaseHelper db;
|
||||||
|
|
||||||
@Bind(R.id.toolbar) Toolbar toolbar;
|
@Bind(R.id.toolbar) Toolbar toolbar;
|
||||||
|
|
||||||
@ -64,9 +66,9 @@ public class SettingsActivity extends BaseActivity {
|
|||||||
SettingsAccountsFragment.newInstance(
|
SettingsAccountsFragment.newInstance(
|
||||||
R.xml.pref_accounts, R.string.pref_category_accounts));
|
R.xml.pref_accounts, R.string.pref_category_accounts));
|
||||||
|
|
||||||
registerSubpreference(R.string.pref_category_cache_key,
|
registerSubpreference(R.string.pref_category_advanced_key,
|
||||||
SettingsCacheFragment.newInstance(
|
SettingsAdvancedFragment.newInstance(
|
||||||
R.xml.pref_cache, R.string.pref_category_cache));
|
R.xml.pref_advanced, R.string.pref_category_advanced));
|
||||||
|
|
||||||
registerSubpreference(R.string.pref_category_about_key,
|
registerSubpreference(R.string.pref_category_about_key,
|
||||||
SettingsAboutFragment.newInstance(
|
SettingsAboutFragment.newInstance(
|
||||||
|
@ -0,0 +1,109 @@
|
|||||||
|
package eu.kanade.mangafeed.ui.setting;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import eu.kanade.mangafeed.R;
|
||||||
|
import eu.kanade.mangafeed.data.cache.ChapterCache;
|
||||||
|
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
||||||
|
import eu.kanade.mangafeed.util.ToastUtil;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
|
import rx.schedulers.Schedulers;
|
||||||
|
import rx.subscriptions.CompositeSubscription;
|
||||||
|
|
||||||
|
public class SettingsAdvancedFragment extends SettingsNestedFragment {
|
||||||
|
|
||||||
|
private CompositeSubscription subscriptions;
|
||||||
|
|
||||||
|
public static SettingsNestedFragment newInstance(int resourcePreference, int resourceTitle) {
|
||||||
|
SettingsNestedFragment fragment = new SettingsAdvancedFragment();
|
||||||
|
fragment.setArgs(resourcePreference, resourceTitle);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
||||||
|
View view = super.onCreateView(inflater, container, savedState);
|
||||||
|
subscriptions = new CompositeSubscription();
|
||||||
|
|
||||||
|
Preference clearCache = findPreference(getString(R.string.pref_clear_chapter_cache_key));
|
||||||
|
clearCache.setOnPreferenceClickListener(preference -> {
|
||||||
|
clearChapterCache(preference);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
clearCache.setSummary(getString(R.string.used_cache, getChapterCache().getReadableSize()));
|
||||||
|
|
||||||
|
Preference clearDatabase = findPreference(getString(R.string.pref_clear_database_key));
|
||||||
|
clearDatabase.setOnPreferenceClickListener(preference -> {
|
||||||
|
clearDatabase();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
subscriptions.unsubscribe();
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearChapterCache(Preference preference) {
|
||||||
|
final ChapterCache chapterCache = getChapterCache();
|
||||||
|
final AtomicInteger deletedFiles = new AtomicInteger();
|
||||||
|
|
||||||
|
File[] files = chapterCache.getCacheDir().listFiles();
|
||||||
|
|
||||||
|
MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(R.string.deleting)
|
||||||
|
.progress(false, files.length, true)
|
||||||
|
.cancelable(false)
|
||||||
|
.show();
|
||||||
|
|
||||||
|
subscriptions.add(Observable.defer(() -> Observable.from(files))
|
||||||
|
.concatMap(file -> {
|
||||||
|
if (chapterCache.remove(file.getName())) {
|
||||||
|
deletedFiles.incrementAndGet();
|
||||||
|
}
|
||||||
|
return Observable.just(file);
|
||||||
|
})
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(file -> dialog.incrementProgress(1),
|
||||||
|
error -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
ToastUtil.showShort(getActivity(), getString(R.string.cache_delete_error));
|
||||||
|
}, () -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
ToastUtil.showShort(getActivity(), getString(R.string.cache_deleted, deletedFiles.get()));
|
||||||
|
preference.setSummary(getString(R.string.used_cache, chapterCache.getReadableSize()));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearDatabase() {
|
||||||
|
final DatabaseHelper db = getSettingsActivity().db;
|
||||||
|
|
||||||
|
new MaterialDialog.Builder(getActivity())
|
||||||
|
.content(R.string.clear_database_confirmation)
|
||||||
|
.positiveText(R.string.button_yes)
|
||||||
|
.negativeText(R.string.button_no)
|
||||||
|
.onPositive((dialog1, which) -> {
|
||||||
|
db.deleteMangasNotInLibrary().executeAsBlocking();
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChapterCache getChapterCache() {
|
||||||
|
return getSettingsActivity().chapterCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,98 +0,0 @@
|
|||||||
package eu.kanade.mangafeed.ui.setting;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import eu.kanade.mangafeed.R;
|
|
||||||
import eu.kanade.mangafeed.data.cache.CacheManager;
|
|
||||||
import eu.kanade.mangafeed.ui.setting.preference.IntListPreference;
|
|
||||||
import eu.kanade.mangafeed.util.ToastUtil;
|
|
||||||
import rx.Observable;
|
|
||||||
import rx.Subscription;
|
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
|
||||||
import rx.schedulers.Schedulers;
|
|
||||||
|
|
||||||
public class SettingsCacheFragment extends SettingsNestedFragment implements Preference.OnPreferenceClickListener {
|
|
||||||
|
|
||||||
private CacheManager cacheManager;
|
|
||||||
private Preference clearCache;
|
|
||||||
private Subscription clearChapterCacheSubscription;
|
|
||||||
|
|
||||||
public static SettingsNestedFragment newInstance(int resourcePreference, int resourceTitle) {
|
|
||||||
SettingsNestedFragment fragment = new SettingsCacheFragment();
|
|
||||||
fragment.setArgs(resourcePreference, resourceTitle);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
|
||||||
View view = super.onCreateView(inflater, container, savedState);
|
|
||||||
|
|
||||||
cacheManager = getSettingsActivity().cacheManager;
|
|
||||||
|
|
||||||
IntListPreference cacheSize = (IntListPreference)findPreference(getString(R.string.pref_chapter_cache_size_key));
|
|
||||||
cacheSize.setOnPreferenceChangeListener(
|
|
||||||
(preference, newValue) -> {
|
|
||||||
cacheManager.setSize(Integer.parseInt(newValue.toString()));
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
clearCache = findPreference(getString(R.string.pref_clear_chapter_cache_key));
|
|
||||||
clearCache.setOnPreferenceClickListener(this);
|
|
||||||
clearCache.setSummary(getString(R.string.used_cache, cacheManager.getReadableSize()));
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
if (preference.equals(clearCache)) {
|
|
||||||
clearChapterCache();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearChapterCache() {
|
|
||||||
final AtomicInteger deletedFiles = new AtomicInteger();
|
|
||||||
|
|
||||||
File[] files = cacheManager.getCacheDir().listFiles();
|
|
||||||
|
|
||||||
MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
|
|
||||||
.title(R.string.deleting)
|
|
||||||
.progress(false, files.length, true)
|
|
||||||
.cancelable(false)
|
|
||||||
.dismissListener(d -> {
|
|
||||||
if (clearChapterCacheSubscription != null && !clearChapterCacheSubscription.isUnsubscribed())
|
|
||||||
clearChapterCacheSubscription.unsubscribe();
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
|
|
||||||
clearChapterCacheSubscription = Observable.defer(() -> Observable.from(files))
|
|
||||||
.concatMap(file -> {
|
|
||||||
if (cacheManager.remove(file.getName())) {
|
|
||||||
deletedFiles.incrementAndGet();
|
|
||||||
}
|
|
||||||
return Observable.just(file);
|
|
||||||
})
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(file -> dialog.incrementProgress(1),
|
|
||||||
error -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
ToastUtil.showShort(getActivity(), getString(R.string.cache_delete_error));
|
|
||||||
}, () -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
ToastUtil.showShort(getActivity(), getString(R.string.cache_deleted, deletedFiles.get()));
|
|
||||||
clearCache.setSummary(getString(R.string.used_cache, cacheManager.getReadableSize()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -3,7 +3,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#333333"
|
android:background="@color/reader_menu_background"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
|
@ -34,6 +34,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/keep_screen_on"
|
android:id="@+id/keep_screen_on"
|
||||||
style="@style/grey_text"
|
style="@style/grey_text"
|
||||||
android:text="Keep screen on"/>
|
android:text="@string/pref_keep_screen_on"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -28,18 +28,6 @@
|
|||||||
<item>3</item>
|
<item>3</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="cache_size">
|
|
||||||
<item>50 MB</item>
|
|
||||||
<item>75 MB</item>
|
|
||||||
<item>100 MB</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="cache_values">
|
|
||||||
<item>50</item>
|
|
||||||
<item>75</item>
|
|
||||||
<item>100</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="reader_themes">
|
<string-array name="reader_themes">
|
||||||
<item>@string/white_theme</item>
|
<item>@string/white_theme</item>
|
||||||
<item>@string/black_theme</item>
|
<item>@string/black_theme</item>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<string name="pref_category_reader_key">pref_category_reader_key</string>
|
<string name="pref_category_reader_key">pref_category_reader_key</string>
|
||||||
<string name="pref_category_accounts_key">pref_category_accounts_key</string>
|
<string name="pref_category_accounts_key">pref_category_accounts_key</string>
|
||||||
<string name="pref_category_downloads_key">pref_category_downloads_key</string>
|
<string name="pref_category_downloads_key">pref_category_downloads_key</string>
|
||||||
<string name="pref_category_cache_key">pref_category_cache_key</string>
|
<string name="pref_category_advanced_key">pref_category_advanced_key</string>
|
||||||
<string name="pref_category_about_key">pref_category_about_key</string>
|
<string name="pref_category_about_key">pref_category_about_key</string>
|
||||||
|
|
||||||
<string name="pref_library_columns_dialog_key">pref_library_columns_dialog_key</string>
|
<string name="pref_library_columns_dialog_key">pref_library_columns_dialog_key</string>
|
||||||
@ -24,8 +24,8 @@
|
|||||||
<string name="pref_download_directory_key">pref_download_directory_key</string>
|
<string name="pref_download_directory_key">pref_download_directory_key</string>
|
||||||
<string name="pref_download_slots_key">pref_download_slots_key</string>
|
<string name="pref_download_slots_key">pref_download_slots_key</string>
|
||||||
|
|
||||||
<string name="pref_chapter_cache_size_key">pref_chapter_cache_size_key</string>
|
|
||||||
<string name="pref_clear_chapter_cache_key">pref_clear_chapter_cache_key</string>
|
<string name="pref_clear_chapter_cache_key">pref_clear_chapter_cache_key</string>
|
||||||
|
<string name="pref_clear_database_key">pref_clear_database_key</string>
|
||||||
|
|
||||||
<string name="pref_version">pref_version</string>
|
<string name="pref_version">pref_version</string>
|
||||||
<string name="pref_build_time">pref_build_time</string>
|
<string name="pref_build_time">pref_build_time</string>
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
<string name="button_ok">OK</string>
|
<string name="button_ok">OK</string>
|
||||||
<string name="button_cancel">Cancel</string>
|
<string name="button_cancel">Cancel</string>
|
||||||
|
<string name="button_yes">Yes</string>
|
||||||
|
<string name="button_no">No</string>
|
||||||
|
|
||||||
<!-- Operations -->
|
<!-- Operations -->
|
||||||
<string name="deleting">Deleting…</string>
|
<string name="deleting">Deleting…</string>
|
||||||
@ -49,7 +51,7 @@
|
|||||||
<string name="pref_category_reader">Reader</string>
|
<string name="pref_category_reader">Reader</string>
|
||||||
<string name="pref_category_accounts">Accounts</string>
|
<string name="pref_category_accounts">Accounts</string>
|
||||||
<string name="pref_category_downloads">Downloads</string>
|
<string name="pref_category_downloads">Downloads</string>
|
||||||
<string name="pref_category_cache">Cache</string>
|
<string name="pref_category_advanced">Advanced</string>
|
||||||
<string name="pref_category_about">About</string>
|
<string name="pref_category_about">About</string>
|
||||||
|
|
||||||
<!-- General section -->
|
<!-- General section -->
|
||||||
@ -58,14 +60,14 @@
|
|||||||
<string name="landscape">Landscape</string>
|
<string name="landscape">Landscape</string>
|
||||||
<string name="default_columns">Default</string>
|
<string name="default_columns">Default</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Reader section -->
|
<!-- Reader section -->
|
||||||
<string name="pref_hide_status_bar">Hide status bar</string>
|
<string name="pref_hide_status_bar">Hide status bar</string>
|
||||||
<string name="pref_lock_orientation">Lock orientation</string>
|
<string name="pref_lock_orientation">Lock orientation</string>
|
||||||
<string name="pref_enable_transitions">Enable transitions</string>
|
<string name="pref_enable_transitions">Enable transitions</string>
|
||||||
<string name="pref_show_page_number">Show page number</string>
|
<string name="pref_show_page_number">Show page number</string>
|
||||||
<string name="pref_custom_brightness">Use custom brightness</string>
|
<string name="pref_custom_brightness">Use custom brightness</string>
|
||||||
<string name="pref_reader_theme">Reader theme</string>
|
<string name="pref_keep_screen_on">Keep screen on</string>
|
||||||
|
<string name="pref_reader_theme">Background color</string>
|
||||||
<string name="white_theme">White</string>
|
<string name="white_theme">White</string>
|
||||||
<string name="black_theme">Black</string>
|
<string name="black_theme">Black</string>
|
||||||
<string name="pref_viewer_type">Default viewer</string>
|
<string name="pref_viewer_type">Default viewer</string>
|
||||||
@ -79,12 +81,14 @@
|
|||||||
<string name="pref_download_directory">Downloads directory</string>
|
<string name="pref_download_directory">Downloads directory</string>
|
||||||
<string name="pref_download_slots">Simultaneous downloads</string>
|
<string name="pref_download_slots">Simultaneous downloads</string>
|
||||||
|
|
||||||
<!-- Cache section -->
|
<!-- Advanced section -->
|
||||||
<string name="pref_chapter_cache_size">Chapters cache size</string>
|
|
||||||
<string name="pref_clear_chapter_cache">Clear chapter cache</string>
|
<string name="pref_clear_chapter_cache">Clear chapter cache</string>
|
||||||
<string name="used_cache">Used: %1$s</string>
|
<string name="used_cache">Used: %1$s</string>
|
||||||
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
|
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
|
||||||
<string name="cache_delete_error">An error occurred clearing cache</string>
|
<string name="cache_delete_error">An error occurred clearing cache</string>
|
||||||
|
<string name="pref_clear_database">Clear database</string>
|
||||||
|
<string name="pref_clear_database_summary">Delete mangas and chapters that are not in your library</string>
|
||||||
|
<string name="clear_database_confirmation">Are you sure? Read chapters and progress of non library mangas will be lost</string>
|
||||||
|
|
||||||
<!-- About section -->
|
<!-- About section -->
|
||||||
<string name="version">Version</string>
|
<string name="version">Version</string>
|
||||||
|
13
app/src/main/res/xml/pref_advanced.xml
Normal file
13
app/src/main/res/xml/pref_advanced.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:title="@string/pref_clear_chapter_cache"
|
||||||
|
android:key="@string/pref_clear_chapter_cache_key" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:title="@string/pref_clear_database"
|
||||||
|
android:key="@string/pref_clear_database_key"
|
||||||
|
android:summary="@string/pref_clear_database_summary"/>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<eu.kanade.mangafeed.ui.setting.preference.IntListPreference
|
|
||||||
android:title="@string/pref_chapter_cache_size"
|
|
||||||
android:key="@string/pref_chapter_cache_size_key"
|
|
||||||
android:entries="@array/cache_size"
|
|
||||||
android:entryValues="@array/cache_values"
|
|
||||||
android:summary="%s"
|
|
||||||
android:defaultValue="75"/>
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:title="@string/pref_clear_chapter_cache"
|
|
||||||
android:key="@string/pref_clear_chapter_cache_key" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@ -22,9 +22,9 @@
|
|||||||
android:title="@string/pref_category_accounts" />
|
android:title="@string/pref_category_accounts" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="@string/pref_category_cache_key"
|
android:key="@string/pref_category_advanced_key"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/pref_category_cache" />
|
android:title="@string/pref_category_advanced" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="@string/pref_category_about_key"
|
android:key="@string/pref_category_about_key"
|
||||||
|
Loading…
Reference in New Issue
Block a user