diff --git a/library/src/androidTest/java/com/vorlonsoft/android/rate/UriHelperTest.java b/library/src/androidTest/java/com/vorlonsoft/android/rate/UriHelperTest.java index 65771d7..f6b5677 100644 --- a/library/src/androidTest/java/com/vorlonsoft/android/rate/UriHelperTest.java +++ b/library/src/androidTest/java/com/vorlonsoft/android/rate/UriHelperTest.java @@ -24,6 +24,7 @@ * @author Shintaro Katafuchi */ +@SuppressWarnings("unused") public class UriHelperTest { private static final String CHINESE_STORES = "market://details?id="; diff --git a/library/src/main/java/com/vorlonsoft/android/rate/AppCompatDialogManager.java b/library/src/main/java/com/vorlonsoft/android/rate/AppCompatDialogManager.java index 0208b13..903a305 100644 --- a/library/src/main/java/com/vorlonsoft/android/rate/AppCompatDialogManager.java +++ b/library/src/main/java/com/vorlonsoft/android/rate/AppCompatDialogManager.java @@ -37,6 +37,7 @@ */ public class AppCompatDialogManager extends DefaultDialogManager implements DialogManager { + /**
The WeakReference to the {@link AppCompatDialogManager} singleton object.
*/ private static volatile WeakReferenceThe WeakReference to the {@link DefaultDialogManager} singleton object.
*/ private static volatile WeakReferenceAnnotated element, represents a logical type and its value should be one of the following * constants: APPLE, CLASSIC, MODERN.
*/ - @SuppressWarnings("WeakerAccess") @Documented @Retention(SOURCE) @IntDef({ diff --git a/library/src/main/java/com/vorlonsoft/android/rate/PreferenceHelper.java b/library/src/main/java/com/vorlonsoft/android/rate/PreferenceHelper.java index 6be3c7d..36ecc31 100644 --- a/library/src/main/java/com/vorlonsoft/android/rate/PreferenceHelper.java +++ b/library/src/main/java/com/vorlonsoft/android/rate/PreferenceHelper.java @@ -116,7 +116,7 @@ static void increment365DayPeriodDialogLaunchTimes(final Context context) { currentDay = (short) (currentDay % YEAR_IN_DAYS); } - if (currentDialogLaunchTimes.matches("(.*):" + currentDay + "y" + currentYear + "-[0-9][0-9]*:")) { + if (currentDialogLaunchTimes != null && currentDialogLaunchTimes.matches("(.*):" + currentDay + "y" + currentYear + "-[0-9][0-9]*:")) { final short length = (short) currentDialogLaunchTimes.length(); String currentDayCount = "" + currentDialogLaunchTimes.charAt(length - 2); for (short s = (short) (length - 3); s > 0; s--) { @@ -137,7 +137,7 @@ static short get365DayPeriodDialogLaunchTimes(final Context context) { final byte currentYear = (byte) (currentDay / YEAR_IN_DAYS); String dialogLaunchTimes = getPreferences(context).getString(PREF_KEY_365_DAY_PERIOD_DIALOG_LAUNCH_TIMES, ":0y0-0:"); - dialogLaunchTimes = dialogLaunchTimes.replaceAll(":[0-9][0-9]*" + "y" + currentYear + "-", ":"); + dialogLaunchTimes = dialogLaunchTimes != null ? dialogLaunchTimes.replaceAll(":[0-9][0-9]*" + "y" + currentYear + "-", ":") : ":0y0-0:"; if (currentYear > 0) { currentDay = (short) (currentDay % YEAR_IN_DAYS); for (short s = currentDay; s < YEAR_IN_DAYS; s++) { diff --git a/library/src/main/java/com/vorlonsoft/android/rate/StoreType.java b/library/src/main/java/com/vorlonsoft/android/rate/StoreType.java index 7fe5a35..12bb862 100644 --- a/library/src/main/java/com/vorlonsoft/android/rate/StoreType.java +++ b/library/src/main/java/com/vorlonsoft/android/rate/StoreType.java @@ -22,45 +22,33 @@ * @author Shintaro Katafuchi */ +@SuppressWarnings("WeakerAccess") public class StoreType { /** Amazon Appstore */ - @SuppressWarnings("WeakerAccess") public static final int AMAZON = 0; /** Apple App Store */ - @SuppressWarnings("WeakerAccess") public static final int APPLE = 1; /** Cafe Bazaar */ - @SuppressWarnings("WeakerAccess") public static final int BAZAAR = 2; /** BlackBerry World */ - @SuppressWarnings("WeakerAccess") public static final int BLACKBERRY = 3; /** 19 chinese app stores */ - @SuppressWarnings("WeakerAccess") public static final int CHINESESTORES = 4; /** Google Play */ - @SuppressWarnings("WeakerAccess") public static final int GOOGLEPLAY = 5; /** Mi Appstore (Xiaomi Market) */ - @SuppressWarnings("WeakerAccess") public static final int MI = 6; /** Samsung Galaxy Apps */ - @SuppressWarnings("WeakerAccess") public static final int SAMSUNG = 7; /** SlideME Marketplace */ - @SuppressWarnings("WeakerAccess") public static final int SLIDEME = 8; /** Tencent App Store */ - @SuppressWarnings("WeakerAccess") public static final int TENCENT = 9; /** Yandex.Store */ - @SuppressWarnings("WeakerAccess") public static final int YANDEX = 10; /** Any custom intents */ - @SuppressWarnings("WeakerAccess") public static final int INTENT = 11; /** Any other Store */ - @SuppressWarnings("WeakerAccess") public static final int OTHER = 12; private StoreType() { @@ -73,7 +61,6 @@ private StoreType() { * constants: AMAZON, BAZAAR, CHINESESTORES, GOOGLEPLAY, MI, SAMSUNG, SLIDEME, TENCENT, * YANDEX. */ - @SuppressWarnings("WeakerAccess") @Documented @Retention(SOURCE) @IntDef({ @@ -95,7 +82,6 @@ private StoreType() { *Annotated element, represents a logical type and its value should be one of the following * constants: APPLE, BLACKBERRY.
*/ - @SuppressWarnings("WeakerAccess") @Documented @Retention(SOURCE) @IntDef({ @@ -111,7 +97,6 @@ private StoreType() { * constants: AMAZON, APPLE, BAZAAR, BLACKBERRY, CHINESESTORES, GOOGLEPLAY, INTENT, MI, OTHER, * SAMSUNG, SLIDEME, TENCENT, YANDEX. */ - @SuppressWarnings("WeakerAccess") @Documented @Retention(SOURCE) @IntDef({ diff --git a/sample/src/main/java/com/vorlonsoft/android/rate/sample/MainActivity.java b/sample/src/main/java/com/vorlonsoft/android/rate/sample/MainActivity.java index 5d356bd..1a56f96 100644 --- a/sample/src/main/java/com/vorlonsoft/android/rate/sample/MainActivity.java +++ b/sample/src/main/java/com/vorlonsoft/android/rate/sample/MainActivity.java @@ -60,27 +60,27 @@ protected void onCreate(Bundle savedInstanceState) { /* uncomment to test other locales - end */ /* comment if you don't want to test AppCompatDialogManager instead DefaultDialogManager */ - DialogManager.Factory appCompatDialogManagerFactory = new AppCompatDialogManager.Factory(); + @SuppressWarnings("unused") DialogManager.Factory appCompatDialogManagerFactory = new AppCompatDialogManager.Factory(); AppRate.with(this) - .setStoreType(StoreType.GOOGLEPLAY) /* default is GOOGLEPLAY (Google Play), other options are AMAZON (Amazon Appstore), BAZAAR (Cafe Bazaar), - * CHINESESTORES (19 chinese app stores), MI (Mi Appstore (Xiaomi Market)), SAMSUNG (Samsung Galaxy Apps), - * SLIDEME (SlideME Marketplace), TENCENT (Tencent App Store), YANDEX (Yandex.Store), - * setStoreType(BLACKBERRY, long) (BlackBerry World, long - your application ID), - * setStoreType(APPLE, long) (Apple App Store, long - your application ID), - * setStoreType(String...) (Any other store/stores, String... - an URI or array of URIs to your app) and - * setStoreType(Intent...) (Any custom intent/intents, Intent... - an intent or array of intents) */ - .setTimeToWait(Time.DAY, (short) 3) // default is 10 days, 0 means install millisecond, 10 means app is launched 10 or more time units later than installation - .setLaunchTimes((byte) 10) // default is 10, 3 means app is launched 3 or more times + .setStoreType(StoreType.GOOGLEPLAY) /* default is GOOGLEPLAY (Google Play), other options are AMAZON (Amazon Appstore), BAZAAR (Cafe Bazaar), + * CHINESESTORES (19 chinese app stores), MI (Mi Appstore (Xiaomi Market)), SAMSUNG (Samsung Galaxy Apps), + * SLIDEME (SlideME Marketplace), TENCENT (Tencent App Store), YANDEX (Yandex.Store), + * setStoreType(BLACKBERRY, long) (BlackBerry World, long - your application ID), + * setStoreType(APPLE, long) (Apple App Store, long - your application ID), + * setStoreType(String...) (Any other store/stores, String... - an URI or array of URIs to your app) and + * setStoreType(Intent...) (Any custom intent/intents, Intent... - an intent or array of intents) */ + .setTimeToWait(Time.DAY, (short) 3) // default is 10 days, 0 means install millisecond, 10 means app is launched 10 or more time units later than installation + .setLaunchTimes((byte) 10) // default is 10, 3 means app is launched 3 or more times .setRemindTimeToWait(Time.DAY, (short) 2) // default is 1 day, 1 means app is launched 1 or more time units after neutral button clicked - .setRemindLaunchesNumber((byte) 1) // default is 0, 1 means app is launched 1 or more times after neutral button clicked - .setSelectedAppLaunches((byte) 4) // default is 1, 1 means each launch, 2 means every 2nd launch, 3 means every 3rd launch, etc - .setShowLaterButton(true) // default is true, true means to show the Neutral button ("Remind me later"). + .setRemindLaunchesNumber((byte) 1) // default is 0, 1 means app is launched 1 or more times after neutral button clicked + .setSelectedAppLaunches((byte) 4) // default is 1, 1 means each launch, 2 means every 2nd launch, 3 means every 3rd launch, etc + .setShowLaterButton(true) // default is true, true means to show the Neutral button ("Remind me later"). .set365DayPeriodMaxNumberDialogLaunchTimes((short) 3) // default is unlimited, 3 means 3 or less occurrences of the display of the Rate Dialog within a 365-day period - .setVersionCodeCheck(true) // default is false, true means to re-enable the Rate Dialog if a new version of app with different version code is installed - .setVersionNameCheck(true) // default is false, true means to re-enable the Rate Dialog if a new version of app with different version name is installed - .setDebug(true) // default is false, true is for development only, true ensures that the Rate Dialog will be shown each time the app is launched - .setCancelable(false) // default false. + .setVersionCodeCheck(true) // default is false, true means to re-enable the Rate Dialog if a new version of app with different version code is installed + .setVersionNameCheck(true) // default is false, true means to re-enable the Rate Dialog if a new version of app with different version name is installed + .setDebug(true) // default is false, true is for development only, true ensures that the Rate Dialog will be shown each time the app is launched + .setCancelable(false) // default false. .setOnClickButtonListener(which -> Log.d(TAG, "RateButton: " + Byte.toString(which))) /* uncomment to test AppCompatDialogManager instead DefaultDialogManager */ //.setDialogManagerFactory(appCompatDialogManagerFactory) diff --git a/sample/src/main/java/com/vorlonsoft/android/rate/sample/SampleApplication.java b/sample/src/main/java/com/vorlonsoft/android/rate/sample/SampleApplication.java index 5464bb0..0650494 100644 --- a/sample/src/main/java/com/vorlonsoft/android/rate/sample/SampleApplication.java +++ b/sample/src/main/java/com/vorlonsoft/android/rate/sample/SampleApplication.java @@ -21,11 +21,13 @@ public SampleApplication() { @Override public void onCreate() { super.onCreate(); + //noinspection ConstantConditions if (LeakCanary.isInAnalyzerProcess(this)) { // This process is dedicated to LeakCanary for heap analysis. // You should not init your app in this process. return; } + //noinspection ResultOfMethodCallIgnored LeakCanary.install(this); // Normal app init code... }