| 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 boolean isAutoTranslateEnable(long dialog_id, int topicId) { |
| 14 | return preferences.getBoolean("autoTranslate_" + dialog_id + (topicId != 0 ? "_" + topicId : ""), NaConfig.INSTANCE.getAutoTranslate().Bool()); |
| 15 | } |
| 16 | |
| 17 | public static boolean hasAutoTranslateConfig(long dialog_id, int topicId) { |
| 18 | return preferences.contains("autoTranslate_" + dialog_id + (topicId != 0 ? "_" + topicId : "")); |
| 19 | } |
| 20 | |
| 21 | public static void setAutoTranslateEnable(long dialog_id, int topicId, boolean enable) { |
| 22 | preferences.edit().putBoolean("autoTranslate_" + dialog_id + (topicId != 0 ? "_" + topicId : ""), enable).apply(); |
| 23 | } |
| 24 | |
| 25 | public static void removeAutoTranslateConfig(long dialog_id, int topicId) { |
| 26 | preferences.edit().remove("autoTranslate_" + dialog_id + (topicId != 0 ? "_" + topicId : "")).apply(); |
| 27 | } |
| 28 | } |
| 29 | |