├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── layout
│ │ │ │ ├── content_main.xml
│ │ │ │ └── activity_main.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── guy
│ │ │ └── rateapplication
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── guy
│ │ │ └── rateapplication
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── guy
│ │ └── rateapplication
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── smartrate
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── colors.xml
│ │ │ ├── drawable
│ │ │ │ ├── border.xml
│ │ │ │ ├── ic_star_active.xml
│ │ │ │ ├── ic_star_deactive.xml
│ │ │ │ ├── ic_google_play.xml
│ │ │ │ └── ic_5_stars.xml
│ │ │ ├── layout
│ │ │ │ └── dialog_rate.xml
│ │ │ └── layout-land
│ │ │ │ └── dialog_rate.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── guy4444
│ │ │ └── smartrate
│ │ │ └── SmartRate.java
│ ├── test
│ │ └── java
│ │ │ └── guy4444
│ │ │ └── smartrate
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── guy4444
│ │ └── smartrate
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── sc.png
├── desc.png
├── sc_1.png
├── sc_2.png
├── sc_5.png
├── sc_6.png
├── preview.jpg
├── preview2.jpg
├── sc_1_sml.png
├── sc_2_sml.png
├── sc_3_sml.png
├── sc_4_sml.png
├── description.docx
├── screen shot.png
├── screen shot 2.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── Screen Shot 2020-05-11 at 20.04.44.png
├── .idea
└── encodings.xml
├── gradle.properties
├── .gitignore
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/smartrate/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':smartrate'
2 |
--------------------------------------------------------------------------------
/sc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc.png
--------------------------------------------------------------------------------
/desc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/desc.png
--------------------------------------------------------------------------------
/sc_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc_1.png
--------------------------------------------------------------------------------
/sc_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc_2.png
--------------------------------------------------------------------------------
/sc_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc_5.png
--------------------------------------------------------------------------------
/sc_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc_6.png
--------------------------------------------------------------------------------
/preview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/preview.jpg
--------------------------------------------------------------------------------
/preview2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/preview2.jpg
--------------------------------------------------------------------------------
/sc_1_sml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc_1_sml.png
--------------------------------------------------------------------------------
/sc_2_sml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc_2_sml.png
--------------------------------------------------------------------------------
/sc_3_sml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc_3_sml.png
--------------------------------------------------------------------------------
/sc_4_sml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/sc_4_sml.png
--------------------------------------------------------------------------------
/description.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/description.docx
--------------------------------------------------------------------------------
/screen shot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/screen shot.png
--------------------------------------------------------------------------------
/screen shot 2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/screen shot 2.png
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/smartrate/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SmartRate
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Screen Shot 2020-05-11 at 20.04.44.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/Screen Shot 2020-05-11 at 20.04.44.png
--------------------------------------------------------------------------------
/smartrate/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guy-4444/SmartRateUsDialog-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Rate Application
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/smartrate/src/main/res/drawable/border.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon May 06 17:53:44 IDT 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #03A9F4
4 | #2196F3
5 | #8BC34A
6 |
7 |
8 | #FFFFFF
9 | #000000
10 |
11 |
--------------------------------------------------------------------------------
/smartrate/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #03A9F4
4 | #0878D1
5 | #8BC34A
6 |
7 |
8 | #FFFFFF
9 | #000000
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/guy/rateapplication/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package guy.rateapplication;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/smartrate/src/test/java/guy4444/smartrate/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package guy4444.smartrate;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/smartrate/src/main/res/drawable/ic_star_active.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
14 |
--------------------------------------------------------------------------------
/smartrate/src/main/res/drawable/ic_star_deactive.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/smartrate/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/guy/rateapplication/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package guy.rateapplication;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("guy.rateapplication", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/smartrate/src/androidTest/java/guy4444/smartrate/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package guy4444.smartrate;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("guy4444.smartrate.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
--------------------------------------------------------------------------------
/smartrate/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 31
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 18
10 | targetSdkVersion 31
11 |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 |
28 | implementation 'androidx.appcompat:appcompat:1.3.1'
29 | implementation 'com.google.android.material:material:1.4.0'
30 | implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
31 | implementation 'androidx.navigation:navigation-fragment:2.3.5'
32 | implementation 'androidx.navigation:navigation-ui:2.3.5'
33 | testImplementation 'junit:junit:4.+'
34 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
36 | }
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # IntelliJ
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/assetWizardSettings.xml
41 | .idea/dictionaries
42 | .idea/libraries
43 | .idea/caches
44 |
45 | # Keystore files
46 | # Uncomment the following line if you do not want to check your keystore files in.
47 | #*.jks
48 |
49 | # External native build folder generated in Android Studio 2.2 and later
50 | .externalNativeBuild
51 |
52 | # Google Services (e.g. APIs or Firebase)
53 | google-services.json
54 |
55 | # Freeline
56 | freeline.py
57 | freeline/
58 | freeline_project_description.json
59 |
60 | # fastlane
61 | fastlane/report.xml
62 | fastlane/Preview.html
63 | fastlane/screenshots
64 | fastlane/test_output
65 | fastlane/readme.md
66 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 31
5 | defaultConfig {
6 | applicationId "guy.rateapplication"
7 | minSdkVersion 18
8 | targetSdkVersion 31
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | compileOptions {
20 | sourceCompatibility JavaVersion.VERSION_1_8
21 | targetCompatibility JavaVersion.VERSION_1_8
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation 'androidx.appcompat:appcompat:1.3.1'
28 | implementation 'com.google.android.material:material:1.4.0'
29 | implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
30 | implementation 'androidx.navigation:navigation-fragment:2.3.5'
31 | implementation 'androidx.navigation:navigation-ui:2.3.5'
32 | testImplementation 'junit:junit:4.+'
33 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
34 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
35 | implementation project(path: ':smartrate')
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
--------------------------------------------------------------------------------
/smartrate/src/main/res/drawable/ic_google_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
14 |
17 |
20 |
23 |
26 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SmartRateUsDialog-Android
2 | 
3 | [](https://jitpack.io/#guy-4444/SmartRateUsDialog-Android)
4 | []()
5 | [](https://android-arsenal.com/details/1/7577)
6 | 
7 |
8 | A library for simple implementation of smart ranking.
9 | The user will see a dialog every x time.
10 | If the user gives a high score, he will be transferred to the Google store. If he gives a low score, he will only receive a thank you toast message.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ## Setup
23 | Step 1. Add it in your root build.gradle at the end of repositories:
24 | ```
25 | allprojects {
26 | repositories {
27 | maven { url 'https://jitpack.io' }
28 | }
29 | }
30 | ```
31 |
32 | Step 2. Add the dependency:
33 |
34 | ```
35 | dependencies {
36 | implementation 'com.github.guy-4444:SmartRateUsDialog-Android:1.00.08'
37 | }
38 | ```
39 | ## Usage
40 |
41 | ###### StepProgress Constructor:
42 | ```java
43 |
44 | // For continual calls -
45 | SmartRate.Rate(MainActivity.this
46 | , "Rate Us"
47 | , "Tell others what you think about this app"
48 | , "Continue"
49 | , "Please take a moment and rate us on Google Play"
50 | , "click here"
51 | , "Ask me later"
52 | , "Never ask again"
53 | , "Cancel"
54 | , "Thanks for the feedback"
55 | , Color.parseColor("#2196F3")
56 | , 4
57 | , 48
58 | , 72
59 | );
60 |
61 | // For one time call
62 | SmartRate.Rate(MainActivity.this
63 | , "Rate Us"
64 | , "Tell others what you think about this app"
65 | , "Continue"
66 | , "Please take a moment and rate us on Google Play"
67 | , "click here"
68 | , "Cancel"
69 | , "Thanks for the feedback"
70 | , Color.parseColor("#2196F3")
71 | , 4
72 | );
73 |
74 | // With Call Back:
75 | SmartRate.Rate(MainActivity.this
76 | , "Rate Us"
77 | , "Tell others what you think about this app"
78 | , "Continue"
79 | , "Please take a moment and rate us on Google Play"
80 | , "click here"
81 | , "Cancel"
82 | , "Thanks for the feedback"
83 | , Color.parseColor("#2196F3")
84 | , 4
85 | , new SmartRate.CallBack_UserRating() {
86 | @Override
87 | public void userRating(int rating) {
88 | // Do something
89 | // maybe from now disable this button
90 | }
91 | }
92 | );
93 |
94 | // Self implement without link to google play store:
95 | // -1 on stars
96 | SmartRate.Rate(MainActivity.this
97 | , Color.parseColor("#E44643")
98 | , -1
99 | , new SmartRate.CallBack_UserRating() {
100 | @Override
101 | public void userRating(int rating) {
102 | Toast.makeText(MainActivity.this, "Rating: " + rating + " Stars", Toast.LENGTH_LONG).show();
103 | //saveUserRating(rating);
104 | }
105 | }
106 | );
107 |
108 | ```
109 |
110 | 
111 |
112 | ## What's new
113 | 1.00.08:
114 | 1. Landscape design improvements
115 | 2. Cancel button
116 | 3. google play click - new implementation
117 | 4. Fix bugs:
118 | - first time does't appear
119 | - 0 hour - now appear
120 | ## License
121 |
122 | Copyright 2019 Guy Isakov
123 |
124 | Licensed under the Apache License, Version 2.0 (the "License");
125 | you may not use this file except in compliance with the License.
126 | You may obtain a copy of the License at
127 |
128 | http://www.apache.org/licenses/LICENSE-2.0
129 |
130 | Unless required by applicable law or agreed to in writing, software
131 | distributed under the License is distributed on an "AS IS" BASIS,
132 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133 | See the License for the specific language governing permissions and
134 | limitations under the License.
135 |
136 | ## Credits
137 |
138 | 5 stars icon:
139 | Icon made by Flat Icons (www.flat-icons.com) from www.flaticon.com
140 | Google play icon:
141 | Icon made by Flat Icons (www.flat-icons.com) from www.flaticon.com
142 |
143 |
--------------------------------------------------------------------------------
/app/src/main/java/guy/rateapplication/MainActivity.java:
--------------------------------------------------------------------------------
1 | package guy.rateapplication;
2 |
3 | import android.app.Activity;
4 | import android.content.ActivityNotFoundException;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.SharedPreferences;
8 | import android.graphics.Color;
9 | import android.graphics.PorterDuff;
10 | import android.net.Uri;
11 | import android.os.Bundle;
12 | import android.view.LayoutInflater;
13 | import android.view.View;
14 | import android.view.Menu;
15 | import android.view.MenuItem;
16 | import android.widget.Button;
17 | import android.widget.ImageButton;
18 | import android.widget.ImageView;
19 | import android.widget.RelativeLayout;
20 | import android.widget.TextView;
21 | import android.widget.Toast;
22 |
23 | import androidx.appcompat.app.AppCompatActivity;
24 | import androidx.appcompat.widget.Toolbar;
25 |
26 | import com.google.android.material.appbar.MaterialToolbar;
27 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
28 |
29 | import guy4444.smartrate.SmartRate;
30 |
31 | public class MainActivity extends AppCompatActivity {
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_main);
37 | MaterialToolbar toolbar = findViewById(R.id.toolbar);
38 | setSupportActionBar(toolbar);
39 |
40 | FloatingActionButton fab = findViewById(R.id.fab);
41 | fab.setOnClickListener(new View.OnClickListener() {
42 | @Override
43 | public void onClick(View view) {
44 | // first call after 3 days, the dialog will appear every 2 days until the user rates the app / or clicks on NEVER ASK AGAIN button
45 | // SmartRate.Rate(MainActivity.this
46 | // , "Rate Us"
47 | // , "Tell others what you think about this app"
48 | // , "Continue"
49 | // , "Please take a moment and rate us on Google Play"
50 | // , "click here"
51 | // , "Ask me later"
52 | // , "Never ask again"
53 | // , "Cancel"
54 | // , "Thanks for the feedback"
55 | // , Color.parseColor("#0878D1")
56 | // , 4
57 | // , 0
58 | // , 0
59 | // );
60 |
61 | SmartRate.Rate(MainActivity.this
62 | , Color.parseColor("#E44643")
63 | , -1
64 | , new SmartRate.CallBack_UserRating() {
65 | @Override
66 | public void userRating(int rating) {
67 | Toast.makeText(MainActivity.this, "Rating: " + rating + " Stars", Toast.LENGTH_LONG).show();
68 | //saveUserRating(rating);
69 | }
70 | }
71 | );
72 |
73 | // SmartRate.Rate(MainActivity.this
74 | // , "Rate Us"
75 | // , "Tell others what you think about this app"
76 | // , "Continue"
77 | // , "Please take a moment and rate us on Google Play"
78 | // , "click here"
79 | // , "Cancel"
80 | // , "Thanks for the feedback"
81 | // , Color.parseColor("#E44643")
82 | // , 4
83 | // );
84 | //
85 | // SmartRate.Rate(MainActivity.this
86 | // , "Rate Us"
87 | // , "Tell others what you think about this app"
88 | // , "Continue"
89 | // , "Please take a moment and rate us on Google Play"
90 | // , "click here"
91 | // , "Cancel"
92 | // , "Thanks for the feedback"
93 | // , Color.parseColor("#0878D1")
94 | // , 4
95 | // , new SmartRate.CallBack_UserRating() {
96 | // @Override
97 | // public void userRating(int rating) {
98 | // // Do something
99 | // // maybe from now disable this button
100 | // }
101 | // }
102 | // );
103 | //
104 | // SmartRate.Rate(MainActivity.this
105 | // , "דרג אותנו"
106 | // , "שתף עם אחרים מה אתה חושב עלינו"
107 | // , "המשך"
108 | // , "בבקשה דרג אותנו גם בחנות גוגל"
109 | // , "לחץ כאו"
110 | // , "ביטול"
111 | // , "תודה על הדירוג"
112 | // , Color.parseColor("#E44643")
113 | // , 4
114 | // );
115 | }
116 | });
117 | }
118 |
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/smartrate/src/main/res/layout/dialog_rate.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
19 |
20 |
21 |
22 |
31 |
32 |
44 |
45 |
56 |
57 |
66 |
67 |
79 |
80 |
87 |
88 |
95 |
96 |
97 |
107 |
108 |
118 |
119 |
129 |
130 |
140 |
141 |
151 |
152 |
153 |
169 |
170 |
171 |
172 |
177 |
178 |
191 |
192 |
196 |
197 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
--------------------------------------------------------------------------------
/smartrate/src/main/res/layout-land/dialog_rate.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
19 |
20 |
21 |
22 |
31 |
32 |
44 |
45 |
56 |
57 |
67 |
68 |
80 |
81 |
82 |
89 |
90 |
97 |
98 |
99 |
109 |
110 |
120 |
121 |
131 |
132 |
142 |
143 |
153 |
154 |
155 |
171 |
172 |
173 |
174 |
178 |
179 |
193 |
194 |
198 |
199 |
214 |
215 |
216 |
217 |
218 |
219 |
--------------------------------------------------------------------------------
/smartrate/src/main/res/drawable/ic_5_stars.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
14 |
17 |
20 |
23 |
26 |
29 |
32 |
35 |
38 |
41 |
44 |
47 |
50 |
53 |
56 |
59 |
62 |
65 |
68 |
71 |
74 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/smartrate/src/main/java/guy4444/smartrate/SmartRate.java:
--------------------------------------------------------------------------------
1 | package guy4444.smartrate;
2 |
3 | import android.app.Activity;
4 | import android.content.ActivityNotFoundException;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.SharedPreferences;
8 | import android.graphics.Color;
9 | import android.graphics.PorterDuff;
10 | import android.net.Uri;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.widget.Button;
14 | import android.widget.ImageButton;
15 | import android.widget.ImageView;
16 | import android.widget.RelativeLayout;
17 | import android.widget.TextView;
18 | import android.widget.Toast;
19 |
20 | import androidx.appcompat.app.AlertDialog;
21 |
22 | import com.google.android.material.button.MaterialButton;
23 |
24 | public class SmartRate {
25 |
26 | public interface CallBack_UserRating {
27 | void userRating(int rating);
28 | }
29 |
30 | private static final long DONT_ASK_AGAIN_VALUE = -1;
31 | private static final String SP_LIBRARY_NAME = "SP_RATE_LIBRARY";
32 | private static final String SP_KEY_LAST_ASK_TIME = "SP_KEY_LAST_ASK_TIME";
33 | private static final String SP_KEY_INIT_TIME = "SP_KEY_INIT_TIME";
34 | private static int selectedStar = 1;
35 | private static final long DEFAULT_TIME_BETWEEN_DIALOG_MS = 1000l * 60 * 60 * 24 * 6; // 3 days
36 | private static final long DEFAULT_DELAY_TO_ACTIVATE_MS = 1000l * 60 * 60 * 24 * 3; // 3 days
37 | private static String DEFAULT_TEXT_TITLE = "Rate Us";
38 | private static String DEFAULT_TEXT_CONTENT = "Tell others what you think about this app";
39 | private static String DEFAULT_TEXT_CONTINUE = "Continue";
40 | private static String DEFAULT_TEXT_GOOGLE_PLAY = "Please take a moment and rate us on Google Play";
41 | private static String DEFAULT_TEXT_CLICK_HERE = "click here";
42 | private static String DEFAULT_TEXT_LATER = "Ask me later";
43 | private static String DEFAULT_TEXT_STOP = "Never ask again";
44 | private static String DEFAULT_TEXT_CANCEL = "Cancel";
45 | private static String DEFAULT_TEXT_THANKS = "Thanks for the feedback";
46 |
47 | private static boolean continueClicked = false;
48 |
49 | public static void Rate(
50 | final Activity activity
51 | , final int mainColor
52 | , final int openStoreFromXStars
53 | , final CallBack_UserRating callBack_userRating
54 | ) {
55 | Rate(activity
56 | , ""
57 | , ""
58 | , ""
59 | , ""
60 | , ""
61 | , ""
62 | , ""
63 | , mainColor
64 | , openStoreFromXStars
65 | , callBack_userRating);
66 | }
67 |
68 | public static void Rate(
69 | final Activity activity
70 | , final String _title
71 | , final String _content
72 | , final String _continue_text
73 | , final String _googlePlay_text
74 | , final String _clickHere_text
75 | , final String _cancel_text
76 | , final String _thanksForFeedback
77 | , final int mainColor
78 | , final int openStoreFromXStars
79 | ) {
80 | Rate(activity
81 | , _title
82 | , _content
83 | , _continue_text
84 | , _googlePlay_text
85 | , _clickHere_text
86 | , ""
87 | , ""
88 | , _cancel_text
89 | , _thanksForFeedback
90 | , mainColor
91 | , openStoreFromXStars
92 | , -1
93 | , -1);
94 | }
95 |
96 | public static void Rate(
97 | final Activity activity
98 | , final String _title
99 | , final String _content
100 | , final String _continue_text
101 | , final String _googlePlay_text
102 | , final String _clickHere_text
103 | , final String _cancel_text
104 | , final String _thanksForFeedback
105 | , final int mainColor
106 | , final int openStoreFromXStars
107 | , CallBack_UserRating callBack_userRating
108 | ) {
109 | Rate(activity
110 | , _title
111 | , _content
112 | , _continue_text
113 | , _googlePlay_text
114 | , _clickHere_text
115 | , ""
116 | , ""
117 | , _cancel_text
118 | , _thanksForFeedback
119 | , mainColor
120 | , openStoreFromXStars
121 | , -1
122 | , -1
123 | , callBack_userRating);
124 | }
125 |
126 | public static void Rate(
127 | final Activity activity
128 | , final String _title
129 | , final String _content
130 | , final String _continue_text
131 | , final String _googlePlay_text
132 | , final String _clickHere_text
133 | , final String _later_text
134 | , final String _stop_text
135 | , final String _cancel_text
136 | , final String _thanksForFeedback
137 | , final int mainColor
138 | , final int openStoreFromXStars
139 | , final int _hoursBetweenCalls
140 | , final int _hoursDelayToActivate
141 | ) {
142 | Rate(activity
143 | , _title
144 | , _content
145 | , _continue_text
146 | , _googlePlay_text
147 | , _clickHere_text
148 | , _later_text
149 | , _stop_text
150 | , _cancel_text
151 | , _thanksForFeedback
152 | , mainColor
153 | , openStoreFromXStars
154 | , _hoursBetweenCalls
155 | , _hoursDelayToActivate
156 | , null);
157 | }
158 |
159 | public static void Rate(
160 | final Activity activity
161 | , final String _title
162 | , final String _content
163 | , final String _continue_text
164 | , final String _googlePlay_text
165 | , final String _clickHere_text
166 | , final String _later_text
167 | , final String _stop_text
168 | , final String _cancel_text
169 | , final String _thanksForFeedback
170 | , final int mainColor
171 | , final int openStoreFromXStars
172 | , final int _hoursBetweenCalls
173 | , final int _hoursDelayToActivate
174 | , final CallBack_UserRating callBack_userRating
175 | ) {
176 |
177 | final String title = (_title != null && !_title.equals("")) ? _title : DEFAULT_TEXT_TITLE;
178 | final String content = (_content != null && !_content.equals("")) ? _content : DEFAULT_TEXT_CONTENT;
179 | final String continue_text = (_continue_text != null && !_continue_text.equals("")) ? _continue_text : DEFAULT_TEXT_CONTINUE;
180 | final String googlePlay_text = (_googlePlay_text != null && !_googlePlay_text.equals("")) ? _googlePlay_text : DEFAULT_TEXT_GOOGLE_PLAY;
181 | final String clickHere_text = (_clickHere_text != null && !_clickHere_text.equals("")) ? _clickHere_text : DEFAULT_TEXT_CLICK_HERE;
182 | final String later_text = (_later_text != null && !_later_text.equals("")) ? _later_text : DEFAULT_TEXT_LATER;
183 | final String stop_text = (_stop_text != null && !_stop_text.equals("")) ? _stop_text : DEFAULT_TEXT_STOP;
184 | final String cancel_text = (_cancel_text != null && !_cancel_text.equals("")) ? _cancel_text : DEFAULT_TEXT_CANCEL;
185 | final String thanksForFeedback = (_thanksForFeedback != null && !_thanksForFeedback.equals("")) ? _thanksForFeedback : DEFAULT_TEXT_THANKS;
186 | final long timeBetweenCalls_Ms = (_hoursBetweenCalls >= 0 && _hoursBetweenCalls < 366 * 24) ? 1000l * 60 * 60 * _hoursBetweenCalls : DEFAULT_TIME_BETWEEN_DIALOG_MS;
187 | final long timeDelayToActivate_Ms = (_hoursDelayToActivate >= 0 && _hoursDelayToActivate < 366 * 24) ? 1000l * 60 * 60 * _hoursDelayToActivate : DEFAULT_DELAY_TO_ACTIVATE_MS;
188 | // final long timeBetweenCalls_Ms = 0;
189 | // final long timeDelayToActivate_Ms = 0;
190 |
191 | continueClicked = false;
192 | boolean hideNeverAskAgain = false;
193 |
194 | if (_hoursBetweenCalls != -1 && _hoursDelayToActivate != -1) {
195 | // no force asking mode
196 | long initTime = getInitTime(activity);
197 | if (initTime == 0) {
198 | initTime = System.currentTimeMillis();
199 | setInitTime(activity, initTime);
200 | }
201 | if (System.currentTimeMillis() < initTime + timeDelayToActivate_Ms) {
202 | return;
203 | }
204 |
205 | if (getLastAskTime(activity) == 0) {
206 | // first time asked
207 | hideNeverAskAgain = true;
208 | }
209 |
210 | if (getLastAskTime(activity) == DONT_ASK_AGAIN_VALUE) {
211 | // user already rate or click on never ask button
212 | return;
213 | }
214 | if (System.currentTimeMillis() < getLastAskTime(activity) + timeBetweenCalls_Ms) {
215 | // There was not enough time between the calls.
216 | return;
217 | }
218 | }
219 |
220 | setLastAskTime(activity, System.currentTimeMillis());
221 |
222 | AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity);
223 | LayoutInflater inflater = activity.getLayoutInflater();
224 | View dialogView = inflater.inflate(R.layout.dialog_rate, null);
225 | dialogBuilder.setView(dialogView);
226 | final AlertDialog alertDialog = dialogBuilder.create();
227 | alertDialog.setCancelable(false);
228 | alertDialog.setCanceledOnTouchOutside(false);
229 |
230 | final RelativeLayout alert_LAY_back = dialogView.findViewById(R.id.alert_LAY_back);
231 | final MaterialButton alert_BTN_ok = dialogView.findViewById(R.id.alert_BTN_ok);
232 | final Button alert_BTN_later = dialogView.findViewById(R.id.alert_BTN_later);
233 | final Button alert_BTN_stop = dialogView.findViewById(R.id.alert_BTN_stop);
234 | final TextView alert_LBL_title = dialogView.findViewById(R.id.alert_LBL_title);
235 | final TextView alert_LBL_content = dialogView.findViewById(R.id.alert_LBL_content);
236 | final TextView alert_LBL_google = dialogView.findViewById(R.id.alert_LBL_google);
237 | final View alert_LAY_stars = dialogView.findViewById(R.id.alert_LAY_stars);
238 | final ImageView alert_IMG_google = dialogView.findViewById(R.id.alert_IMG_google);
239 | final ImageButton alert_BTN_star_1 = dialogView.findViewById(R.id.alert_BTN_star_1);
240 | final ImageButton alert_BTN_star_2 = dialogView.findViewById(R.id.alert_BTN_star_2);
241 | final ImageButton alert_BTN_star_3 = dialogView.findViewById(R.id.alert_BTN_star_3);
242 | final ImageButton alert_BTN_star_4 = dialogView.findViewById(R.id.alert_BTN_star_4);
243 | final ImageButton alert_BTN_star_5 = dialogView.findViewById(R.id.alert_BTN_star_5);
244 | final ImageButton[] stars = new ImageButton[]{alert_BTN_star_1, alert_BTN_star_2, alert_BTN_star_3, alert_BTN_star_4, alert_BTN_star_5};
245 |
246 |
247 | alert_LBL_google.setVisibility(View.GONE);
248 | alert_IMG_google.setVisibility(View.GONE);
249 | alert_LAY_back.setBackgroundColor(mainColor);
250 | alert_BTN_ok.getBackground().setColorFilter(mainColor, PorterDuff.Mode.MULTIPLY);
251 | alert_LBL_title.setTextColor(mainColor);
252 | alert_LBL_content.setTextColor(mainColor);
253 | alert_BTN_later.setTextColor(Color.parseColor(shadeColor(String.format("#%06X", 0xFFFFFF & mainColor), -33)));
254 | alert_BTN_stop.setTextColor(Color.parseColor(shadeColor(String.format("#%06X", 0xFFFFFF & mainColor), -33)));
255 |
256 |
257 | final int drawable_active = R.drawable.ic_star_active;
258 | final int drawable_deactive = R.drawable.ic_star_deactive;
259 |
260 | View.OnClickListener starsClickListener = new View.OnClickListener() {
261 | @Override
262 | public void onClick(View v) {
263 | int clickedIndex = -1;
264 | for (int i = 0; i < stars.length; i++) {
265 | if (stars[i].getId() == v.getId()) {
266 | clickedIndex = i;
267 | break;
268 | }
269 | }
270 |
271 | if (clickedIndex != -1) {
272 | for (int i = 0; i <= clickedIndex; i++) {
273 | stars[i].setImageResource(drawable_active);
274 | }
275 | for (int i = clickedIndex + 1; i < stars.length; i++) {
276 | stars[i].setImageResource(drawable_deactive);
277 | }
278 | }
279 |
280 | alert_BTN_ok.setEnabled(true);
281 | alert_BTN_ok.setText((clickedIndex + 1) + "/5\n" + continue_text);
282 | selectedStar = clickedIndex + 1;
283 | }
284 | };
285 |
286 | alert_BTN_star_1.setOnClickListener(starsClickListener);
287 | alert_BTN_star_2.setOnClickListener(starsClickListener);
288 | alert_BTN_star_3.setOnClickListener(starsClickListener);
289 | alert_BTN_star_4.setOnClickListener(starsClickListener);
290 | alert_BTN_star_5.setOnClickListener(starsClickListener);
291 |
292 |
293 | alert_LBL_title.setText(title);
294 | alert_LBL_content.setText(content);
295 |
296 |
297 | if (continue_text != null && !continue_text.equals("")) {
298 | alert_BTN_ok.setText(continue_text);
299 | alert_BTN_ok.setText("?/5\n" + continue_text);
300 | alert_BTN_ok.setOnClickListener(new View.OnClickListener() {
301 | @Override
302 | public void onClick(View view) {
303 |
304 | int _openStoreFrom_Stars = openStoreFromXStars;
305 | if (openStoreFromXStars < 1 || openStoreFromXStars > 5) {
306 | _openStoreFrom_Stars = 4;
307 | }
308 |
309 | if (continueClicked) {
310 | setLastAskTime(activity, DONT_ASK_AGAIN_VALUE);
311 |
312 |
313 | if (selectedStar >= _openStoreFrom_Stars) {
314 | launchMarket(activity);
315 | } else {
316 | Toast.makeText(activity, thanksForFeedback, Toast.LENGTH_SHORT).show();
317 | }
318 | alertDialog.dismiss();
319 | } else {
320 | if (openStoreFromXStars != -1 && selectedStar >= _openStoreFrom_Stars) {
321 | continueClicked = true;
322 |
323 | alert_LBL_title.setVisibility(View.GONE);
324 | alert_LBL_content.setVisibility(View.GONE);
325 | alert_LAY_stars.setVisibility(View.GONE);
326 | alert_BTN_stop.setVisibility(View.GONE);
327 | alert_LBL_google.setVisibility(View.VISIBLE);
328 | alert_IMG_google.setVisibility(View.VISIBLE);
329 | alert_LBL_google.setText(googlePlay_text);
330 | alert_BTN_ok.setText(clickHere_text);
331 | alert_BTN_later.setText(cancel_text);
332 |
333 | //String text = googlePlay_text + "\n(" + clickHere_text + ")";
334 | //Spannable span = new SpannableString(text);
335 | //span.setSpan(new RelativeSizeSpan(0.7f), 0, googlePlay_text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
336 | //span.setSpan(new RelativeSizeSpan(0.4f), googlePlay_text.length(), text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
337 | //alert_BTN_ok.setText(span);
338 | } else {
339 | alertDialog.dismiss();
340 | Toast.makeText(activity, thanksForFeedback, Toast.LENGTH_SHORT).show();
341 | }
342 | }
343 |
344 | if (callBack_userRating != null) {
345 | callBack_userRating.userRating(selectedStar);
346 | }
347 |
348 | }
349 | });
350 | } else {
351 | alert_BTN_ok.setVisibility(View.INVISIBLE);
352 | }
353 | alert_BTN_ok.setEnabled(false);
354 |
355 | if (hideNeverAskAgain) {
356 | alert_BTN_stop.setVisibility(View.GONE);
357 | }
358 |
359 | if (later_text != null && !later_text.equals("")) {
360 | alert_BTN_later.setText(later_text);
361 | alert_BTN_later.setOnClickListener(new View.OnClickListener() {
362 | @Override
363 | public void onClick(View view) {
364 |
365 | alertDialog.dismiss();
366 | }
367 | });
368 | } else {
369 | alert_BTN_later.setVisibility(View.INVISIBLE);
370 | }
371 |
372 | if (stop_text != null && !stop_text.equals("")) {
373 | alert_BTN_stop.setText(stop_text);
374 | alert_BTN_stop.setOnClickListener(new View.OnClickListener() {
375 | @Override
376 | public void onClick(View view) {
377 | setLastAskTime(activity, DONT_ASK_AGAIN_VALUE);
378 | alertDialog.dismiss();
379 | }
380 | });
381 | } else {
382 | alert_BTN_stop.setVisibility(View.GONE);
383 | }
384 |
385 |
386 | if (_hoursBetweenCalls == -1 && _hoursDelayToActivate == -1) {
387 | // force asking mode
388 | alert_BTN_later.setText(cancel_text);
389 | alert_BTN_stop.setVisibility(View.GONE);
390 | }
391 |
392 | alertDialog.show();
393 | }
394 |
395 | private static void launchMarket(Activity activity) {
396 | Uri uri = Uri.parse("market://details?id=" + activity.getPackageName());
397 | Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri);
398 | try {
399 | activity.startActivity(myAppLinkToMarket);
400 | } catch (ActivityNotFoundException e) {
401 | Toast.makeText(activity, " unable to find google play app", Toast.LENGTH_LONG).show();
402 | }
403 | }
404 |
405 | private static long getLastAskTime(Activity activity) {
406 | SharedPreferences sharedPreferences = activity.getSharedPreferences(SP_LIBRARY_NAME, Context.MODE_PRIVATE);
407 | long val = sharedPreferences.getLong(SP_KEY_LAST_ASK_TIME, 0);
408 | return val;
409 | }
410 |
411 | private static void setLastAskTime(Activity activity, long time) {
412 | SharedPreferences.Editor editor = activity.getSharedPreferences(SP_LIBRARY_NAME, Context.MODE_PRIVATE).edit();
413 | editor.putLong(SP_KEY_LAST_ASK_TIME, time);
414 | editor.apply();
415 | }
416 |
417 | private static long getInitTime(Activity activity) {
418 | SharedPreferences sharedPreferences = activity.getSharedPreferences(SP_LIBRARY_NAME, Context.MODE_PRIVATE);
419 | long val = sharedPreferences.getLong(SP_KEY_INIT_TIME, 0);
420 | return val;
421 | }
422 |
423 | private static void setInitTime(Activity activity, long time) {
424 | SharedPreferences.Editor editor = activity.getSharedPreferences(SP_LIBRARY_NAME, Context.MODE_PRIVATE).edit();
425 | editor.putLong(SP_KEY_INIT_TIME, time);
426 | editor.apply();
427 | }
428 |
429 | private static String shadeColor(String color, int percent) {
430 |
431 | int R = Integer.parseInt(color.substring(1, 3), 16);
432 | int G = Integer.parseInt(color.substring(3, 5), 16);
433 | int B = Integer.parseInt(color.substring(5, 7), 16);
434 |
435 | R = R * (100 + percent) / 100;
436 | G = G * (100 + percent) / 100;
437 | B = B * (100 + percent) / 100;
438 |
439 | R = (R < 255) ? R : 255;
440 | G = (G < 255) ? G : 255;
441 | B = (B < 255) ? B : 255;
442 |
443 | String RR = (Integer.toString(R, 16).length() == 1) ? "0" + Integer.toString(R, 16) : Integer.toString(R, 16);
444 | String GG = (Integer.toString(G, 16).length() == 1) ? "0" + Integer.toString(G, 16) : Integer.toString(G, 16);
445 | String BB = (Integer.toString(B, 16).length() == 1) ? "0" + Integer.toString(B, 16) : Integer.toString(B, 16);
446 |
447 | return "#" + RR + GG + BB;
448 | }
449 | }
450 |
--------------------------------------------------------------------------------