From 4f580cde3affd1e25085bff1893d72ee24970039 Mon Sep 17 00:00:00 2001 From: Guy Date: Sun, 19 May 2019 18:16:15 +0300 Subject: [PATCH] first time - disable dont ask again button fix bugs. --- .../guy/rateapplication/MainActivity.java | 68 +++++++++---------- build.gradle | 2 +- .../java/guy4444/smartrate/SmartRate.java | 18 +++-- 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/guy/rateapplication/MainActivity.java b/app/src/main/java/guy/rateapplication/MainActivity.java index 1e5fefb..e1d71f9 100644 --- a/app/src/main/java/guy/rateapplication/MainActivity.java +++ b/app/src/main/java/guy/rateapplication/MainActivity.java @@ -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 // , "דרג אותנו" diff --git a/build.gradle b/build.gradle index fafc1b9..02199bb 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/smartrate/src/main/java/guy4444/smartrate/SmartRate.java b/smartrate/src/main/java/guy4444/smartrate/SmartRate.java index a344b4a..f43ec54 100644 --- a/smartrate/src/main/java/guy4444/smartrate/SmartRate.java +++ b/smartrate/src/main/java/guy4444/smartrate/SmartRate.java @@ -128,8 +128,8 @@ public static void Rate( , _thanksForFeedback , mainColor , openStoreFromXStars - , -1 - , -1 + , _hoursBetweenCalls + , _hoursDelayToActivate , null); } @@ -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 @@ -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; @@ -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); @@ -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() {