diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.java b/app/src/main/java/com/hippo/ehviewer/EhApplication.java index 41d37d9e5..cfd1711a3 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhApplication.java +++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.java @@ -24,7 +24,6 @@ import com.hippo.conaco.Conaco; import com.hippo.ehviewer.client.EhClient; import com.hippo.ehviewer.network.EhHttpClient; import com.hippo.ehviewer.util.Settings; -import com.hippo.httpclient.HttpClient; import com.hippo.scene.SceneApplication; import com.hippo.util.Log; import com.hippo.vectorold.content.VectorContext; @@ -34,7 +33,7 @@ import java.io.IOException; public class EhApplication extends SceneApplication { - private HttpClient mHttpClient; + private EhHttpClient mEhHttpClient; private EhClient mEhClient; private Conaco mConaco; private SimpleDiskCache mReadcache; @@ -45,8 +44,8 @@ public class EhApplication extends SceneApplication { Settings.initialize(this); - mHttpClient = new EhHttpClient(this); - mEhClient = new EhClient(mHttpClient); + mEhHttpClient = new EhHttpClient(this); + mEhClient = new EhClient(mEhHttpClient); Conaco.Builder conacoBuilder = new Conaco.Builder(); conacoBuilder.hasMemoryCache = true; @@ -54,7 +53,7 @@ public class EhApplication extends SceneApplication { conacoBuilder.hasDiskCache = true; conacoBuilder.diskCacheDir = new File(getCacheDir(), "conaco"); conacoBuilder.diskCacheMaxSize = 50 * 1024 * 1024; - conacoBuilder.httpClient = mHttpClient; + conacoBuilder.httpClient = mEhHttpClient; mConaco = conacoBuilder.build(); try { @@ -85,9 +84,9 @@ public class EhApplication extends SceneApplication { } } - public static HttpClient getHttpClient(Context context) { + public static EhHttpClient getEhHttpClient(Context context) { EhApplication application = (EhApplication) context.getApplicationContext(); - return application.mHttpClient; + return application.mEhHttpClient; } public static EhClient getEhClient(Context context) { diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java b/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java index 20fa275dc..c04ff76dc 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java @@ -189,56 +189,57 @@ public class EhConfig implements Cloneable { public static final int NAMESPACES_ARTIST = 0x20; public static final int NAMESPACES_MALE = 0x40; public static final int NAMESPACES_FEMALE = 0x80; - public static final int JAPANESE_TRANSLATED = 1024; - public static final int JAPANESE_REWRITE = 2048; - public static final int ENGLISH_ORIGINAL = 1; - public static final int ENGLISH_TRANSLATED = 1025; - public static final int ENGLISH_REWRITE = 2049; - public static final int CHINESE_ORIGINAL = 10; - public static final int CHINESE_TRANSLATED = 1034; - public static final int CHINESE_REWRITE = 2058; - public static final int DUTCH_ORIGINAL = 20; - public static final int DUTCH_TRANSLATED = 1044; - public static final int DUTCH_REWRITE = 2068; - public static final int FRENCH_ORIGINAL = 30; - public static final int FRENCH_TRANSLATED = 1054; - public static final int FRENCH_REWRITE = 2078; - public static final int GERMAN_ORIGINAL = 40; - public static final int GERMAN_TRANSLATED = 1064; - public static final int GERMAN_REWRITE = 2088; - public static final int HUNGARIAN_ORIGINAL = 50; - public static final int HUNGARIAN_TRANSLATED = 1074; - public static final int HUNGARIAN_REWRITE = 2098; - public static final int ITALIAN_ORIGINAL = 60; - public static final int ITALIAN_TRANSLATED = 1084; - public static final int ITALIAN_REWRITE = 2108; - public static final int KOREAN_ORIGINAL = 70; - public static final int KOREAN_TRANSLATED = 1094; - public static final int KOREAN_REWRITE = 2118; - public static final int POLISH_ORIGINAL = 80; - public static final int POLISH_TRANSLATED = 1104; - public static final int POLISH_REWRITE = 2128; - public static final int PORTUGUESE_ORIGINAL = 90; - public static final int PORTUGUESE_TRANSLATED = 1114; - public static final int PORTUGUESE_REWRITE = 2138; - public static final int RUSSIAN_ORIGINAL = 100; - public static final int RUSSIAN_TRANSLATED = 1124; - public static final int RUSSIAN_REWRITE = 2148; - public static final int SPANISH_ORIGINAL = 110; - public static final int SPANISH_TRANSLATED = 1134; - public static final int SPANISH_REWRITE = 2158; - public static final int THAI_ORIGINAL = 120; - public static final int THAI_TRANSLATED = 1144; - public static final int THAI_REWRITE = 2168; - public static final int VIETNAMESE_ORIGINAL = 130; - public static final int VIETNAMESE_TRANSLATED = 1154; - public static final int VIETNAMESE_REWRITE = 2178; - public static final int NA_ORIGINAL = 254; - public static final int NA_TRANSLATED = 1278; - public static final int NA_REWRITE = 2302; - public static final int OTHER_ORIGINAL = 255; - public static final int OTHER_TRANSLATED = 1279; - public static final int OTHER_REWRITE = 2303; + + public static final String JAPANESE_TRANSLATED = "1024"; + public static final String JAPANESE_REWRITE = "2048"; + public static final String ENGLISH_ORIGINAL = "1"; + public static final String ENGLISH_TRANSLATED = "1025"; + public static final String ENGLISH_REWRITE = "2049"; + public static final String CHINESE_ORIGINAL = "10"; + public static final String CHINESE_TRANSLATED = "1034"; + public static final String CHINESE_REWRITE = "2058"; + public static final String DUTCH_ORIGINAL = "20"; + public static final String DUTCH_TRANSLATED = "1044"; + public static final String DUTCH_REWRITE = "2068"; + public static final String FRENCH_ORIGINAL = "30"; + public static final String FRENCH_TRANSLATED = "1054"; + public static final String FRENCH_REWRITE = "2078"; + public static final String GERMAN_ORIGINAL = "40"; + public static final String GERMAN_TRANSLATED = "1064"; + public static final String GERMAN_REWRITE = "2088"; + public static final String HUNGARIAN_ORIGINAL = "50"; + public static final String HUNGARIAN_TRANSLATED = "1074"; + public static final String HUNGARIAN_REWRITE = "2098"; + public static final String ITALIAN_ORIGINAL = "60"; + public static final String ITALIAN_TRANSLATED = "1084"; + public static final String ITALIAN_REWRITE = "2108"; + public static final String KOREAN_ORIGINAL = "70"; + public static final String KOREAN_TRANSLATED = "1094"; + public static final String KOREAN_REWRITE = "2118"; + public static final String POLISH_ORIGINAL = "80"; + public static final String POLISH_TRANSLATED = "1104"; + public static final String POLISH_REWRITE = "2128"; + public static final String PORTUGUESE_ORIGINAL = "90"; + public static final String PORTUGUESE_TRANSLATED = "1114"; + public static final String PORTUGUESE_REWRITE = "2138"; + public static final String RUSSIAN_ORIGINAL = "100"; + public static final String RUSSIAN_TRANSLATED = "1124"; + public static final String RUSSIAN_REWRITE = "2148"; + public static final String SPANISH_ORIGINAL = "110"; + public static final String SPANISH_TRANSLATED = "1134"; + public static final String SPANISH_REWRITE = "2158"; + public static final String THAI_ORIGINAL = "120"; + public static final String THAI_TRANSLATED = "1144"; + public static final String THAI_REWRITE = "2168"; + public static final String VIETNAMESE_ORIGINAL = "130"; + public static final String VIETNAMESE_TRANSLATED = "1154"; + public static final String VIETNAMESE_REWRITE = "2178"; + public static final String NA_ORIGINAL = "254"; + public static final String NA_TRANSLATED = "1278"; + public static final String NA_REWRITE = "2302"; + public static final String OTHER_ORIGINAL = "255"; + public static final String OTHER_TRANSLATED = "1279"; + public static final String OTHER_REWRITE = "2303"; /** * 25 results per page for the index/search page and torrent search pages diff --git a/app/src/main/java/com/hippo/ehviewer/network/EhHttpClient.java b/app/src/main/java/com/hippo/ehviewer/network/EhHttpClient.java index b5d592683..b70d51d01 100644 --- a/app/src/main/java/com/hippo/ehviewer/network/EhHttpClient.java +++ b/app/src/main/java/com/hippo/ehviewer/network/EhHttpClient.java @@ -55,7 +55,12 @@ public class EhHttpClient extends HttpClient { } mCookieManager = CookieManager.getInstance(); - mEhConfig = Settings.getEhConfig(); + mEhConfig = Settings.generateEhConfig(); + } + + public void setExcludedLanguages(String excludedLanguages) { + mEhConfig.excludedLanguages = excludedLanguages; + mEhConfig.setDirty(); } private String getDomain(URL uri) { diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/EHSettingsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/EHSettingsScene.java index d83671b1b..ff519d822 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/EHSettingsScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/EHSettingsScene.java @@ -21,6 +21,7 @@ import android.content.res.Resources; import com.hippo.ehviewer.Constants; import com.hippo.ehviewer.R; import com.hippo.ehviewer.client.EhUrl; +import com.hippo.scene.SimpleCurtain; import com.hippo.scene.preference.ListPreference; import com.hippo.scene.preference.Preference; import com.hippo.scene.preference.PreferenceCategory; @@ -28,16 +29,28 @@ import com.hippo.scene.preference.PreferenceScene; import com.hippo.scene.preference.PreferenceSet; import com.hippo.util.Messenger; -public final class EHSettingsScene extends PreferenceScene { +public final class EHSettingsScene extends PreferenceScene implements Preference.OnClickListener { private static final String KEY_EH_SOURCE = "eh_source"; private static final int DEFAULT_EH_SOURCE = EhUrl.SOURCE_G; + private static final String KEY_EH_API = "eh_api"; + private static final int DEFAULT_EH_API = EhUrl.SOURCE_G; + + private static final String KEY_DEFAULT_CATEGORIES = "default_categories"; + private static final int DEFAULT_DEFAULT_CATEGORIES = 0; + + private static final String KEY_EXCLUDED_NAMESPACES = "excluded_namespaces"; + private static final int DEFAULT_EXCLUDED_NAMESPACES = 0; + + private static final String KEY_EXCLUDED_LANGUAGES = "excluded_languages"; + private static final String DEFAULT_EXCLUDED_LANGUAGES = ""; + @Override protected void onCreate(boolean rebirth) { super.onCreate(rebirth); - setTitle(R.string.settings); + setTitle(R.string.settings_eh); setIcon(R.drawable.ic_arrow_left_dark); setPreferenceSet(getPreferenceSet()); @@ -60,11 +73,18 @@ public final class EHSettingsScene extends PreferenceScene { sourcePreference.setDefaultValue(DEFAULT_EH_SOURCE); sourcePreference.setOnValueChangeListener(valueChangeListener); + + Preference languagePreference = new Preference( + KEY_EXCLUDED_LANGUAGES, + resources.getString(R.string.excluded_languages), null); + languagePreference.setOnClickListener(this); + PreferenceSet preferenceSet = new PreferenceSet(); preferenceSet.setPreferenceCategory(new PreferenceCategory(resources.getString(R.string.settings_eh))); preferenceSet.setPreferenceList(new Preference[] { - sourcePreference + sourcePreference, + languagePreference }); return new PreferenceSet[] { @@ -72,6 +92,17 @@ public final class EHSettingsScene extends PreferenceScene { }; } + @Override + public boolean onClick(Preference preference) { + String key = preference.getKey(); + if (KEY_EXCLUDED_LANGUAGES.equals(key)) { + startScene(ExcludedLanguagesScene.class, null, new SimpleCurtain(SimpleCurtain.DIRECTION_BOTTOM)); + return true; + } else { + return false; + } + } + private static class ValueChangeListener implements Preference.OnValueChangeListener { @Override diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/ExcludedLanguagesScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/ExcludedLanguagesScene.java new file mode 100644 index 000000000..3c12b354b --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/ExcludedLanguagesScene.java @@ -0,0 +1,339 @@ +/* + * Copyright 2015 Hippo Seven + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hippo.ehviewer.ui.scene.preference; + +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.hippo.ehviewer.EhApplication; +import com.hippo.ehviewer.R; +import com.hippo.ehviewer.client.EhConfig; +import com.hippo.ehviewer.util.Settings; +import com.hippo.rippleold.RippleSalon; +import com.hippo.scene.AppbarScene; +import com.hippo.widget.SensitiveCheckBox; +import com.hippo.widget.recyclerview.EasyRecyclerView; + +public class ExcludedLanguagesScene extends AppbarScene implements View.OnClickListener{ + + private static final int ROW_COUNT = 17; + private static final int[] LANGUAGE_STR_IDS = { + R.string.language_japanese, + R.string.language_english, + R.string.language_chinese, + R.string.language_dutch, + R.string.language_french, + R.string.language_german, + R.string.language_hungarian, + R.string.language_italian, + R.string.language_korean, + R.string.language_polish, + R.string.language_portuguese, + R.string.language_russian, + R.string.language_spanish, + R.string.language_thai, + R.string.language_vietnamese, + R.string.language_na, + R.string.language_other + }; + + private static final String[] LANGUAGES = { + EhConfig.JAPANESE_TRANSLATED, + EhConfig.JAPANESE_REWRITE, + EhConfig.ENGLISH_ORIGINAL, + EhConfig.ENGLISH_TRANSLATED, + EhConfig.ENGLISH_REWRITE, + EhConfig.CHINESE_ORIGINAL, + EhConfig.CHINESE_TRANSLATED, + EhConfig.CHINESE_REWRITE, + EhConfig.DUTCH_ORIGINAL, + EhConfig.DUTCH_TRANSLATED, + EhConfig.DUTCH_REWRITE, + EhConfig.FRENCH_ORIGINAL, + EhConfig.FRENCH_TRANSLATED, + EhConfig.FRENCH_REWRITE, + EhConfig.GERMAN_ORIGINAL, + EhConfig.GERMAN_TRANSLATED, + EhConfig.GERMAN_REWRITE, + EhConfig.HUNGARIAN_ORIGINAL, + EhConfig.HUNGARIAN_TRANSLATED, + EhConfig.HUNGARIAN_REWRITE, + EhConfig.ITALIAN_ORIGINAL, + EhConfig.ITALIAN_TRANSLATED, + EhConfig.ITALIAN_REWRITE, + EhConfig.KOREAN_ORIGINAL, + EhConfig.KOREAN_TRANSLATED, + EhConfig.KOREAN_REWRITE, + EhConfig.POLISH_ORIGINAL, + EhConfig.POLISH_TRANSLATED, + EhConfig.POLISH_REWRITE, + EhConfig.PORTUGUESE_ORIGINAL, + EhConfig.PORTUGUESE_TRANSLATED, + EhConfig.PORTUGUESE_REWRITE, + EhConfig.RUSSIAN_ORIGINAL, + EhConfig.RUSSIAN_TRANSLATED, + EhConfig.RUSSIAN_REWRITE, + EhConfig.SPANISH_ORIGINAL, + EhConfig.SPANISH_TRANSLATED, + EhConfig.SPANISH_REWRITE, + EhConfig.THAI_ORIGINAL, + EhConfig.THAI_TRANSLATED, + EhConfig.THAI_REWRITE, + EhConfig.VIETNAMESE_ORIGINAL, + EhConfig.VIETNAMESE_TRANSLATED, + EhConfig.VIETNAMESE_REWRITE, + EhConfig.NA_ORIGINAL, + EhConfig.NA_TRANSLATED, + EhConfig.NA_REWRITE, + EhConfig.OTHER_ORIGINAL, + EhConfig.OTHER_TRANSLATED, + EhConfig.OTHER_REWRITE}; + + private boolean[][] mSeletions = new boolean[ROW_COUNT][3]; + + private View mCancel; + private View mOk; + private View mSelectAll; + private View mDeselectAll; + private View mInvertSelection; + private EasyRecyclerView mRecyclerView; + + private LanguageAdapter mAdapter; + + private int mOriginalRecyclerViewPaddingBottom; + + @Override + protected void onCreate(boolean rebirth) { + super.onCreate(rebirth); + + setContentView(R.layout.scene_excluded_languages); + setTitle(R.string.excluded_languages); + setIcon(R.drawable.ic_arrow_left_dark); + + + mCancel = findViewById(R.id.cancel); + mOk = findViewById(R.id.ok); + mSelectAll = findViewById(R.id.select_all); + mDeselectAll = findViewById(R.id.deselect_all); + mInvertSelection = findViewById(R.id.invert_selection); + mRecyclerView = (EasyRecyclerView) findViewById(R.id.recycler_view); + + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setClipToPadding(false); + mAdapter = new LanguageAdapter(); + mRecyclerView.setAdapter(mAdapter); + mRecyclerView.setLayoutManager(new LinearLayoutManager(getStageActivity())); + + mOriginalRecyclerViewPaddingBottom = mRecyclerView.getPaddingBottom(); + + mCancel.setOnClickListener(this); + mOk.setOnClickListener(this); + mSelectAll.setOnClickListener(this); + mDeselectAll.setOnClickListener(this); + mInvertSelection.setOnClickListener(this); + + RippleSalon.addRipple(mCancel, false); + RippleSalon.addRipple(mOk, false); + RippleSalon.addRipple(mSelectAll, false); + RippleSalon.addRipple(mDeselectAll, false); + RippleSalon.addRipple(mInvertSelection, false); + } + + @Override + protected void onBind() { + super.onBind(); + + String excludedLanguages = Settings.getExcludedLanguages(); + String[] languages = excludedLanguages.split("x"); + + int iLength = languages.length; + int jLength = LANGUAGES.length; + for (int i = 0, j = 0; i < iLength; i++) { + String language = languages[i]; + if (!isDecimal(language)) { + continue; + } + + for (; j < jLength; j++) { + String pattern = LANGUAGES[j]; + if (pattern.equals(language)) { + // Get it + int row = (j + 1) / 3; + int column = (j + 1) % 3; + mSeletions[row][column] = true; + break; + } + } + } + } + + private boolean isDecimal(String str) { + int length = str.length(); + + // "" is not decimal + if (length <= 0) { + return false; + } + + for (int i = 0; i < length; i++) { + char ch = str.charAt(i); + if (ch < '0' || ch > '9') { + return false; + } + } + return true; + } + + @Override + public void onIconClick() { + finish(); + } + + @Override + protected void onGetFitPaddingBottom(int b) { + EasyRecyclerView recyclerView = mRecyclerView; + recyclerView.setPadding(recyclerView.getPaddingLeft(), + recyclerView.getPaddingTop(), + recyclerView.getPaddingRight(), + mOriginalRecyclerViewPaddingBottom + b); + } + + @Override + public void onClick(View v) { + if (v == mCancel) { + finish(); + } else if (v == mOk) { + StringBuilder sb = new StringBuilder(); + int i = -1; + boolean first = true; + for (boolean[] selections : mSeletions) { + for (boolean b : selections) { + i++; + if (i == 0) { + continue; + } + if (b) { + if (!first) { + sb.append("x"); + } else { + first = false; + } + sb.append(LANGUAGES[i - 1]); + } + } + } + + String excludedLanguages = sb.toString(); + Settings.putExcludedLanguages(excludedLanguages); + EhApplication.getEhHttpClient(getStageActivity()).setExcludedLanguages(excludedLanguages); + finish(); + } else if (v == mSelectAll) { + for (boolean[] selections : mSeletions) { + int length = selections.length; + for (int i = 0; i < length; i++) { + selections[i] = true; + } + } + mAdapter.notifyDataSetChanged(); + } else if (v == mDeselectAll) { + for (boolean[] selections : mSeletions) { + int length = selections.length; + for (int i = 0; i < length; i++) { + selections[i] = false; + } + } + mAdapter.notifyDataSetChanged(); + } else if (v == mInvertSelection) { + for (boolean[] selections : mSeletions) { + int length = selections.length; + for (int i = 0; i < length; i++) { + selections[i] = !selections[i]; + } + } + mAdapter.notifyDataSetChanged(); + } + } + + class LanguageHolder extends RecyclerView.ViewHolder implements SensitiveCheckBox.OnCheckedChangeListener { + + public TextView language; + public SensitiveCheckBox original; + public SensitiveCheckBox translated; + public SensitiveCheckBox rewrite; + + public LanguageHolder(View itemView) { + super(itemView); + + ViewGroup viewGroup = (ViewGroup) itemView; + language = (TextView) viewGroup.getChildAt(0); + original = (SensitiveCheckBox) viewGroup.getChildAt(1); + translated = (SensitiveCheckBox) viewGroup.getChildAt(2); + rewrite = (SensitiveCheckBox) viewGroup.getChildAt(3); + + original.setOnCheckedChangeListener(this); + translated.setOnCheckedChangeListener(this); + rewrite.setOnCheckedChangeListener(this); + } + + @Override + public void onCheckedChanged(SensitiveCheckBox view, boolean isChecked, boolean fromUser) { + if (fromUser) { + int row = getAdapterPosition(); + int column; + if (view == original) { + column = 0; + } else if (view == translated) { + column = 1; + } else { + column = 2; + } + mSeletions[row][column] = !mSeletions[row][column]; + } + } + } + + class LanguageAdapter extends RecyclerView.Adapter { + + @Override + public LanguageHolder onCreateViewHolder(ViewGroup parent, int viewType) { + return new LanguageHolder(getStageActivity().getLayoutInflater() + .inflate(R.layout.item_language, parent, false)); + } + + @Override + public void onBindViewHolder(LanguageHolder holder, int position) { + holder.language.setText(LANGUAGE_STR_IDS[position]); + if (position == 0) { + holder.original.setVisibility(View.INVISIBLE); + } else { + holder.original.setVisibility(View.VISIBLE); + } + boolean[] selections = mSeletions[position]; + holder.original.setChecked(selections[0]); + holder.translated.setChecked(selections[1]); + holder.rewrite.setChecked(selections[2]); + } + + @Override + public int getItemCount() { + return ROW_COUNT; + } + } +} diff --git a/app/src/main/java/com/hippo/ehviewer/util/Settings.java b/app/src/main/java/com/hippo/ehviewer/util/Settings.java index 795bb8e05..75c2ae696 100644 --- a/app/src/main/java/com/hippo/ehviewer/util/Settings.java +++ b/app/src/main/java/com/hippo/ehviewer/util/Settings.java @@ -149,10 +149,22 @@ public final class Settings { } /****** EhConfig ******/ - private static EhConfig sEhConfig = new EhConfig(); + private static final String KEY_EXCLUDED_LANGUAGES = "excluded_languages"; + private static final String DEFAULT_EXCLUDED_LANGUAGES = ""; - public static EhConfig getEhConfig() { - return sEhConfig; + + public static EhConfig generateEhConfig() { + EhConfig config = new EhConfig(); + config.excludedLanguages = getExcludedLanguages(); + return config; + } + + public static void putExcludedLanguages(String value) { + putString(KEY_EXCLUDED_LANGUAGES, value); + } + + public static String getExcludedLanguages() { + return getString(KEY_EXCLUDED_LANGUAGES, DEFAULT_EXCLUDED_LANGUAGES); } /****** Advance ******/ diff --git a/app/src/main/java/com/hippo/scene/preference/Preference.java b/app/src/main/java/com/hippo/scene/preference/Preference.java index 8bd0bdf88..9177f956f 100644 --- a/app/src/main/java/com/hippo/scene/preference/Preference.java +++ b/app/src/main/java/com/hippo/scene/preference/Preference.java @@ -146,7 +146,7 @@ public class Preference extends PreferenceBase { @Override public boolean onClick(RecyclerView.ViewHolder viewHolder, int x, int y) { - return mOnClickListener != null && mOnClickListener.onClick(); + return mOnClickListener != null && mOnClickListener.onClick(this); } protected boolean stableWidgetFrame() { @@ -174,7 +174,7 @@ public class Preference extends PreferenceBase { } public interface OnClickListener { - boolean onClick(); + boolean onClick(Preference preferenc); } public interface OnValueChangeListener { diff --git a/app/src/main/java/com/hippo/widget/SensitiveCheckBox.java b/app/src/main/java/com/hippo/widget/SensitiveCheckBox.java new file mode 100644 index 000000000..01e16e171 --- /dev/null +++ b/app/src/main/java/com/hippo/widget/SensitiveCheckBox.java @@ -0,0 +1,83 @@ +/* + * Copyright 2015 Hippo Seven + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hippo.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.CheckBox; +import android.widget.RatingBar; + +public class SensitiveCheckBox extends CheckBox { + + private boolean mFromUser; + + private OnCheckedChangeListener mOnCheckedChangeListener; + + public SensitiveCheckBox(Context context) { + super(context); + } + + public SensitiveCheckBox(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public SensitiveCheckBox(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + RatingBar a; + } + + @Override + public boolean performClick() { + boolean result; + + mFromUser = true; + result = super.performClick(); + mFromUser = false; + + return result; + } + + public void setOnCheckedChangeListener(OnCheckedChangeListener listener) { + mOnCheckedChangeListener = listener; + } + + @Override + public void setChecked(boolean checked) { + super.setChecked(checked); + + if (mOnCheckedChangeListener != null) { + mOnCheckedChangeListener.onCheckedChanged(this, checked, mFromUser); + } + } + + /** + * Interface definition for a callback to be invoked when the checked state + * of a compound button changed. + */ + public interface OnCheckedChangeListener { + /** + * Called when the checked state of a compound button has changed. + * + * @param view The sensitive check box view whose state has changed. + * @param isChecked The new checked state of buttonView. + * @param fromUser True if the rating change was initiated by a user's + * touch gesture. + */ + void onCheckedChanged(SensitiveCheckBox view, boolean isChecked, boolean fromUser); + } +} diff --git a/app/src/main/res/layout/item_language.xml b/app/src/main/res/layout/item_language.xml new file mode 100644 index 000000000..1ae056399 --- /dev/null +++ b/app/src/main/res/layout/item_language.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/scene_excluded_languages.xml b/app/src/main/res/layout/scene_excluded_languages.xml new file mode 100644 index 000000000..3be6bef01 --- /dev/null +++ b/app/src/main/res/layout/scene_excluded_languages.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ed2cfba6b..57f6b471b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -145,6 +145,34 @@ Show application stats Show application stats at the top-right corner of the screen + + Excluded languages + All + None + Invert + Language + Original + Translated + Rewrite + + Japanese + English + Chinese + Dutch + French + German + Hungarian + Italian + Korean + Polish + Portuguese + Russian + Spanish + Thai + Vietnamese + N/A + Other + \"What ?\" \"I lose my panda …\" diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 38c16a911..036772471 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -66,12 +66,16 @@ @style/TextAppearance.AppCompat.Button bold center - 48dp + 40dp 88dp @dimen/card_button_padding ?attr/colorPrimary + +