正在查看: Delta Chat v1.58.3 应用的 Prefs.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Delta Chat v1.58.3 应用的 Prefs.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.thoughtcrime.securesms.util;
import android.content.ContentUris;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.provider.ContactsContract;
import android.provider.Settings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
public class Prefs {
public static final String ALWAYS_LOAD_REMOTE_CONTENT = "pref_always_load_remote_content";
public static final boolean ALWAYS_LOAD_REMOTE_CONTENT_DEFAULT = false;
public static final String ASKED_FOR_NOTIFICATION_PERMISSION = "pref_asked_for_notification_permission";
public static final String BACKGROUND_PREF = "pref_chat_background";
private static final String CHAT_RINGTONE = "pref_chat_ringtone_";
private static final String CHAT_VIBRATE = "pref_chat_vibrate_";
private static final String DATABASE_ENCRYPTED_SECRET = "pref_database_encrypted_secret_";
private static final String DATABASE_UNENCRYPTED_SECRET = "pref_database_unencrypted_secret_";
public static final String DEFAULT_WEBXDC_STORE_URL = "https://webxdc.org/apps/";
public static final String DISABLE_PASSPHRASE_PREF = "pref_disable_passphrase";
public static final String DOZE_ASKED_DIRECTLY = "pref_doze_asked_directly";
private static final String ENTER_SENDS_PREF = "pref_enter_sends";
public static final String INCOGNITO_KEYBORAD_PREF = "pref_incognito_keyboard";
private static final String IN_THREAD_NOTIFICATION_PREF = "pref_key_inthread_notifications";
public static final String LAST_DEVICE_MSG_LABEL = "pref_last_device_msg_id";
public static final String LED_COLOR_PREF = "pref_led_color";
public static final String NOTIFICATION_PRIORITY_PREF = "pref_notification_priority";
public static final String NOTIFICATION_PRIVACY_PREF = "pref_notification_privacy";
private static final String PREF_CONTACT_PHOTO_IDENTIFIERS = "pref_contact_photo_identifiers";
private static final String PROFILE_AVATAR_ID_PREF = "pref_profile_avatar_id";
private static final String PROMPTED_DOZE_MSG_ID_PREF = "pref_prompted_doze_msg_id";
public static final String RINGTONE_PREF = "pref_key_ringtone";
public static final String SCREEN_SECURITY_PREF = "pref_screen_security";
private static final String TAG = "Prefs";
public static final String THEME_PREF = "pref_theme";
private static final String VIBRATE_PREF = "pref_key_vibrate";
public static final String WEBXDC_STORE_URL_PREF = "pref_webxdc_store_url";
public static boolean isPushEnabled(Context context) {
return false;
}
public enum VibrateState {
DEFAULT(0),
ENABLED(1),
DISABLED(2);
private final int id;
VibrateState(int i) {
this.id = i;
}
public int getId() {
return this.id;
}
public static VibrateState fromId(int i) {
return values()[i];
}
}
public static void setDatabaseEncryptedSecret(Context context, String str, int i) {
setStringPreference(context, DATABASE_ENCRYPTED_SECRET + i, str);
}
public static void setDatabaseUnencryptedSecret(Context context, String str, int i) {
setStringPreference(context, DATABASE_UNENCRYPTED_SECRET + i, str);
}
public static String getDatabaseUnencryptedSecret(Context context, int i) {
return getStringPreference(context, DATABASE_UNENCRYPTED_SECRET + i, null);
}
public static String getDatabaseEncryptedSecret(Context context, int i) {
return getStringPreference(context, DATABASE_ENCRYPTED_SECRET + i, null);
}
public static boolean isIncognitoKeyboardEnabled(Context context) {
return getBooleanPreference(context, INCOGNITO_KEYBORAD_PREF, false);
}
public static void setProfileAvatarId(Context context, int i) {
setIntegerPreference(context, PROFILE_AVATAR_ID_PREF, i);
}
public static int getProfileAvatarId(Context context) {
return getIntegerPreference(context, PROFILE_AVATAR_ID_PREF, 0);
}
public static int getNotificationPriority(Context context) {
return Integer.valueOf(getStringPreference(context, NOTIFICATION_PRIORITY_PREF, String.valueOf(1))).intValue();
}
public static NotificationPrivacyPreference getNotificationPrivacy(Context context) {
return new NotificationPrivacyPreference(getStringPreference(context, NOTIFICATION_PRIVACY_PREF, "all"));
}
public static boolean isInChatNotifications(Context context) {
return getBooleanPreference(context, IN_THREAD_NOTIFICATION_PREF, true);
}
public static void setEnterSendsEnabled(Context context, boolean z) {
setBooleanPreference(context, ENTER_SENDS_PREF, z);
}
public static boolean isEnterSendsEnabled(Context context) {
return getBooleanPreference(context, ENTER_SENDS_PREF, false);
}
public static boolean isPasswordDisabled(Context context) {
return getBooleanPreference(context, DISABLE_PASSPHRASE_PREF, false);
}
public static void setScreenSecurityEnabled(Context context, boolean z) {
setBooleanPreference(context, SCREEN_SECURITY_PREF, z);
}
public static boolean isScreenSecurityEnabled(Context context) {
return getBooleanPreference(context, SCREEN_SECURITY_PREF, false);
}
public static String getTheme(Context context) {
return getStringPreference(context, THEME_PREF, DynamicTheme.systemThemeAvailable() ? DynamicTheme.SYSTEM : DynamicTheme.LIGHT);
}
public static String getWebxdcStoreUrl(Context context) {
return getStringPreference(context, WEBXDC_STORE_URL_PREF, DEFAULT_WEBXDC_STORE_URL);
}
public static void setWebxdcStoreUrl(Context context, String str) {
if (str == null || str.trim().isEmpty() || DEFAULT_WEBXDC_STORE_URL.equals(str)) {
str = null;
}
setStringPreference(context, WEBXDC_STORE_URL_PREF, str);
}
public static void setPromptedDozeMsgId(Context context, int i) {
setIntegerPreference(context, PROMPTED_DOZE_MSG_ID_PREF, i);
}
public static int getPrompteDozeMsgId(Context context) {
return getIntegerPreference(context, PROMPTED_DOZE_MSG_ID_PREF, 0);
}
public static boolean isHardCompressionEnabled(Context context) {
return DcHelper.getContext(context).getConfigInt(DcHelper.CONFIG_MEDIA_QUALITY) == 1;
}
public static boolean isLocationStreamingEnabled(Context context) {
try {
return getBooleanPreference(context, "pref_location_streaming_enabled", false);
} catch (Exception unused) {
return false;
}
}
public static boolean isDeveloperModeEnabled(Context context) {
return getBooleanPreference(context, "pref_developer_mode_enabled", false);
}
public static boolean isNewBroadcastListAvailable(Context context) {
return getBooleanPreference(context, "pref_new_broadcast_list", false);
}
public static Uri getNotificationRingtone(Context context) {
String stringPreference = getStringPreference(context, RINGTONE_PREF, Settings.System.DEFAULT_NOTIFICATION_URI.toString());
if (stringPreference != null && stringPreference.startsWith("file:")) {
stringPreference = Settings.System.DEFAULT_NOTIFICATION_URI.toString();
}
return Uri.parse(stringPreference);
}
public static void removeNotificationRingtone(Context context) {
removePreference(context, RINGTONE_PREF);
}
public static void setNotificationRingtone(Context context, Uri uri) {
setStringPreference(context, RINGTONE_PREF, uri.toString());
}
public static void setChatRingtone(Context context, int i, int i2, Uri uri) {
String str = CHAT_RINGTONE;
if (i != 0 && i2 != 0) {
str = CHAT_RINGTONE + i + "." + i2;
}
if (uri != null) {
setStringPreference(context, str, uri.toString());
} else {
removePreference(context, str);
}
}
public static Uri getChatRingtone(Context context, int i, int i2) {
String str = CHAT_RINGTONE;
if (i != 0 && i2 != 0) {
str = CHAT_RINGTONE + i + "." + i2;
}
String stringPreference = getStringPreference(context, str, null);
if (stringPreference == null) {
return null;
}
return Uri.parse(stringPreference);
}
public static boolean reliableService(Context context) {
try {
return getBooleanPreference(context, "pref_reliable_service", false);
} catch (Exception unused) {
return false;
}
}
public static boolean isNotificationVibrateEnabled(Context context) {
return getBooleanPreference(context, VIBRATE_PREF, true);
}
public static void setChatVibrate(Context context, int i, int i2, VibrateState vibrateState) {
String str = CHAT_VIBRATE;
if (i != 0 && i2 != 0) {
str = CHAT_VIBRATE + i + "." + i2;
}
if (vibrateState != VibrateState.DEFAULT) {
setIntegerPreference(context, str, vibrateState.getId());
} else {
removePreference(context, str);
}
}
public static VibrateState getChatVibrate(Context context, int i, int i2) {
String str = CHAT_VIBRATE;
if (i != 0 && i2 != 0) {
str = CHAT_VIBRATE + i + "." + i2;
}
return VibrateState.fromId(getIntegerPreference(context, str, VibrateState.DEFAULT.getId()));
}
public static String getNotificationLedColor(Context context) {
return getStringPreference(context, LED_COLOR_PREF, "blue");
}
public static String getBackgroundImagePath(Context context, int i) {
return getStringPreference(context, BACKGROUND_PREF + i, "");
}
public static void setBackgroundImagePath(Context context, int i, String str) {
setStringPreference(context, BACKGROUND_PREF + i, str);
}
public static boolean getAlwaysLoadRemoteContent(Context context) {
return getBooleanPreference(context, ALWAYS_LOAD_REMOTE_CONTENT, false);
}
public static void setBooleanPreference(Context context, String str, boolean z) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(str, z).apply();
}
public static boolean getBooleanPreference(Context context, String str, boolean z) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(str, z);
}
public static void setStringPreference(Context context, String str, String str2) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putString(str, str2).apply();
}
public static String getStringPreference(Context context, String str, String str2) {
return PreferenceManager.getDefaultSharedPreferences(context).getString(str, str2);
}
private static int getIntegerPreference(Context context, String str, int i) {
return PreferenceManager.getDefaultSharedPreferences(context).getInt(str, i);
}
private static void setIntegerPreference(Context context, String str, int i) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putInt(str, i).apply();
}
public static long getLongPreference(Context context, String str, long j) {
return PreferenceManager.getDefaultSharedPreferences(context).getLong(str, j);
}
private static void setLongPreference(Context context, String str, long j) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putLong(str, j).apply();
}
public static void removePreference(Context context, String str) {
PreferenceManager.getDefaultSharedPreferences(context).edit().remove(str).apply();
}
private static Set<String> getStringSetPreference(Context context, String str, Set<String> set) {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
return defaultSharedPreferences.contains(str) ? defaultSharedPreferences.getStringSet(str, Collections.emptySet()) : set;
}
public static void setSystemContactPhotos(Context context, Set<String> set) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putStringSet(PREF_CONTACT_PHOTO_IDENTIFIERS, set).apply();
}
public static Uri getSystemContactPhoto(Context context, String str) {
for (String str2 : new ArrayList(getStringSetPreference(context, PREF_CONTACT_PHOTO_IDENTIFIERS, new HashSet()))) {
if (str2.contains(str)) {
return ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.valueOf(str2.split("\\|")[1]).longValue());
}
}
return null;
}
}