| 1 | package tw.nekomimi.nekogram; |
| 2 | |
| 3 | import android.content.Context; |
| 4 | import android.content.SharedPreferences; |
| 5 | |
| 6 | import org.telegram.messenger.ApplicationLoader; |
| 7 | |
| 8 | import xyz.nextalone.nagram.NaConfig; |
| 9 | |
| 10 | public class DialogConfig { |
| 11 | private static final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekodialogconfig", Context.MODE_PRIVATE); |
| 12 | |
| 13 | public static String getAutoTranslateKey(long dialogId, long topicId) { |
| 14 | return "autoTranslate_" + dialogId + (topicId != 0 ? "_" + topicId : ""); |
| 15 | } |
| 16 | |
| 17 | public static boolean isAutoTranslateEnable(long dialogId, long topicId) { |
| 18 | return preferences.getBoolean(getAutoTranslateKey(dialogId, topicId), NaConfig.INSTANCE.getAutoTranslate().Bool()); |
| 19 | } |
| 20 | |
| 21 | public static boolean hasAutoTranslateConfig(long dialogId, long topicId) { |
| 22 | return preferences.contains(getAutoTranslateKey(dialogId, topicId)); |
| 23 | } |
| 24 | |
| 25 | public static void setAutoTranslateEnable(long dialogId, long topicId, boolean enable) { |
| 26 | preferences.edit().putBoolean(getAutoTranslateKey(dialogId, topicId), enable).apply(); |
| 27 | } |
| 28 | |
| 29 | public static void removeAutoTranslateConfig(long dialogId, long topicId) { |
| 30 | preferences.edit().remove(getAutoTranslateKey(dialogId, topicId)).apply(); |
| 31 | } |
| 32 | |
| 33 | public static String getCustomForumTabsKey(long dialogId) { |
| 34 | return "customForumTabs_" + dialogId; |
| 35 | } |
| 36 | |
| 37 | public static boolean isCustomForumTabsEnable(long dialogId) { |
| 38 | return preferences.getBoolean(getCustomForumTabsKey(dialogId), false); |
| 39 | } |
| 40 | |
| 41 | public static boolean hasCustomForumTabsConfig(long dialogId) { |
| 42 | return preferences.contains(getCustomForumTabsKey(dialogId)); |
| 43 | } |
| 44 | |
| 45 | public static void setCustomForumTabsEnable(long dialogId, boolean enable) { |
| 46 | preferences.edit().putBoolean(getCustomForumTabsKey(dialogId), enable).apply(); |
| 47 | } |
| 48 | |
| 49 | public static void removeCustomForumTabsConfig(long dialogId) { |
| 50 | preferences.edit().remove(getCustomForumTabsKey(dialogId)).apply(); |
| 51 | } |
| 52 | } |
| 53 | |