Commit 9606bf63 authored by Grigory Fedorov's avatar Grigory Fedorov

New activity ThemeSettings and ThemeSettingsFragment for "Theme settings" preferences screen.

parent 2e2dfb1c
......@@ -307,6 +307,14 @@
android:excludeFromRecents="true"
/>
<activity
android:name="com.xabber.android.ui.preferences.ThemeSettings"
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
......
......@@ -10,10 +10,8 @@ import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceManager;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.ui.ContactList;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
......@@ -73,9 +71,6 @@ public class PreferencesFragment extends android.preference.PreferenceFragment
changeGrouping();
} else if (key.equals(getString(R.string.contacts_show_groups_key))) {
changeGrouping();
} else if (key.equals(getString(R.string.interface_theme_key))) {
ActivityManager.getInstance().clearStack(true);
startActivity(ContactList.createIntent(getActivity()));
}
}
......
package com.xabber.android.ui.preferences;
import android.app.Activity;
import android.os.Bundle;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.ui.ContactList;
import com.xabber.androiddev.R;
public class ThemeSettings extends Activity
implements ThemeSettingsFragment.OnThemeSettingsFragmentInteractionListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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 ThemeSettingsFragment()).commit();
}
}
@Override
public void onThemeChanged() {
ActivityManager.getInstance().clearStack(true);
startActivity(ContactList.createIntent(this));
}
}
package com.xabber.android.ui.preferences;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class ThemeSettingsFragment extends android.preference.PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
private OnThemeSettingsFragmentInteractionListener mListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_theme);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
@Override
public void onResume() {
super.onResume();
PreferenceManager.getDefaultSharedPreferences(getActivity())
.registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onPause() {
super.onPause();
PreferenceManager.getDefaultSharedPreferences(getActivity())
.unregisterOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(getString(R.string.interface_theme_key))) {
mListener.onThemeChanged();
}
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnThemeSettingsFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnThemeSettingsFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnThemeSettingsFragmentInteractionListener {
public void onThemeChanged();
}
}
......@@ -21,25 +21,15 @@
android:targetPackage="@string/application_package"
android:targetClass="com.xabber.android.ui.preferences.AccountList"/>
</Preference>
<PreferenceScreen
<Preference
android:title="@string/preference_interface"
android:key="@string/preference_interface"
>
<ListPreference
android:title="@string/interface_theme"
android:key="@string/interface_theme_key"
android:entries="@array/interface_theme_entries"
android:entryValues="@array/interface_theme_entryvalues"
android:defaultValue="@string/interface_theme_default"
/>
<ListPreference
android:title="@string/interface_smiles"
android:key="@string/interface_smiles_key"
android:entries="@array/interface_smiles_entries"
android:entryValues="@array/interface_smiles_entryvalues"
android:defaultValue="@string/interface_smiles_default"
/>
</PreferenceScreen>
<intent
android:targetPackage="@string/application_package"
android:targetClass="com.xabber.android.ui.preferences.ThemeSettings"/>
</Preference>
<PreferenceScreen
android:title="@string/preference_contacts"
android:key="@string/preference_contacts"
......
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:title="@string/interface_theme"
android:key="@string/interface_theme_key"
android:entries="@array/interface_theme_entries"
android:entryValues="@array/interface_theme_entryvalues"
android:defaultValue="@string/interface_theme_default"
/>
<ListPreference
android:title="@string/interface_smiles"
android:key="@string/interface_smiles_key"
android:entries="@array/interface_smiles_entries"
android:entryValues="@array/interface_smiles_entryvalues"
android:defaultValue="@string/interface_smiles_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