Add image size option
This commit is contained in:
1 parent
084f352d71
commit
3ca6b69984
10 files changed
+76
-11
No files matched your search
@@ -55,6 +55,7 @@ public class Settings {
|
||||
|
||||
private static EhConfig loadEhConfig() {
|
||||
EhConfig ehConfig= new EhConfig();
|
||||
ehConfig.imageSize = getImageSize();
|
||||
ehConfig.excludedLanguages = getExcludedLanguages();
|
||||
ehConfig.defaultCategories = getDefaultCategories();
|
||||
ehConfig.excludedNamespaces = getExcludedTagNamespaces();
|
||||
@@ -591,6 +592,19 @@ public class Settings {
|
||||
putIntToStr(KEY_PRELOAD_IMAGE, value);
|
||||
}
|
||||
|
||||
public static final String KEY_IMAGE_SIZE = "image_size";
|
||||
public static final String DEFAULT_IMAGE_SIZE = EhConfig.IMAGE_SIZE_AUTO;
|
||||
|
||||
public static String getImageSize() {
|
||||
return getString(KEY_IMAGE_SIZE, DEFAULT_IMAGE_SIZE);
|
||||
}
|
||||
|
||||
public static void putImageSize(String value) {
|
||||
sEhConfig.imageSize = value;
|
||||
sEhConfig.setDirty();
|
||||
putString(KEY_IMAGE_SIZE, value);
|
||||
}
|
||||
|
||||
private static final String KEY_DOWNLOAD_ORIGIN_IMAGE = "download_origin_image";
|
||||
private static final boolean DEFAULT_DOWNLOAD_ORIGIN_IMAGE = false;
|
||||
|
||||
|
||||
@@ -213,27 +213,27 @@ public class EhConfig implements Cloneable {
|
||||
/**
|
||||
* Image Size Auto
|
||||
*/
|
||||
private static final String IMAGE_SIZE_AUTO = "0";
|
||||
public static final String IMAGE_SIZE_AUTO = "a";
|
||||
/**
|
||||
* Image Size 780x
|
||||
*/
|
||||
private static final String IMAGE_SIZE_780X = "1";
|
||||
public static final String IMAGE_SIZE_780X = "780";
|
||||
/**
|
||||
* Image Size 980x
|
||||
*/
|
||||
private static final String IMAGE_SIZE_980X = "2";
|
||||
public static final String IMAGE_SIZE_980X = "980";
|
||||
/**
|
||||
* Image Size 1280x
|
||||
*/
|
||||
private static final String IMAGE_SIZE_1280X = "3";
|
||||
public static final String IMAGE_SIZE_1280X = "1280";
|
||||
/**
|
||||
* Image Size 1600x
|
||||
*/
|
||||
private static final String IMAGE_SIZE_1600X = "4";
|
||||
public static final String IMAGE_SIZE_1600X = "1600";
|
||||
/**
|
||||
* Image Size 2400x
|
||||
*/
|
||||
private static final String IMAGE_SIZE_2400X = "5";
|
||||
public static final String IMAGE_SIZE_2400X = "2400";
|
||||
|
||||
/**
|
||||
* Default gallery title
|
||||
|
||||
@@ -35,7 +35,9 @@ import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.ui.DirPickerActivity;
|
||||
import com.hippo.unifile.UniFile;
|
||||
|
||||
public class DownloadFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
|
||||
public class DownloadFragment extends PreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener,
|
||||
Preference.OnPreferenceClickListener {
|
||||
|
||||
public static final int REQUEST_CODE_PICK_IMAGE_DIR = 0;
|
||||
public static final int REQUEST_CODE_PICK_IMAGE_DIR_L = 1;
|
||||
@@ -50,10 +52,13 @@ public class DownloadFragment extends PreferenceFragment implements Preference.O
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.download_settings);
|
||||
|
||||
Preference imageSize = findPreference(Settings.KEY_IMAGE_SIZE);
|
||||
mDownloadLocation = findPreference(KEY_DOWNLOAD_LOCATION);
|
||||
|
||||
onUpdateDownloadLocation();
|
||||
|
||||
imageSize.setOnPreferenceChangeListener(this);
|
||||
|
||||
if (mDownloadLocation != null) {
|
||||
mDownloadLocation.setOnPreferenceClickListener(this);
|
||||
}
|
||||
@@ -181,4 +186,16 @@ public class DownloadFragment extends PreferenceFragment implements Preference.O
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
if (Settings.KEY_IMAGE_SIZE.equals(key)) {
|
||||
if (newValue instanceof String) {
|
||||
Settings.putImageSize((String) newValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import android.support.annotation.ArrayRes;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
@@ -140,9 +139,6 @@ public class ListPreference extends DialogPreference {
|
||||
* @param value The value to set for the key.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
|
||||
Log.d("TAG", "value = " + value);
|
||||
|
||||
// Always persist/notify the first time.
|
||||
final boolean changed = !TextUtils.equals(mValue, value);
|
||||
if (changed || !mValueSet) {
|
||||
|
||||
Reference in new issue
Block a user