123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package com.epson.mobilephone.common;
- import android.content.Context;
- import android.content.SharedPreferences;
- import androidx.annotation.NonNull;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Locale;
- public class StoreReview {
- private static final String STORE_REVIEW_DATE_KEY = "iprint.storereview.date";
- private static final String STORE_REVIEW_REFS_NAME = "iprint.storereview";
- private static final int STORE_REVIEW_SHOW_TIME = 2;
- private static final String STORE_REVIEW_TASK_COUNT_KEY = "iprint.storereview.taskcount";
- public boolean checkPrintSuccessCount(@NonNull Context context) {
- int loadTaskCount = loadTaskCount(context) + 1;
- if (loadTaskCount <= 2) {
- saveTaskCount(context, loadTaskCount);
- }
- if (loadTaskCount == 2) {
- return true;
- }
- return false;
- }
- public void resetTaskCount(@NonNull Context context) {
- SharedPreferences.Editor edit = getLocalSharedPreferences(context).edit();
- edit.putInt(STORE_REVIEW_TASK_COUNT_KEY, 0);
- edit.apply();
- }
- private SharedPreferences getLocalSharedPreferences(@NonNull Context context) {
- return context.getSharedPreferences(STORE_REVIEW_REFS_NAME, 0);
- }
- private void saveTaskCount(@NonNull Context context, int i) {
- SharedPreferences.Editor edit = getLocalSharedPreferences(context).edit();
- edit.putInt(STORE_REVIEW_TASK_COUNT_KEY, i);
- edit.apply();
- }
- private int loadTaskCount(@NonNull Context context) {
- return getLocalSharedPreferences(context).getInt(STORE_REVIEW_TASK_COUNT_KEY, 0);
- }
- private void saveDate(@NonNull Context context) {
- SharedPreferences.Editor edit = getLocalSharedPreferences(context).edit();
- edit.putString(STORE_REVIEW_DATE_KEY, new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(new Date()));
- edit.apply();
- }
- }
|