com.gianlu.commonutils.preferences.CommonPK Java Examples
The following examples show how to use
com.gianlu.commonutils.preferences.CommonPK.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnalyticsPreferenceDialog.java From CommonUtils with Apache License 2.0 | 6 votes |
@NonNull @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_analytics_preference, container, false); SwitchMaterial tracking = layout.findViewById(R.id.analyticsPrefsDialog_tracking); tracking.setChecked(Prefs.getBoolean(CommonPK.TRACKING_ENABLED, true)); tracking.setOnCheckedChangeListener((buttonView, isChecked) -> Prefs.putBoolean(CommonPK.TRACKING_ENABLED, isChecked)); SwitchMaterial crashReport = layout.findViewById(R.id.analyticsPrefsDialog_crashReport); crashReport.setChecked(Prefs.getBoolean(CommonPK.CRASH_REPORT_ENABLED, true)); crashReport.setOnCheckedChangeListener((buttonView, isChecked) -> Prefs.putBoolean(CommonPK.CRASH_REPORT_ENABLED, isChecked)); Button ok = layout.findViewById(R.id.analyticsPrefsDialog_ok); ok.setOnClickListener(v -> dismissAllowingStateLoss()); return layout; }
Example #2
Source File: AnalyticsApplication.java From CommonUtils with Apache License 2.0 | 5 votes |
@Override @CallSuper public void onCreate() { super.onCreate(); String uuid = Prefs.getString(CommonPK.ANALYTICS_USER_ID, null); if (uuid == null) { uuid = UUID.randomUUID().toString(); Prefs.putString(CommonPK.ANALYTICS_USER_ID, uuid); } if (FossUtils.hasFirebaseCrashlytics()) { if (Prefs.getBoolean(CommonPK.CRASH_REPORT_ENABLED)) { FirebaseCrashlytics.getInstance().setUserId(uuid); CRASHLYTICS_ENABLED = true; } else { CRASHLYTICS_ENABLED = false; } } else { Prefs.putBoolean(CommonPK.CRASH_REPORT_ENABLED, false); } if (FossUtils.hasFirebaseAnalytics()) { ANALYTICS = FirebaseAnalytics.getInstance(this); if (Prefs.getBoolean(CommonPK.TRACKING_ENABLED)) { ANALYTICS.setUserId(uuid); ANALYTICS.setAnalyticsCollectionEnabled(true); } else { ANALYTICS.setAnalyticsCollectionEnabled(false); ANALYTICS = null; } } else { Prefs.putBoolean(CommonPK.TRACKING_ENABLED, false); } }
Example #3
Source File: AnalyticsApplication.java From CommonUtils with Apache License 2.0 | 5 votes |
@Override @CallSuper public void onCreate() { super.onCreate(); Prefs.putBoolean(CommonPK.CRASH_REPORT_ENABLED, false); Prefs.putBoolean(CommonPK.TRACKING_ENABLED, false); }
Example #4
Source File: TutorialManager.java From CommonUtils with Apache License 2.0 | 4 votes |
public static void restartTutorial() { Prefs.remove(CommonPK.TUTORIAL_DISCOVERIES); }
Example #5
Source File: TutorialManager.java From CommonUtils with Apache License 2.0 | 4 votes |
private boolean shouldShowFor(@NonNull BaseTutorial tutorial) { return !Prefs.setContains(CommonPK.TUTORIAL_DISCOVERIES, tutorial.discovery.name()); }
Example #6
Source File: TutorialManager.java From CommonUtils with Apache License 2.0 | 4 votes |
private void setShown(@NonNull BaseTutorial tutorial) { Prefs.addToSet(CommonPK.TUTORIAL_DISCOVERIES, tutorial.discovery.name()); }
Example #7
Source File: NightlyActivity.java From CommonUtils with Apache License 2.0 | 4 votes |
public final void applyNight() { getDelegate().setLocalNightMode(Prefs.getBoolean(CommonPK.NIGHT_MODE, false) ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_UNSPECIFIED); }