From 0226106cf35518e27b455ecbfe101e127545fa04 Mon Sep 17 00:00:00 2001 From: Mygod Date: Tue, 10 Apr 2018 11:38:31 -0700 Subject: [PATCH 1/3] Fix DayNight theme inconsistency issues (#147) * Fix https://github.com/shadowsocks/shadowsocks-android/issues/1718 This preference lib doesn't have day night support. This commit fixes the inconsistency issues. * Update Android plugin * Update dependencies * Fix https://github.com/shadowsocks/shadowsocks-android/issues/1716 Remove the way too fancy ForegroundCheckableTextView. --- build.gradle | 7 +- gradle/wrapper/gradle-wrapper.properties | 4 +- .../widget/ForegroundCheckTextView.java | 227 ------------------ .../drawable/simple_menu_item_background.xml | 19 +- .../src/main/res/layout/simple_menu_item.xml | 3 +- .../src/main/res/values-night/colors.xml | 4 - .../src/main/res/values/attrs.xml | 6 - 7 files changed, 19 insertions(+), 251 deletions(-) delete mode 100644 preference-v7-simplemenu/src/main/java/com/takisoft/fix/support/v7/preference/widget/ForegroundCheckTextView.java delete mode 100644 preference-v7-simplemenu/src/main/res/values-night/colors.xml diff --git a/build.gradle b/build.gradle index ba29489..66a3507 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -project.ext.buildToolsVersion = '27.0.1' +project.ext.buildToolsVersion = '27.0.3' project.ext.minSdkVersion = 14 project.ext.sdkVersion = 27 project.ext.supportLibraryVersion = '27.1.0' @@ -13,10 +13,11 @@ buildscript { repositories { jcenter() maven { url "https://maven.google.com" } + google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' + classpath 'com.android.tools.build:gradle:3.1.0' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 243b3e2..37ad3e0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Aug 25 20:17:43 CEST 2017 +#Tue Apr 03 22:42:27 PDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/preference-v7-simplemenu/src/main/java/com/takisoft/fix/support/v7/preference/widget/ForegroundCheckTextView.java b/preference-v7-simplemenu/src/main/java/com/takisoft/fix/support/v7/preference/widget/ForegroundCheckTextView.java deleted file mode 100644 index af68149..0000000 --- a/preference-v7-simplemenu/src/main/java/com/takisoft/fix/support/v7/preference/widget/ForegroundCheckTextView.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.takisoft.fix.support.v7.preference.widget; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.support.annotation.NonNull; -import android.support.v7.widget.AppCompatCheckedTextView; -import android.util.AttributeSet; -import android.view.Gravity; - -import com.takisoft.fix.support.v7.preference.simplemenu.R; - -/** - * Extension of {@link AppCompatCheckedTextView} that adds a Foreground drawable. - */ -public class ForegroundCheckTextView extends AppCompatCheckedTextView { - - private Drawable mForeground; - - private final Rect mSelfBounds = new Rect(); - - private final Rect mOverlayBounds = new Rect(); - - private int mForegroundGravity = Gravity.FILL; - - protected boolean mForegroundInPadding = true; - - boolean mForegroundBoundsChanged = false; - - public ForegroundCheckTextView(Context context) { - this(context, null); - } - - public ForegroundCheckTextView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public ForegroundCheckTextView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - - init(context, attrs, defStyleAttr); - } - -// @TargetApi(Build.VERSION_CODES.LOLLIPOP) -// public ForegroundCheckTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { -// super(context, attrs, defStyleAttr, defStyleRes); -// -// init(context, attrs, defStyleAttr); -// } - - private void init(Context context, AttributeSet attrs, int defStyleAttr) { - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundCheckTextView, - defStyleAttr, 0); - - mForegroundGravity = a.getInt( - R.styleable.ForegroundCheckTextView_android_foregroundGravity, mForegroundGravity); - - final Drawable d = a.getDrawable(R.styleable.ForegroundCheckTextView_android_foreground); - if (d != null) { - setForeground(d); - } - - mForegroundInPadding = a.getBoolean( - R.styleable.ForegroundCheckTextView_pref_foregroundInsidePadding, true); - - a.recycle(); - } - - /** - * Describes how the foreground is positioned. - * - * @return foreground gravity. - * @see #setForegroundGravity(int) - */ - public int getForegroundGravity() { - return mForegroundGravity; - } - - /** - * Describes how the foreground is positioned. Defaults to START and TOP. - * - * @param foregroundGravity See {@link Gravity} - * @see #getForegroundGravity() - */ - public void setForegroundGravity(int foregroundGravity) { - if (mForegroundGravity != foregroundGravity) { - if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { - foregroundGravity |= Gravity.START; - } - - if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { - foregroundGravity |= Gravity.TOP; - } - - mForegroundGravity = foregroundGravity; - - if (mForegroundGravity == Gravity.FILL && mForeground != null) { - Rect padding = new Rect(); - mForeground.getPadding(padding); - } - - requestLayout(); - } - } - - @Override - protected boolean verifyDrawable(Drawable who) { - return super.verifyDrawable(who) || (who == mForeground); - } - - @Override - public void jumpDrawablesToCurrentState() { - super.jumpDrawablesToCurrentState(); - if (mForeground != null) { - mForeground.jumpToCurrentState(); - } - } - - @Override - protected void drawableStateChanged() { - super.drawableStateChanged(); - if (mForeground != null && mForeground.isStateful()) { - mForeground.setState(getDrawableState()); - } - } - - /** - * Supply a Drawable that is to be rendered on top of all of the child - * views in the frame layout. Any padding in the Drawable will be taken - * into account by ensuring that the children are inset to be placed - * inside of the padding area. - * - * @param drawable The Drawable to be drawn on top of the children. - */ - public void setForeground(Drawable drawable) { - if (mForeground != drawable) { - if (mForeground != null) { - mForeground.setCallback(null); - unscheduleDrawable(mForeground); - } - - mForeground = drawable; - - if (drawable != null) { - setWillNotDraw(false); - drawable.setCallback(this); - if (drawable.isStateful()) { - drawable.setState(getDrawableState()); - } - if (mForegroundGravity == Gravity.FILL) { - Rect padding = new Rect(); - drawable.getPadding(padding); - } - } else { - setWillNotDraw(true); - } - requestLayout(); - invalidate(); - } - } - - /** - * Returns the drawable used as the foreground of this FrameLayout. The - * foreground drawable, if non-null, is always drawn on top of the children. - * - * @return A Drawable or null if no foreground was set. - */ - public Drawable getForeground() { - return mForeground; - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - mForegroundBoundsChanged |= changed; - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - mForegroundBoundsChanged = true; - } - - @Override - public void draw(@NonNull Canvas canvas) { - super.draw(canvas); - - if (mForeground != null) { - final Drawable foreground = mForeground; - - if (mForegroundBoundsChanged) { - mForegroundBoundsChanged = false; - final Rect selfBounds = mSelfBounds; - final Rect overlayBounds = mOverlayBounds; - - final int w = getRight() - getLeft(); - final int h = getBottom() - getTop(); - - if (mForegroundInPadding) { - selfBounds.set(0, 0, w, h); - } else { - selfBounds.set(getPaddingLeft(), getPaddingTop(), - w - getPaddingRight(), h - getPaddingBottom()); - } - - Gravity.apply(mForegroundGravity, foreground.getIntrinsicWidth(), - foreground.getIntrinsicHeight(), selfBounds, overlayBounds); - foreground.setBounds(overlayBounds); - } - - foreground.draw(canvas); - } - } - - @Override - public void drawableHotspotChanged(float x, float y) { - super.drawableHotspotChanged(x, y); - if (mForeground != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - mForeground.setHotspot(x, y); - } - } - } -} diff --git a/preference-v7-simplemenu/src/main/res/drawable/simple_menu_item_background.xml b/preference-v7-simplemenu/src/main/res/drawable/simple_menu_item_background.xml index 92a15ef..45e99a7 100644 --- a/preference-v7-simplemenu/src/main/res/drawable/simple_menu_item_background.xml +++ b/preference-v7-simplemenu/src/main/res/drawable/simple_menu_item_background.xml @@ -1,9 +1,14 @@ - - - - - + + + + + + + + + + - - \ No newline at end of file + + \ No newline at end of file diff --git a/preference-v7-simplemenu/src/main/res/layout/simple_menu_item.xml b/preference-v7-simplemenu/src/main/res/layout/simple_menu_item.xml index b870e9c..14d22b2 100644 --- a/preference-v7-simplemenu/src/main/res/layout/simple_menu_item.xml +++ b/preference-v7-simplemenu/src/main/res/layout/simple_menu_item.xml @@ -17,12 +17,11 @@ ** limitations under the License. */ --> - - - #303030 - \ No newline at end of file diff --git a/preference-v7-simplemenu/src/main/res/values/attrs.xml b/preference-v7-simplemenu/src/main/res/values/attrs.xml index 116462e..9cda96b 100644 --- a/preference-v7-simplemenu/src/main/res/values/attrs.xml +++ b/preference-v7-simplemenu/src/main/res/values/attrs.xml @@ -5,12 +5,6 @@ - - - - - - From 3d2685726f5ae092172e9f931c669cebe30d876d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20K=C5=91r=C3=B6ssy?= Date: Tue, 10 Apr 2018 21:01:16 +0200 Subject: [PATCH 2/3] Updated to 27.1.1.0 --- CHANGELOG.md | 7 +++++++ README.md | 7 +++++++ build.gradle | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a256d3..a33a4b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +**2018-04-10** + +New version: 27.1.1.0 (based on v27.1.1) + +- No support preferences related changes in the support library. +- Some bug fixes (see #147 for more info). + **2018-02-28** New version: 27.1.0.0 (based on v27.1.0) diff --git a/README.md b/README.md index 4a130ad..141ef83 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,13 @@ API 15 | API 21 | API 26 ### Changelog +**2018-04-10** + +New version: 27.1.1.0 (based on v27.1.1) + +- No support preferences related changes in the support library. +- Some bug fixes (see #147 for more info). + **2018-02-28** New version: 27.1.0.0 (based on v27.1.0) diff --git a/build.gradle b/build.gradle index 66a3507..48e893d 100644 --- a/build.gradle +++ b/build.gradle @@ -2,8 +2,8 @@ project.ext.buildToolsVersion = '27.0.3' project.ext.minSdkVersion = 14 project.ext.sdkVersion = 27 -project.ext.supportLibraryVersion = '27.1.0' -project.ext.supportLibraryVersionPrefix = '27.1.0' +project.ext.supportLibraryVersion = '27.1.1' +project.ext.supportLibraryVersionPrefix = '27.1.1' project.ext.supportLibraryVersionSuffix = '' project.ext.fixLibraryVersion = '0' From c18c2f1a699d39a1313eae3bea191b733fa32b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20K=C5=91r=C3=B6ssy?= Date: Tue, 10 Apr 2018 22:16:40 +0200 Subject: [PATCH 3/3] Updated README.md --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 141ef83..5de9b65 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,12 @@ If you would like to support me, you may donate some small amount via PayPal. ### 1. Add gradle dependency First, **remove** the unnecessary lines of preference-v7 and preference-v14 from your gradle file as the bugfix contains both of them: ```gradle -compile 'com.android.support:preference-v7:27.1.0' -compile 'com.android.support:preference-v14:27.1.0' +compile 'com.android.support:preference-v7:27.1.1' +compile 'com.android.support:preference-v14:27.1.1' ``` And **add** this single line to your gradle file: ```gradle -compile 'com.takisoft.fix:preference-v7:27.1.0.0' +compile 'com.takisoft.fix:preference-v7:27.1.1.0' ``` > Notice the versioning: the first three numbers are *always* the same as the latest official library while the last number is for own updates. I try to keep it up-to-date but if, for whatever reasons, I wouldn't notice the new support library versions, just issue a ticket. @@ -92,18 +92,18 @@ Now you can enjoy using the support preferences API without losing all your hair There are additional preferences not part of the official support library, but decided to add them to some extra libraries. You can add all of them to your project using ```gradle -compile 'com.takisoft.fix:preference-v7-extras:27.1.0.0' +compile 'com.takisoft.fix:preference-v7-extras:27.1.1.0' ``` or one or more groups: Preference | Dependency | Preview -|-|- -[`RingtonePreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#ringtonepreference) | `compile 'com.takisoft.fix:preference-v7-ringtone:27.1.0.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/ringtone_api26.png) -[`DatePickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#datepickerpreference) | `compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.0.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/datepicker_api26.png) -[`TimePickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#timepickerpreference) | `compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.0.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/timepicker_api26.png) -[`ColorPickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#colorpickerpreference) | `compile 'com.takisoft.fix:preference-v7-colorpicker:27.1.0.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/colorpicker_api26_fixed.png) -[`SimpleMenuPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#simplemenupreference) | `compile 'com.takisoft.fix:preference-v7-simplemenu:27.1.0.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/simplemenu_api26.png) +[`RingtonePreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#ringtonepreference) | `compile 'com.takisoft.fix:preference-v7-ringtone:27.1.1.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/ringtone_api26.png) +[`DatePickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#datepickerpreference) | `compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.1.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/datepicker_api26.png) +[`TimePickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#timepickerpreference) | `compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.1.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/timepicker_api26.png) +[`ColorPickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#colorpickerpreference) | `compile 'com.takisoft.fix:preference-v7-colorpicker:27.1.1.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/colorpicker_api26_fixed.png) +[`SimpleMenuPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#simplemenupreference) | `compile 'com.takisoft.fix:preference-v7-simplemenu:27.1.1.0'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/simplemenu_api26.png) --- @@ -149,7 +149,7 @@ The original implementation uses `?attr/textAppearanceSmall` as the message styl --- ## Version -The current stable version is **27.1.0.0**. +The current stable version is **27.1.1.0**. ## Notes # This demo / bugfix is set to work on API level 14+.