summaryrefslogtreecommitdiff
path: root/org.fox.ttcomics
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-06-26 14:51:08 +0300
committerAndrew Dolgov <[email protected]>2015-06-26 14:51:08 +0300
commitb7e30291f6c6223f72ec0a71bcfc172839576c9f (patch)
tree30b5c3debc3ab5f28c94f7844c52ff93e337e0ba /org.fox.ttcomics
parent67dc449fd8952d17ac88daa9b84f74c8185f7570 (diff)
add workaround for android issue 26194
Diffstat (limited to 'org.fox.ttcomics')
-rwxr-xr-xorg.fox.ttcomics/src/main/AndroidManifest.xml4
-rw-r--r--org.fox.ttcomics/src/main/java/org/fox/ttcomics2/utils/LessBrokenSwitchPreference.java77
-rw-r--r--org.fox.ttcomics/src/main/res/xml/preferences.xml14
3 files changed, 86 insertions, 9 deletions
diff --git a/org.fox.ttcomics/src/main/AndroidManifest.xml b/org.fox.ttcomics/src/main/AndroidManifest.xml
index 07760ae..1af2d1d 100755
--- a/org.fox.ttcomics/src/main/AndroidManifest.xml
+++ b/org.fox.ttcomics/src/main/AndroidManifest.xml
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttcomics2"
- android:versionCode="66"
- android:versionName="1.25" >
+ android:versionCode="67"
+ android:versionName="1.26" >
<uses-sdk
android:minSdkVersion="16"
diff --git a/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/utils/LessBrokenSwitchPreference.java b/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/utils/LessBrokenSwitchPreference.java
new file mode 100644
index 0000000..fe2949b
--- /dev/null
+++ b/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/utils/LessBrokenSwitchPreference.java
@@ -0,0 +1,77 @@
+package org.fox.ttcomics2.utils;
+
+// android is shit garbage
+// https://code.google.com/p/android/issues/detail?id=26194
+
+import android.content.Context;
+import android.preference.SwitchPreference;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Switch;
+
+public class LessBrokenSwitchPreference extends SwitchPreference {
+
+ /**
+ * Construct a new SwitchPreference with the given style options.
+ *
+ * @param context The Context that will style this preference
+ * @param attrs Style attributes that differ from the default
+ * @param defStyle Theme attribute defining the default style options
+ */
+ public LessBrokenSwitchPreference(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ /**
+ * Construct a new SwitchPreference with the given style options.
+ *
+ * @param context The Context that will style this preference
+ * @param attrs Style attributes that differ from the default
+ */
+ public LessBrokenSwitchPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ /**
+ * Construct a new SwitchPreference with default style options.
+ *
+ * @param context The Context that will style this preference
+ */
+ public LessBrokenSwitchPreference(Context context) {
+ super(context, null);
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ // Clean listener before invoke SwitchPreference.onBindView
+ ViewGroup viewGroup= (ViewGroup)view;
+ clearListenerInViewGroup(viewGroup);
+ super.onBindView(view);
+ }
+
+ /**
+ * Clear listener in Switch for specify ViewGroup.
+ *
+ * @param viewGroup The ViewGroup that will need to clear the listener.
+ */
+ private void clearListenerInViewGroup(ViewGroup viewGroup) {
+ if (null == viewGroup) {
+ return;
+ }
+
+ int count = viewGroup.getChildCount();
+ for(int n = 0; n < count; ++n) {
+ View childView = viewGroup.getChildAt(n);
+ if(childView instanceof Switch) {
+ final Switch switchView = (Switch) childView;
+ switchView.setOnCheckedChangeListener(null);
+ return;
+ } else if (childView instanceof ViewGroup){
+ ViewGroup childGroup = (ViewGroup)childView;
+ clearListenerInViewGroup(childGroup);
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/org.fox.ttcomics/src/main/res/xml/preferences.xml b/org.fox.ttcomics/src/main/res/xml/preferences.xml
index 8d5f05b..243c63d 100644
--- a/org.fox.ttcomics/src/main/res/xml/preferences.xml
+++ b/org.fox.ttcomics/src/main/res/xml/preferences.xml
@@ -8,14 +8,14 @@
android:summary="@string/prefs_comics_directory_summary"
android:title="@string/prefs_comics_directory" >
</Preference>
- <SwitchPreference
+ <org.fox.ttcomics2.utils.LessBrokenSwitchPreference
android:defaultValue="true"
android:key="enable_fab"
android:summary="Show floating action button"
android:title="Enable FAB" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefs_sync" >
- <SwitchPreference
+ <org.fox.ttcomics2.utils.LessBrokenSwitchPreference
android:defaultValue="false"
android:key="use_position_sync"
android:title="@string/prefs_use_position_sync"
@@ -32,27 +32,27 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefs_reading" android:key="prefs_reading">
- <SwitchPreference
+ <org.fox.ttcomics2.utils.LessBrokenSwitchPreference
android:defaultValue="false"
android:key="use_dark_theme"
android:title="@string/prefs_dark_theme" />
- <!-- <SwitchPreference
+ <!-- <org.fox.ttcomics2.utils.LessBrokenSwitchPreference
android:defaultValue="false"
android:key="dim_status_bar"
android:title="@string/prefs_dim_status_bar" /> -->
- <SwitchPreference
+ <org.fox.ttcomics2.utils.LessBrokenSwitchPreference
android:defaultValue="false"
android:key="use_full_screen"
android:title="@string/prefs_use_full_screen" />
- <SwitchPreference
+ <org.fox.ttcomics2.utils.LessBrokenSwitchPreference
android:defaultValue="false"
android:key="fit_to_width"
android:title="@string/prefs_fit_to_width" />
- <SwitchPreference
+ <org.fox.ttcomics2.utils.LessBrokenSwitchPreference
android:defaultValue="false"
android:key="prevent_screen_sleep"
android:title="@string/prefs_prevent_screen_sleep" />