|
16 | 16 | */ |
17 | 17 | package io.github.ratul.topactivity.utils; |
18 | 18 |
|
19 | | -import android.content.Context; |
20 | | -import android.content.SharedPreferences; |
21 | 19 | import io.github.ratul.topactivity.App; |
22 | 20 |
|
23 | 21 | /** |
24 | 22 | * Created by Wen on 16/02/2017. |
25 | 23 | * Refactored by Ratul on 04/05/2022. |
26 | 24 | */ |
27 | 25 | 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 | + } |
88 | 77 | } |
0 commit comments