diff --git a/.gradle/6.1/executionHistory/executionHistory.bin b/.gradle/6.1/executionHistory/executionHistory.bin
new file mode 100644
index 0000000..92a63a0
Binary files /dev/null and b/.gradle/6.1/executionHistory/executionHistory.bin differ
diff --git a/.gradle/6.1/executionHistory/executionHistory.lock b/.gradle/6.1/executionHistory/executionHistory.lock
new file mode 100644
index 0000000..3a33421
Binary files /dev/null and b/.gradle/6.1/executionHistory/executionHistory.lock differ
diff --git a/.gradle/6.1/fileChanges/last-build.bin b/.gradle/6.1/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/.gradle/6.1/fileChanges/last-build.bin differ
diff --git a/.gradle/6.1/fileContent/fileContent.lock b/.gradle/6.1/fileContent/fileContent.lock
new file mode 100644
index 0000000..3687e9c
Binary files /dev/null and b/.gradle/6.1/fileContent/fileContent.lock differ
diff --git a/.gradle/6.1/fileHashes/fileHashes.bin b/.gradle/6.1/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..c7ce6de
Binary files /dev/null and b/.gradle/6.1/fileHashes/fileHashes.bin differ
diff --git a/.gradle/6.1/fileHashes/fileHashes.lock b/.gradle/6.1/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..7aaff10
Binary files /dev/null and b/.gradle/6.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/6.1/fileHashes/resourceHashesCache.bin b/.gradle/6.1/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..4b88f2c
Binary files /dev/null and b/.gradle/6.1/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/6.1/gc.properties b/.gradle/6.1/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/.gradle/6.1/javaCompile/classAnalysis.bin b/.gradle/6.1/javaCompile/classAnalysis.bin
new file mode 100644
index 0000000..df27b28
Binary files /dev/null and b/.gradle/6.1/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/6.1/javaCompile/jarAnalysis.bin b/.gradle/6.1/javaCompile/jarAnalysis.bin
new file mode 100644
index 0000000..4bf739d
Binary files /dev/null and b/.gradle/6.1/javaCompile/jarAnalysis.bin differ
diff --git a/.gradle/6.1/javaCompile/javaCompile.lock b/.gradle/6.1/javaCompile/javaCompile.lock
new file mode 100644
index 0000000..b9a3455
Binary files /dev/null and b/.gradle/6.1/javaCompile/javaCompile.lock differ
diff --git a/.gradle/6.1/javaCompile/taskHistory.bin b/.gradle/6.1/javaCompile/taskHistory.bin
new file mode 100644
index 0000000..225e9aa
Binary files /dev/null and b/.gradle/6.1/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
new file mode 100644
index 0000000..810e62d
Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties
new file mode 100644
index 0000000..081e3b5
--- /dev/null
+++ b/.gradle/buildOutputCleanup/cache.properties
@@ -0,0 +1,2 @@
+#Fri Jan 24 16:37:42 CST 2020
+gradle.version=6.1
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
new file mode 100644
index 0000000..dd8728e
Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock
new file mode 100644
index 0000000..0779dc0
Binary files /dev/null and b/.gradle/checksums/checksums.lock differ
diff --git a/.gradle/checksums/md5-checksums.bin b/.gradle/checksums/md5-checksums.bin
new file mode 100644
index 0000000..ad36832
Binary files /dev/null and b/.gradle/checksums/md5-checksums.bin differ
diff --git a/.gradle/checksums/sha1-checksums.bin b/.gradle/checksums/sha1-checksums.bin
new file mode 100644
index 0000000..49d8c4a
Binary files /dev/null and b/.gradle/checksums/sha1-checksums.bin differ
diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/README.md b/README.md
index 8de1b1a..18abbde 100644
--- a/README.md
+++ b/README.md
@@ -124,3 +124,24 @@ I'd really want to thank:
Lib is licenced under *Apache2 licence*, so you can do whatever you want with it.
I'd highly recommend to push changes back to make it cooler :D
+# something new
+2020-02-07 by doerma
+1.SeekBarPreferenceCompat migrate to AndroidX.
+2.Icon supported. using:iconSeekBarPreference\iconSeekBarPreferenceCompat\iconSeekBarPreferenceView instead.
+for example:
+```xml
+
+````
+3.Fix a bug that sometimes seekbar can't seek to the end.
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 33b908c..dc61128 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,14 +1,19 @@
buildscript {
repositories {
+ google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.2'
+ classpath 'com.android.tools.build:gradle:3.5.2'
}
}
allprojects {
repositories {
+ maven { url 'https://maven.google.com' }
jcenter()
+ mavenCentral()
+ google()
}
}
+
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..5465fec
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,2 @@
+android.enableJetifier=true
+android.useAndroidX=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..f6b961f
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..735e85d
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Jan 24 16:29:41 CST 2020
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..cccdd3d
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/library/build.gradle b/library/build.gradle
index e6a3bdd..504a572 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
+ compileSdkVersion 29
+ buildToolsVersion '29.0.2'
defaultConfig {
- minSdkVersion 7
- targetSdkVersion 23
+ minSdkVersion 11
+ targetSdkVersion 29
versionCode 13
versionName "2.3.0"
}
@@ -17,8 +17,8 @@ android {
}
dependencies {
- compile 'com.android.support:appcompat-v7:23.4.0'
- compile 'com.android.support:preference-v7:23.4.0'
+ implementation 'androidx.appcompat:appcompat:1.0.0'
+ implementation 'androidx.preference:preference:1.0.0'
}
ext {
@@ -27,5 +27,5 @@ ext {
PUBLISH_VERSION = '2.3.0'
}
-apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
+//apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
// ./gradlew clean build generateRelease
\ No newline at end of file
diff --git a/library/src/main/java/com/pavelsikun/seekbarpreference/CustomValueDialog.java b/library/src/main/java/com/pavelsikun/seekbarpreference/CustomValueDialog.java
index 04392c4..4b6afaf 100644
--- a/library/src/main/java/com/pavelsikun/seekbarpreference/CustomValueDialog.java
+++ b/library/src/main/java/com/pavelsikun/seekbarpreference/CustomValueDialog.java
@@ -3,7 +3,6 @@
import android.app.Dialog;
import android.content.Context;
import android.content.res.TypedArray;
-import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
@@ -13,6 +12,8 @@
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Created by Pavel Sikun on 21.05.16.
*/
@@ -88,9 +89,16 @@ void show() {
private void tryApply() {
int value;
+ String s = customValueView.getText().toString();
try {
- value = Integer.parseInt(customValueView.getText().toString());
+
+ if (s.isEmpty()) {
+ value = currentValue;
+ }
+ else {
+ value = Integer.parseInt(s);
+ }
if (value > maxValue) {
Log.e(TAG, "wrong input( > than required): " + customValueView.getText().toString());
notifyWrongInput();
diff --git a/library/src/main/java/com/pavelsikun/seekbarpreference/PreferenceControllerDelegate.java b/library/src/main/java/com/pavelsikun/seekbarpreference/PreferenceControllerDelegate.java
index 75720c4..d942b3d 100644
--- a/library/src/main/java/com/pavelsikun/seekbarpreference/PreferenceControllerDelegate.java
+++ b/library/src/main/java/com/pavelsikun/seekbarpreference/PreferenceControllerDelegate.java
@@ -2,10 +2,12 @@
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
@@ -31,6 +33,8 @@ class PreferenceControllerDelegate implements SeekBar.OnSeekBarChangeListener, V
private int minValue;
private int interval;
private int currentValue;
+
+
private String measurementUnit;
private boolean dialogEnabled;
@@ -47,6 +51,7 @@ class PreferenceControllerDelegate implements SeekBar.OnSeekBarChangeListener, V
private String title;
private String summary;
private boolean isEnabled;
+ private Drawable mIcon;
//controller stuff
private boolean isView = false;
@@ -83,8 +88,8 @@ void loadValuesFromXml(AttributeSet attrs) {
minValue = DEFAULT_MIN_VALUE;
maxValue = DEFAULT_MAX_VALUE;
interval = DEFAULT_INTERVAL;
- dialogEnabled = DEFAULT_DIALOG_ENABLED;
+ dialogEnabled = DEFAULT_DIALOG_ENABLED;
isEnabled = DEFAULT_IS_ENABLED;
}
else {
@@ -92,13 +97,14 @@ void loadValuesFromXml(AttributeSet attrs) {
try {
minValue = a.getInt(R.styleable.SeekBarPreference_msbp_minValue, DEFAULT_MIN_VALUE);
interval = a.getInt(R.styleable.SeekBarPreference_msbp_interval, DEFAULT_INTERVAL);
- int saved_maxValue = a.getInt(R.styleable.SeekBarPreference_msbp_maxValue, DEFAULT_MAX_VALUE);
- maxValue = (saved_maxValue - minValue) / interval;
+ maxValue = a.getInt(R.styleable.SeekBarPreference_msbp_maxValue, DEFAULT_MAX_VALUE);
+
dialogEnabled = a.getBoolean(R.styleable.SeekBarPreference_msbp_dialogEnabled, DEFAULT_DIALOG_ENABLED);
measurementUnit = a.getString(R.styleable.SeekBarPreference_msbp_measurementUnit);
currentValue = attrs.getAttributeIntValue("http://schemas.android.com/apk/res/android", "defaultValue", DEFAULT_CURRENT_VALUE);
+ mIcon=a.getDrawable(R.styleable.SeekBarPreference_icon);
// TODO make it work:
// dialogStyle = a.getInt(R.styleable.SeekBarPreference_msbp_interval, DEFAULT_DIALOG_STYLE);
@@ -129,6 +135,10 @@ void onBind(View view) {
summaryView.setText(summary);
}
+ final ImageView imageView = (ImageView)view.findViewById(R.id.icon);
+ if ((imageView != null) && (this.mIcon != null)) {
+ imageView.setImageDrawable(this.mIcon);
+ }
view.setClickable(false);
seekBarView = (SeekBar) view.findViewById(R.id.seekbar);
@@ -180,7 +190,7 @@ public void onClick(final View v) {
public boolean persistInt(int value) {
setCurrentValue(value);
seekBarView.setOnSeekBarChangeListener(null);
- seekBarView.setProgress(currentValue - minValue);
+ seekBarView.setProgress((currentValue - minValue)/interval);
seekBarView.setOnSeekBarChangeListener(PreferenceControllerDelegate.this);
valueView.setText(String.valueOf(currentValue));
@@ -256,16 +266,11 @@ int getMaxValue() {
void setMaxValue(int maxValue) {
this.maxValue = maxValue;
+ int max = (maxValue - minValue) / interval;
if (seekBarView != null) {
- if (minValue <= 0 && maxValue >= 0) {
- seekBarView.setMax(maxValue - minValue);
- }
- else {
- seekBarView.setMax(maxValue);
- }
-
- seekBarView.setProgress(currentValue - minValue);
+ seekBarView.setMax(max);
+ seekBarView.setProgress((currentValue - minValue)/interval);
}
}
@@ -301,7 +306,7 @@ void setCurrentValue(int value) {
}
currentValue = value;
if(seekBarView != null)
- seekBarView.setProgress(currentValue - minValue);
+ seekBarView.setProgress((currentValue - minValue)/interval);
if(persistValueListener != null) {
persistValueListener.persistInt(value);
@@ -336,4 +341,12 @@ void setDialogEnabled(boolean dialogEnabled) {
void setDialogStyle(int dialogStyle) {
this.dialogStyle = dialogStyle;
}
+ public void setIcon(final Drawable icon) {
+ if (((icon == null) && (this.mIcon != null)) || ((icon != null) && (!icon.equals(this.mIcon)))) {
+ this.mIcon = icon;
+ }
+ }
+ public Drawable getIcon() {
+ return this.mIcon;
+ }
}
diff --git a/library/src/main/java/com/pavelsikun/seekbarpreference/SeekBarPreference.java b/library/src/main/java/com/pavelsikun/seekbarpreference/SeekBarPreference.java
index 978894c..4726409 100644
--- a/library/src/main/java/com/pavelsikun/seekbarpreference/SeekBarPreference.java
+++ b/library/src/main/java/com/pavelsikun/seekbarpreference/SeekBarPreference.java
@@ -24,20 +24,19 @@ public SeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
public SeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(attrs);
- }
+ }
public SeekBarPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(attrs);
+ this(context, attrs,0);
}
public SeekBarPreference(Context context) {
- super(context);
- init(null);
+ this(context,null,0);
}
private void init(AttributeSet attrs) {
setLayoutResource(R.layout.seekbar_view_layout);
+
controllerDelegate = new PreferenceControllerDelegate(getContext(), false);
controllerDelegate.setViewStateListener(this);
@@ -126,4 +125,5 @@ public void setDialogEnabled(boolean dialogEnabled) {
public void setDialogStyle(int dialogStyle) {
controllerDelegate.setDialogStyle(dialogStyle);
}
+
}
diff --git a/library/src/main/java/com/pavelsikun/seekbarpreference/SeekBarPreferenceCompat.java b/library/src/main/java/com/pavelsikun/seekbarpreference/SeekBarPreferenceCompat.java
index 6d96d5d..3519c17 100644
--- a/library/src/main/java/com/pavelsikun/seekbarpreference/SeekBarPreferenceCompat.java
+++ b/library/src/main/java/com/pavelsikun/seekbarpreference/SeekBarPreferenceCompat.java
@@ -3,11 +3,12 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.view.View;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+
/**
* Created by Pavel Sikun on 22.05.16.
*/
diff --git a/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreference.java b/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreference.java
new file mode 100644
index 0000000..a7ee23a
--- /dev/null
+++ b/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreference.java
@@ -0,0 +1,138 @@
+package com.pavelsikun.seekbarpreference;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.preference.Preference;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.ImageView;
+
+/**
+ * Created by doerma 2020.1.25
+ */
+
+public class iconSeekBarPreference extends Preference implements View.OnClickListener, PreferenceControllerDelegate.ViewStateListener, PersistValueListener, ChangeValueListener {
+
+ private PreferenceControllerDelegate controllerDelegate;
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public iconSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ init(attrs);
+ }
+
+ public iconSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(attrs);
+ }
+
+ public iconSeekBarPreference(Context context, AttributeSet attrs) {
+ this(context, attrs,0);
+ }
+
+ public iconSeekBarPreference(Context context) {
+ this(context,null,0);
+ }
+
+ private void init(AttributeSet attrs) {
+ setLayoutResource(R.layout.seekbar_view_layout);
+
+ controllerDelegate = new PreferenceControllerDelegate(getContext(), false);
+
+ controllerDelegate.setViewStateListener(this);
+ controllerDelegate.setPersistValueListener(this);
+ controllerDelegate.setChangeValueListener(this);
+
+ controllerDelegate.loadValuesFromXml(attrs);
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ controllerDelegate.onBind(view);
+ }
+
+ @Override
+ protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
+ super.onSetInitialValue(restorePersistedValue, defaultValue);
+ controllerDelegate.setCurrentValue(getPersistedInt(controllerDelegate.getCurrentValue()));
+ }
+
+ @Override
+ public boolean persistInt(int value) {
+ return super.persistInt(value);
+ }
+
+ @Override
+ public boolean onChange(int value) {
+ return callChangeListener(value);
+ }
+
+ @Override
+ public void onClick(final View v) {
+ controllerDelegate.onClick(v);
+ }
+
+ public int getMaxValue() {
+ return controllerDelegate.getMaxValue();
+ }
+
+ public void setMaxValue(int maxValue) {
+ controllerDelegate.setMaxValue(maxValue);
+ }
+
+ public int getMinValue() {
+ return controllerDelegate.getMinValue();
+ }
+
+ public void setMinValue(int minValue) {
+ controllerDelegate.setMinValue(minValue);
+ }
+
+ public int getInterval() {
+ return controllerDelegate.getInterval();
+ }
+
+ public void setInterval(int interval) {
+ controllerDelegate.setInterval(interval);
+ }
+
+ public int getCurrentValue() {
+ return controllerDelegate.getCurrentValue();
+ }
+
+ public void setCurrentValue(int currentValue) {
+ controllerDelegate.setCurrentValue(currentValue);
+ persistInt(controllerDelegate.getCurrentValue());
+ }
+
+ public String getMeasurementUnit() {
+ return controllerDelegate.getMeasurementUnit();
+ }
+
+ public void setMeasurementUnit(String measurementUnit) {
+ controllerDelegate.setMeasurementUnit(measurementUnit);
+ }
+
+ public boolean isDialogEnabled() {
+ return controllerDelegate.isDialogEnabled();
+ }
+
+ public void setDialogEnabled(boolean dialogEnabled) {
+ controllerDelegate.setDialogEnabled(dialogEnabled);
+ }
+
+ public void setDialogStyle(int dialogStyle) {
+ controllerDelegate.setDialogStyle(dialogStyle);
+ }
+
+ public void setIcon(final Drawable icon) {
+ controllerDelegate.setIcon(icon);
+ this.notifyChanged();
+ }
+ public Drawable getIcon() {
+ return controllerDelegate.getIcon();
+ }
+}
diff --git a/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreferenceCompat.java b/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreferenceCompat.java
new file mode 100644
index 0000000..d1dc92d
--- /dev/null
+++ b/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreferenceCompat.java
@@ -0,0 +1,139 @@
+package com.pavelsikun.seekbarpreference;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.util.AttributeSet;
+import android.view.View;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+
+/**
+ * Created by Pavel Sikun on 22.05.16.
+ */
+
+public class iconSeekBarPreferenceCompat extends Preference implements View.OnClickListener, PreferenceControllerDelegate.ViewStateListener, PersistValueListener, ChangeValueListener {
+
+ private PreferenceControllerDelegate controllerDelegate;
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public iconSeekBarPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ init(attrs);
+ }
+
+ public iconSeekBarPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(attrs);
+ }
+
+ public iconSeekBarPreferenceCompat(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(attrs);
+ }
+
+ public iconSeekBarPreferenceCompat(Context context) {
+ super(context);
+ init(null);
+ }
+
+ private void init(AttributeSet attrs) {
+ setLayoutResource(R.layout.seekbar_view_layout);
+ controllerDelegate = new PreferenceControllerDelegate(getContext(), false);
+
+ controllerDelegate.setViewStateListener(this);
+ controllerDelegate.setPersistValueListener(this);
+ controllerDelegate.setChangeValueListener(this);
+
+ controllerDelegate.loadValuesFromXml(attrs);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder viewRoot) {
+ super.onBindViewHolder(viewRoot);
+ controllerDelegate.onBind(viewRoot.itemView);
+ }
+
+ @Override
+ protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
+ super.onSetInitialValue(restorePersistedValue, defaultValue);
+ controllerDelegate.setCurrentValue(getPersistedInt(controllerDelegate.getCurrentValue()));
+ }
+
+ @Override
+ public boolean persistInt(int value) {
+ return super.persistInt(value);
+ }
+
+ @Override
+ public boolean onChange(int value) {
+ return callChangeListener(value);
+ }
+
+ @Override
+ public void onClick(final View v) {
+ controllerDelegate.onClick(v);
+ }
+
+ public int getMaxValue() {
+ return controllerDelegate.getMaxValue();
+ }
+
+ public void setMaxValue(int maxValue) {
+ controllerDelegate.setMaxValue(maxValue);
+ }
+
+ public int getMinValue() {
+ return controllerDelegate.getMinValue();
+ }
+
+ public void setMinValue(int minValue) {
+ controllerDelegate.setMinValue(minValue);
+ }
+
+ public int getInterval() {
+ return controllerDelegate.getInterval();
+ }
+
+ public void setInterval(int interval) {
+ controllerDelegate.setInterval(interval);
+ }
+
+ public int getCurrentValue() {
+ return controllerDelegate.getCurrentValue();
+ }
+
+ public void setCurrentValue(int currentValue) {
+ controllerDelegate.setCurrentValue(currentValue);
+ persistInt(controllerDelegate.getCurrentValue());
+ }
+
+ public String getMeasurementUnit() {
+ return controllerDelegate.getMeasurementUnit();
+ }
+
+ public void setMeasurementUnit(String measurementUnit) {
+ controllerDelegate.setMeasurementUnit(measurementUnit);
+ }
+
+ public boolean isDialogEnabled() {
+ return controllerDelegate.isDialogEnabled();
+ }
+
+ public void setDialogEnabled(boolean dialogEnabled) {
+ controllerDelegate.setDialogEnabled(dialogEnabled);
+ }
+
+ public void setDialogStyle(int dialogStyle) {
+ controllerDelegate.setDialogStyle(dialogStyle);
+ }
+ public void setIcon(final Drawable icon) {
+ controllerDelegate.setIcon(icon);
+ this.notifyChanged();
+ }
+ public Drawable getIcon() {
+ return controllerDelegate.getIcon();
+ }
+}
diff --git a/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreferenceView.java b/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreferenceView.java
new file mode 100644
index 0000000..0b719db
--- /dev/null
+++ b/library/src/main/java/com/pavelsikun/seekbarpreference/iconSeekBarPreferenceView.java
@@ -0,0 +1,145 @@
+package com.pavelsikun.seekbarpreference;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+
+/**
+ * Created by Pavel Sikun on 21.05.16.
+ */
+
+public class iconSeekBarPreferenceView extends FrameLayout implements View.OnClickListener {
+
+ private PreferenceControllerDelegate controllerDelegate;
+
+ public iconSeekBarPreferenceView(Context context) {
+ super(context);
+ init(null);
+ }
+
+ public iconSeekBarPreferenceView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(attrs);
+ }
+
+ public iconSeekBarPreferenceView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(attrs);
+ }
+
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public iconSeekBarPreferenceView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ init(attrs);
+ }
+
+ private void init(AttributeSet attrs) {
+ controllerDelegate = new PreferenceControllerDelegate(getContext(), true);
+ controllerDelegate.loadValuesFromXml(attrs);
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ View view = inflate(getContext(), R.layout.seekbar_view_layout, this);
+ controllerDelegate.onBind(view);
+ }
+
+ @Override
+ public void onClick(final View v) {
+ controllerDelegate.onClick(v);
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ controllerDelegate.setEnabled(enabled);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return controllerDelegate.isEnabled();
+ }
+
+ public int getMaxValue() {
+ return controllerDelegate.getMaxValue();
+ }
+
+ public void setMaxValue(int maxValue) {
+ controllerDelegate.setMaxValue(maxValue);
+ }
+
+ public String getTitle() {
+ return controllerDelegate.getTitle();
+ }
+
+ public void setTitle(String title) {
+ controllerDelegate.setTitle(title);
+ }
+
+ public String getSummary() {
+ return controllerDelegate.getSummary();
+ }
+
+ public void setSummary(String summary) {
+ controllerDelegate.setSummary(summary);
+ }
+
+ public int getMinValue() {
+ return controllerDelegate.getMinValue();
+ }
+
+ public void setMinValue(int minValue) {
+ controllerDelegate.setMinValue(minValue);
+ }
+
+ public int getInterval() {
+ return controllerDelegate.getInterval();
+ }
+
+ public void setInterval(int interval) {
+ controllerDelegate.setInterval(interval);
+ }
+
+ public int getCurrentValue() {
+ return controllerDelegate.getCurrentValue();
+ }
+
+ public void setCurrentValue(int currentValue) {
+ controllerDelegate.setCurrentValue(currentValue);
+ }
+
+ public String getMeasurementUnit() {
+ return controllerDelegate.getMeasurementUnit();
+ }
+
+ public void setMeasurementUnit(String measurementUnit) {
+ controllerDelegate.setMeasurementUnit(measurementUnit);
+ }
+
+ public void setOnValueSelectedListener(PersistValueListener persistValueListener) {
+ controllerDelegate.setPersistValueListener(persistValueListener);
+ }
+
+ public boolean isDialogEnabled() {
+ return controllerDelegate.isDialogEnabled();
+ }
+
+ public void setDialogEnabled(boolean dialogEnabled) {
+ controllerDelegate.setDialogEnabled(dialogEnabled);
+ }
+
+ public void setDialogStyle(int dialogStyle) {
+ controllerDelegate.setDialogStyle(dialogStyle);
+ }
+ public void setIcon(final Drawable icon) {
+ controllerDelegate.setIcon(icon);
+ }
+ public Drawable getIcon() {
+ return controllerDelegate.getIcon();
+ }
+}
diff --git a/library/src/main/res/layout/icon_seekbar_preference.xml b/library/src/main/res/layout/icon_seekbar_preference.xml
new file mode 100644
index 0000000..31c4b44
--- /dev/null
+++ b/library/src/main/res/layout/icon_seekbar_preference.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/layout/seekbar_view_layout.xml b/library/src/main/res/layout/seekbar_view_layout.xml
index 4cc7331..23373f7 100644
--- a/library/src/main/res/layout/seekbar_view_layout.xml
+++ b/library/src/main/res/layout/seekbar_view_layout.xml
@@ -1,5 +1,22 @@
-
+
+
+
+
+ android:fadingEdge="horizontal"
+ android:singleLine="true" />
+ android:textColor="?android:attr/textColorSecondary"
+ android:singleLine="true" />
+
\ No newline at end of file
diff --git a/library/src/main/res/values-zh-rCN/strings.xml b/library/src/main/res/values-zh-rCN/strings.xml
new file mode 100644
index 0000000..4fadcb5
--- /dev/null
+++ b/library/src/main/res/values-zh-rCN/strings.xml
@@ -0,0 +1,7 @@
+
+
+ 必须在两者之间:
+ 输入自定义值
+ 应用
+ 和
+
\ No newline at end of file
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index 83d936c..e902bf9 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -14,5 +14,7 @@
+
+
\ No newline at end of file
diff --git a/local.properties b/local.properties
new file mode 100644
index 0000000..393607a
--- /dev/null
+++ b/local.properties
@@ -0,0 +1,8 @@
+## This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+#
+# Location of the SDK. This is only used by Gradle.
+# For customization when using a Version Control System, please read the
+# header note.
+#Fri Jan 24 16:26:31 CST 2020
+sdk.dir=D\:\\Android\\sdk
diff --git a/sample/build.gradle b/sample/build.gradle
index 365db01..5ce1478 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
+ compileSdkVersion 29
+ buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.pavelsikun.seekbarpreference.sample"
- minSdkVersion 7
- targetSdkVersion 23
+ minSdkVersion 14
+ targetSdkVersion 29
versionCode 6
versionName "6.0"
}
@@ -20,11 +20,11 @@ android {
}
dependencies {
- compile project(':library')
+ implementation project(':library')
// for your projects use:
// compile 'com.pavelsikun:material-seekbar-preference:2.3.0'
- compile 'com.android.support:appcompat-v7:23.4.0'
- compile 'com.android.support:cardview-v7:23.4.0'
- compile 'com.android.support:preference-v7:23.4.0'
+ implementation 'androidx.appcompat:appcompat:1.0.0'
+ implementation 'androidx.cardview:cardview:1.0.0'
+ implementation 'androidx.preference:preference:1.0.0'
}
diff --git a/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExamplePreferenceActivity.java b/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExamplePreferenceActivity.java
index b5321ae..68136c3 100644
--- a/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExamplePreferenceActivity.java
+++ b/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExamplePreferenceActivity.java
@@ -1,11 +1,12 @@
package com.pavelsikun.seekbarpreference.sample;
import android.annotation.TargetApi;
+import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceFragment;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import com.pavelsikun.seekbarpreference.SeekBarPreference;
@@ -49,6 +50,7 @@ public void onCreate(Bundle savedInstanceState) {
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+
SeekBarPreference pref = new SeekBarPreference(getActivity());
pref.setTitle("Dynamic Preference");
pref.setSummary("This one was added from Java");
diff --git a/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExamplePreferenceCompatActivity.java b/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExamplePreferenceCompatActivity.java
index 7fb8310..4e4a568 100644
--- a/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExamplePreferenceCompatActivity.java
+++ b/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExamplePreferenceCompatActivity.java
@@ -1,9 +1,9 @@
package com.pavelsikun.seekbarpreference.sample;
import android.os.Bundle;
-import android.support.v7.preference.PreferenceFragmentCompat;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
diff --git a/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExampleViewActivity.java b/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExampleViewActivity.java
index 4f7550d..b9a19aa 100644
--- a/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExampleViewActivity.java
+++ b/sample/src/main/java/com/pavelsikun/seekbarpreference/sample/ExampleViewActivity.java
@@ -3,10 +3,10 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.SwitchCompat;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.SwitchCompat;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
diff --git a/sample/src/main/res/drawable/settings_box.xml b/sample/src/main/res/drawable/settings_box.xml
index 25e7ab7..e10f375 100644
--- a/sample/src/main/res/drawable/settings_box.xml
+++ b/sample/src/main/res/drawable/settings_box.xml
@@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
-
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/view_demo.xml b/sample/src/main/res/layout/view_demo.xml
index 7a2685f..faa2048 100644
--- a/sample/src/main/res/layout/view_demo.xml
+++ b/sample/src/main/res/layout/view_demo.xml
@@ -14,7 +14,8 @@
android:orientation="vertical"
android:id="@+id/root">
-
-
+
-
-
+ sample:msbp_minValue="0"
+ sample:icon="@drawable/settings_box"/>