Skip to content

Commit 4000a52

Browse files
committed
remove unnecessary preferences
1 parent 7391365 commit 4000a52

File tree

1 file changed

+51
-62
lines changed

1 file changed

+51
-62
lines changed

app/src/main/java/io/github/ratul/topactivity/utils/DatabaseUtil.java

Lines changed: 51 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,73 +16,62 @@
1616
*/
1717
package io.github.ratul.topactivity.utils;
1818

19-
import android.content.Context;
20-
import android.content.SharedPreferences;
2119
import io.github.ratul.topactivity.App;
2220

2321
/**
2422
* Created by Wen on 16/02/2017.
2523
* Refactored by Ratul on 04/05/2022.
2624
*/
2725
public class DatabaseUtil {
28-
private static SharedPreferences sp = App.getApp().getSharedPreferences("io.github.ratul.topactivity", 0);
29-
30-
public static int getDisplayWidth() {
31-
return sp.getInt("width", 720);
32-
}
33-
34-
public static void setDisplayWidth(int width) {
35-
sp.edit().putInt("width", width).apply();
36-
}
37-
38-
public static boolean isShowWindow() {
39-
return sp.getBoolean("is_show_window", false);
40-
}
41-
42-
public static boolean hasBattery() {
43-
return sp.getBoolean("hasBattery", false);
44-
}
45-
46-
public static void setHasBattery(boolean bool) {
47-
sp.edit().putBoolean("hasBattery", bool).apply();
48-
}
49-
50-
public static void setIsShowWindow(boolean isShow) {
51-
sp.edit().putBoolean("is_show_window", isShow).apply();
52-
}
53-
54-
public static boolean appInitiated() {
55-
return sp.getBoolean("app_init", false);
56-
}
57-
58-
public static void setAppInitiated(boolean added) {
59-
sp.edit().putBoolean("app_init", added).apply();
60-
}
61-
62-
public static boolean hasAccess() {
63-
return sp.getBoolean("has_access", true);
64-
}
65-
66-
public static void setHasAccess(boolean added) {
67-
sp.edit().putBoolean("has_access", added).apply();
68-
}
69-
70-
public static boolean hasQSTileAdded() {
71-
return sp.getBoolean("has_qs_tile_added", false);
72-
}
73-
74-
public static void setQSTileAdded(boolean added) {
75-
sp.edit().putBoolean("has_qs_tile_added", added).apply();
76-
}
77-
78-
public static boolean isNotificationToggleEnabled() {
79-
if (!hasQSTileAdded()) {
80-
return true;
81-
}
82-
return sp.getBoolean("is_noti_toggle_enabled", true);
83-
}
84-
85-
public static void setNotificationToggleEnabled(boolean isEnabled) {
86-
sp.edit().putBoolean("is_noti_toggle_enabled", isEnabled).apply();
87-
}
26+
public static int getDisplayWidth() {
27+
return App.getInstance().getSharedPreferences()
28+
.getInt("width", 720);
29+
}
30+
31+
public static void setDisplayWidth(int width) {
32+
App.getInstance().getSharedPreferences().edit()
33+
.putInt("width", width)
34+
.apply();
35+
}
36+
37+
public static int getUserWidth() {
38+
return App.getInstance().getSharedPreferences()
39+
.getInt("user_width", -1);
40+
}
41+
42+
public static void setUserWidth(int width) {
43+
App.getInstance().getSharedPreferences().edit()
44+
.putInt("user_width", width)
45+
.apply();
46+
}
47+
48+
public static boolean isShowingWindow() {
49+
return App.getInstance().getSharedPreferences()
50+
.getBoolean("is_show_window", false);
51+
}
52+
53+
public static void setShowingWindow(boolean bool) {
54+
App.getInstance().getSharedPreferences().edit()
55+
.putBoolean("is_show_window", bool).apply();
56+
}
57+
58+
public static boolean useAccessibility() {
59+
return App.getInstance().getSharedPreferences()
60+
.getBoolean("has_access", false);
61+
}
62+
63+
public static void setUseAccessibility(boolean bool) {
64+
App.getInstance().getSharedPreferences().edit()
65+
.putBoolean("has_access", bool).apply();
66+
}
67+
68+
public static boolean isShowNotification() {
69+
return App.getInstance().getSharedPreferences()
70+
.getBoolean("show_notification", false);
71+
}
72+
73+
public static void setShowNotification(boolean bool) {
74+
App.getInstance().getSharedPreferences().edit()
75+
.putBoolean("show_notification", bool).apply();
76+
}
8877
}

0 commit comments

Comments
 (0)