Small edit

This commit is contained in:
cepprice 2021-02-25 15:55:55 +05:00
parent e084416ce1
commit 588d9b2916
3 changed files with 14 additions and 49 deletions

View file

@ -26,7 +26,6 @@ import androidx.fragment.app.FragmentManager;
public class RateUsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
public static final String TAG = "RateUsBottomSheetDialogFragment";
private static final Log LOG = PlatformUtil.getLog(SendAnalyticsBottomSheetDialogFragment.class);
private static final long SIXTY_DAYS = 60 * 24 * 60 * 60 * 1000L;
private RateUsHelper rateUsHelper;

View file

@ -1,44 +0,0 @@
package net.osmand.plus.dialogs;
import android.os.Debug;
import android.util.Log;
import com.google.android.play.core.review.ReviewInfo;
import com.google.android.play.core.review.ReviewManager;
import com.google.android.play.core.review.ReviewManagerFactory;
import com.google.android.play.core.tasks.OnCompleteListener;
import com.google.android.play.core.tasks.Task;
import net.osmand.plus.activities.MapActivity;
import androidx.annotation.NonNull;
public class ReviewHelper {
public static void review(final MapActivity mapActivity) {
final ReviewManager manager = ReviewManagerFactory.create(mapActivity);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(new OnCompleteListener<ReviewInfo>() {
@Override
public void onComplete(@NonNull Task<ReviewInfo> task) {
if (task.isSuccessful()) {
showInAppReview(manager, mapActivity, task.getResult());
}
}
});
}
private static void showInAppReview(ReviewManager manager, MapActivity mapActivity, ReviewInfo task) {
Task<Void> flow = manager.launchReviewFlow(mapActivity, task);
flow.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
// TODO: Update
Log.v("M_ReviewHelper", "Shown");
}
}
});
}
}

View file

@ -17,6 +17,8 @@ import net.osmand.plus.settings.backend.OsmandSettings;
import org.apache.commons.logging.Log;
import java.lang.ref.WeakReference;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
@ -91,14 +93,18 @@ public class RateUsHelper {
}
}
private static void showInAppRateDialog(final FragmentActivity activity) {
private static void showInAppRateDialog(FragmentActivity activity) {
final ReviewManager reviewManager = ReviewManagerFactory.create(activity);
final WeakReference<FragmentActivity> activityRef = new WeakReference<>(activity);
Task<ReviewInfo> requestReview = reviewManager.requestReviewFlow();
requestReview.addOnCompleteListener(new OnCompleteListener<ReviewInfo>() {
@Override
public void onComplete(@NonNull Task<ReviewInfo> task) {
if (task.isSuccessful()) {
FragmentActivity activity = activityRef.get();
if (activity != null) {
showInAppRateDialogInternal(reviewManager, activity, task.getResult());
}
} else {
log.error(task.getException());
}
@ -106,13 +112,17 @@ public class RateUsHelper {
});
}
private static void showInAppRateDialogInternal(ReviewManager reviewManager, final FragmentActivity activity, ReviewInfo reviewInfo) {
private static void showInAppRateDialogInternal(ReviewManager reviewManager, FragmentActivity activity, ReviewInfo reviewInfo) {
Task<Void> reviewFlow = reviewManager.launchReviewFlow(activity, reviewInfo);
final WeakReference<FragmentActivity> activityRef = new WeakReference<>(activity);
reviewFlow.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
FragmentActivity activity = activityRef.get();
if (activity != null) {
storeRateResult(activity, RateUsState.IGNORED);
}
} else {
log.error(task.getException());
}