Commit 81682f05 authored by Grigory Fedorov's avatar Grigory Fedorov

New SecuritySettings activity, SecuritySettingsFragment and SecurityClearCertificateDialog.

parent b67909d5
......@@ -352,6 +352,15 @@
android:value="com.xabber.android.ui.preferences.PreferenceEditor" />
</activity>
<activity
android:name="com.xabber.android.ui.preferences.SecuritySettings"
android:parentActivityName="com.xabber.android.ui.preferences.PreferenceEditor">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.xabber.android.ui.preferences.PreferenceEditor" />
</activity>
<service android:name="com.xabber.android.service.XabberService" />
<service
android:name="com.xabber.android.service.SyncAdapterService"
......
......@@ -18,6 +18,5 @@ public class ContactResetOfflineSettingsDialog extends DialogPreference {
if (positiveResult) {
GroupManager.getInstance().resetShowOfflineModes();
}
}
}
......@@ -61,9 +61,6 @@ public class PreferenceEditor extends ManagedActivity
public boolean onPreferenceClick(Preference preference) {
if (preference.getKey().equals(getString(R.string.cache_clear_key))) {
showDialog(R.string.cache_clear_warning);
} else if (preference.getKey().equals(
getString(R.string.security_clear_certificate_key))) {
showDialog(R.string.security_clear_certificate_warning);
}
return false;
}
......@@ -75,11 +72,6 @@ public class PreferenceEditor extends ManagedActivity
case R.string.cache_clear_warning:
return new ConfirmDialogBuilder(this, R.string.cache_clear_warning,
this).setMessage(R.string.cache_clear_warning).create();
case R.string.security_clear_certificate_warning:
return new ConfirmDialogBuilder(this,
R.string.security_clear_certificate_warning, this)
.setMessage(R.string.security_clear_certificate_warning)
.create();
case R.string.application_state_closing:
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog
......@@ -102,10 +94,6 @@ public class PreferenceEditor extends ManagedActivity
Application.getInstance().requestToClose();
showDialog(R.string.application_state_closing);
break;
case R.string.security_clear_certificate_warning:
CertificateManager.getInstance().removeCertificates();
ConnectionManager.getInstance().updateConnections(true);
break;
}
}
......
......@@ -26,8 +26,6 @@ public class PreferencesFragment extends android.preference.PreferenceFragment {
getPreferenceScreen().findPreference(getString(R.string.cache_clear_key))
.setOnPreferenceClickListener(mListener.getOnPreferenceClickListener());
getPreferenceScreen().findPreference(getString(R.string.security_clear_certificate_key))
.setOnPreferenceClickListener(mListener.getOnPreferenceClickListener());
getPreferenceScreen().findPreference(getString(R.string.debug_log_key))
.setEnabled(LogManager.isDebugable());
......
package com.xabber.android.ui.preferences;
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import com.xabber.android.data.connection.CertificateManager;
import com.xabber.android.data.connection.ConnectionManager;
public class SecurityClearCertificateDialog extends DialogPreference {
public SecurityClearCertificateDialog(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
CertificateManager.getInstance().removeCertificates();
ConnectionManager.getInstance().updateConnections(true);
}
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
public class SecuritySettings extends ManagedActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
setContentView(R.layout.activity_preferences);
getActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new SecuritySettingsFragment()).commit();
}
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class SecuritySettingsFragment extends android.preference.PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_security);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
}
......@@ -62,32 +62,14 @@
android:targetPackage="@string/application_package"
android:targetClass="com.xabber.android.ui.preferences.ConnectionSettings"/>
</Preference>
<PreferenceScreen
<Preference
android:title="@string/preference_security"
android:key="@string/preference_security"
>
<CheckBoxPreference
android:title="@string/security_check_certificate"
android:key="@string/security_check_certificate_key"
android:defaultValue="@bool/security_check_certificate_default"
/>
<PreferenceScreen
android:title="@string/security_clear_certificate"
android:key="@string/security_clear_certificate_key"
/>
<ListPreference
android:title="@string/security_otr_mode"
android:key="@string/security_otr_mode_key"
android:entries="@array/security_otr_mode_entries"
android:entryValues="@array/security_otr_mode_entryvalues"
android:defaultValue="@string/security_otr_mode_default"
/>
<CheckBoxPreference
android:title="@string/security_otr_history"
android:key="@string/security_otr_history_key"
android:defaultValue="@bool/security_otr_history_default"
/>
</PreferenceScreen>
<intent
android:targetPackage="@string/application_package"
android:targetClass="com.xabber.android.ui.preferences.SecuritySettings"/>
</Preference>
<PreferenceScreen
android:title="@string/preference_debug"
android:key="@string/preference_debug"
......
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:title="@string/security_check_certificate"
android:key="@string/security_check_certificate_key"
android:defaultValue="@bool/security_check_certificate_default"
/>
<com.xabber.android.ui.preferences.SecurityClearCertificateDialog
android:title="@string/security_clear_certificate"
android:key="@string/security_clear_certificate_key"
android:dialogMessage="@string/security_clear_certificate_warning"/>
<ListPreference
android:title="@string/security_otr_mode"
android:key="@string/security_otr_mode_key"
android:entries="@array/security_otr_mode_entries"
android:entryValues="@array/security_otr_mode_entryvalues"
android:defaultValue="@string/security_otr_mode_default"
/>
<CheckBoxPreference
android:title="@string/security_otr_history"
android:key="@string/security_otr_history_key"
android:defaultValue="@bool/security_otr_history_default"
/>
</PreferenceScreen>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment