Add set excluded languages

This commit is contained in:
seven332 committed 2015-07-12 16:15:21 +08:00
1 parent 593b32f03b
commit 22af14e83b
13 files changed
+778 -68

No files matched your search

@@ -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) {
@@ -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
@@ -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) {
@@ -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
@@ -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<LanguageHolder> {
@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;
}
}
}
@@ -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 ******/
@@ -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 {
@@ -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);
}
}
+43
View File
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<com.hippo.widget.SensitiveCheckBox
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<com.hippo.widget.SensitiveCheckBox
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<com.hippo.widget.SensitiveCheckBox
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="@dimen/keyline_margin"
android:paddingRight="@dimen/keyline_margin"
android:paddingTop="8dp">
<TextView
android:id="@+id/cancel"
style="@style/ButtonInCard.Accent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@android:string/cancel"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@color/divider_light"/>
<TextView
android:id="@+id/ok"
style="@style/ButtonInCard.Accent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@android:string/ok"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="@dimen/keyline_margin"
android:paddingRight="@dimen/keyline_margin"
android:paddingTop="8dp">
<TextView
android:id="@+id/select_all"
style="@style/ButtonInCard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/select_all"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@color/divider_light"/>
<TextView
android:id="@+id/deselect_all"
style="@style/ButtonInCard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/deselect_all"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@color/divider_light"/>
<TextView
android:id="@+id/invert_selection"
style="@style/ButtonInCard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/invert_selection"/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="@dimen/keyline_margin"
android:paddingRight="@dimen/keyline_margin"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/primary_text_light"
android:text="@string/language"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/primary_text_light"
android:text="@string/original"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/primary_text_light"
android:text="@string/translated"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/primary_text_light"
android:text="@string/rewrite"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/keyline_margin"
android:layout_marginRight="@dimen/keyline_margin"
android:background="@color/divider_light"/>
<com.hippo.widget.recyclerview.EasyRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="@dimen/keyline_margin"
android:paddingRight="@dimen/keyline_margin"
android:paddingBottom="8dp"/>
</LinearLayout>
+28
View File
@@ -145,6 +145,34 @@
<string name="settings_show_application_stats_title">Show application stats</string>
<string name="settings_show_application_stats_summary">Show application stats at the top-right corner of the screen</string>
<!-- ExcludedLanguagesScene -->
<string name="excluded_languages">Excluded languages</string>
<string name="select_all">All</string>
<string name="deselect_all">None</string>
<string name="invert_selection">Invert</string>
<string name="language">Language</string>
<string name="original">Original</string>
<string name="translated">Translated</string>
<string name="rewrite">Rewrite</string>
<string name="language_japanese">Japanese</string>
<string name="language_english">English</string>
<string name="language_chinese">Chinese</string>
<string name="language_dutch">Dutch</string>
<string name="language_french">French</string>
<string name="language_german">German</string>
<string name="language_hungarian">Hungarian</string>
<string name="language_italian">Italian</string>
<string name="language_korean">Korean</string>
<string name="language_polish">Polish</string>
<string name="language_portuguese">Portuguese</string>
<string name="language_russian">Russian</string>
<string name="language_spanish">Spanish</string>
<string name="language_thai">Thai</string>
<string name="language_vietnamese">Vietnamese</string>
<string name="language_na">N/A</string>
<string name="language_other">Other</string>
<!-- Sign in -->
<string name="line_dean">\"What ?\"</string>
<string name="line_sam">\"I lose my panda …\"</string>
+5 -1
View File
@@ -66,12 +66,16 @@
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Button</item>
<item name="android:textStyle">bold</item>
<item name="android:gravity">center</item>
<item name="android:minHeight">48dp</item>
<item name="android:minHeight">40dp</item>
<item name="android:minWidth">88dp</item>
<item name="android:padding">@dimen/card_button_padding</item>
<item name="android:textColor">?attr/colorPrimary</item>
</style>
<style name="ButtonInCard.Accent">
<item name="android:textColor">?attr/colorAccent</item>
</style>
<!-- Progress Bar -->
<style name="ProgressBar" parent="android:Widget.ProgressBar">
<item name="android:indeterminateDrawable">@drawable/progress_medium_material</item>