Skip to content

Commit dbe7990

Browse files
committed
LIBff11210
1 parent 3c741fb commit dbe7990

File tree

10 files changed

+48
-49
lines changed

10 files changed

+48
-49
lines changed

.idea/dictionaries/Alexander.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ protected void onCreate(Bundle savedInstanceState) {
3434
.setStoreType(StoreType.GOOGLEPLAY) //default is GOOGLEPLAY (Google Play), other options are
3535
// AMAZON (Amazon Appstore) and
3636
// SAMSUNG (Samsung Galaxy Apps)
37-
.setInstallDays(0) // default 10, 0 means install day
38-
.setLaunchTimes(3) // default 10
39-
.setRemindInterval(2) // default 1
40-
.setRemindLaunchTimes(2) // default 1 (each launch)
37+
.setInstallDays((byte) 0) // default 10, 0 means install day
38+
.setLaunchTimes((byte) 3) // default 10
39+
.setRemindInterval((byte) 2) // default 1
40+
.setRemindLaunchTimes((byte) 2) // default 1 (each launch)
4141
.setShowLaterButton(true) // default true
4242
.setDebug(false) // default false
43-
//Java 8+: .setOnClickButtonListener(which -> Log.d(MainActivity.class.getName(), Integer.toString(which)))
43+
//Java 8+: .setOnClickButtonListener(which -> Log.d(MainActivity.class.getName(), Byte.toString(which)))
4444
.setOnClickButtonListener(new OnClickButtonListener() { // callback listener.
4545
@Override
46-
public void onClickButton(int which) {
47-
Log.d(MainActivity.class.getName(), Integer.toString(which));
46+
public void onClickButton(byte which) {
47+
Log.d(MainActivity.class.getName(), Byte.toString(which));
4848
}
4949
})
5050
.monitor();
@@ -64,10 +64,10 @@ protected void onCreate(Bundle savedInstanceState) {
6464

6565
The default conditions to show rate dialog is as below:
6666

67-
1. App is launched more than 10 days later than installation. Change via `AppRate#setInstallDays(int)`.
68-
2. App is launched more than 10 times. Change via `AppRate#setLaunchTimes(int)`.
69-
3. App is launched more than 1 days after neutral button clicked. Change via `AppRate#setRemindInterval(int)`.
70-
4. App is launched X times and X % 1 = 0. Change via `AppRate#setRemindLaunchTimes(int)`.
67+
1. App is launched more than 10 days later than installation. Change via `AppRate#setInstallDays(byte)`.
68+
2. App is launched more than 10 times. Change via `AppRate#setLaunchTimes(byte)`.
69+
3. App is launched more than 1 days after neutral button clicked. Change via `AppRate#setRemindInterval(byte)`.
70+
4. App is launched X times and X % 1 = 0. Change via `AppRate#setRemindLaunchTimes(byte)`.
7171
5. App shows neutral dialog (Remind me later) by default. Change via `setShowLaterButton(boolean)`.
7272
6. To specify the callback when the button is pressed. The same value as the second argument of `DialogInterface.OnClickListener#onClick` will be passed in the argument of `onClickButton`.
7373
7. Setting `AppRate#setDebug(boolean)` will ensure that the rating request is shown each time the app is launched. **This feature is only for development!**.
@@ -77,9 +77,9 @@ The default conditions to show rate dialog is as below:
7777
You can add additional optional requirements for showing dialog. Each requirement can be added/referenced as a unique string. You can set a minimum count for each such event (for e.g. "action_performed" 3 times, "button_clicked" 5 times, etc.)
7878

7979
```java
80-
AppRate.with(this).setMinimumEventCount(String, long);
80+
AppRate.with(this).setMinimumEventCount(String, short);
8181
AppRate.with(this).incrementEventCount(String);
82-
AppRate.with(this).setEventCountValue(String, long);
82+
AppRate.with(this).setEventCountValue(String, short);
8383
```
8484

8585
### Clear show dialog flag
@@ -113,7 +113,7 @@ AppRate.with(this).setView(view).monitor();
113113
You can use a specific theme to inflate the dialog.
114114

115115
```java
116-
AppRate.with(this).setThemeResId(Integer);
116+
AppRate.with(this).setThemeResId(int);
117117
```
118118

119119
### Custom dialog

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Wed Dec 06 03:48:14 MSK 2017
1+
#Wed Dec 06 06:57:40 MSK 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME

gradlew.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ echo location of your Java installation.
4646
goto fail
4747

4848
:init
49-
@rem Get command-line arguments, handling Windowz variants
49+
@rem Get command-line arguments, handling Windows variants
5050

5151
if not "%OS%" == "Windows_NT" goto win9xME_args
5252
if "%@eval[2+2]" == "4" goto 4NT_args

library/src/main/java/com/vorlonsoft/android/rate/AppRate.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public final class AppRate {
2626

2727
private final DialogOptions options = new DialogOptions();
2828

29-
private int installDate = 10;
29+
private byte installDate = 10;
3030

31-
private int launchTimes = 10;
31+
private byte launchTimes = 10;
3232

33-
private int remindInterval = 1;
33+
private byte remindInterval = 1;
3434

35-
private final HashMap<String, Long> customEventCounts = new HashMap<>();
35+
private final HashMap<String, Short> customEventCounts = new HashMap<>();
3636

37-
private int remindLaunchTimes = 1;
37+
private byte remindLaunchTimes = 1;
3838

3939
private boolean isDebug = false;
4040

@@ -64,32 +64,32 @@ public static boolean showRateDialogIfMeetsConditions(Activity activity) {
6464
return isMeetsConditions;
6565
}
6666

67-
private static boolean isOverDate(long targetDate, int threshold) {
67+
private static boolean isOverDate(long targetDate, byte threshold) {
6868
return new Date().getTime() - targetDate >= threshold * 24 * 60 * 60 * 1000;
6969
}
7070

71-
public AppRate setLaunchTimes(@SuppressWarnings("SameParameterValue") int launchTimes) {
71+
public AppRate setLaunchTimes(@SuppressWarnings("SameParameterValue") byte launchTimes) {
7272
this.launchTimes = launchTimes;
7373
return this;
7474
}
7575

76-
public AppRate setInstallDays(@SuppressWarnings("SameParameterValue") int installDate) {
76+
public AppRate setInstallDays(@SuppressWarnings("SameParameterValue") byte installDate) {
7777
this.installDate = installDate;
7878
return this;
7979
}
8080

81-
public AppRate setRemindInterval(@SuppressWarnings("SameParameterValue") int remindInterval) {
81+
public AppRate setRemindInterval(@SuppressWarnings("SameParameterValue") byte remindInterval) {
8282
this.remindInterval = remindInterval;
8383
return this;
8484
}
8585

8686
@SuppressWarnings("unused")
87-
public AppRate setMinimumEventCount(String eventName, long minimumCount) {
87+
public AppRate setMinimumEventCount(String eventName, short minimumCount) {
8888
this.customEventCounts.put(eventName, minimumCount);
8989
return this;
9090
}
9191

92-
public AppRate setRemindLaunchTimes(@SuppressWarnings("SameParameterValue") int remindLaunchTimes) {
92+
public AppRate setRemindLaunchTimes(@SuppressWarnings("SameParameterValue") byte remindLaunchTimes) {
9393
this.remindLaunchTimes = remindLaunchTimes;
9494
return this;
9595
}
@@ -213,17 +213,17 @@ public StoreType getStoreType() {
213213

214214
@SuppressWarnings("unused")
215215
public AppRate incrementEventCount(String eventName) {
216-
return setEventCountValue(eventName, getCustomEventCount(context,eventName) + 1);
216+
return setEventCountValue(eventName, (short) (getCustomEventCount(context,eventName) + 1));
217217
}
218218

219219
@SuppressWarnings("WeakerAccess")
220-
public AppRate setEventCountValue(String eventName, long countValue) {
220+
public AppRate setEventCountValue(String eventName, short countValue) {
221221
setCustomEventCount(context, eventName, countValue);
222222
return this;
223223
}
224224

225225
@SuppressWarnings("unused")
226-
public AppRate setThemeResId(Integer pThemeResId){
226+
public AppRate setThemeResId(int pThemeResId){
227227
options.setThemeResId(pThemeResId);
228228
return this;
229229
}
@@ -273,8 +273,8 @@ private boolean isOverRemindDate() {
273273
}
274274

275275
private boolean isOverCustomEventRequirements() {
276-
for(Map.Entry<String, Long> eventRequirement : customEventCounts.entrySet()) {
277-
Long currentCount = getCustomEventCount(context, eventRequirement.getKey());
276+
for(Map.Entry<String, Short> eventRequirement : customEventCounts.entrySet()) {
277+
Short currentCount = getCustomEventCount(context, eventRequirement.getKey());
278278
if(currentCount < eventRequirement.getValue()) {
279279
return false;
280280
}

library/src/main/java/com/vorlonsoft/android/rate/DefaultDialogManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public DialogManager createDialogManager(Context context, DialogOptions options)
3131
}
3232
}
3333

34-
private static final String TAG = "AndroidRate";
34+
private static final String TAG = "ANDROIDRATE";
3535

3636
private final Context context;
3737
private final DialogOptions options;
@@ -58,23 +58,23 @@ public void onClick(DialogInterface dialog, int which) {
5858
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppstore, e);
5959
}
6060
setAgreeShowDialog(context, false);
61-
if (listener != null) listener.onClickButton(which);
61+
if (listener != null) listener.onClickButton((byte) which);
6262
}
6363
};
6464
@SuppressWarnings("WeakerAccess")
6565
protected final DialogInterface.OnClickListener negativeListener = new DialogInterface.OnClickListener() {
6666
@Override
6767
public void onClick(DialogInterface dialog, int which) {
6868
setAgreeShowDialog(context, false);
69-
if (DefaultDialogManager.this.listener != null) DefaultDialogManager.this.listener.onClickButton(which);
69+
if (DefaultDialogManager.this.listener != null) DefaultDialogManager.this.listener.onClickButton((byte) which);
7070
}
7171
};
7272
@SuppressWarnings("WeakerAccess")
7373
protected final DialogInterface.OnClickListener neutralListener = new DialogInterface.OnClickListener() {
7474
@Override
7575
public void onClick(DialogInterface dialog, int which) {
7676
setRemindInterval(context);
77-
if (listener != null) listener.onClickButton(which);
77+
if (listener != null) listener.onClickButton((byte) which);
7878
}
7979
};
8080

library/src/main/java/com/vorlonsoft/android/rate/DialogOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class DialogOptions {
3636

3737
private String titleText = null;
3838

39-
private Integer themeResId;
39+
private int themeResId;
4040

4141
private String messageText = null;
4242

@@ -240,7 +240,7 @@ public Integer getThemeResId() {
240240
}
241241

242242
@SuppressWarnings("WeakerAccess")
243-
public void setThemeResId(Integer themeResId) {
243+
public void setThemeResId(int themeResId) {
244244
this.themeResId = themeResId;
245245
}
246246
}

library/src/main/java/com/vorlonsoft/android/rate/OnClickButtonListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
public interface OnClickButtonListener {
1010

11-
void onClickButton(int which);
11+
void onClickButton(byte which);
1212

1313
}

library/src/main/java/com/vorlonsoft/android/rate/PreferenceHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ static boolean isFirstLaunch(Context context) {
105105
* Add a prefix for the key for each custom event,
106106
* so that there is no clash with existing keys (PREF_KEY_LAUNCH_TIME, PREF_KEY_INSTALL_DATE, etc.)
107107
*/
108-
static long getCustomEventCount(Context context, String eventName) {
108+
static short getCustomEventCount(Context context, String eventName) {
109109
String eventKey = PREF_CUSTOM_EVENT_KEY_PREFIX + eventName;
110-
return getPreferences(context).getLong(eventKey, 0);
110+
return (short) getPreferences(context).getInt(eventKey, 0);
111111
}
112112

113-
static void setCustomEventCount(Context context, String eventName, long eventCount) {
113+
static void setCustomEventCount(Context context, String eventName, short eventCount) {
114114
String eventKey = PREF_CUSTOM_EVENT_KEY_PREFIX + eventName;
115115
SharedPreferences.Editor editor = getPreferencesEditor(context);
116-
editor.putLong(eventKey, eventCount);
116+
editor.putInt(eventKey, eventCount);
117117
editor.apply();
118118
}
119119
}

sample/src/main/java/com/vorlonsoft/android/rate/sample/MainActivity.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ protected void onCreate(Bundle savedInstanceState) {
6464
.setStoreType(StoreType.GOOGLEPLAY) //default is GOOGLEPLAY (Google Play), other options are
6565
// AMAZON (Amazon Appstore) and
6666
// SAMSUNG (Samsung Galaxy Apps)
67-
.setInstallDays(3) // default 10, 0 means install day.
68-
.setLaunchTimes(10) // default 10 times.
69-
.setRemindInterval(2) // default 1 day.
70-
.setRemindLaunchTimes (4) // default 1 (each launch).
67+
.setInstallDays((byte) 3) // default 10, 0 means install day.
68+
.setLaunchTimes((byte) 10) // default 10 times.
69+
.setRemindInterval((byte) 2) // default 1 day.
70+
.setRemindLaunchTimes ((byte) 4) // default 1 (each launch).
7171
.setShowLaterButton(true) // default true.
7272
.setDebug(true) // default false.
7373
.setCancelable(false) // default false.
74-
.setOnClickButtonListener(which -> Log.d(TAG, "RateButton: " + Integer.toString(which) + ""))
74+
.setOnClickButtonListener(which -> Log.d(TAG, "RateButton: " + Byte.toString(which) + ""))
7575
// comment to use library strings instead app strings
7676
.setTitle(R.string.new_rate_dialog_title)
7777
.setTextLater(R.string.new_rate_dialog_later)

0 commit comments

Comments
 (0)