public final class AppRate extends Object
AppRate Class - main class of the AndroidRate library, thread-safe and a fast singleton implementation.
Modifier and Type | Method and Description |
---|---|
AppRate |
clearAgreeShowDialog() |
AppRate |
clearRemindButtonClick()
Clears shared preferences that were set up by clicking the Remind Button.
|
AppRate |
clearSettingsParam() |
void |
dismissRateDialog()
Dismisses Rate Dialog, removing it from the screen, and
clears weak reference dialog object.
|
int |
getStoreType()
Gets the app store type from library options.
|
AppRate |
incrementEventCount(String eventName) |
boolean |
isDebug()
Checks if the library is in Debug mode.
|
boolean |
isShowingRateDialog()
Checks whether the Rate Dialog is currently showing.
|
void |
monitor()
Monitors launches of the application.
|
void |
rateNow(Activity activity)
Call this method directly if you want to send a user to rate your app right in the app
store.
|
AppRate |
set365DayPeriodMaxNumberDialogLaunchTimes(short dialogLaunchTimes)
Sets the max number of occurrences of the display of the Rate Dialog within a 365-day
period.
|
AppRate |
setAgreeShowDialog(boolean isAgree) |
AppRate |
setCancelable(boolean cancelable)
Sets whether the rating dialog is cancelable or not.
|
AppRate |
setDebug(boolean isDebug)
Debug mode.
|
AppRate |
setDialogManagerFactory(DialogManager.Factory dialogManagerFactory)
Sets
DialogManager.Factory implementation. |
AppRate |
setEventCountValue(String eventName,
short countValue) |
AppRate |
setInstallDays(byte installDate)
Sets the minimal number of days until the Rating Dialog pops up for the first time.
|
AppRate |
setLaunchTimes(byte appLaunchTimes)
Sets the minimum number of launches until the rating dialog pops up for
the first time.
|
AppRate |
setMessage(int resourceId) |
AppRate |
setMessage(String message) |
AppRate |
setMinimumEventCount(String eventName,
short minimumCount) |
AppRate |
setOnClickButtonListener(OnClickButtonListener listener)
Specifies the callback when the button of Rate Dialog is pressed.
|
AppRate |
setRemindInterval(byte remindInterval)
Sets the minimal number of days until the Rating Dialog pops up for the next time after
neutral button clicked.
|
AppRate |
setRemindLaunchesNumber(byte remindLaunchesNumber)
Sets the minimal number of app's launches after neutral button clicked until the Rating
Dialog pops up next time.
|
AppRate |
setRemindLaunchTimes(byte selectedAppLaunches)
Deprecated.
since 1.2.0, use
setSelectedAppLaunches(byte) with the same param instead |
AppRate |
setRemindTimeToWait(long timeUnit,
short timeUnitsNumber)
Sets the minimal number of time units until the Rating Dialog pops up for the next time
after neutral button clicked.
|
AppRate |
setSelectedAppLaunches(byte selectedAppLaunches)
Selects App launches.
|
AppRate |
setShowLaterButton(boolean isShowNeutralButton)
Decides whether the Neutral button ("Remind me later") appears in the Rating Dialog or
not.
|
AppRate |
setShowNeverButton(boolean isShowNeverButton)
Decides if Never button appear in the rating dialog or not
|
AppRate |
setShowTitle(boolean isShowTitle) |
AppRate |
setStoreType(int storeType)
Sets one of the app stores defined by
StoreType.StoreWithoutApplicationId to
the Positive button. |
AppRate |
setStoreType(Intent... intents)
Sets custom action to the Positive button.
|
AppRate |
setStoreType(int storeType,
long applicationId)
Sets one of the app stores defined by
StoreType.StoreWithApplicationId to
the Positive button. |
AppRate |
setStoreType(String... uris)
Sets any other app store/stores to the Positive button.
|
AppRate |
setTextLater(int resourceId) |
AppRate |
setTextLater(String neutralText) |
AppRate |
setTextNever(int resourceId) |
AppRate |
setTextNever(String negativeText) |
AppRate |
setTextRateNow(int resourceId) |
AppRate |
setTextRateNow(String positiveText) |
AppRate |
setThemeResId(int themeResId)
Sets dialog theme.
|
AppRate |
setTimeToWait(long timeUnit,
short timeUnitsNumber)
Sets the minimal number of time units until the Rating Dialog pops up for the first time.
|
AppRate |
setTitle(int resourceId) |
AppRate |
setTitle(String title) |
AppRate |
setVersionCodeCheck(boolean isVersionCodeCheck)
Sets the check whether the version code of the app is changed.
|
AppRate |
setVersionNameCheck(boolean isVersionNameCheck)
Sets the check whether the version name of the app is changed.
|
AppRate |
setView(View view) |
boolean |
shouldShowRateDialog()
Call this method to determine whether conditions to show the rate dialog meets or not.
|
void |
showRateDialog(Activity activity)
Call this method directly if you want to force display of the Rate Dialog.
|
static boolean |
showRateDialogIfMeetsConditions(Activity activity)
Shows the Rate Dialog when conditions are met.
|
static AppRate |
with(Context context) |
public static boolean showRateDialogIfMeetsConditions(Activity activity)
Shows the Rate Dialog when conditions are met.
Call this method at the end of your onCreate() method to determine whether to show the rate dialog or not. It will check if the conditions are met and show rate dialog if yes.
activity
- your activity, use "this" in most casespublic AppRate set365DayPeriodMaxNumberDialogLaunchTimes(short dialogLaunchTimes)
Sets the max number of occurrences of the display of the Rate Dialog within a 365-day period.
dialogLaunchTimes
- the max number of the display of the Rate Dialog within a 365-day
period, default is Short.MAX_VALUE
, Short.MAX_VALUE
means unlimited occurrencesAppRate
singleton objectpublic AppRate setLaunchTimes(byte appLaunchTimes)
Sets the minimum number of launches until the rating dialog pops up for the first time.
appLaunchTimes
- number of launches, default is 10, 3 means app is launched 3 or
more timesAppRate
singleton objectpublic AppRate setInstallDays(byte installDate)
Sets the minimal number of days until the Rating Dialog pops up for the first time.
installDate
- number of days, default is 10, 0 means install day, 10 means app is
launched 10 or more days later than installationAppRate
singleton objectsetTimeToWait(long, short)
public AppRate setTimeToWait(@Time.TimeUnits long timeUnit, short timeUnitsNumber)
Sets the minimal number of time units until the Rating Dialog pops up for the first time.
Default is 10 days
, 0 means install millisecond, 10 means app is launched
10 or more time units later than installation.
timeUnit
- one of the values defined by Time.TimeUnits
timeUnitsNumber
- time units numberAppRate
singleton objectsetInstallDays(byte)
,
Time.TimeUnits
public AppRate setRemindInterval(byte remindInterval)
Sets the minimal number of days until the Rating Dialog pops up for the next time after neutral button clicked.
remindInterval
- number of days, default is 1, 1 means app is launched 1 or more days
after neutral button clickedAppRate
singleton objectsetRemindTimeToWait(long, short)
public AppRate setRemindTimeToWait(@Time.TimeUnits long timeUnit, short timeUnitsNumber)
Sets the minimal number of time units until the Rating Dialog pops up for the next time after neutral button clicked.
Default is 1 day
, 1 means app is launched 1 or more time units after
neutral button clicked.
timeUnit
- one of the values defined by Time.TimeUnits
timeUnitsNumber
- time units numberAppRate
singleton objectsetRemindInterval(byte)
,
Time.TimeUnits
public AppRate setRemindLaunchesNumber(byte remindLaunchesNumber)
Sets the minimal number of app's launches after neutral button clicked until the Rating Dialog pops up next time.
remindLaunchesNumber
- number of app launches, default is 0, 1 means app is launched 1
or more times after neutral button clickedAppRate
singleton objectpublic AppRate clearRemindButtonClick()
Clears shared preferences that were set up by clicking the Remind Button.
AppRate
singleton objectpublic AppRate setSelectedAppLaunches(byte selectedAppLaunches)
Selects App launches.
Method sets divisor for division of app launches with a remainder. This condition is
satisfied if appLaunches % divisorAppLaunches == 0
selectedAppLaunches
- default is 1, 1 means each launch, 2 means every 2nd launch,
3 means every 3rd launch, etcAppRate
singleton objectpublic AppRate setRemindLaunchTimes(byte selectedAppLaunches)
setSelectedAppLaunches(byte)
with the same param
insteadSelects App launches.
Method sets divisor for division of app launches with a remainder. This condition is
satisfied if appLaunches % divisorAppLaunches == 0
selectedAppLaunches
- default is 1, 1 means each launch, 2 means every 2nd launch,
3 means every 3rd launch, etcAppRate
singleton objectsetSelectedAppLaunches(byte)
public AppRate setShowLaterButton(boolean isShowNeutralButton)
Decides whether the Neutral button ("Remind me later") appears in the Rating Dialog or not.
isShowNeutralButton
- default is true, true means to show the Neutral buttonAppRate
singleton objectpublic AppRate setShowNeverButton(boolean isShowNeverButton)
isShowNeverButton
- default is trueAppRate
singleton objectpublic AppRate setShowTitle(boolean isShowTitle)
public AppRate clearAgreeShowDialog()
public AppRate clearSettingsParam()
public AppRate setAgreeShowDialog(boolean isAgree)
public AppRate setOnClickButtonListener(OnClickButtonListener listener)
Specifies the callback when the button of Rate Dialog is pressed.
listener
- implemented OnClickButtonListener
InterfaceAppRate
singleton objectpublic AppRate setTitle(int resourceId)
public AppRate setMessage(int resourceId)
public AppRate setTextRateNow(int resourceId)
public AppRate setTextLater(int resourceId)
public AppRate setTextNever(int resourceId)
public AppRate setCancelable(boolean cancelable)
cancelable
- default is falseAppRate
singleton objectpublic AppRate setStoreType(@StoreType.StoreWithoutApplicationId int storeType) throws IllegalArgumentException
Sets one of the app stores defined by StoreType.StoreWithoutApplicationId
to
the Positive button.
storeType
- one of the values defined by StoreType.StoreWithoutApplicationId
AppRate
singleton objectIllegalArgumentException
- if storeType
isn't defined by StoreType.StoreWithoutApplicationId
setStoreType(int, long)
,
setStoreType(String...)
,
setStoreType(Intent...)
public AppRate setStoreType(@StoreType.StoreWithApplicationId int storeType, long applicationId) throws IllegalArgumentException
Sets one of the app stores defined by StoreType.StoreWithApplicationId
to
the Positive button.
storeType
- one of the values defined by StoreType.StoreWithApplicationId
applicationId
- application ID in the storeType
app storeAppRate
singleton objectIllegalArgumentException
- if storeType
isn't defined by StoreType.StoreWithApplicationId
or by StoreType.StoreWithoutApplicationId
setStoreType(int)
,
setStoreType(String...)
,
setStoreType(Intent...)
public AppRate setStoreType(@NonNull String... uris) throws IllegalArgumentException
Sets any other app store/stores to the Positive button.
uris
- an RFC 2396-compliant URI or array of URIs to your app,
e. g. https://otherstore.com/app?id=com.yourapp
or otherstore://apps/com.yourapp
AppRate
singleton objectIllegalArgumentException
- if uris
equals nullsetStoreType(int)
,
setStoreType(int, long)
,
setStoreType(Intent...)
@StoreType.AnyStoreType public int getStoreType()
Gets the app store type from library options.
NOTE: this method doesn't get an app store type from user's device.
StoreType.AnyStoreType
public AppRate setStoreType(@NonNull Intent... intents) throws IllegalArgumentException
Sets custom action to the Positive button.
For example, you can open your custom RateActivity when the Positive button clicked.
intents
- any custom intent or array of intents,
first will be executed (startActivity(intents[0])
), if first fails,
second will be executed (startActivity(intents[1])
), etc.AppRate
singleton objectIllegalArgumentException
- if intents
equals nullsetStoreType(int)
,
setStoreType(int, long)
,
setStoreType(String...)
public AppRate setThemeResId(int themeResId)
Sets dialog theme. You can use a specific theme to inflate the dialog.
themeResId
- theme resource ID, default is 0AppRate
singleton objectpublic AppRate setDialogManagerFactory(@Nullable DialogManager.Factory dialogManagerFactory)
Sets DialogManager.Factory
implementation.
Call AppRate.with(this).setDialogManagerFactory(null)
to set
DefaultDialogManager.Factory
implementation.
dialogManagerFactory
- object of class that implements DialogManager.Factory
,
default is DefaultDialogManager.Factory
class objectAppRate
singleton objectpublic AppRate setVersionCodeCheck(boolean isVersionCodeCheck)
Sets the check whether the version code of the app is changed.
isVersionCodeCheck
- true means to re-enable the Rate Dialog if a new version of app
with different version code is installed, default is falseAppRate
singleton objectpublic AppRate setVersionNameCheck(boolean isVersionNameCheck)
Sets the check whether the version name of the app is changed.
isVersionNameCheck
- true means to re-enable the Rate Dialog if a new version of app
with different version name is installed, default is falseAppRate
singleton objectpublic void monitor()
Monitors launches of the application.
Call this method when the onCreate()
of the app's launcher activity is launched.
public void showRateDialog(Activity activity)
Call this method directly if you want to force display of the Rate Dialog.
Call it when some button presses on. Method also useful for testing purposes.
activity
- your activity, use "this" in most casespublic boolean isShowingRateDialog()
Checks whether the Rate Dialog is currently showing.
public void dismissRateDialog()
Dismisses Rate Dialog, removing it from the screen, and clears weak reference dialog object.
This method can be invoked safely from any thread.
public void rateNow(Activity activity)
Call this method directly if you want to send a user to rate your app right in the app store.
activity
- your activity, use "this" in most casespublic boolean shouldShowRateDialog()
public boolean isDebug()
Checks if the library is in Debug mode. For development only!
public AppRate setDebug(boolean isDebug)
Debug mode. For development only!
Setting the library to Debug mode ensures that the Rate Dialog will be shown each time the app is launched.
isDebug
- default is false, true ensures that the Rate Dialog will be shown each time
the app is launchedAppRate
singleton object