Skip to content

Commit

Permalink
first time - disable dont ask again button
Browse files Browse the repository at this point in the history
fix bugs.
  • Loading branch information
guy-4444 committed May 19, 2019
1 parent 4d8086c commit 4f580cd
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 39 deletions.
68 changes: 34 additions & 34 deletions app/src/main/java/guy/rateapplication/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,51 +43,51 @@ protected void onCreate(Bundle savedInstanceState) {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// SmartRate.Rate(MainActivity.this
// , "Rate Us"
// , "Tell others what you think about this app"
// , "Continue"
// , "Please take a moment and rate us on Google Play"
// , "click here"
// , "Ask me later"
// , "Never ask again"
// , "Thanks for the feedback"
// , Color.parseColor("#2196F3")
// , 4
// , 48
// , 72
// );

SmartRate.Rate(MainActivity.this
, "Rate Us"
, "Tell others what you think about this app"
, "Continue"
, "Please take a moment and rate us on Google Play"
, "click here"
, "Cancel"
, "Ask me later"
, "Never ask again"
, "Thanks for the feedback"
, Color.parseColor("#2196F3")
, 4
, 1
, 24
);

SmartRate.Rate(MainActivity.this
, "Rate Us"
, "Tell others what you think about this app"
, "Continue"
, "Please take a moment and rate us on Google Play"
, "click here"
, "Cancel"
, "Thanks for the feedback"
, Color.parseColor("#2196F3")
, 4
, new SmartRate.CallBack_UserRating() {
@Override
public void userRating(int rating) {
// Do something
// from now disable this option
}
}
);
// SmartRate.Rate(MainActivity.this
// , "Rate Us"
// , "Tell others what you think about this app"
// , "Continue"
// , "Please take a moment and rate us on Google Play"
// , "click here"
// , "Cancel"
// , "Thanks for the feedback"
// , Color.parseColor("#2196F3")
// , 4
// );
//
// SmartRate.Rate(MainActivity.this
// , "Rate Us"
// , "Tell others what you think about this app"
// , "Continue"
// , "Please take a moment and rate us on Google Play"
// , "click here"
// , "Cancel"
// , "Thanks for the feedback"
// , Color.parseColor("#2196F3")
// , 4
// , new SmartRate.CallBack_UserRating() {
// @Override
// public void userRating(int rating) {
// // Do something
// // from now disable this option
// }
// }
// );

// SmartRate.Rate(MainActivity.this
// , "דרג אותנו"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:3.4.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
18 changes: 14 additions & 4 deletions smartrate/src/main/java/guy4444/smartrate/SmartRate.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public static void Rate(
, _thanksForFeedback
, mainColor
, openStoreFromXStars
, -1
, -1
, _hoursBetweenCalls
, _hoursDelayToActivate
, null);
}

Expand Down Expand Up @@ -162,6 +162,7 @@ public static void Rate(
final long timeDelayToActivate_Ms = (_hoursDelayToActivate >= 1 && _hoursDelayToActivate < 366 * 24) ? 1000l * 60 * 60 * _hoursDelayToActivate : DEFAULT_DELAY_TO_ACTIVATE_MS;

continueClicked = false;
boolean hideAskMeLater = false;

if (_hoursBetweenCalls != -1 && _hoursDelayToActivate != -1) {
// no force asking mode
Expand All @@ -174,6 +175,11 @@ public static void Rate(
return;
}

if (getLastAskTime(activity) == 0) {
// first time asked
hideAskMeLater = true;
}

if (getLastAskTime(activity) == DONT_ASK_AGAIN_VALUE) {
// user already rate or click on never ask button
return;
Expand All @@ -191,8 +197,8 @@ public static void Rate(
View dialogView = inflater.inflate(R.layout.dialog_rate, null);
dialogBuilder.setView(dialogView);
final AlertDialog alertDialog = dialogBuilder.create();
alertDialog.setCancelable(true);
alertDialog.setCanceledOnTouchOutside(true);
alertDialog.setCancelable(false);
alertDialog.setCanceledOnTouchOutside(false);

final RelativeLayout alert_LAY_back = (RelativeLayout) dialogView.findViewById(R.id.alert_LAY_back);
final AppCompatButton alert_BTN_ok = (AppCompatButton) dialogView.findViewById(R.id.alert_BTN_ok);
Expand Down Expand Up @@ -303,6 +309,10 @@ public void onClick(View view) {
}
alert_BTN_ok.setEnabled(false);

if (hideAskMeLater) {
alert_BTN_stop.setVisibility(View.GONE);
}

if (later_text != null && !later_text.equals("")) {
alert_BTN_later.setText(later_text);
alert_BTN_later.setOnClickListener(new View.OnClickListener() {
Expand Down

0 comments on commit 4f580cd

Please sign in to comment.