mirror of https://github.com/M66B/FairEmail.git
Ask for reviews
This commit is contained in:
parent
5b91b8ee8d
commit
053d0704b8
|
@ -382,7 +382,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
}).setExternal(true));
|
||||
|
||||
if ((Helper.isPlayStoreInstall() || BuildConfig.DEBUG) &&
|
||||
getIntentRate(this).resolveActivity(pm) != null)
|
||||
Helper.getIntentRate(this).resolveActivity(pm) != null)
|
||||
extra.add(new NavMenuItem(R.drawable.baseline_star_24, R.string.menu_rate, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1164,13 +1164,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
return intent;
|
||||
}
|
||||
|
||||
private static Intent getIntentRate(Context context) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + BuildConfig.APPLICATION_ID));
|
||||
if (intent.resolveActivity(context.getPackageManager()) == null)
|
||||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static class FragmentDialogFirst extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
|
@ -1204,7 +1197,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
.setNegativeButton(R.string.title_no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Helper.view(getContext(), getIntentRate(getContext()));
|
||||
Helper.view(getContext(), Helper.getIntentRate(getContext()));
|
||||
}
|
||||
})
|
||||
.create();
|
||||
|
|
|
@ -30,6 +30,8 @@ import android.content.Intent;
|
|||
import android.content.IntentFilter;
|
||||
import android.content.IntentSender;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
|
@ -288,6 +290,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
static final String ACTION_DECRYPT = BuildConfig.APPLICATION_ID + ".DECRYPT";
|
||||
static final String ACTION_NEW_MESSAGE = BuildConfig.APPLICATION_ID + ".NEW_MESSAGE";
|
||||
|
||||
private static final long REVIEW_ASK_DELAY = 24 * 3600 * 1000L; // milliseonds
|
||||
|
||||
private static final List<String> DUPLICATE_ORDER = Collections.unmodifiableList(Arrays.asList(
|
||||
EntityFolder.INBOX,
|
||||
EntityFolder.OUTBOX,
|
||||
|
@ -2577,7 +2581,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
else
|
||||
fabMore.hide();
|
||||
|
||||
checkReporting();
|
||||
if (!checkReporting())
|
||||
checkReview();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2695,24 +2700,69 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}
|
||||
};
|
||||
|
||||
private void checkReporting() {
|
||||
if (viewType == AdapterMessage.ViewType.UNIFIED) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
if (prefs.getBoolean("crash_reports", false) ||
|
||||
prefs.getBoolean("crash_reports_asked", false))
|
||||
return;
|
||||
private boolean checkReporting() {
|
||||
if (viewType != AdapterMessage.ViewType.UNIFIED)
|
||||
return false;
|
||||
|
||||
final Snackbar snackbar = Snackbar.make(view, R.string.title_ask_help, Snackbar.LENGTH_INDEFINITE);
|
||||
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
snackbar.dismiss();
|
||||
new FragmentDialogReporting().show(getParentFragmentManager(), "reporting");
|
||||
}
|
||||
});
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
if (prefs.getBoolean("crash_reports", false) ||
|
||||
prefs.getBoolean("crash_reports_asked", false))
|
||||
return false;
|
||||
|
||||
snackbar.show();
|
||||
final Snackbar snackbar = Snackbar.make(view, R.string.title_ask_help, Snackbar.LENGTH_INDEFINITE);
|
||||
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
snackbar.dismiss();
|
||||
new FragmentDialogReporting().show(getParentFragmentManager(), "reporting");
|
||||
}
|
||||
});
|
||||
|
||||
snackbar.show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkReview() {
|
||||
if (viewType != AdapterMessage.ViewType.UNIFIED)
|
||||
return false;
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
if (prefs.getBoolean("review_asked", false))
|
||||
return false;
|
||||
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
|
||||
Intent intent = Helper.getIntentRate(getContext());
|
||||
if (intent.resolveActivity(pm) == null)
|
||||
return false;
|
||||
|
||||
long installed = 0;
|
||||
try {
|
||||
PackageInfo pi = pm.getPackageInfo(BuildConfig.APPLICATION_ID, 0);
|
||||
if (pi != null)
|
||||
installed = pi.firstInstallTime;
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
Log.i("Installed=" + new Date(installed));
|
||||
|
||||
long now = new Date().getTime();
|
||||
if (installed + REVIEW_ASK_DELAY > now)
|
||||
return false;
|
||||
|
||||
final Snackbar snackbar = Snackbar.make(view, R.string.title_ask_review, Snackbar.LENGTH_INDEFINITE);
|
||||
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
snackbar.dismiss();
|
||||
new FragmentDialogReview().show(getParentFragmentManager(), "review");
|
||||
}
|
||||
});
|
||||
|
||||
snackbar.show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5413,6 +5463,36 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogReview extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_review, null);
|
||||
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
|
||||
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean("review_asked", isChecked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean("review_asked", true).apply();
|
||||
startActivity(Helper.getIntentRate(getContext()));
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogAccount extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
|
|
|
@ -68,7 +68,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
};
|
||||
|
||||
private final static String[] RESET_QUESTIONS = new String[]{
|
||||
"welcome", "crash_reports_asked",
|
||||
"welcome", "crash_reports_asked", "review_asked",
|
||||
"html_always_images", "print_html_confirmed",
|
||||
"identities_asked", "cc_bcc", "inline_image_hint", "compose_reference", "send_dialog"
|
||||
};
|
||||
|
|
|
@ -324,6 +324,13 @@ public class Helper {
|
|||
return new Intent(Intent.ACTION_VIEW, Uri.parse(XDA_URI));
|
||||
}
|
||||
|
||||
static Intent getIntentRate(Context context) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + BuildConfig.APPLICATION_ID));
|
||||
if (intent.resolveActivity(context.getPackageManager()) == null)
|
||||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID));
|
||||
return intent;
|
||||
}
|
||||
|
||||
// Graphics
|
||||
|
||||
static int dp2pixels(Context context, int dp) {
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="24dp"
|
||||
android:scrollbarStyle="outsideOverlay">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvMessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_ask_review"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvExplanation"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_ask_review_rationale"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbNotAgain"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_no_ask_again"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvExplanation" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
|
@ -657,6 +657,10 @@
|
|||
<string name="title_ask_help">Help improve FairEmail</string>
|
||||
<string name="title_ask_reporting">Send error reports?</string>
|
||||
<string name="title_reporting_why">Error reporting will help improve FairEmail</string>
|
||||
|
||||
<string name="title_ask_review" translatable="false">Please review FairEmail</string>
|
||||
<string name="title_ask_review_rationale" translatable="false">You have been using FairEmail for a while. It is appreciated if you rate FairEmail in the Play Store, also to maintain a balance between unfavorable and favorable reviews.</string>
|
||||
|
||||
<string name="title_expand_warning">Expanding this message will download %1$s</string>
|
||||
<string name="title_download_message">Downloading …</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue