12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package epson.common;
- import android.content.Context;
- import android.content.SharedPreferences;
- import android.preference.PreferenceManager;
- import androidx.annotation.NonNull;
- /**
- * sp中用户确认隐私协议保存设置
- */
- public class IprintAppRecord {
- private static final String KEY_LICENSE_AGREE_TIME = "license_agree_time";
- private static final String KEY_LICENSE_AGREE_VERSION_CODE = "license_agree_version_code";
- private static final String KEY_LICENSE_SCREEN_SHOWN_PREF = "licenseScreenShown";
- /**
- * 用户是否同意了协议
- *
- * @param context
- * @return
- */
- public boolean getLicenseAgreementValue(@NonNull Context context) {
- return getLicensePreferences(context).getBoolean(KEY_LICENSE_SCREEN_SHOWN_PREF, false);
- }
- public int getLicenseAgreeVersionCode(@NonNull Context context) {
- return getLicensePreferences(context).getInt(KEY_LICENSE_AGREE_VERSION_CODE, 0);
- }
- public void setLicenseAgreement(@NonNull Context context, int i, boolean z) {
- getLicensePreferences(context).edit().putInt(KEY_LICENSE_AGREE_VERSION_CODE, i).putBoolean(KEY_LICENSE_SCREEN_SHOWN_PREF, z).putLong(KEY_LICENSE_AGREE_TIME, System.currentTimeMillis()).apply();
- }
- public long getLicenseAgreeTime(@NonNull Context context) {
- return getLicensePreferences(context).getLong(KEY_LICENSE_AGREE_TIME, -1);
- }
- private SharedPreferences getLicensePreferences(@NonNull Context context) {
- return PreferenceManager.getDefaultSharedPreferences(context);
- }
- }
|