2017-11-14 18:40:15 +00:00
|
|
|
/*
|
2011-12-20 18:20:44 +00:00
|
|
|
* Copyright (C) 2011 Whisper Systems
|
2017-11-14 18:40:15 +00:00
|
|
|
* Copyright (C) 2013-2017 Open Whisper Systems
|
2012-07-20 02:23:49 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2012-07-20 02:23:49 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2017-04-17 19:23:17 +00:00
|
|
|
import android.annotation.TargetApi;
|
2019-06-05 06:45:12 +00:00
|
|
|
import android.content.ClipData;
|
|
|
|
import android.content.ClipboardManager;
|
2017-04-17 19:23:17 +00:00
|
|
|
import android.content.Context;
|
2019-06-06 05:01:06 +00:00
|
|
|
import android.content.DialogInterface;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
2017-04-17 19:23:17 +00:00
|
|
|
import android.content.res.TypedArray;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.os.Build;
|
2015-07-15 12:02:03 +00:00
|
|
|
import android.os.Build.VERSION;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.os.Bundle;
|
2017-09-21 01:10:44 +00:00
|
|
|
import android.support.annotation.Nullable;
|
2014-06-29 03:40:57 +00:00
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
|
import android.support.v4.app.FragmentTransaction;
|
2017-04-17 19:23:17 +00:00
|
|
|
import android.support.v4.content.ContextCompat;
|
|
|
|
import android.support.v4.graphics.drawable.DrawableCompat;
|
2019-06-06 05:01:06 +00:00
|
|
|
import android.support.v7.app.AlertDialog;
|
2017-09-21 01:10:44 +00:00
|
|
|
import android.support.v7.preference.Preference;
|
2019-12-17 09:04:08 +00:00
|
|
|
import android.util.Log;
|
2019-06-05 06:45:12 +00:00
|
|
|
import android.widget.Toast;
|
2013-11-27 19:08:58 +00:00
|
|
|
|
2019-06-06 05:01:06 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
2014-11-04 14:19:48 +00:00
|
|
|
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
2018-02-02 03:22:48 +00:00
|
|
|
import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment;
|
2017-04-15 03:39:38 +00:00
|
|
|
import org.thoughtcrime.securesms.preferences.CorrectedPreferenceFragment;
|
2014-11-04 14:19:48 +00:00
|
|
|
import org.thoughtcrime.securesms.preferences.NotificationsPreferenceFragment;
|
2018-02-02 03:22:48 +00:00
|
|
|
import org.thoughtcrime.securesms.preferences.widgets.ProfilePreference;
|
2014-12-11 23:04:32 +00:00
|
|
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
2013-06-30 01:03:55 +00:00
|
|
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
2013-06-21 18:56:59 +00:00
|
|
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
2013-07-11 21:58:40 +00:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2019-06-06 05:01:06 +00:00
|
|
|
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec;
|
|
|
|
import org.whispersystems.signalservice.loki.utilities.SerializationKt;
|
|
|
|
|
|
|
|
import java.io.File;
|
2012-10-23 02:17:08 +00:00
|
|
|
|
2019-07-24 02:30:23 +00:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
/**
|
|
|
|
* The Activity for application preference display and management.
|
2012-07-20 02:23:49 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* @author Moxie Marlinspike
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-06-29 03:40:57 +00:00
|
|
|
public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarActivity
|
2013-06-21 18:56:59 +00:00
|
|
|
implements SharedPreferences.OnSharedPreferenceChangeListener
|
|
|
|
{
|
2017-11-14 18:40:15 +00:00
|
|
|
@SuppressWarnings("unused")
|
2014-11-04 14:19:48 +00:00
|
|
|
private static final String TAG = ApplicationPreferencesActivity.class.getSimpleName();
|
2011-12-20 18:20:44 +00:00
|
|
|
|
2017-08-16 19:01:26 +00:00
|
|
|
private static final String PREFERENCE_CATEGORY_PROFILE = "preference_category_profile";
|
2019-07-16 07:09:15 +00:00
|
|
|
// private static final String PREFERENCE_CATEGORY_SMS_MMS = "preference_category_sms_mms";
|
2014-11-04 14:19:48 +00:00
|
|
|
private static final String PREFERENCE_CATEGORY_NOTIFICATIONS = "preference_category_notifications";
|
|
|
|
private static final String PREFERENCE_CATEGORY_APP_PROTECTION = "preference_category_app_protection";
|
2019-07-16 07:09:15 +00:00
|
|
|
// private static final String PREFERENCE_CATEGORY_APPEARANCE = "preference_category_appearance";
|
2015-08-24 22:24:31 +00:00
|
|
|
private static final String PREFERENCE_CATEGORY_CHATS = "preference_category_chats";
|
2019-07-16 07:09:15 +00:00
|
|
|
// private static final String PREFERENCE_CATEGORY_DEVICES = "preference_category_devices";
|
|
|
|
// private static final String PREFERENCE_CATEGORY_ADVANCED = "preference_category_advanced";
|
2019-06-05 06:45:12 +00:00
|
|
|
private static final String PREFERENCE_CATEGORY_PUBLIC_KEY = "preference_category_public_key";
|
2019-08-23 01:00:07 +00:00
|
|
|
private static final String PREFERENCE_CATEGORY_QR_CODE = "preference_category_qr_code";
|
2019-11-19 22:50:40 +00:00
|
|
|
private static final String PREFERENCE_CATEGORY_LINKED_DEVICES = "preference_category_linked_devices";
|
2019-06-06 05:01:06 +00:00
|
|
|
private static final String PREFERENCE_CATEGORY_SEED = "preference_category_seed";
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2013-06-30 01:03:55 +00:00
|
|
|
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
|
|
|
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
2013-06-21 18:56:59 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
@Override
|
2014-12-15 20:25:55 +00:00
|
|
|
protected void onPreCreate() {
|
2013-06-21 18:56:59 +00:00
|
|
|
dynamicTheme.onCreate(this);
|
2013-06-30 01:03:55 +00:00
|
|
|
dynamicLanguage.onCreate(this);
|
2014-12-15 20:25:55 +00:00
|
|
|
}
|
2012-08-03 03:23:41 +00:00
|
|
|
|
2014-12-15 20:25:55 +00:00
|
|
|
@Override
|
2018-02-02 03:22:48 +00:00
|
|
|
protected void onCreate(Bundle icicle, boolean ready) {
|
2017-11-14 18:40:15 +00:00
|
|
|
//noinspection ConstantConditions
|
2012-08-03 03:23:41 +00:00
|
|
|
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
2015-07-15 12:02:03 +00:00
|
|
|
|
2018-08-16 16:47:43 +00:00
|
|
|
if (getIntent() != null && getIntent().getCategories() != null && getIntent().getCategories().contains("android.intent.category.NOTIFICATION_PREFERENCES")) {
|
|
|
|
initFragment(android.R.id.content, new NotificationsPreferenceFragment());
|
|
|
|
} else if (icicle == null) {
|
2018-02-02 03:22:48 +00:00
|
|
|
initFragment(android.R.id.content, new ApplicationPreferenceFragment());
|
2015-07-15 12:02:03 +00:00
|
|
|
}
|
2014-06-29 03:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
dynamicTheme.onResume(this);
|
|
|
|
dynamicLanguage.onResume(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-11-22 12:31:54 +00:00
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
|
|
|
{
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
|
|
|
|
fragment.onActivityResult(requestCode, resultCode, data);
|
|
|
|
}
|
|
|
|
|
2014-11-04 14:19:48 +00:00
|
|
|
@Override
|
|
|
|
public boolean onSupportNavigateUp() {
|
|
|
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
|
if (fragmentManager.getBackStackEntryCount() > 0) {
|
|
|
|
fragmentManager.popBackStack();
|
|
|
|
} else {
|
|
|
|
Intent intent = new Intent(this, ConversationListActivity.class);
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
startActivity(intent);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-29 03:40:57 +00:00
|
|
|
@Override
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
|
|
|
if (key.equals(TextSecurePreferences.THEME_PREF)) {
|
2017-11-14 18:40:15 +00:00
|
|
|
recreate();
|
2014-06-29 03:40:57 +00:00
|
|
|
} else if (key.equals(TextSecurePreferences.LANGUAGE_PREF)) {
|
2017-11-14 18:40:15 +00:00
|
|
|
recreate();
|
2014-12-11 23:04:32 +00:00
|
|
|
|
|
|
|
Intent intent = new Intent(this, KeyCachingService.class);
|
|
|
|
intent.setAction(KeyCachingService.LOCALE_CHANGE_EVENT);
|
|
|
|
startService(intent);
|
2014-06-29 03:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-15 03:39:38 +00:00
|
|
|
public static class ApplicationPreferenceFragment extends CorrectedPreferenceFragment {
|
|
|
|
|
2014-11-04 14:19:48 +00:00
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle icicle) {
|
|
|
|
super.onCreate(icicle);
|
|
|
|
|
2019-10-08 01:17:25 +00:00
|
|
|
String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(getContext());
|
2019-10-11 02:37:56 +00:00
|
|
|
boolean isMasterDevice = (masterHexEncodedPublicKey == null);
|
2019-10-08 01:17:25 +00:00
|
|
|
|
|
|
|
Preference profilePreference = this.findPreference(PREFERENCE_CATEGORY_PROFILE);
|
2019-10-24 02:35:14 +00:00
|
|
|
if (isMasterDevice) { profilePreference.setOnPreferenceClickListener(new ProfileClickListener()); }
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2014-11-04 14:19:48 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
|
2018-02-02 03:22:48 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_SMS_MMS));
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2014-11-04 14:19:48 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
|
2019-11-20 00:45:54 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_NOTIFICATIONS));
|
2014-11-04 14:19:48 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION)
|
2019-11-20 00:45:54 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_APP_PROTECTION));
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2014-11-04 14:19:48 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_APPEARANCE)
|
2018-02-02 03:22:48 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_APPEARANCE));
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2015-08-24 22:24:31 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_CHATS)
|
2019-11-20 00:45:54 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_CHATS));
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2015-11-19 18:21:19 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_DEVICES)
|
2018-02-02 03:22:48 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_DEVICES));
|
2014-11-04 14:19:48 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_ADVANCED)
|
2018-02-02 03:22:48 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_ADVANCED));
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2019-06-05 06:45:12 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_PUBLIC_KEY)
|
2019-11-20 00:45:54 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_PUBLIC_KEY));
|
2019-08-23 01:00:07 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_QR_CODE)
|
2019-11-20 00:45:54 +00:00
|
|
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_QR_CODE));
|
2019-10-21 04:35:52 +00:00
|
|
|
|
2019-11-19 22:50:40 +00:00
|
|
|
Preference linkDevicesPreference = this.findPreference(PREFERENCE_CATEGORY_LINKED_DEVICES);
|
|
|
|
linkDevicesPreference.setVisible(isMasterDevice);
|
2019-11-20 00:45:54 +00:00
|
|
|
linkDevicesPreference.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_LINKED_DEVICES));
|
2019-11-18 01:43:26 +00:00
|
|
|
|
2019-10-08 01:17:25 +00:00
|
|
|
Preference seedPreference = this.findPreference(PREFERENCE_CATEGORY_SEED);
|
|
|
|
// Hide if this is a slave device
|
|
|
|
seedPreference.setVisible(isMasterDevice);
|
2019-11-20 00:45:54 +00:00
|
|
|
seedPreference.setOnPreferenceClickListener(new CategoryClickListener((PREFERENCE_CATEGORY_SEED)));
|
2017-04-17 19:23:17 +00:00
|
|
|
|
2017-11-14 18:40:15 +00:00
|
|
|
if (VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
2017-04-17 19:23:17 +00:00
|
|
|
tintIcons(getActivity());
|
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-20 02:23:49 +00:00
|
|
|
|
2017-09-21 01:10:44 +00:00
|
|
|
@Override
|
|
|
|
public void onCreatePreferences(@Nullable Bundle savedInstanceState, String rootKey) {
|
|
|
|
addPreferencesFromResource(R.xml.preferences);
|
|
|
|
}
|
|
|
|
|
2014-11-04 14:19:48 +00:00
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
2017-11-14 18:40:15 +00:00
|
|
|
//noinspection ConstantConditions
|
2014-11-04 14:19:48 +00:00
|
|
|
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.text_secure_normal__menu_settings);
|
|
|
|
setCategorySummaries();
|
2016-11-18 21:10:59 +00:00
|
|
|
setCategoryVisibility();
|
2014-02-20 22:49:31 +00:00
|
|
|
}
|
2014-03-30 09:28:38 +00:00
|
|
|
|
2014-11-04 14:19:48 +00:00
|
|
|
private void setCategorySummaries() {
|
2017-08-25 00:40:35 +00:00
|
|
|
((ProfilePreference)this.findPreference(PREFERENCE_CATEGORY_PROFILE)).refresh();
|
|
|
|
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2014-11-04 14:19:48 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
|
|
|
|
.setSummary(SmsMmsPreferenceFragment.getSummary(getActivity()));
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2014-11-04 14:19:48 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
|
|
|
|
.setSummary(NotificationsPreferenceFragment.getSummary(getActivity()));
|
|
|
|
this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION)
|
|
|
|
.setSummary(AppProtectionPreferenceFragment.getSummary(getActivity()));
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2014-11-04 14:19:48 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_APPEARANCE)
|
|
|
|
.setSummary(AppearancePreferenceFragment.getSummary(getActivity()));
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2015-08-24 22:24:31 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_CHATS)
|
|
|
|
.setSummary(ChatsPreferenceFragment.getSummary(getActivity()));
|
2014-03-30 09:28:38 +00:00
|
|
|
}
|
2014-02-20 22:49:31 +00:00
|
|
|
|
2016-11-18 21:10:59 +00:00
|
|
|
private void setCategoryVisibility() {
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2016-11-18 21:10:59 +00:00
|
|
|
Preference devicePreference = this.findPreference(PREFERENCE_CATEGORY_DEVICES);
|
|
|
|
if (devicePreference != null && !TextSecurePreferences.isPushRegistered(getActivity())) {
|
|
|
|
getPreferenceScreen().removePreference(devicePreference);
|
|
|
|
}
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2016-11-18 21:10:59 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:23:17 +00:00
|
|
|
@TargetApi(11)
|
|
|
|
private void tintIcons(Context context) {
|
|
|
|
Drawable sms = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_textsms_white_24dp));
|
|
|
|
Drawable notifications = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_notifications_white_24dp));
|
|
|
|
Drawable privacy = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_security_white_24dp));
|
|
|
|
Drawable appearance = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_brightness_6_white_24dp));
|
|
|
|
Drawable chats = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_forum_white_24dp));
|
2017-04-28 23:30:20 +00:00
|
|
|
Drawable devices = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_laptop_white_24dp));
|
2017-04-17 19:23:17 +00:00
|
|
|
Drawable advanced = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_advanced_white_24dp));
|
2019-06-06 05:01:06 +00:00
|
|
|
Drawable publicKey = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_textsms_24dp));
|
2019-08-23 01:00:07 +00:00
|
|
|
Drawable qrCode = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_qr_code));
|
2019-09-30 06:22:12 +00:00
|
|
|
Drawable linkDevice = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_link));
|
2019-08-23 01:00:07 +00:00
|
|
|
Drawable seed = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_seedling));
|
2017-04-17 19:23:17 +00:00
|
|
|
|
|
|
|
int[] tintAttr = new int[]{R.attr.pref_icon_tint};
|
|
|
|
TypedArray typedArray = context.obtainStyledAttributes(tintAttr);
|
|
|
|
int color = typedArray.getColor(0, 0x0);
|
|
|
|
typedArray.recycle();
|
|
|
|
|
|
|
|
DrawableCompat.setTint(sms, color);
|
|
|
|
DrawableCompat.setTint(notifications, color);
|
|
|
|
DrawableCompat.setTint(privacy, color);
|
|
|
|
DrawableCompat.setTint(appearance, color);
|
|
|
|
DrawableCompat.setTint(chats, color);
|
2017-04-28 23:30:20 +00:00
|
|
|
DrawableCompat.setTint(devices, color);
|
2017-04-17 19:23:17 +00:00
|
|
|
DrawableCompat.setTint(advanced, color);
|
2019-06-06 05:01:06 +00:00
|
|
|
DrawableCompat.setTint(publicKey, color);
|
2019-08-23 01:00:07 +00:00
|
|
|
DrawableCompat.setTint(qrCode, color);
|
2019-09-30 06:22:12 +00:00
|
|
|
DrawableCompat.setTint(linkDevice, color);
|
2019-06-06 05:01:06 +00:00
|
|
|
DrawableCompat.setTint(seed, color);
|
2017-04-17 19:23:17 +00:00
|
|
|
|
2019-07-16 07:09:15 +00:00
|
|
|
// this.findPreference(PREFERENCE_CATEGORY_SMS_MMS).setIcon(sms);
|
2017-04-17 19:23:17 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS).setIcon(notifications);
|
|
|
|
this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION).setIcon(privacy);
|
2019-07-16 07:09:15 +00:00
|
|
|
// this.findPreference(PREFERENCE_CATEGORY_APPEARANCE).setIcon(appearance);
|
2017-04-17 19:23:17 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_CHATS).setIcon(chats);
|
2019-07-16 07:09:15 +00:00
|
|
|
// this.findPreference(PREFERENCE_CATEGORY_DEVICES).setIcon(devices);
|
|
|
|
// this.findPreference(PREFERENCE_CATEGORY_ADVANCED).setIcon(advanced);
|
2019-06-05 06:45:12 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_PUBLIC_KEY).setIcon(publicKey);
|
2019-08-23 01:00:07 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_QR_CODE).setIcon(qrCode);
|
2019-11-19 22:50:40 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_LINKED_DEVICES).setIcon(linkDevice);
|
2019-06-06 05:01:06 +00:00
|
|
|
this.findPreference(PREFERENCE_CATEGORY_SEED).setIcon(seed);
|
2017-04-17 19:23:17 +00:00
|
|
|
}
|
|
|
|
|
2019-11-20 00:45:54 +00:00
|
|
|
private class CategoryClickListener implements Preference.OnPreferenceClickListener {
|
2018-02-02 03:22:48 +00:00
|
|
|
private String category;
|
2013-07-11 21:58:40 +00:00
|
|
|
|
2019-11-20 00:45:54 +00:00
|
|
|
CategoryClickListener(String category) {
|
2018-02-02 03:22:48 +00:00
|
|
|
this.category = category;
|
2013-07-11 21:58:40 +00:00
|
|
|
}
|
|
|
|
|
2014-11-04 14:19:48 +00:00
|
|
|
@Override
|
|
|
|
public boolean onPreferenceClick(Preference preference) {
|
2015-06-20 05:02:10 +00:00
|
|
|
Fragment fragment = null;
|
2013-07-11 21:58:40 +00:00
|
|
|
|
2014-11-04 14:19:48 +00:00
|
|
|
switch (category) {
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2014-11-04 14:19:48 +00:00
|
|
|
case PREFERENCE_CATEGORY_SMS_MMS:
|
|
|
|
fragment = new SmsMmsPreferenceFragment();
|
|
|
|
break;
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2014-11-04 14:19:48 +00:00
|
|
|
case PREFERENCE_CATEGORY_NOTIFICATIONS:
|
|
|
|
fragment = new NotificationsPreferenceFragment();
|
|
|
|
break;
|
|
|
|
case PREFERENCE_CATEGORY_APP_PROTECTION:
|
|
|
|
fragment = new AppProtectionPreferenceFragment();
|
|
|
|
break;
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2014-11-04 14:19:48 +00:00
|
|
|
case PREFERENCE_CATEGORY_APPEARANCE:
|
|
|
|
fragment = new AppearancePreferenceFragment();
|
|
|
|
break;
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2015-08-24 22:24:31 +00:00
|
|
|
case PREFERENCE_CATEGORY_CHATS:
|
|
|
|
fragment = new ChatsPreferenceFragment();
|
2014-11-04 14:19:48 +00:00
|
|
|
break;
|
2019-07-16 07:09:15 +00:00
|
|
|
/*
|
2015-06-20 05:02:10 +00:00
|
|
|
case PREFERENCE_CATEGORY_DEVICES:
|
2015-11-19 18:21:19 +00:00
|
|
|
Intent intent = new Intent(getActivity(), DeviceActivity.class);
|
2015-06-20 05:02:10 +00:00
|
|
|
startActivity(intent);
|
|
|
|
break;
|
2014-11-04 14:19:48 +00:00
|
|
|
case PREFERENCE_CATEGORY_ADVANCED:
|
|
|
|
fragment = new AdvancedPreferenceFragment();
|
|
|
|
break;
|
2019-07-16 07:09:15 +00:00
|
|
|
*/
|
2019-06-05 06:45:12 +00:00
|
|
|
case PREFERENCE_CATEGORY_PUBLIC_KEY:
|
2019-10-08 01:17:25 +00:00
|
|
|
String hexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(getContext());
|
|
|
|
if (hexEncodedPublicKey == null) {
|
|
|
|
hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(getContext());
|
|
|
|
}
|
2019-06-06 00:04:43 +00:00
|
|
|
Intent shareIntent = new Intent();
|
|
|
|
shareIntent.setAction(Intent.ACTION_SEND);
|
|
|
|
shareIntent.putExtra(Intent.EXTRA_TEXT, hexEncodedPublicKey);
|
|
|
|
shareIntent.setType("text/plain");
|
|
|
|
startActivity(shareIntent);
|
2019-06-05 06:45:12 +00:00
|
|
|
break;
|
2020-01-31 01:50:25 +00:00
|
|
|
case PREFERENCE_CATEGORY_QR_CODE: break;
|
|
|
|
case PREFERENCE_CATEGORY_LINKED_DEVICES: break;
|
2019-06-06 05:01:06 +00:00
|
|
|
case PREFERENCE_CATEGORY_SEED:
|
|
|
|
File languageFileDirectory = new File(getContext().getApplicationInfo().dataDir);
|
2019-08-19 05:34:21 +00:00
|
|
|
try {
|
|
|
|
String hexEncodedSeed = IdentityKeyUtil.retrieve(getContext(), IdentityKeyUtil.lokiSeedKey);
|
|
|
|
if (hexEncodedSeed == null) {
|
|
|
|
hexEncodedSeed = SerializationKt.getHexEncodedPrivateKey(IdentityKeyUtil.getIdentityKeyPair(getContext())); // Legacy account
|
|
|
|
}
|
|
|
|
String seed = new MnemonicCodec(languageFileDirectory).encode(hexEncodedSeed, MnemonicCodec.Language.Configuration.Companion.getEnglish());
|
|
|
|
new AlertDialog.Builder(getContext())
|
|
|
|
.setTitle(R.string.activity_settings_seed_dialog_title)
|
|
|
|
.setMessage(seed)
|
|
|
|
.setPositiveButton(R.string.activity_settings_seed_dialog_copy_button_title, (DialogInterface.OnClickListener) (dialog, which) -> {
|
|
|
|
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
|
ClipData clip = ClipData.newPlainText("seed", seed);
|
|
|
|
clipboard.setPrimaryClip(clip);
|
|
|
|
Toast.makeText(getContext(), R.string.activity_settings_seed_copied_message, Toast.LENGTH_SHORT).show();
|
|
|
|
})
|
|
|
|
.setNeutralButton(R.string.activity_settings_seed_dialog_ok_button_title, null)
|
|
|
|
.show();
|
|
|
|
} catch (Exception e) {
|
2019-12-17 09:04:08 +00:00
|
|
|
Log.d("Loki", e.getMessage());
|
2019-08-19 05:34:21 +00:00
|
|
|
}
|
2019-06-06 05:01:06 +00:00
|
|
|
break;
|
2014-11-04 14:19:48 +00:00
|
|
|
default:
|
|
|
|
throw new AssertionError();
|
|
|
|
}
|
2012-10-23 02:17:08 +00:00
|
|
|
|
2015-06-20 05:02:10 +00:00
|
|
|
if (fragment != null) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
fragment.setArguments(args);
|
2015-04-03 00:16:55 +00:00
|
|
|
|
2015-06-20 05:02:10 +00:00
|
|
|
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
|
|
|
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
|
|
fragmentTransaction.replace(android.R.id.content, fragment);
|
|
|
|
fragmentTransaction.addToBackStack(null);
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
}
|
2012-10-23 02:17:08 +00:00
|
|
|
|
2014-11-04 14:19:48 +00:00
|
|
|
return true;
|
2012-10-23 02:17:08 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-16 19:01:26 +00:00
|
|
|
|
|
|
|
private class ProfileClickListener implements Preference.OnPreferenceClickListener {
|
|
|
|
@Override
|
|
|
|
public boolean onPreferenceClick(Preference preference) {
|
|
|
|
Intent intent = new Intent(preference.getContext(), CreateProfileActivity.class);
|
|
|
|
intent.putExtra(CreateProfileActivity.EXCLUDE_SYSTEM, true);
|
|
|
|
|
2017-08-25 00:40:35 +00:00
|
|
|
getActivity().startActivity(intent);
|
|
|
|
// ((BaseActionBarActivity)getActivity()).startActivitySceneTransition(intent, getActivity().findViewById(R.id.avatar), "avatar");
|
2017-08-16 19:01:26 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-03-01 22:17:55 +00:00
|
|
|
}
|
2017-08-16 19:01:26 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|