diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..4efc526 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,28 @@ + + +**Do you want to request a *feature* or report a *bug*?** + +**What is the current behavior?** + +**If the current behavior is a bug, please provide the steps to reproduce.** + + + +**Any logs, error output, bugreport etc?** + + +**What is the expected behavior?** + +**Any other comments?** + + +**What versions of software are you using?** ++ **Device Information:** + ++ **Android Version:** + ++ **Configuration Information:** + ++ **Misc:** + + \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..b1e50c4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,26 @@ + + +**What does this implement/fix? Explain your changes** + +**Does this close any currently open issues?** + +**Any relevant logs, error output, bugreport etc?** + + +**Any other comments?** + ++ **Where has this been tested?** + ++ **Device Information:** + ++ **Android Version:** + ++ **Target Platform:** + ++ **SDK Version:** + ++ **Configuration Information:** + ++ **Misc:** + + \ No newline at end of file diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..38f711c --- /dev/null +++ b/Changelog.md @@ -0,0 +1,11 @@ +# Changelog + +## 2.0.0 [17 Feb 2022] + +- ✅ Switched to Kotlin +- 🧹 Updated project + +## 1.0.3 [22 Aug 2016] + +- ✅ Initial Release + \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/README.md b/README.md index 0a58f1c..169d977 100644 --- a/README.md +++ b/README.md @@ -1,91 +1,37 @@ -# StackedHorizontalProgressBar - - -### Specs -[![Maven Central](https://img.shields.io/maven-central/v/com.github.nisrulz/stackedhorizontalprogressbar.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.nisrulz%22%20AND%20a:%22stackedhorizontalprogressbar%22) - -### Featured in -[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-StackedHorizontalProgressBar-green.svg?style=true)](https://android-arsenal.com/details/1/3554) [![AndroidDev Digest](https://img.shields.io/badge/AndroidDev%20Digest-%23101-blue.svg)](https://www.androiddevdigest.com/digest-101/) - -### Show some :heart: -[![GitHub stars](https://img.shields.io/github/stars/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Star)](https://github.com/nisrulz/stackedhorizontalprogressbar) [![GitHub forks](https://img.shields.io/github/forks/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Fork)](https://github.com/nisrulz/stackedhorizontalprogressbar/fork) [![GitHub watchers](https://img.shields.io/github/watchers/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Watch)](https://github.com/nisrulz/stackedhorizontalprogressbar) [![GitHub followers](https://img.shields.io/github/followers/nisrulz.svg?style=social&label=Follow)](https://github.com/nisrulz) -[![Twitter Follow](https://img.shields.io/twitter/follow/nisrulz.svg?style=social)](https://twitter.com/nisrulz) - - -Android library with ability to show two progress indicators in one horizontal progress bar. - -![Walkthrough](img/walkthrough-cropped.gif) - -# Including in your project -StackedHorizontalProgressBar is available in the Jcenter, so getting it as simple as adding it as a dependency -```gradle -compile 'com.github.nisrulz:stackedhorizontalprogressbar:{latest version}' -``` -where `{latest version}` corresponds to published version in [![Maven Central](https://img.shields.io/maven-central/v/com.github.nisrulz/stackedhorizontalprogressbar.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.nisrulz%22%20AND%20a:%22stackedhorizontalprogressbar%22) - -### Usage - -1. Put the StackedHorizontalProgressBar element in your layout - ```xml - - - - ``` -2. Reference in code as below - ```java - int primary_pts = 3; - int secondary_pts = 6; - int max = 10; - - StackedHorizontalProgressBar stackedHorizontalProgressBar; - stackedHorizontalProgressBar = (StackedHorizontalProgressBar) findViewById(R.id.stackedhorizontalprogressbar); - stackedHorizontalProgressBar.setMax(max); - stackedHorizontalProgressBar.setProgress(primary_pts); - stackedHorizontalProgressBar.setSecondaryProgress(secondary_pts); - - ``` - -3. If you wish to edit the colors, just edit the `colors.xml` file under the `res` > `values` -folder and add the below colors (modify the values as per your requirement) - - ```xml - - #3F51B5 - #FF4081 - ``` - -### Pull Requests -I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request: - 1. Match coding style (braces, spacing, etc.) This is best achieved using `CMD`+`Option`+`L` (Reformat code) on Mac (not sure for Windows) with Android Studio defaults. - 2. If its a feature, bugfix, or anything please only change code to what you specify. - 3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :) - 4. Pull requests _must_ be made against `develop` branch. Any other branch (unless specified by the maintainers) will get rejected. - 5. Check for existing [issues](https://github.com/nisrulz/stackedhorizontalprogressbar/issues) first, before filing an issue. - 6. Have fun! - -### Created & Maintained By -[Nishant Srivastava](https://github.com/nisrulz) ([@nisrulz](https://www.twitter.com/nisrulz)) - - -License -======= +![Image](img/github_banner.png) + +
+ +[![Maven Central](https://img.shields.io/maven-central/v/com.github.nisrulz/stackedhorizontalprogressbar)](https://search.maven.org/artifact/com.github.nisrulz/stackedhorizontalprogressbar) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-stackedhorizontalprogressbar-green.svg?style=true)](https://android-arsenal.com/details/1/3554) [![AndroidDev Digest](https://img.shields.io/badge/AndroidDev%20Digest-%23101-blue.svg)](https://www.androiddevdigest.com/digest-101/) [![GitHub stars](https://img.shields.io/github/stars/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Star)](https://github.com/nisrulz/stackedhorizontalprogressbar) [![GitHub forks](https://img.shields.io/github/forks/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Fork)](https://github.com/nisrulz/stackedhorizontalprogressbar/fork) [![GitHub watchers](https://img.shields.io/github/watchers/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Watch)](https://github.com/nisrulz/stackedhorizontalprogressbar) + +[![GitHub followers](https://img.shields.io/github/followers/nisrulz.svg?style=social&label=Follow)](https://github.com/nisrulz/stackedhorizontalprogressbar) [![Twitter Follow](https://img.shields.io/twitter/follow/nisrulz.svg?style=social)](https://twitter.com/nisrulz) + +Stacked dual progress indicator progress-bar for Android. + +
+ +- 📕 Usage Docs (at) https://nisrulz.com/stackedhorizontalprogressbar/ + +- [Changelog](Changelog.md) +- Sample App + + ![Walkthrough](img/walkthrough-cropped.gif) + +- Pull Requests + + Here are some basic rules to follow to ensure timely addition of your request: + + - If its a feature, bugfix, or anything please only change code to what you specify. + - Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :smile: + - Pull requests _must_ be made against `develop` branch. Any other branch (unless specified by the maintainers) will get rejected. + - Check for existing [issues](https://github.com/nisrulz/stackedhorizontalprogressbar/issues) first, before filing an issue. + +- License Copyright 2016 Nishant Srivastava - 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 + Licensed under the Apache License, Version 2.0, [click here for the full license](/LICENSE). - http://www.apache.org/licenses/LICENSE-2.0 +- Logo - 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. + Credit:Progress bar icons created by Freepik - Flaticon diff --git a/build.gradle b/build.gradle index 115c6dd..77311c8 100644 --- a/build.gradle +++ b/build.gradle @@ -17,43 +17,39 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - - // Required plugins added to classpath to facilitate pushing to Jcenter/Bintray - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' - } -} -allprojects { - repositories { - jcenter() - } + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" + + classpath 'com.vanniktech:gradle-maven-publish-plugin:0.18.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } } task clean(type: Delete) { - delete rootProject.buildDir + delete rootProject.buildDir } ext { - //Other - supportLibVersion = '25.0.0' - - // Lib info - libVersionCode = 4 - libVersionName = '1.0.3' - libPomUrl = 'https://github.com/nisrulz/stackedhorizontalprogressbar' - libGithubRepo = 'nisrulz/stackedhorizontalprogressbar' - - - libModuleName = 'stackedhorizontalprogressbar' - libModuleDesc = 'Android library to implement stacked horizontal progressbar' - libBintrayName = 'com.github.nisrulz:stackedhorizontalprogressbar' -} + // Deps + appCompat = "1.4.1" + annotation = "1.3.0" + lifecycle = "2.4.1" + + //Other + targetSdkVersion = 32 + minSdkVersion = 14 + compileSdkVersion = targetSdkVersion + + // Library Info + libVersionCode = 7 + libVersionName = '1.1.0' +} \ No newline at end of file diff --git a/docs/Readme.md b/docs/Readme.md new file mode 100755 index 0000000..17c02bc --- /dev/null +++ b/docs/Readme.md @@ -0,0 +1,52 @@ +![Banner](https://github.com/nisrulz/stackedhorizontalprogressbar/raw/master/img/github_banner.png) + +[![Maven Central](https://img.shields.io/maven-central/v/com.github.nisrulz/stackedhorizontalprogressbar)](https://search.maven.org/artifact/com.github.nisrulz/stackedhorizontalprogressbar) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-stackedhorizontalprogressbar-green.svg?style=true)](https://android-arsenal.com/details/1/3554) [![AndroidDev Digest](https://img.shields.io/badge/AndroidDev%20Digest-%23101-blue.svg)](https://www.androiddevdigest.com/digest-101/) [![GitHub stars](https://img.shields.io/github/stars/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Star)](https://github.com/nisrulz/stackedhorizontalprogressbar) [![GitHub forks](https://img.shields.io/github/forks/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Fork)](https://github.com/nisrulz/stackedhorizontalprogressbar/fork) [![GitHub watchers](https://img.shields.io/github/watchers/nisrulz/stackedhorizontalprogressbar.svg?style=social&label=Watch)](https://github.com/nisrulz/stackedhorizontalprogressbar) + +## Including in your project + +Stacked Horizontal ProgressBar is available in the MavenCentral, so getting it as simple as adding it as a dependency +inside your build.gradle file + +```gradle +implementation "com.github.nisrulz:stackedhorizontalprogressbar:$version" +``` + +where `$version` corresponds to latest version published in [![Maven Central](https://img.shields.io/maven-central/v/com.github.nisrulz/stackedhorizontalprogressbar)](https://search.maven.org/artifact/com.github.nisrulz/stackedhorizontalprogressbar) + +## Usage + +Put the StackedHorizontalProgressBar element in your layout + +```xml + + +``` + +Reference in code as below + +```kt +val primary_pts = 3 +val secondary_pts = 6 +val max = 10 + +val stackedHorizontalProgressBar = findViewById(R.id.stackedhorizontalprogressbar) +stackedHorizontalProgressBar.let { + it.max = max + it.progress = primary_pts + it.secondaryProgress = secondary_pts +} +``` + +If you wish to edit the colors, just edit the `colors.xml` file under the `res` > `values` folder and add the below colors (modify the values as per your requirement) + +```xml + +#3F51B5 +#FF4081 +``` diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..cc35c1d --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-modernist \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..ce14fed --- /dev/null +++ b/gradle.properties @@ -0,0 +1,31 @@ +## For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +#Mon May 24 02:20:09 CEST 2021 +android.useAndroidX=true +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official + +##### Publishing +# RELEASE_SIGNING_ENABLED=false +VERSION_NAME=1.1.0 + +POM_NAME=StackedHorizontalProgressbar +POM_ARTIFACT_ID=stackedhorizontalprogressbar +POM_DESCRIPTION=Stacked dual progress indicator progress-bar for Android. +POM_INCEPTION_YEAR=2016 +POM_URL=https://github.com/nisrulz/stackedhorizontalprogressbar/ +POM_SCM_URL=https://github.com/nisrulz/stackedhorizontalprogressbar/ +POM_SCM_CONNECTION=scm:git:git://github.com/nisrulz/stackedhorizontalprogressbar.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/nisrulz/stackedhorizontalprogressbar.git diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..41d9927 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 index 36eec40..41dfb87 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Sep 14 00:22:33 IST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip diff --git a/gradlew b/gradlew index 9d82f78..1b6c787 100755 --- a/gradlew +++ b/gradlew @@ -1,74 +1,129 @@ -#!/usr/bin/env bash +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# 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 +# +# https://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. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${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='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -# 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 - 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" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -77,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + 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 @@ -85,76 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "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 +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac 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 +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# 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\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg 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 -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index aec9973..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -8,20 +24,23 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@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= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + @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 +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,34 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_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=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -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% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/img/github_banner.png b/img/github_banner.png new file mode 100644 index 0000000..e046498 Binary files /dev/null and b/img/github_banner.png differ diff --git a/img/logo_colored.png b/img/logo_colored.png new file mode 100644 index 0000000..3a20dbf Binary files /dev/null and b/img/logo_colored.png differ diff --git a/publish_local.sh b/publish_local.sh new file mode 100755 index 0000000..6da7f16 --- /dev/null +++ b/publish_local.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +./gradlew publishToMavenLocal diff --git a/publish_release.sh b/publish_release.sh new file mode 100755 index 0000000..c728b7d --- /dev/null +++ b/publish_release.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +./gradlew publish --no-daemon --no-parallel +./gradlew closeAndReleaseRepository + diff --git a/sample/build.gradle b/sample/build.gradle index cec4abc..66bf770 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -15,29 +15,52 @@ */ apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' android { - compileSdkVersion 25 - buildToolsVersion "25.0.0" - - defaultConfig { - applicationId "github.nisrulz.stackedhorizontalprogressbarproject" - minSdkVersion 9 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + compileSdk rootProject.ext.compileSdkVersion + + defaultConfig { + minSdk rootProject.ext.minSdkVersion + targetSdk rootProject.ext.targetSdkVersion + applicationId "com.github.nisrulz.stackedhorizontalprogressbarproject" + + versionCode 1 + versionName '1.0.0' + + vectorDrawables.useSupportLibrary = true + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + debug { + minifyEnabled false + debuggable true + } + release { + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + buildFeatures { + viewBinding true } - } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibVersion" - compile project(':stackedhorizontalprogressbar') -} + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation "androidx.appcompat:appcompat:$appCompat" + implementation "androidx.annotation:annotation:$annotation" + + // Include as module + // Uncomment when developing + implementation project(':stackedhorizontalprogressbar') + + // Include as maven artifact + // Use with mavenLocal to test publication + // Or use with MavenCentral after publication + // implementation "com.github.nisrulz:stackedhorizontalprogressbar:$libVersionName" +} \ No newline at end of file diff --git a/sample/proguard-rules.pro b/sample/proguard-rules.pro index c5fc3e4..bf6891d 100644 --- a/sample/proguard-rules.pro +++ b/sample/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in /Users/nishant/android_sdk/tools/proguard/proguard-android.txt +# in /Users/nishant/sdks/android_sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 4812539..f3bc92d 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - - - + - + android:theme="@style/AppTheme" + tools:ignore="GoogleAppIndexingWarning"> + - + - + diff --git a/sample/src/main/java/com/github/nisrulz/shprogressbarproject/MainActivity.kt b/sample/src/main/java/com/github/nisrulz/shprogressbarproject/MainActivity.kt new file mode 100644 index 0000000..528c4fa --- /dev/null +++ b/sample/src/main/java/com/github/nisrulz/shprogressbarproject/MainActivity.kt @@ -0,0 +1,98 @@ +/* + * Copyright © 2016 Nishant Srivastava + * + * 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.github.nisrulz.shprogressbarproject + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.github.nisrulz.shprogressbarproject.databinding.ActivityMainBinding +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit + +class MainActivity : AppCompatActivity() { + + private var countPrimary = 10 + private var countSecondary = 0 + private val max = 100 + private val primaryPts = 50 + private val secondaryPts = 40 + + private lateinit var binding: ActivityMainBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityMainBinding.inflate(layoutInflater) + + binding.apply { + setContentView(root) + + stackedHorizontalProgressBar.max = max + btnReload.setOnClickListener { + countPrimary = 0 + setPrimaryText() + + countSecondary = 0 + setSecondaryText() + updateValuesWithDelay() + } + } + + // Update on load + updateValuesWithDelay() + } + + + private fun updateValuesWithDelay() { + val executor = Executors.newSingleThreadScheduledExecutor() + executor.scheduleWithFixedDelay({ + updateValues() + + if (countPrimary > primaryPts) { + executor.shutdown() + } + }, 0, 100, TimeUnit.MILLISECONDS) + } + + + private fun setPrimaryText() { + binding.apply { + stackedHorizontalProgressBar.progress = countPrimary + txtViewPrimary.text = getString(R.string.primary_value, countPrimary) + } + } + + private fun setSecondaryText() { + binding.apply { + stackedHorizontalProgressBar.secondaryProgress = countSecondary + txtViewSecondary.text = getString(R.string.secondary_value, countSecondary) + } + } + + + private fun updateValues() { + binding.apply { + if (countSecondary <= secondaryPts) { + setSecondaryText() + countSecondary++ + } + + if (countPrimary <= primaryPts) { + setPrimaryText() + countPrimary++ + } + } + } +} diff --git a/sample/src/main/java/github/nisrulz/stackedhorizontalprogressbarproject/MainActivity.java b/sample/src/main/java/github/nisrulz/stackedhorizontalprogressbarproject/MainActivity.java deleted file mode 100644 index 3b5730e..0000000 --- a/sample/src/main/java/github/nisrulz/stackedhorizontalprogressbarproject/MainActivity.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2016 Nishant Srivastava - * - * 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 github.nisrulz.stackedhorizontalprogressbarproject; - -import android.os.Bundle; -import android.os.Handler; -import android.support.v7.app.AppCompatActivity; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; -import github.nisrulz.stackedhorizontalprogressbar.StackedHorizontalProgressBar; - -public class MainActivity extends AppCompatActivity { - - final int primary_pts = 50; - int secondary_pts = 40; - int max = 100; - - int countPrimary = 0; - int countSecondary = 0; - StackedHorizontalProgressBar stackedHorizontalProgressBar; - Handler handlerPrimaryProgress, handlerSecondaryProgress; - - TextView txt_primary, txt_secondary; - Button btn_reload; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - stackedHorizontalProgressBar = - (StackedHorizontalProgressBar) findViewById(R.id.stackedhorizontalprogressbar); - stackedHorizontalProgressBar.setMax(max); - - txt_primary = (TextView) findViewById(R.id.txt_primary); - txt_secondary = (TextView) findViewById(R.id.txt_secondary); - - btn_reload = (Button) findViewById(R.id.btn_reload); - btn_reload.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - handlerPrimaryProgress.removeCallbacks(runnablePrimary); - handlerSecondaryProgress.removeCallbacks(runnableSecondary); - - countPrimary = 0; - stackedHorizontalProgressBar.setProgress(countPrimary); - txt_primary.setText("Primary Value : " + countPrimary + "%"); - - countSecondary = 0; - stackedHorizontalProgressBar.setSecondaryProgress(countSecondary); - txt_secondary.setText("Secondary Value : " + countSecondary + "%"); - - handlerPrimaryProgress.post(runnablePrimary); - handlerSecondaryProgress.post(runnableSecondary); - } - }); - - handlerPrimaryProgress = new Handler(); - handlerSecondaryProgress = new Handler(); - - handlerPrimaryProgress.post(runnablePrimary); - handlerSecondaryProgress.post(runnableSecondary); - } - - Runnable runnablePrimary = new Runnable() { - @Override - public void run() { - if (countPrimary <= primary_pts) { - stackedHorizontalProgressBar.setProgress(countPrimary); - txt_primary.setText("Primary Value : " + countPrimary + "%"); - handlerPrimaryProgress.postDelayed(runnablePrimary, 50); - countPrimary++; - } - } - }; - - Runnable runnableSecondary = new Runnable() { - @Override - public void run() { - if (countSecondary <= secondary_pts) { - stackedHorizontalProgressBar.setSecondaryProgress(countSecondary); - txt_secondary.setText("Secondary Value : " + countSecondary + "%"); - handlerSecondaryProgress.postDelayed(runnableSecondary, 50); - countSecondary++; - } - } - }; -} diff --git a/sample/src/main/res/appstore.png b/sample/src/main/res/appstore.png new file mode 100644 index 0000000..7406326 Binary files /dev/null and b/sample/src/main/res/appstore.png differ diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index d274f74..0b017d7 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -1,5 +1,4 @@ - - - + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingBottom="@dimen/activity_vertical_margin" + tools:context=".MainActivity"> + + + - + + - - -