parent
eb49a7f5e5
commit
e204457c31
|
@ -293,6 +293,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
}
|
}
|
||||||
binding.hostnameLayout.setError(null);
|
binding.hostnameLayout.setError(null);
|
||||||
binding.portLayout.setError(null);
|
binding.portLayout.setError(null);
|
||||||
|
if (mAccount.isOnion()) {
|
||||||
|
Toast.makeText(EditAccountActivity.this, R.string.audio_video_disabled_tor, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
if (mAccount.isEnabled()
|
if (mAccount.isEnabled()
|
||||||
&& !registerNewAccount
|
&& !registerNewAccount
|
||||||
&& !mInitMode) {
|
&& !mInitMode) {
|
||||||
|
|
|
@ -38,14 +38,13 @@ import eu.siacs.conversations.persistance.FileBackend;
|
||||||
import eu.siacs.conversations.services.ExportBackupService;
|
import eu.siacs.conversations.services.ExportBackupService;
|
||||||
import eu.siacs.conversations.services.MemorizingTrustManager;
|
import eu.siacs.conversations.services.MemorizingTrustManager;
|
||||||
import eu.siacs.conversations.services.QuickConversationsService;
|
import eu.siacs.conversations.services.QuickConversationsService;
|
||||||
|
import eu.siacs.conversations.ui.util.SettingsUtils;
|
||||||
import eu.siacs.conversations.ui.util.StyledAttributes;
|
import eu.siacs.conversations.ui.util.StyledAttributes;
|
||||||
import eu.siacs.conversations.utils.GeoHelper;
|
import eu.siacs.conversations.utils.GeoHelper;
|
||||||
import eu.siacs.conversations.ui.util.SettingsUtils;
|
|
||||||
import eu.siacs.conversations.utils.TimeFrameUtils;
|
import eu.siacs.conversations.utils.TimeFrameUtils;
|
||||||
import eu.siacs.conversations.xmpp.Jid;
|
import eu.siacs.conversations.xmpp.Jid;
|
||||||
|
|
||||||
public class SettingsActivity extends XmppActivity implements
|
public class SettingsActivity extends XmppActivity implements OnSharedPreferenceChangeListener {
|
||||||
OnSharedPreferenceChangeListener {
|
|
||||||
|
|
||||||
public static final String KEEP_FOREGROUND_SERVICE = "enable_foreground_service";
|
public static final String KEEP_FOREGROUND_SERVICE = "enable_foreground_service";
|
||||||
public static final String AWAY_WHEN_SCREEN_IS_OFF = "away_when_screen_off";
|
public static final String AWAY_WHEN_SCREEN_IS_OFF = "away_when_screen_off";
|
||||||
|
@ -70,34 +69,40 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
setContentView(R.layout.activity_settings);
|
setContentView(R.layout.activity_settings);
|
||||||
FragmentManager fm = getFragmentManager();
|
FragmentManager fm = getFragmentManager();
|
||||||
mSettingsFragment = (SettingsFragment) fm.findFragmentById(R.id.settings_content);
|
mSettingsFragment = (SettingsFragment) fm.findFragmentById(R.id.settings_content);
|
||||||
if (mSettingsFragment == null || !mSettingsFragment.getClass().equals(SettingsFragment.class)) {
|
if (mSettingsFragment == null
|
||||||
|
|| !mSettingsFragment.getClass().equals(SettingsFragment.class)) {
|
||||||
mSettingsFragment = new SettingsFragment();
|
mSettingsFragment = new SettingsFragment();
|
||||||
fm.beginTransaction().replace(R.id.settings_content, mSettingsFragment).commit();
|
fm.beginTransaction().replace(R.id.settings_content, mSettingsFragment).commit();
|
||||||
}
|
}
|
||||||
mSettingsFragment.setActivityIntent(getIntent());
|
mSettingsFragment.setActivityIntent(getIntent());
|
||||||
this.mTheme = findTheme();
|
this.mTheme = findTheme();
|
||||||
setTheme(this.mTheme);
|
setTheme(this.mTheme);
|
||||||
getWindow().getDecorView().setBackgroundColor(StyledAttributes.getColor(this, R.attr.color_background_primary));
|
getWindow()
|
||||||
|
.getDecorView()
|
||||||
|
.setBackgroundColor(
|
||||||
|
StyledAttributes.getColor(this, R.attr.color_background_primary));
|
||||||
setSupportActionBar(findViewById(R.id.toolbar));
|
setSupportActionBar(findViewById(R.id.toolbar));
|
||||||
configureActionBar(getSupportActionBar());
|
configureActionBar(getSupportActionBar());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onBackendConnected() {
|
void onBackendConnected() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
changeOmemoSettingSummary();
|
changeOmemoSettingSummary();
|
||||||
|
|
||||||
if (QuickConversationsService.isQuicksy()) {
|
if (QuickConversationsService.isQuicksy()) {
|
||||||
final PreferenceCategory connectionOptions = (PreferenceCategory) mSettingsFragment.findPreference("connection_options");
|
final PreferenceCategory connectionOptions =
|
||||||
final PreferenceCategory groupChats = (PreferenceCategory) mSettingsFragment.findPreference("group_chats");
|
(PreferenceCategory) mSettingsFragment.findPreference("connection_options");
|
||||||
final Preference channelDiscoveryMethod = mSettingsFragment.findPreference("channel_discovery_method");
|
final PreferenceCategory groupChats =
|
||||||
|
(PreferenceCategory) mSettingsFragment.findPreference("group_chats");
|
||||||
|
final Preference channelDiscoveryMethod =
|
||||||
|
mSettingsFragment.findPreference("channel_discovery_method");
|
||||||
PreferenceScreen expert = (PreferenceScreen) mSettingsFragment.findPreference("expert");
|
PreferenceScreen expert = (PreferenceScreen) mSettingsFragment.findPreference("expert");
|
||||||
if (connectionOptions != null) {
|
if (connectionOptions != null) {
|
||||||
expert.removePreference(connectionOptions);
|
expert.removePreference(connectionOptions);
|
||||||
|
@ -107,23 +112,28 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferenceScreen mainPreferenceScreen = (PreferenceScreen) mSettingsFragment.findPreference("main_screen");
|
PreferenceScreen mainPreferenceScreen =
|
||||||
|
(PreferenceScreen) mSettingsFragment.findPreference("main_screen");
|
||||||
|
|
||||||
PreferenceCategory attachmentsCategory = (PreferenceCategory) mSettingsFragment.findPreference("attachments");
|
PreferenceCategory attachmentsCategory =
|
||||||
CheckBoxPreference locationPlugin = (CheckBoxPreference) mSettingsFragment.findPreference("use_share_location_plugin");
|
(PreferenceCategory) mSettingsFragment.findPreference("attachments");
|
||||||
|
CheckBoxPreference locationPlugin =
|
||||||
|
(CheckBoxPreference) mSettingsFragment.findPreference("use_share_location_plugin");
|
||||||
if (attachmentsCategory != null && locationPlugin != null) {
|
if (attachmentsCategory != null && locationPlugin != null) {
|
||||||
if (!GeoHelper.isLocationPluginInstalled(this)) {
|
if (!GeoHelper.isLocationPluginInstalled(this)) {
|
||||||
attachmentsCategory.removePreference(locationPlugin);
|
attachmentsCategory.removePreference(locationPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//this feature is only available on Huawei Android 6.
|
// this feature is only available on Huawei Android 6.
|
||||||
PreferenceScreen huaweiPreferenceScreen = (PreferenceScreen) mSettingsFragment.findPreference("huawei");
|
PreferenceScreen huaweiPreferenceScreen =
|
||||||
|
(PreferenceScreen) mSettingsFragment.findPreference("huawei");
|
||||||
if (huaweiPreferenceScreen != null) {
|
if (huaweiPreferenceScreen != null) {
|
||||||
Intent intent = huaweiPreferenceScreen.getIntent();
|
Intent intent = huaweiPreferenceScreen.getIntent();
|
||||||
//remove when Api version is above M (Version 6.0) or if the intent is not callable
|
// remove when Api version is above M (Version 6.0) or if the intent is not callable
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M || !isCallable(intent)) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M || !isCallable(intent)) {
|
||||||
PreferenceCategory generalCategory = (PreferenceCategory) mSettingsFragment.findPreference("general");
|
PreferenceCategory generalCategory =
|
||||||
|
(PreferenceCategory) mSettingsFragment.findPreference("general");
|
||||||
generalCategory.removePreference(huaweiPreferenceScreen);
|
generalCategory.removePreference(huaweiPreferenceScreen);
|
||||||
if (generalCategory.getPreferenceCount() == 0) {
|
if (generalCategory.getPreferenceCount() == 0) {
|
||||||
if (mainPreferenceScreen != null) {
|
if (mainPreferenceScreen != null) {
|
||||||
|
@ -133,9 +143,11 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListPreference automaticMessageDeletionList = (ListPreference) mSettingsFragment.findPreference(AUTOMATIC_MESSAGE_DELETION);
|
ListPreference automaticMessageDeletionList =
|
||||||
|
(ListPreference) mSettingsFragment.findPreference(AUTOMATIC_MESSAGE_DELETION);
|
||||||
if (automaticMessageDeletionList != null) {
|
if (automaticMessageDeletionList != null) {
|
||||||
final int[] choices = getResources().getIntArray(R.array.automatic_message_deletion_values);
|
final int[] choices =
|
||||||
|
getResources().getIntArray(R.array.automatic_message_deletion_values);
|
||||||
CharSequence[] entries = new CharSequence[choices.length];
|
CharSequence[] entries = new CharSequence[choices.length];
|
||||||
CharSequence[] entryValues = new CharSequence[choices.length];
|
CharSequence[] entryValues = new CharSequence[choices.length];
|
||||||
for (int i = 0; i < choices.length; ++i) {
|
for (int i = 0; i < choices.length; ++i) {
|
||||||
|
@ -150,14 +162,22 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
automaticMessageDeletionList.setEntryValues(entryValues);
|
automaticMessageDeletionList.setEntryValues(entryValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean removeLocation =
|
||||||
|
new Intent("eu.siacs.conversations.location.request")
|
||||||
|
.resolveActivity(getPackageManager())
|
||||||
|
== null;
|
||||||
|
boolean removeVoice =
|
||||||
|
new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION)
|
||||||
|
.resolveActivity(getPackageManager())
|
||||||
|
== null;
|
||||||
|
|
||||||
boolean removeLocation = new Intent("eu.siacs.conversations.location.request").resolveActivity(getPackageManager()) == null;
|
ListPreference quickAction =
|
||||||
boolean removeVoice = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION).resolveActivity(getPackageManager()) == null;
|
(ListPreference) mSettingsFragment.findPreference("quick_action");
|
||||||
|
|
||||||
ListPreference quickAction = (ListPreference) mSettingsFragment.findPreference("quick_action");
|
|
||||||
if (quickAction != null && (removeLocation || removeVoice)) {
|
if (quickAction != null && (removeLocation || removeVoice)) {
|
||||||
ArrayList<CharSequence> entries = new ArrayList<>(Arrays.asList(quickAction.getEntries()));
|
ArrayList<CharSequence> entries =
|
||||||
ArrayList<CharSequence> entryValues = new ArrayList<>(Arrays.asList(quickAction.getEntryValues()));
|
new ArrayList<>(Arrays.asList(quickAction.getEntries()));
|
||||||
|
ArrayList<CharSequence> entryValues =
|
||||||
|
new ArrayList<>(Arrays.asList(quickAction.getEntryValues()));
|
||||||
int index = entryValues.indexOf("location");
|
int index = entryValues.indexOf("location");
|
||||||
if (index > 0 && removeLocation) {
|
if (index > 0 && removeLocation) {
|
||||||
entries.remove(index);
|
entries.remove(index);
|
||||||
|
@ -172,35 +192,48 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
quickAction.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()]));
|
quickAction.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Preference removeCertsPreference = mSettingsFragment.findPreference("remove_trusted_certificates");
|
final Preference removeCertsPreference =
|
||||||
|
mSettingsFragment.findPreference("remove_trusted_certificates");
|
||||||
if (removeCertsPreference != null) {
|
if (removeCertsPreference != null) {
|
||||||
removeCertsPreference.setOnPreferenceClickListener(preference -> {
|
removeCertsPreference.setOnPreferenceClickListener(
|
||||||
final MemorizingTrustManager mtm = xmppConnectionService.getMemorizingTrustManager();
|
preference -> {
|
||||||
|
final MemorizingTrustManager mtm =
|
||||||
|
xmppConnectionService.getMemorizingTrustManager();
|
||||||
final ArrayList<String> aliases = Collections.list(mtm.getCertificates());
|
final ArrayList<String> aliases = Collections.list(mtm.getCertificates());
|
||||||
if (aliases.size() == 0) {
|
if (aliases.size() == 0) {
|
||||||
displayToast(getString(R.string.toast_no_trusted_certs));
|
displayToast(getString(R.string.toast_no_trusted_certs));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final ArrayList<Integer> selectedItems = new ArrayList<>();
|
final ArrayList<Integer> selectedItems = new ArrayList<>();
|
||||||
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this);
|
final AlertDialog.Builder dialogBuilder =
|
||||||
dialogBuilder.setTitle(getResources().getString(R.string.dialog_manage_certs_title));
|
new AlertDialog.Builder(SettingsActivity.this);
|
||||||
dialogBuilder.setMultiChoiceItems(aliases.toArray(new CharSequence[aliases.size()]), null,
|
dialogBuilder.setTitle(
|
||||||
|
getResources().getString(R.string.dialog_manage_certs_title));
|
||||||
|
dialogBuilder.setMultiChoiceItems(
|
||||||
|
aliases.toArray(new CharSequence[aliases.size()]),
|
||||||
|
null,
|
||||||
(dialog, indexSelected, isChecked) -> {
|
(dialog, indexSelected, isChecked) -> {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
selectedItems.add(indexSelected);
|
selectedItems.add(indexSelected);
|
||||||
} else if (selectedItems.contains(indexSelected)) {
|
} else if (selectedItems.contains(indexSelected)) {
|
||||||
selectedItems.remove(Integer.valueOf(indexSelected));
|
selectedItems.remove(Integer.valueOf(indexSelected));
|
||||||
}
|
}
|
||||||
((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(selectedItems.size() > 0);
|
((AlertDialog) dialog)
|
||||||
|
.getButton(DialogInterface.BUTTON_POSITIVE)
|
||||||
|
.setEnabled(selectedItems.size() > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogBuilder.setPositiveButton(
|
dialogBuilder.setPositiveButton(
|
||||||
getResources().getString(R.string.dialog_manage_certs_positivebutton), (dialog, which) -> {
|
getResources()
|
||||||
|
.getString(R.string.dialog_manage_certs_positivebutton),
|
||||||
|
(dialog, which) -> {
|
||||||
int count = selectedItems.size();
|
int count = selectedItems.size();
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
try {
|
try {
|
||||||
Integer item = Integer.valueOf(selectedItems.get(i).toString());
|
Integer item =
|
||||||
|
Integer.valueOf(
|
||||||
|
selectedItems.get(i).toString());
|
||||||
String alias = aliases.get(item);
|
String alias = aliases.get(item);
|
||||||
mtm.deleteCertificate(alias);
|
mtm.deleteCertificate(alias);
|
||||||
} catch (KeyStoreException e) {
|
} catch (KeyStoreException e) {
|
||||||
|
@ -211,10 +244,18 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
if (xmppConnectionServiceBound) {
|
if (xmppConnectionServiceBound) {
|
||||||
reconnectAccounts();
|
reconnectAccounts();
|
||||||
}
|
}
|
||||||
displayToast(getResources().getQuantityString(R.plurals.toast_delete_certificates, count, count));
|
displayToast(
|
||||||
|
getResources()
|
||||||
|
.getQuantityString(
|
||||||
|
R.plurals.toast_delete_certificates,
|
||||||
|
count,
|
||||||
|
count));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialogBuilder.setNegativeButton(getResources().getString(R.string.dialog_manage_certs_negativebutton), null);
|
dialogBuilder.setNegativeButton(
|
||||||
|
getResources()
|
||||||
|
.getString(R.string.dialog_manage_certs_negativebutton),
|
||||||
|
null);
|
||||||
AlertDialog removeCertsDialog = dialogBuilder.create();
|
AlertDialog removeCertsDialog = dialogBuilder.create();
|
||||||
removeCertsDialog.show();
|
removeCertsDialog.show();
|
||||||
removeCertsDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
removeCertsDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||||
|
@ -224,8 +265,12 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
|
|
||||||
final Preference createBackupPreference = mSettingsFragment.findPreference("create_backup");
|
final Preference createBackupPreference = mSettingsFragment.findPreference("create_backup");
|
||||||
if (createBackupPreference != null) {
|
if (createBackupPreference != null) {
|
||||||
createBackupPreference.setSummary(getString(R.string.pref_create_backup_summary, FileBackend.getBackupDirectory(this).getAbsolutePath()));
|
createBackupPreference.setSummary(
|
||||||
createBackupPreference.setOnPreferenceClickListener(preference -> {
|
getString(
|
||||||
|
R.string.pref_create_backup_summary,
|
||||||
|
FileBackend.getBackupDirectory(this).getAbsolutePath()));
|
||||||
|
createBackupPreference.setOnPreferenceClickListener(
|
||||||
|
preference -> {
|
||||||
if (hasStoragePermission(REQUEST_CREATE_BACKUP)) {
|
if (hasStoragePermission(REQUEST_CREATE_BACKUP)) {
|
||||||
createBackup();
|
createBackup();
|
||||||
}
|
}
|
||||||
|
@ -239,20 +284,25 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
cleanCachePreference.setOnPreferenceClickListener(preference -> cleanCache());
|
cleanCachePreference.setOnPreferenceClickListener(preference -> cleanCache());
|
||||||
}
|
}
|
||||||
|
|
||||||
final Preference cleanPrivateStoragePreference = mSettingsFragment.findPreference("clean_private_storage");
|
final Preference cleanPrivateStoragePreference =
|
||||||
|
mSettingsFragment.findPreference("clean_private_storage");
|
||||||
if (cleanPrivateStoragePreference != null) {
|
if (cleanPrivateStoragePreference != null) {
|
||||||
cleanPrivateStoragePreference.setOnPreferenceClickListener(preference -> cleanPrivateStorage());
|
cleanPrivateStoragePreference.setOnPreferenceClickListener(
|
||||||
|
preference -> cleanPrivateStorage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Preference deleteOmemoPreference = mSettingsFragment.findPreference("delete_omemo_identities");
|
final Preference deleteOmemoPreference =
|
||||||
|
mSettingsFragment.findPreference("delete_omemo_identities");
|
||||||
if (deleteOmemoPreference != null) {
|
if (deleteOmemoPreference != null) {
|
||||||
deleteOmemoPreference.setOnPreferenceClickListener(preference -> deleteOmemoIdentities());
|
deleteOmemoPreference.setOnPreferenceClickListener(
|
||||||
|
preference -> deleteOmemoIdentities());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeOmemoSettingSummary() {
|
private void changeOmemoSettingSummary() {
|
||||||
ListPreference omemoPreference = (ListPreference) mSettingsFragment.findPreference(OMEMO_SETTING);
|
ListPreference omemoPreference =
|
||||||
|
(ListPreference) mSettingsFragment.findPreference(OMEMO_SETTING);
|
||||||
if (omemoPreference != null) {
|
if (omemoPreference != null) {
|
||||||
String value = omemoPreference.getValue();
|
String value = omemoPreference.getValue();
|
||||||
switch (value) {
|
switch (value) {
|
||||||
|
@ -267,15 +317,18 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG,"unable to find preference named "+OMEMO_SETTING);
|
Log.d(Config.LOGTAG, "unable to find preference named " + OMEMO_SETTING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCallable(final Intent i) {
|
private boolean isCallable(final Intent i) {
|
||||||
return i != null && getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
|
return i != null
|
||||||
|
&& getPackageManager()
|
||||||
|
.queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY)
|
||||||
|
.size()
|
||||||
|
> 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean cleanCache() {
|
private boolean cleanCache() {
|
||||||
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||||
|
@ -284,7 +337,7 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean cleanPrivateStorage() {
|
private boolean cleanPrivateStorage() {
|
||||||
for(String type : Arrays.asList("Images", "Videos", "Files", "Recordings")) {
|
for (String type : Arrays.asList("Images", "Videos", "Files", "Recordings")) {
|
||||||
cleanPrivateFiles(type);
|
cleanPrivateFiles(type);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -320,7 +373,10 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final boolean[] checkedItems = new boolean[accounts.size()];
|
final boolean[] checkedItems = new boolean[accounts.size()];
|
||||||
builder.setMultiChoiceItems(accounts.toArray(new CharSequence[accounts.size()]), checkedItems, (dialog, which, isChecked) -> {
|
builder.setMultiChoiceItems(
|
||||||
|
accounts.toArray(new CharSequence[accounts.size()]),
|
||||||
|
checkedItems,
|
||||||
|
(dialog, which, isChecked) -> {
|
||||||
checkedItems[which] = isChecked;
|
checkedItems[which] = isChecked;
|
||||||
final AlertDialog alertDialog = (AlertDialog) dialog;
|
final AlertDialog alertDialog = (AlertDialog) dialog;
|
||||||
for (boolean item : checkedItems) {
|
for (boolean item : checkedItems) {
|
||||||
|
@ -332,7 +388,9 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
|
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
builder.setPositiveButton(R.string.delete_selected_keys, (dialog, which) -> {
|
builder.setPositiveButton(
|
||||||
|
R.string.delete_selected_keys,
|
||||||
|
(dialog, which) -> {
|
||||||
for (int i = 0; i < checkedItems.length; ++i) {
|
for (int i = 0; i < checkedItems.length; ++i) {
|
||||||
if (checkedItems[i]) {
|
if (checkedItems[i]) {
|
||||||
try {
|
try {
|
||||||
|
@ -344,7 +402,6 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -363,7 +420,8 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String name) {
|
public void onSharedPreferenceChanged(SharedPreferences preferences, String name) {
|
||||||
final List<String> resendPresence = Arrays.asList(
|
final List<String> resendPresence =
|
||||||
|
Arrays.asList(
|
||||||
"confirm_messages",
|
"confirm_messages",
|
||||||
DND_ON_SILENT_MODE,
|
DND_ON_SILENT_MODE,
|
||||||
AWAY_WHEN_SCREEN_IS_OFF,
|
AWAY_WHEN_SCREEN_IS_OFF,
|
||||||
|
@ -387,6 +445,9 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
xmppConnectionService.updateMemorizingTrustmanager();
|
xmppConnectionService.updateMemorizingTrustmanager();
|
||||||
reconnectAccounts();
|
reconnectAccounts();
|
||||||
} else if (name.equals("use_tor")) {
|
} else if (name.equals("use_tor")) {
|
||||||
|
if (preferences.getBoolean(name, false)) {
|
||||||
|
displayToast(getString(R.string.audio_video_disabled_tor));
|
||||||
|
}
|
||||||
reconnectAccounts();
|
reconnectAccounts();
|
||||||
xmppConnectionService.reinitializeMuclumbusService();
|
xmppConnectionService.reinitializeMuclumbusService();
|
||||||
} else if (name.equals(AUTOMATIC_MESSAGE_DELETION)) {
|
} else if (name.equals(AUTOMATIC_MESSAGE_DELETION)) {
|
||||||
|
@ -396,26 +457,34 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
if (this.mTheme != theme) {
|
if (this.mTheme != theme) {
|
||||||
recreate();
|
recreate();
|
||||||
}
|
}
|
||||||
} else if(name.equals(PREVENT_SCREENSHOTS)){
|
} else if (name.equals(PREVENT_SCREENSHOTS)) {
|
||||||
SettingsUtils.applyScreenshotPreventionSetting(this);
|
SettingsUtils.applyScreenshotPreventionSetting(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume(){
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
SettingsUtils.applyScreenshotPreventionSetting(this);
|
SettingsUtils.applyScreenshotPreventionSetting(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(
|
||||||
|
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
if (grantResults.length > 0)
|
if (grantResults.length > 0)
|
||||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
if (requestCode == REQUEST_CREATE_BACKUP) {
|
if (requestCode == REQUEST_CREATE_BACKUP) {
|
||||||
createBackup();
|
createBackup();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, getString(R.string.no_storage_permission, getString(R.string.app_name)), Toast.LENGTH_SHORT).show();
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
getString(
|
||||||
|
R.string.no_storage_permission,
|
||||||
|
getString(R.string.app_name)),
|
||||||
|
Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,7 +509,6 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshUiReal() {
|
public void refreshUiReal() {
|
||||||
//nothing to do. This Activity doesn't implement any listeners
|
// nothing to do. This Activity doesn't implement any listeners
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -986,5 +986,6 @@
|
||||||
<string name="no_xmpp_adddress_found">No XMPP address found</string>
|
<string name="no_xmpp_adddress_found">No XMPP address found</string>
|
||||||
<string name="account_status_temporary_auth_failure">Temporary authentication failure</string>
|
<string name="account_status_temporary_auth_failure">Temporary authentication failure</string>
|
||||||
<string name="delete_avatar">Delete avatar</string>
|
<string name="delete_avatar">Delete avatar</string>
|
||||||
|
<string name="audio_video_disabled_tor">Calls are disabled when using Tor</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue