Commit 155af8df authored by Grigory Fedorov's avatar Grigory Fedorov

Merge branch 'feature/new_preferences' into develop

parents 828972a5 e3b2429e
...@@ -8,8 +8,8 @@ android { ...@@ -8,8 +8,8 @@ android {
applicationId "com.xabber.androiddev" applicationId "com.xabber.androiddev"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 21 targetSdkVersion 21
versionCode 87 versionCode 88
versionName '0.10.2' versionName '0.10.3'
} }
buildTypes { buildTypes {
...@@ -22,5 +22,5 @@ android { ...@@ -22,5 +22,5 @@ android {
dependencies { dependencies {
compile files('libs/otr4j.jar') compile files('libs/otr4j.jar')
compile 'com.android.support:support-v4:21.0.3' compile 'com.android.support:appcompat-v7:21.0.3'
} }
This diff is collapsed.
...@@ -14,24 +14,21 @@ ...@@ -14,24 +14,21 @@
*/ */
package com.xabber.android.data; package com.xabber.android.data;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.WeakHashMap;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.TypedArray;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
import com.xabber.android.data.SettingsManager.InterfaceTheme;
import com.xabber.android.ui.ContactList; import com.xabber.android.ui.ContactList;
import com.xabber.android.ui.LoadActivity; import com.xabber.android.ui.LoadActivity;
import com.xabber.android.ui.PreferenceEditor;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.WeakHashMap;
/** /**
* Activity stack manager. * Activity stack manager.
* *
...@@ -123,30 +120,14 @@ public class ActivityManager implements OnUnloadListener { ...@@ -123,30 +120,14 @@ public class ActivityManager implements OnUnloadListener {
return false; return false;
} }
/** /**
* Apply theme settings. * Apply theme settings.
* *
* @param activity * @param activity
*/ */
private void applyTheme(Activity activity) { private void applyTheme(Activity activity) {
if (activity instanceof PreferenceEditor) activity.setTheme(R.style.Theme);
return; }
TypedArray title = activity.getTheme().obtainStyledAttributes(
new int[] { android.R.attr.windowNoTitle,
android.R.attr.windowIsFloating });
boolean noTitle = title.getBoolean(0, false);
boolean isFloating = title.getBoolean(1, false);
title.recycle();
if (isFloating)
return;
InterfaceTheme theme = SettingsManager.interfaceTheme();
if (theme == SettingsManager.InterfaceTheme.light)
activity.setTheme(noTitle ? R.style.Theme_Light_NoTitleBar
: R.style.Theme_Light);
else if (theme == SettingsManager.InterfaceTheme.dark)
activity.setTheme(noTitle ? R.style.Theme_Dark_NoTitleBar
: R.style.Theme_Dark);
}
/** /**
* Push activity to stack. * Push activity to stack.
...@@ -212,9 +193,9 @@ public class ActivityManager implements OnUnloadListener { ...@@ -212,9 +193,9 @@ public class ActivityManager implements OnUnloadListener {
LogManager.i(this, "Wait for loading"); LogManager.i(this, "Wait for loading");
activity.startActivity(LoadActivity.createIntent(activity)); activity.startActivity(LoadActivity.createIntent(activity));
} }
if (onErrorListener != null) if (onErrorListener != null) {
application application.removeUIListener(OnErrorListener.class, onErrorListener);
.removeUIListener(OnErrorListener.class, onErrorListener); }
onErrorListener = new OnErrorListener() { onErrorListener = new OnErrorListener() {
@Override @Override
public void onError(final int resourceId) { public void onError(final int resourceId) {
......
...@@ -19,7 +19,7 @@ import android.content.Intent; ...@@ -19,7 +19,7 @@ import android.content.Intent;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.entity.AccountRelated; import com.xabber.android.data.entity.AccountRelated;
import com.xabber.android.data.notification.AccountNotificationItem; import com.xabber.android.data.notification.AccountNotificationItem;
import com.xabber.android.ui.AccountEditor; import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
public class AccountAuthorizationError extends AccountRelated implements public class AccountAuthorizationError extends AccountRelated implements
......
...@@ -91,7 +91,7 @@ public class AccountAdd extends ManagedActivity implements ...@@ -91,7 +91,7 @@ public class AccountAdd extends ManagedActivity implements
inputManager.hideSoftInputFromWindow(findViewById(R.id.ok) inputManager.hideSoftInputFromWindow(findViewById(R.id.ok)
.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
......
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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.
*
* 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 com.xabber.android.ui;
import java.util.HashMap;
import java.util.Map;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.ArchiveMode;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.message.chat.ChatManager;
import com.xabber.android.ui.helper.BaseSettingsActivity;
import com.xabber.androiddev.R;
public class ChatEditor extends BaseSettingsActivity {
private String account;
private String user;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
protected void onInflate(Bundle savedInstanceState) {
account = getAccount(getIntent());
user = getUser(getIntent());
AccountItem accountItem = AccountManager.getInstance().getAccount(
account);
if (accountItem == null || user == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish();
return;
}
addPreferencesFromResource(R.xml.chat_editor);
if (accountItem.getArchiveMode() == ArchiveMode.server
|| accountItem.getArchiveMode() == ArchiveMode.dontStore)
getPreferenceScreen().removePreference(
getPreferenceScreen().findPreference(
getString(R.string.chat_save_history_key)));
}
@Override
protected Map<String, Object> getValues() {
Map<String, Object> map = new HashMap<String, Object>();
putValue(map, R.string.chat_save_history_key, ChatManager.getInstance()
.isSaveMessages(account, user));
putValue(map, R.string.chat_events_visible_chat_key, ChatManager
.getInstance().isNotifyVisible(account, user));
putValue(map, R.string.chat_events_show_text_key, ChatManager
.getInstance().isShowText(account, user));
putValue(map, R.string.chat_events_vibro_key, ChatManager.getInstance()
.isMakeVibro(account, user));
putValue(map, R.string.chat_events_sound_key, ChatManager.getInstance()
.getSound(account, user));
return map;
}
@Override
protected boolean setValues(Map<String, Object> source,
Map<String, Object> result) {
if (hasChanges(source, result, R.string.chat_save_history_key))
ChatManager.getInstance().setSaveMessages(account, user,
getBoolean(result, R.string.chat_save_history_key));
if (hasChanges(source, result, R.string.chat_events_visible_chat_key))
ChatManager.getInstance().setNotifyVisible(account, user,
getBoolean(result, R.string.chat_events_visible_chat_key));
if (hasChanges(source, result, R.string.chat_events_show_text_key))
ChatManager.getInstance().setShowText(account, user,
getBoolean(result, R.string.chat_events_show_text_key));
if (hasChanges(source, result, R.string.chat_events_vibro_key))
ChatManager.getInstance().setMakeVibro(account, user,
getBoolean(result, R.string.chat_events_vibro_key));
if (hasChanges(source, result, R.string.chat_events_sound_key))
ChatManager.getInstance().setSound(account, user,
getUri(result, R.string.chat_events_sound_key));
return true;
}
public static Intent createIntent(Context context, String account,
String user) {
return new EntityIntentBuilder(context, ChatEditor.class)
.setAccount(account).setUser(user).build();
}
private static String getAccount(Intent intent) {
return EntityIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
}
...@@ -50,7 +50,7 @@ public class ChatList extends ManagedListActivity implements ...@@ -50,7 +50,7 @@ public class ChatList extends ManagedListActivity implements
setListAdapter(listAdapter); setListAdapter(listAdapter);
getListView().setOnItemClickListener(this); getListView().setOnItemClickListener(this);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
......
...@@ -115,7 +115,7 @@ public class ChatViewer extends ManagedActivity implements OnSelectListener, ...@@ -115,7 +115,7 @@ public class ChatViewer extends ManagedActivity implements OnSelectListener,
if (actionWithUser == null) if (actionWithUser == null)
actionWithUser = user; actionWithUser = user;
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
selectChat(actionWithAccount, actionWithUser); selectChat(actionWithAccount, actionWithUser);
} }
...@@ -179,7 +179,6 @@ public class ChatViewer extends ManagedActivity implements OnSelectListener, ...@@ -179,7 +179,6 @@ public class ChatViewer extends ManagedActivity implements OnSelectListener,
String account = getAccount(intent); String account = getAccount(intent);
String user = getUser(intent); String user = getUser(intent);
if (account == null || user == null) { if (account == null || user == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
return; return;
} }
if (hasAttention(intent)) if (hasAttention(intent))
......
...@@ -57,6 +57,7 @@ import com.xabber.android.ui.adapter.ChatMessageAdapter; ...@@ -57,6 +57,7 @@ import com.xabber.android.ui.adapter.ChatMessageAdapter;
import com.xabber.android.ui.dialog.ChatExportDialogFragment; import com.xabber.android.ui.dialog.ChatExportDialogFragment;
import com.xabber.android.ui.helper.AbstractAvatarInflaterHelper; import com.xabber.android.ui.helper.AbstractAvatarInflaterHelper;
import com.xabber.android.ui.helper.ContactTitleInflater; import com.xabber.android.ui.helper.ContactTitleInflater;
import com.xabber.android.ui.preferences.ChatEditor;
import com.xabber.android.ui.widget.PageSwitcher; import com.xabber.android.ui.widget.PageSwitcher;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
......
...@@ -62,7 +62,7 @@ public class ContactAdd extends GroupListActivity implements ...@@ -62,7 +62,7 @@ public class ContactAdd extends GroupListActivity implements
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
......
...@@ -47,7 +47,7 @@ public class ContactEditor extends GroupListActivity implements ...@@ -47,7 +47,7 @@ public class ContactEditor extends GroupListActivity implements
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
......
...@@ -24,7 +24,6 @@ import android.graphics.Bitmap; ...@@ -24,7 +24,6 @@ import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.app.FragmentTransaction;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent; import android.view.KeyEvent;
...@@ -55,6 +54,7 @@ import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListene ...@@ -55,6 +54,7 @@ import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListene
import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment; import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment;
import com.xabber.android.ui.dialog.StartAtBootDialogFragment; import com.xabber.android.ui.dialog.StartAtBootDialogFragment;
import com.xabber.android.ui.helper.ManagedActivity; import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.preferences.PreferenceEditor;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.uri.XMPPUri; import com.xabber.xmpp.uri.XMPPUri;
......
...@@ -39,6 +39,7 @@ import com.xabber.android.ui.adapter.ContactListState; ...@@ -39,6 +39,7 @@ import com.xabber.android.ui.adapter.ContactListState;
import com.xabber.android.ui.adapter.GroupConfiguration; import com.xabber.android.ui.adapter.GroupConfiguration;
import com.xabber.android.ui.adapter.UpdatableAdapter; import com.xabber.android.ui.adapter.UpdatableAdapter;
import com.xabber.android.ui.helper.ContextMenuHelper; import com.xabber.android.ui.helper.ContextMenuHelper;
import com.xabber.android.ui.preferences.AccountList;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
public class ContactListFragment extends Fragment implements public class ContactListFragment extends Fragment implements
......
...@@ -120,7 +120,7 @@ public class FingerprintViewer extends ManagedActivity implements ...@@ -120,7 +120,7 @@ public class FingerprintViewer extends ManagedActivity implements
copyView.setOnClickListener(this); copyView.setOnClickListener(this);
isUpdating = false; isUpdating = false;
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
......
...@@ -72,7 +72,7 @@ public class MUCEditor extends ManagedActivity implements View.OnClickListener, ...@@ -72,7 +72,7 @@ public class MUCEditor extends ManagedActivity implements View.OnClickListener,
setContentView(R.layout.muc_editor); setContentView(R.layout.muc_editor);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
accountView = (Spinner) findViewById(R.id.contact_account); accountView = (Spinner) findViewById(R.id.contact_account);
serverView = (EditText) findViewById(R.id.muc_server); serverView = (EditText) findViewById(R.id.muc_server);
......
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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.
*
* 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 com.xabber.android.ui;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.PatternSyntaxException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.widget.Toast;
import com.xabber.android.data.Application;
import com.xabber.android.data.intent.SegmentIntentBuilder;
import com.xabber.android.data.message.phrase.Phrase;
import com.xabber.android.data.message.phrase.PhraseManager;
import com.xabber.android.ui.helper.BaseSettingsActivity;
import com.xabber.androiddev.R;
public class PhraseEditor extends BaseSettingsActivity {
private Phrase phrase;
@Override
protected void onInflate(Bundle savedInstanceState) {
addPreferencesFromResource(R.xml.phrase_editor);
Integer index = getPhraseIndex(getIntent());
if (index == null) {
phrase = null;
setTitle(R.string.phrase_add);
} else {
phrase = PhraseManager.getInstance().getPhrase(index);
if (phrase == null) {
finish();
return;
}
String title = phrase.getText();
if ("".equals(title))
title = Application.getInstance().getString(
R.string.phrase_empty);
setTitle(title);
}
}
@Override
protected Map<String, Object> getValues() {
Map<String, Object> source = new HashMap<String, Object>();
putValue(source, R.string.phrase_text_key,
phrase == null ? "" : phrase.getText());
putValue(source, R.string.phrase_user_key,
phrase == null ? "" : phrase.getUser());
putValue(source, R.string.phrase_group_key, phrase == null ? ""
: phrase.getGroup());
putValue(source, R.string.phrase_regexp_key, phrase == null ? false
: phrase.isRegexp());
putValue(source, R.string.phrase_sound_key,
phrase == null ? Settings.System.DEFAULT_NOTIFICATION_URI
: phrase.getSound());
return source;
}
@Override
protected boolean setValues(Map<String, Object> source,
Map<String, Object> result) {
String text = getString(result, R.string.phrase_text_key);
String user = getString(result, R.string.phrase_user_key);
String group = getString(result, R.string.phrase_group_key);
boolean regexp = getBoolean(result, R.string.phrase_regexp_key);
Uri sound = getUri(result, R.string.phrase_sound_key);
if (regexp)
try {
Phrase.compile(text);
Phrase.compile(user);
Phrase.compile(group);
} catch (PatternSyntaxException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
return false;
}
if (phrase == null && "".equals(text) && "".equals(user)
&& "".equals(group))
return true;
PhraseManager.getInstance().updateOrCreatePhrase(phrase, text, user,
group, regexp, sound);
return true;
}
public static Intent createIntent(Context context) {
return createIntent(context, null);
}
public static Intent createIntent(Context context, Integer phraseIndex) {
SegmentIntentBuilder<?> builder = new SegmentIntentBuilder<SegmentIntentBuilder<?>>(
context, PhraseEditor.class);
if (phraseIndex != null)
builder.addSegment(phraseIndex.toString());
return builder.build();
}
private Integer getPhraseIndex(Intent intent) {
String value = SegmentIntentBuilder.getSegment(intent, 0);
if (value == null)
return null;
else
return Integer.valueOf(value);
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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.
*
* 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 com.xabber.android.ui;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.connection.CertificateManager;
import com.xabber.android.data.connection.ConnectionManager;
import com.xabber.android.data.roster.GroupManager;
import com.xabber.android.ui.dialog.ConfirmDialogBuilder;
import com.xabber.android.ui.dialog.ConfirmDialogListener;
import com.xabber.android.ui.dialog.DialogBuilder;
import com.xabber.android.ui.helper.ManagedPreferenceActivity;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class PreferenceEditor extends ManagedPreferenceActivity implements
OnPreferenceClickListener, OnSharedPreferenceChangeListener,
ConfirmDialogListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
getActionBar().setDisplayHomeAsUpEnabled(true);
addPreferencesFromResource(R.xml.preference_editor);
getPreferenceScreen().findPreference(
getString(R.string.preference_accounts_key)).setIntent(
AccountList.createIntent(this));
getPreferenceScreen()
.findPreference(getString(R.string.events_phrases)).setIntent(
PhraseList.createIntent(this));
getPreferenceScreen().findPreference(
getString(R.string.cache_clear_key))
.setOnPreferenceClickListener(this);
getPreferenceScreen().findPreference(
getString(R.string.security_clear_certificate_key))
.setOnPreferenceClickListener(this);
getPreferenceScreen().findPreference(
getString(R.string.contacts_reset_offline_key))
.setOnPreferenceClickListener(this);
getPreferenceScreen().findPreference(getString(R.string.debug_log_key))
.setEnabled(LogManager.isDebugable());
// Force request sound. This will set default value if not specified.
SettingsManager.eventsSound();
SettingsManager.chatsAttentionSound();
PreferenceScreen about = (PreferenceScreen) getPreferenceScreen()
.findPreference(getString(R.string.preference_about_key));
about.setSummary(getString(R.string.application_name) + "\n" + getVersionName());
about.setIntent(AboutViewer.createIntent(this));
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
private String getVersionName() {
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
return pInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return "";
}
@Override
protected void onResume() {
super.onResume();
PreferenceManager.getDefaultSharedPreferences(this)
.registerOnSharedPreferenceChangeListener(this);
}
@Override
protected void onPause() {
super.onPause();
PreferenceManager.getDefaultSharedPreferences(this)
.unregisterOnSharedPreferenceChangeListener(this);
}
private void changeGrouping() {
boolean grouped = SettingsManager.contactsShowAccounts()
|| SettingsManager.contactsShowGroups();
((CheckBoxPreference) getPreferenceScreen().findPreference(
getString(R.string.contacts_stay_active_chats_key)))
.setChecked(grouped);
((CheckBoxPreference) getPreferenceScreen().findPreference(
getString(R.string.contacts_show_empty_groups_key)))
.setEnabled(grouped);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (key.equals(getString(R.string.contacts_show_accounts_key))) {
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(this));
}
}
@Override
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);
} else if (preference.getKey().equals(
getString(R.string.contacts_reset_offline_key))) {
showDialog(R.string.contacts_reset_offline_warning);
}
return false;
}
@Override
protected Dialog onCreateDialog(int id) {
super.onCreateDialog(id);
switch (id) {
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.contacts_reset_offline_warning:
return new ConfirmDialogBuilder(this,
R.string.contacts_reset_offline_warning, this).setMessage(
R.string.contacts_reset_offline_warning).create();
case R.string.application_state_closing:
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog
.setMessage(getString(R.string.application_state_closing));
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
return progressDialog;
default:
return null;
}
}
@Override
public void onAccept(DialogBuilder dialogBuilder) {
switch (dialogBuilder.getDialogId()) {
case R.string.cache_clear_warning:
AccountManager.getInstance()
.setStatus(StatusMode.unavailable, null);
((Application) getApplication()).requestToClear();
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;
case R.string.contacts_reset_offline_warning:
GroupManager.getInstance().resetShowOfflineModes();
break;
}
}
@Override
public void onDecline(DialogBuilder dialogBuilder) {
}
@Override
public void onCancel(DialogBuilder dialogBuilder) {
}
public static Intent createIntent(Context context) {
return new Intent(context, PreferenceEditor.class);
}
}
...@@ -99,7 +99,7 @@ public class QuestionViewer extends ManagedActivity implements ...@@ -99,7 +99,7 @@ public class QuestionViewer extends ManagedActivity implements
findViewById(R.id.cancel).setOnClickListener(this); findViewById(R.id.cancel).setOnClickListener(this);
findViewById(R.id.send).setOnClickListener(this); findViewById(R.id.send).setOnClickListener(this);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
......
...@@ -72,7 +72,7 @@ public class StatusEditor extends ManagedListActivity implements ...@@ -72,7 +72,7 @@ public class StatusEditor extends ManagedListActivity implements
setContentView(R.layout.status_editor); setContentView(R.layout.status_editor);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent(); Intent intent = getIntent();
account = StatusEditor.getAccount(intent); account = StatusEditor.getAccount(intent);
......
...@@ -29,7 +29,7 @@ import com.xabber.android.data.account.AccountItem; ...@@ -29,7 +29,7 @@ import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.connection.ConnectionState; import com.xabber.android.data.connection.ConnectionState;
import com.xabber.android.data.extension.avatar.AvatarManager; import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.ui.AccountList; import com.xabber.android.ui.preferences.AccountList;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
/** /**
......
...@@ -21,7 +21,7 @@ import java.util.List; ...@@ -21,7 +21,7 @@ import java.util.List;
import android.app.Activity; import android.app.Activity;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import com.xabber.android.ui.helper.BaseListEditor; import com.xabber.android.ui.preferences.BaseListEditor;
/** /**
* This class manage abstract list for {@link BaseListEditor}. * This class manage abstract list for {@link BaseListEditor}.
......
...@@ -33,11 +33,11 @@ import com.xabber.android.data.roster.AbstractContact; ...@@ -33,11 +33,11 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.GroupManager; import com.xabber.android.data.roster.GroupManager;
import com.xabber.android.data.roster.PresenceManager; import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ShowOfflineMode; import com.xabber.android.data.roster.ShowOfflineMode;
import com.xabber.android.ui.AccountEditor; import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.android.ui.ChatViewer; import com.xabber.android.ui.ChatViewer;
import com.xabber.android.ui.ContactAdd; import com.xabber.android.ui.ContactAdd;
import com.xabber.android.ui.ContactEditor; import com.xabber.android.ui.ContactEditor;
import com.xabber.android.ui.ContactViewer; import com.xabber.android.ui.preferences.ContactViewer;
import com.xabber.android.ui.MUCEditor; import com.xabber.android.ui.MUCEditor;
import com.xabber.android.ui.StatusEditor; import com.xabber.android.ui.StatusEditor;
import com.xabber.android.ui.adapter.UpdatableAdapter; import com.xabber.android.ui.adapter.UpdatableAdapter;
......
...@@ -16,7 +16,7 @@ package com.xabber.android.ui.helper; ...@@ -16,7 +16,7 @@ package com.xabber.android.ui.helper;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v7.app.ActionBarActivity;
import com.xabber.android.data.ActivityManager; import com.xabber.android.data.ActivityManager;
...@@ -28,7 +28,7 @@ import com.xabber.android.data.ActivityManager; ...@@ -28,7 +28,7 @@ import com.xabber.android.data.ActivityManager;
* @author alexander.ivanov * @author alexander.ivanov
* *
*/ */
public abstract class ManagedActivity extends FragmentActivity { public abstract class ManagedActivity extends ActionBarActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
......
...@@ -16,7 +16,7 @@ package com.xabber.android.ui.helper; ...@@ -16,7 +16,7 @@ package com.xabber.android.ui.helper;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v7.app.ActionBarActivity;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
...@@ -30,7 +30,7 @@ import com.xabber.android.data.ActivityManager; ...@@ -30,7 +30,7 @@ import com.xabber.android.data.ActivityManager;
* @author alexander.ivanov * @author alexander.ivanov
* *
*/ */
public abstract class ManagedListActivity extends FragmentActivity { public abstract class ManagedListActivity extends ActionBarActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
......
...@@ -26,25 +26,47 @@ import android.preference.PreferenceGroup; ...@@ -26,25 +26,47 @@ import android.preference.PreferenceGroup;
*/ */
public final class PreferenceSummaryHelper { public final class PreferenceSummaryHelper {
private PreferenceSummaryHelper() { private PreferenceSummaryHelper() {
} }
public static void updateSummary(PreferenceGroup group) { public static void updateSummary(PreferenceGroup group) {
for (int index = 0; index < group.getPreferenceCount(); index++) { for (int index = 0; index < group.getPreferenceCount(); index++) {
Preference preference = group.getPreference(index); Preference preference = group.getPreference(index);
if (preference instanceof PreferenceGroup) if (preference instanceof PreferenceGroup) {
updateSummary((PreferenceGroup) preference); updateSummary((PreferenceGroup) preference);
String title = preference.getTitle().toString(); }
int delimeter = title.indexOf("\n"); String titleAndSummary = preference.getTitle().toString();
if (delimeter == -1)
continue; if (!isTitleAndSummary(titleAndSummary)) {
preference.setTitle(title.substring(0, delimeter)); continue;
if (preference instanceof DialogPreference) }
((DialogPreference) preference).setDialogTitle(preference
.getTitle()); preference.setTitle(getPreferenceTitle(titleAndSummary));
preference if (preference instanceof DialogPreference) {
.setSummary(title.substring(delimeter + 1, title.length())); ((DialogPreference) preference).setDialogTitle(preference.getTitle());
} }
} preference.setSummary(getPreferenceSummary(titleAndSummary));
}
}
private static boolean isTitleAndSummary(String titleAndSummary) {
return titleAndSummary.contains("\n");
}
public static String getPreferenceTitle(String titleAndSummary) {
int delimiter = titleAndSummary.indexOf("\n");
if (delimiter == -1) {
return titleAndSummary;
}
return titleAndSummary.substring(0, delimiter);
}
private static String getPreferenceSummary(String titleAndSummary) {
int delimiter = titleAndSummary.indexOf("\n");
if (delimiter == -1) {
return "";
}
return titleAndSummary.substring(delimiter + 1, titleAndSummary.length());
}
} }
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License, * You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/. * along with this program. If not, see http://www.gnu.org/licenses/.
*/ */
package com.xabber.android.ui; package com.xabber.android.ui.preferences;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -39,7 +39,7 @@ public class AboutViewer extends ManagedActivity { ...@@ -39,7 +39,7 @@ public class AboutViewer extends ManagedActivity {
((TextView) findViewById(R.id.about_license)) ((TextView) findViewById(R.id.about_license))
.setMovementMethod(LinkMovementMethod.getInstance()); .setMovementMethod(LinkMovementMethod.getInstance());
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
private String getVersionName() { private String getVersionName() {
......
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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.
*
* 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 com.xabber.android.ui.preferences;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.ui.OAuthActivity;
import com.xabber.android.ui.dialog.OrbotInstallerDialogBuilder;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
public class AccountEditor extends ManagedActivity implements
OnPreferenceClickListener, AccountEditorFragment.AccountEditorFragmentInteractionListener {
private static final int OAUTH_WML_REQUEST_CODE = 1;
private static final String SAVED_TOKEN = "com.xabber.android.ui.preferences.AccountEditor.TOKEN";
public static final String INVALIDATED_TOKEN = "com.xabber.android.ui.preferences.AccountEditor.INVALIDATED";
private static final int ORBOT_DIALOG_ID = 9050;
private String account;
private AccountItem accountItem;
private String token;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
account = AccountEditor.getAccount(getIntent());
if (account == null) {
finish();
return;
}
accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null) {
Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
finish();
return;
}
if (savedInstanceState == null) {
token = accountItem.getConnectionSettings().getPassword();
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new AccountEditorFragment()).commit();
} else {
token = savedInstanceState.getString(SAVED_TOKEN);
}
setTitle(AccountManager.getInstance().getVerboseName(account));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_preferences);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(SAVED_TOKEN, token);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == OAUTH_WML_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
if (OAuthActivity.isInvalidated(data)) {
token = INVALIDATED_TOKEN;
} else {
String value = OAuthActivity.getToken(data);
if (value == null)
Application.getInstance().onError(
R.string.AUTHENTICATION_FAILED);
else
token = value;
}
((AccountEditorFragment)getFragmentManager().findFragmentById(
R.id.preferences_activity_container)).onOAuthChange();
}
}
}
@Override
public boolean onPreferenceClick(Preference preference) {
if (getString(R.string.account_oauth_key).equals(preference.getKey())) {
startActivityForResult(OAuthActivity.createIntent(this, accountItem
.getConnectionSettings().getProtocol()),
OAUTH_WML_REQUEST_CODE);
return true;
}
return false;
}
@Override
protected Dialog onCreateDialog(int id) {
if (id == ORBOT_DIALOG_ID) {
return new OrbotInstallerDialogBuilder(this, ORBOT_DIALOG_ID)
.create();
}
return super.onCreateDialog(id);
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
public static Intent createIntent(Context context, String account) {
return new AccountIntentBuilder(context, AccountEditor.class)
.setAccount(account).build();
}
@Override
public String getAccount() {
return account;
}
@Override
public AccountItem getAccountItem() {
return accountItem;
}
@Override
public String getToken() {
return token;
}
@Override
public void onOAuthClick() {
startActivityForResult(OAuthActivity.createIntent(this, accountItem
.getConnectionSettings().getProtocol()),
OAUTH_WML_REQUEST_CODE);
}
@Override
public void showOrbotDialog() {
showDialog(ORBOT_DIALOG_ID);
}
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License, * You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/. * along with this program. If not, see http://www.gnu.org/licenses/.
*/ */
package com.xabber.android.ui; package com.xabber.android.ui.preferences;
import java.util.Collection; import java.util.Collection;
...@@ -26,9 +26,11 @@ import com.xabber.android.data.Application; ...@@ -26,9 +26,11 @@ import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountItem; import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener; import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.ui.AccountAdd;
import com.xabber.android.ui.StatusEditor;
import com.xabber.android.ui.adapter.AccountListAdapter; import com.xabber.android.ui.adapter.AccountListAdapter;
import com.xabber.android.ui.adapter.BaseListEditorAdapter; import com.xabber.android.ui.adapter.BaseListEditorAdapter;
import com.xabber.android.ui.helper.BaseListEditor; import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
public class AccountList extends BaseListEditor<String> implements public class AccountList extends BaseListEditor<String> implements
...@@ -40,15 +42,22 @@ public class AccountList extends BaseListEditor<String> implements ...@@ -40,15 +42,22 @@ public class AccountList extends BaseListEditor<String> implements
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_accounts)));
} }
@Override @Override
protected int getAddTextResourceId() { protected int getOptionsMenuId() {
return R.string.account_add; return R.menu.add_account;
} }
@Override @Override
protected int getAddActionId() {
return R.id.action_add_account;
}
@Override
protected Intent getAddIntent() { protected Intent getAddIntent() {
return AccountAdd.createIntent(this); return AccountAdd.createIntent(this);
} }
...@@ -137,7 +146,7 @@ public class AccountList extends BaseListEditor<String> implements ...@@ -137,7 +146,7 @@ public class AccountList extends BaseListEditor<String> implements
bundle.putString(key, actionWith); bundle.putString(key, actionWith);
} }
public static Intent createIntent(Context context) { public static Intent createIntent(Context context) {
return new Intent(context, AccountList.class); return new Intent(context, AccountList.class);
} }
......
...@@ -12,26 +12,25 @@ ...@@ -12,26 +12,25 @@
* You should have received a copy of the GNU General Public License, * You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/. * along with this program. If not, see http://www.gnu.org/licenses/.
*/ */
package com.xabber.android.ui.helper; package com.xabber.android.ui.preferences;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import com.xabber.android.ui.adapter.BaseListEditorAdapter; import com.xabber.android.ui.adapter.BaseListEditorAdapter;
import com.xabber.android.ui.dialog.ConfirmDialogBuilder; import com.xabber.android.ui.dialog.ConfirmDialogBuilder;
import com.xabber.android.ui.dialog.ConfirmDialogListener; import com.xabber.android.ui.dialog.ConfirmDialogListener;
import com.xabber.android.ui.dialog.DialogBuilder; import com.xabber.android.ui.dialog.DialogBuilder;
import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
/** /**
...@@ -46,8 +45,7 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -46,8 +45,7 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
private static final String SAVED_ACTION_WITH = "com.xabber.android.ui.BaseListActivity.SAVED_ACTION_WITH"; private static final String SAVED_ACTION_WITH = "com.xabber.android.ui.BaseListActivity.SAVED_ACTION_WITH";
private static final int OPTION_MENU_ADD_ID = Menu.FIRST; private static final int CONTEXT_MENU_DELETE_ID = 0x10;
private static final int CONTEXT_MENU_DELETE_ID = 0x10;
private static final int DIALOG_DELETE_ID = 0x100; private static final int DIALOG_DELETE_ID = 0x100;
private T actionWith; private T actionWith;
...@@ -65,11 +63,6 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -65,11 +63,6 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
else else
actionWith = null; actionWith = null;
ListView listView = getListView(); ListView listView = getListView();
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.add_item, null, true);
((TextView) view.findViewById(android.R.id.message))
.setText(getAddTextResourceId());
listView.addFooterView(view, null, true);
listView.setOnItemClickListener(this); listView.setOnItemClickListener(this);
registerForContextMenu(listView); registerForContextMenu(listView);
adapter = createListAdapter(); adapter = createListAdapter();
...@@ -90,7 +83,9 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -90,7 +83,9 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
protected abstract void putSavedValue(Bundle bundle, String key, protected abstract void putSavedValue(Bundle bundle, String key,
T actionWith); T actionWith);
protected abstract int getAddTextResourceId(); protected abstract int getOptionsMenuId();
protected abstract int getAddActionId();
protected abstract Intent getAddIntent(); protected abstract Intent getAddIntent();
...@@ -121,16 +116,15 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -121,16 +116,15 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
putSavedValue(outState, SAVED_ACTION_WITH, actionWith); putSavedValue(outState, SAVED_ACTION_WITH, actionWith);
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
menu.add(0, OPTION_MENU_ADD_ID, 0, getString(getAddTextResourceId())) getMenuInflater().inflate(getOptionsMenuId(), menu);
.setIcon(android.R.drawable.ic_menu_add) menu.findItem(getAddActionId()).setIntent(getAddIntent());
.setIntent(getAddIntent()); return true;
return true; }
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void onCreateContextMenu(ContextMenu menu, View v, public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) { ContextMenuInfo menuInfo) {
...@@ -175,12 +169,10 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -175,12 +169,10 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
public void onItemClick(AdapterView<?> parent, View view, int position, public void onItemClick(AdapterView<?> parent, View view, int position,
long id) { long id) {
T actionWith = (T) parent.getAdapter().getItem(position); T actionWith = (T) parent.getAdapter().getItem(position);
Intent intent; if (actionWith != null) {
if (actionWith == null) Intent intent = getEditIntent(actionWith);
intent = getAddIntent(); startActivity(intent);
else }
intent = getEditIntent(actionWith);
startActivity(intent);
} }
@Override @Override
......
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.data.message.phrase.Phrase;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
public abstract class BasePhrasePreferences extends ManagedActivity
implements PhraseEditorFragment.OnPhraseEditorFragmentInteractionListener {
private Phrase phrase;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_preferences);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new PhraseEditorFragment()).commit();
}
}
@Override
public Phrase getPhrase() {
return phrase;
}
@Override
public void setPhrase(Phrase phrase) {
this.phrase = phrase;
}
}
package com.xabber.android.ui.preferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.android.ui.widget.RingtonePreference;
import java.util.HashMap;
import java.util.Map;
public abstract class BaseSettingsFragment extends PreferenceFragment
implements Preference.OnPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
onInflate(savedInstanceState);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
if (savedInstanceState == null)
operation(Operation.read);
PreferenceScreen preferenceScreen = getPreferenceScreen();
for (int index = 0; index < preferenceScreen.getPreferenceCount(); index++) {
Preference preference = preferenceScreen.getPreference(index);
preference.setOnPreferenceChangeListener(this);
if (preference instanceof EditTextPreference)
onPreferenceChange(preference,
((EditTextPreference) preference).getText());
else if (preference instanceof CheckBoxPreference)
onPreferenceChange(preference,
((CheckBoxPreference) preference).isChecked());
else if (preference instanceof ListPreference)
onPreferenceChange(preference,
((ListPreference) preference).getValue());
}
}
/**
* Inflates layout.
*
* @param savedInstanceState
*/
protected abstract void onInflate(Bundle savedInstanceState);
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference instanceof EditTextPreference)
preference.setSummary((String) newValue);
return true;
}
/**
* Possible operations.
*/
private static enum Operation {
save, discard, read
}
protected void putValue(Map<String, Object> map, int resoureId, Object value) {
map.put(getString(resoureId), value);
}
protected String getString(Map<String, Object> map, int resoureId) {
return (String) map.get(getString(resoureId));
}
protected int getInt(Map<String, Object> map, int resoureId) {
return (Integer) map.get(getString(resoureId));
}
protected boolean getBoolean(Map<String, Object> map, int resoureId) {
return (Boolean) map.get(getString(resoureId));
}
protected Uri getUri(Map<String, Object> map, int resoureId) {
return (Uri) map.get(getString(resoureId));
}
/**
* @param intent
* @return Whether an operation succeed.
*/
private boolean operation(Operation selected) {
Map<String, Object> source = getValues();
if (selected == Operation.read)
setPreferences(source);
else {
Map<String, Object> result = getPreferences(source);
for (Map.Entry<String, Object> entry : source.entrySet())
if (!result.containsKey(entry.getKey()))
result.put(entry.getKey(), entry.getValue());
if (selected == Operation.save)
return setValues(source, result);
else if (selected == Operation.discard) {
for (String key : source.keySet())
if (hasChanges(source, result, key))
return false;
} else
throw new IllegalStateException();
}
return true;
}
/**
* @param source
* @param result
* @param key
* @return Whether value has been changed.
*/
protected boolean hasChanges(Map<String, Object> source,
Map<String, Object> result, String key) {
Object sourceValue = source.get(key);
Object targetValue = result.get(key);
return (sourceValue == null && targetValue != null)
|| (sourceValue != null && !sourceValue.equals(targetValue));
}
/**
* @param source
* @param result
* @param resourceId
* @return Whether value has been changed.
*/
protected boolean hasChanges(Map<String, Object> source,
Map<String, Object> result, int resourceId) {
return hasChanges(source, result, getString(resourceId));
}
/**
* @return Map with source values.
*/
protected abstract Map<String, Object> getValues();
/**
* Set values to the UI elements.
*
* @param source
*/
protected void setPreferences(Map<String, Object> source) {
PreferenceScreen preferenceScreen = getPreferenceScreen();
for (int index = 0; index < preferenceScreen.getPreferenceCount(); index++) {
Preference preference = preferenceScreen.getPreference(index);
Object value = source.get(preference.getKey());
setPreference(preference, value);
}
}
/**
* Set value to the UI element.
*
* @param preference
* @param value
*/
protected void setPreference(Preference preference, Object value) {
if (preference instanceof EditTextPreference)
((EditTextPreference) preference)
.setText(value instanceof Integer ? String.valueOf(value)
: (String) value);
else if (preference instanceof CheckBoxPreference)
((CheckBoxPreference) preference).setChecked((Boolean) value);
else if (preference instanceof ListPreference)
((ListPreference) preference).setValueIndex((Integer) value);
else if (preference instanceof RingtonePreference)
((RingtonePreference) preference).setUri((Uri) value);
}
/**
* Get values from the UI elements.
*
* @param source
* @return
*/
protected Map<String, Object> getPreferences(Map<String, Object> source) {
Map<String, Object> result = new HashMap<>();
PreferenceScreen preferenceScreen = getPreferenceScreen();
for (int index = 0; index < preferenceScreen.getPreferenceCount(); index++) {
Preference preference = preferenceScreen.getPreference(index);
result.put(preference.getKey(), getPreference(preference, source));
}
return result;
}
/**
* Get value from the UI element.
*
* @param preference
* @param source
* @return
*/
protected Object getPreference(Preference preference, Map<String, Object> source) {
if (preference instanceof PreferenceScreen) {
return null;
} else if (preference instanceof EditTextPreference) {
String value = ((EditTextPreference) preference).getText();
if (source.get(preference.getKey()) instanceof Integer)
try {
return Integer.parseInt(value);
} catch (Exception NumberFormatException) {
return null;
}
else
return value;
} else if (preference instanceof CheckBoxPreference)
return ((CheckBoxPreference) preference).isChecked();
else if (preference instanceof ListPreference)
return ((ListPreference) preference)
.findIndexOfValue(((ListPreference) preference).getValue());
else if (preference instanceof RingtonePreference)
return ((RingtonePreference) preference).getUri();
throw new IllegalStateException();
}
/**
* Apply result values.
*
* @param source
* @param result
* @return Whether operation succeed.
*/
protected abstract boolean setValues(Map<String, Object> source, Map<String, Object> result);
protected boolean saveChanges() {
return operation(Operation.save);
}
}
package com.xabber.android.ui.preferences;
import android.app.ProgressDialog;
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.StatusMode;
import com.xabber.androiddev.R;
public class CacheClearDialog extends DialogPreference {
public CacheClearDialog(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
AccountManager.getInstance().setStatus(StatusMode.unavailable, null);
Application.getInstance().requestToClear();
Application.getInstance().requestToClose();
ProgressDialog progressDialog = new ProgressDialog(getContext());
progressDialog.setMessage(getContext().getString(R.string.application_state_closing));
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.show();
}
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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.
*
* 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 com.xabber.android.ui.preferences;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
public class ChatEditor extends ManagedActivity
implements ChatEditorFragment.ChatEditorFragmentInteractionListener {
private String account;
private String user;
private AccountItem accountItem;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
account = getAccount(getIntent());
user = getUser(getIntent());
accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null || user == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish();
return;
}
setContentView(R.layout.activity_preferences);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new ChatEditorFragment()).commit();
}
}
public static Intent createIntent(Context context, String account,
String user) {
return new EntityIntentBuilder(context, ChatEditor.class)
.setAccount(account).setUser(user).build();
}
private static String getAccount(Intent intent) {
return EntityIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
@Override
public String getAccount() {
return account;
}
@Override
public AccountItem getAccountItem() {
return accountItem;
}
@Override
public String getUser() {
return user;
}
}
package com.xabber.android.ui.preferences;
import android.app.Activity;
import android.os.Bundle;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.ArchiveMode;
import com.xabber.android.data.message.chat.ChatManager;
import com.xabber.androiddev.R;
import java.util.HashMap;
import java.util.Map;
public class ChatEditorFragment extends BaseSettingsFragment {
private ChatEditorFragmentInteractionListener mListener;
@Override
protected void onInflate(Bundle savedInstanceState) {
addPreferencesFromResource(R.xml.chat_editor);
AccountItem accountItem = mListener.getAccountItem();
if (accountItem.getArchiveMode() == ArchiveMode.server
|| accountItem.getArchiveMode() == ArchiveMode.dontStore) {
getPreferenceScreen().removePreference(getPreferenceScreen()
.findPreference(getString(R.string.chat_save_history_key)));
}
}
@Override
public void onPause() {
super.onPause();
saveChanges();
}
@Override
protected Map<String, Object> getValues() {
Map<String, Object> map = new HashMap<>();
String account = mListener.getAccount();
String user = mListener.getUser();
putValue(map, R.string.chat_save_history_key, ChatManager.getInstance()
.isSaveMessages(account, user));
putValue(map, R.string.chat_events_visible_chat_key, ChatManager
.getInstance().isNotifyVisible(account, user));
putValue(map, R.string.chat_events_show_text_key, ChatManager
.getInstance().isShowText(account, user));
putValue(map, R.string.chat_events_vibro_key, ChatManager.getInstance()
.isMakeVibro(account, user));
putValue(map, R.string.chat_events_sound_key, ChatManager.getInstance()
.getSound(account, user));
return map;
}
@Override
protected boolean setValues(Map<String, Object> source, Map<String, Object> result) {
String account = mListener.getAccount();
String user = mListener.getUser();
if (hasChanges(source, result, R.string.chat_save_history_key))
ChatManager.getInstance().setSaveMessages(account, user,
getBoolean(result, R.string.chat_save_history_key));
if (hasChanges(source, result, R.string.chat_events_visible_chat_key))
ChatManager.getInstance().setNotifyVisible(account, user,
getBoolean(result, R.string.chat_events_visible_chat_key));
if (hasChanges(source, result, R.string.chat_events_show_text_key))
ChatManager.getInstance().setShowText(account, user,
getBoolean(result, R.string.chat_events_show_text_key));
if (hasChanges(source, result, R.string.chat_events_vibro_key))
ChatManager.getInstance().setMakeVibro(account, user,
getBoolean(result, R.string.chat_events_vibro_key));
if (hasChanges(source, result, R.string.chat_events_sound_key))
ChatManager.getInstance().setSound(account, user,
getUri(result, R.string.chat_events_sound_key));
return true;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (ChatEditorFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement ChatEditorFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface ChatEditorFragmentInteractionListener {
public String getAccount();
public AccountItem getAccountItem();
public String getUser();
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class ChatSettings extends ManagedActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
setContentView(R.layout.activity_preferences);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.chat_viewer)));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new ChatSettingsFragment()).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 ChatSettingsFragment extends android.preference.PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_chat);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class ConnectionSettings extends ManagedActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
setContentView(R.layout.activity_preferences);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_connection)));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new ConnectionSettingsFragment()).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 ConnectionSettingsFragment extends android.preference.PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_connection);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class ContactListSettings extends ManagedActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
setContentView(R.layout.activity_preferences);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_contacts)));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new ContactListSettingsFragment()).commit();
}
}
}
package com.xabber.android.ui.preferences;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class ContactListSettingsFragment extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences_contact_list);
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.contacts_show_accounts_key))
|| key.equals(getString(R.string.contacts_show_groups_key))) {
changeGrouping();
}
}
private void changeGrouping() {
boolean grouped = SettingsManager.contactsShowAccounts()
|| SettingsManager.contactsShowGroups();
((CheckBoxPreference) getPreferenceScreen().findPreference(
getString(R.string.contacts_stay_active_chats_key)))
.setChecked(grouped);
getPreferenceScreen().findPreference(getString(R.string.contacts_show_empty_groups_key))
.setEnabled(grouped);
}
}
package com.xabber.android.ui.preferences;
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import com.xabber.android.data.roster.GroupManager;
public class ContactResetOfflineSettingsDialog extends DialogPreference {
public ContactResetOfflineSettingsDialog(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
GroupManager.getInstance().resetShowOfflineModes();
}
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import com.xabber.android.data.extension.capability.CapabilitiesManager;
import com.xabber.android.data.extension.capability.ClientInfo;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ResourceItem;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.android.ui.widget.StatusPreference;
import com.xabber.androiddev.R;
import com.xabber.xmpp.vcard.Address;
import com.xabber.xmpp.vcard.AddressProperty;
import com.xabber.xmpp.vcard.AddressType;
import com.xabber.xmpp.vcard.Email;
import com.xabber.xmpp.vcard.EmailType;
import com.xabber.xmpp.vcard.NameProperty;
import com.xabber.xmpp.vcard.Organization;
import com.xabber.xmpp.vcard.Telephone;
import com.xabber.xmpp.vcard.TelephoneType;
import com.xabber.xmpp.vcard.VCard;
import com.xabber.xmpp.vcard.VCardProperty;
import java.util.ArrayList;
import java.util.List;
public class ContactViewerFragment extends android.preference.PreferenceFragment {
private List<PreferenceCategory> addresses;
private List<PreferenceCategory> telephones;
private List<PreferenceCategory> emails;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addresses = new ArrayList<>();
telephones = new ArrayList<>();
emails = new ArrayList<>();
addPreferencesFromResource(R.xml.contact_viewer);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
/**
* Sets value for the preference by its id.
*
* @param resourceId
* @param value
*/
private void setValue(int resourceId, String value) {
if (value == null)
value = "";
findPreference(getString(resourceId)).setSummary(value);
}
/**
* @param source
* @param value
* @param splitter
* @return Concatenated source and value with splitter if necessary.
*/
private String addString(String source, String value, String splitter) {
if (value == null || "".equals(value))
return source;
if (source == null || "".equals(source))
return value;
return source + splitter + value;
}
public void updateContact(String account, String bareAddress) {
setValue(R.string.contact_viewer_jid, bareAddress);
RosterContact rosterContact = RosterManager.getInstance()
.getRosterContact(account, bareAddress);
setValue(R.string.contact_viewer_name, rosterContact == null ? null
: rosterContact.getRealName());
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(getString(R.string.contact_viewer_resources));
preferenceCategory.removeAll();
if (rosterContact != null && rosterContact.isConnected())
for (ResourceItem resourceItem : PresenceManager.getInstance()
.getResourceItems(account, bareAddress)) {
StatusPreference preference = new StatusPreference(getActivity());
preference.setLayoutResource(R.layout.info_preference);
preference.setStatusMode(resourceItem.getStatusMode());
String user = resourceItem.getUser(bareAddress);
ClientInfo clientInfo = CapabilitiesManager.getInstance()
.getClientInfo(account, user);
String client;
if (clientInfo == null) {
CapabilitiesManager.getInstance().request(account, user);
client = getString(R.string.please_wait);
} else if (clientInfo == CapabilitiesManager.INVALID_CLIENT_INFO) {
client = getString(R.string.unknown);
} else {
String name = clientInfo.getName();
if (name == null)
name = getString(R.string.unknown);
String type = clientInfo.getType();
if (type == null)
type = getString(R.string.unknown);
client = getString(R.string.contact_viewer_client_info,
name, type);
}
preference.setTitle(getString(
R.string.contact_viewer_resource_summary,
resourceItem.getVerbose(), resourceItem.getPriority(),
client));
preference.setSummary(resourceItem.getStatusText());
preferenceCategory.addPreference(preference);
}
}
public void updateVCard(VCard vCard) {
if (vCard == null)
return;
setValue(R.string.vcard_nick_name,
vCard.getField(VCardProperty.NICKNAME));
setValue(R.string.vcard_formatted_name, vCard.getFormattedName());
setValue(R.string.vcard_prefix_name,
vCard.getField(NameProperty.PREFIX));
setValue(R.string.vcard_given_name, vCard.getField(NameProperty.GIVEN));
setValue(R.string.vcard_middle_name,
vCard.getField(NameProperty.MIDDLE));
setValue(R.string.vcard_family_name,
vCard.getField(NameProperty.FAMILY));
setValue(R.string.vcard_suffix_name,
vCard.getField(NameProperty.SUFFIX));
setValue(R.string.vcard_birth_date, vCard.getField(VCardProperty.BDAY));
setValue(R.string.vcard_title, vCard.getField(VCardProperty.TITLE));
setValue(R.string.vcard_role, vCard.getField(VCardProperty.ROLE));
List<Organization> organizations = vCard.getOrganizations();
String organization;
if (organizations.isEmpty())
organization = null;
else {
organization = organizations.get(0).getName();
for (String unit : organizations.get(0).getUnits())
organization = addString(organization, unit, "\n");
}
setValue(R.string.vcard_organization, organization);
setValue(R.string.vcard_url, vCard.getField(VCardProperty.URL));
String categories = null;
for (String category : vCard.getCategories())
categories = addString(categories, category, "\n");
setValue(R.string.vcard_categories, categories);
setValue(R.string.vcard_note, vCard.getField(VCardProperty.NOTE));
setValue(R.string.vcard_decsription, vCard.getField(VCardProperty.DESC));
PreferenceScreen screen = getPreferenceScreen();
for (PreferenceCategory category : addresses)
screen.removePreference(category);
for (PreferenceCategory category : telephones)
screen.removePreference(category);
for (PreferenceCategory category : emails)
screen.removePreference(category);
for (Address address : vCard.getAddresses()) {
String types = null;
for (AddressType type : address.getTypes())
types = addString(types, getString(ContactViewer.getAddressTypeMap().get(type)),
", ");
String value = null;
for (AddressProperty property : AddressProperty.values())
value = addString(value, address.getProperties().get(property),
"\n");
PreferenceScreen addressScreen = createTypedCategory(
R.string.vcard_address, types, value);
for (AddressProperty property : AddressProperty.values())
addPreferenceScreen(addressScreen,
ContactViewer.getAddressPropertyMap().get(property), address
.getProperties().get(property));
}
for (Telephone telephone : vCard.getTelephones()) {
String types = null;
for (TelephoneType type : telephone.getTypes())
types = addString(types,
getString(ContactViewer.getTelephoneTypeMap().get(type)), ", ");
createTypedCategory(R.string.vcard_telephone, types,
telephone.getValue());
}
for (Email email : vCard.getEmails()) {
String types = null;
for (EmailType type : email.getTypes())
types = addString(types, getString(ContactViewer.getEmailTypeMap().get(type)),
", ");
createTypedCategory(R.string.vcard_email, types, email.getValue());
}
}
private PreferenceScreen createTypedCategory(int title, String types,
String value) {
PreferenceCategory preferenceCategory = new PreferenceCategory(getActivity());
preferenceCategory.setTitle(title);
getPreferenceScreen().addPreference(preferenceCategory);
addPreferenceScreen(preferenceCategory, R.string.vcard_type, types);
return addPreferenceScreen(preferenceCategory, title, value);
}
private PreferenceScreen addPreferenceScreen(PreferenceGroup container,
int title, String summary) {
PreferenceScreen preference = getPreferenceManager().createPreferenceScreen(getActivity());
preference.setLayoutResource(R.layout.info_preference);
preference.setTitle(title);
preference.setSummary(summary == null ? "" : summary);
container.addPreference(preference);
return preference;
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class DebugSettings extends ManagedActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
setContentView(R.layout.activity_preferences);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_debug)));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new DebugSettingsFragment()).commit();
}
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.data.LogManager;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class DebugSettingsFragment extends android.preference.PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_debug);
getPreferenceScreen().findPreference(getString(R.string.debug_log_key)).setEnabled(LogManager.isDebugable());
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class NotificationsSettings extends ManagedActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
setContentView(R.layout.activity_preferences);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_events)));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new NotificationsSettingsFragment()).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 NotificationsSettingsFragment extends android.preference.PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_notifications);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
}
package com.xabber.android.ui.preferences;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.xabber.android.data.intent.SegmentIntentBuilder;
import com.xabber.androiddev.R;
public class PhraseAdder extends BasePhrasePreferences {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.phrase_add);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.save, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_save:
boolean success = ((PhraseEditorFragment) getFragmentManager()
.findFragmentById(R.id.preferences_activity_container)).saveChanges();
if (success) {
finish();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public static Intent createIntent(Context context) {
return new SegmentIntentBuilder<>(context, PhraseAdder.class).build();
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber 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.
*
* 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 com.xabber.android.ui.preferences;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.xabber.android.data.Application;
import com.xabber.android.data.intent.SegmentIntentBuilder;
import com.xabber.android.data.message.phrase.Phrase;
import com.xabber.android.data.message.phrase.PhraseManager;
import com.xabber.androiddev.R;
public class PhraseEditor extends BasePhrasePreferences {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Integer index = getPhraseIndex(getIntent());
if (index == null) {
finish();
return;
}
Phrase phrase = PhraseManager.getInstance().getPhrase(index);
if (phrase == null) {
finish();
return;
}
setPhrase(phrase);
String title = phrase.getText();
if ("".equals(title))
title = Application.getInstance().getString(
R.string.phrase_empty);
setTitle(title);
}
@Override
protected void onPause() {
super.onPause();
((PhraseEditorFragment) getFragmentManager()
.findFragmentById(R.id.preferences_activity_container)).saveChanges();
}
private Integer getPhraseIndex(Intent intent) {
String value = SegmentIntentBuilder.getSegment(intent, 0);
if (value == null)
return null;
else
return Integer.valueOf(value);
}
public static Intent createIntent(Context context, Integer phraseIndex) {
SegmentIntentBuilder<?> builder = new SegmentIntentBuilder<>(
context, PhraseEditor.class);
if (phraseIndex != null)
builder.addSegment(phraseIndex.toString());
return builder.build();
}
}
package com.xabber.android.ui.preferences;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.widget.Toast;
import com.xabber.android.data.message.phrase.Phrase;
import com.xabber.android.data.message.phrase.PhraseManager;
import com.xabber.androiddev.R;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.PatternSyntaxException;
public class PhraseEditorFragment extends BaseSettingsFragment {
private OnPhraseEditorFragmentInteractionListener mListener;
@Override
protected void onInflate(Bundle savedInstanceState) {
addPreferencesFromResource(R.xml.phrase_editor);
}
@Override
protected Map<String, Object> getValues() {
Phrase phrase = mListener.getPhrase();
Map<String, Object> source = new HashMap<>();
putValue(source, R.string.phrase_text_key,
phrase == null ? "" : phrase.getText());
putValue(source, R.string.phrase_user_key,
phrase == null ? "" : phrase.getUser());
putValue(source, R.string.phrase_group_key, phrase == null ? ""
: phrase.getGroup());
putValue(source, R.string.phrase_regexp_key, phrase != null && phrase.isRegexp());
putValue(source, R.string.phrase_sound_key,
phrase == null ? Settings.System.DEFAULT_NOTIFICATION_URI
: phrase.getSound());
return source;
}
@Override
protected boolean setValues(Map<String, Object> source,
Map<String, Object> result) {
String text = getString(result, R.string.phrase_text_key);
String user = getString(result, R.string.phrase_user_key);
String group = getString(result, R.string.phrase_group_key);
boolean regexp = getBoolean(result, R.string.phrase_regexp_key);
Uri sound = getUri(result, R.string.phrase_sound_key);
Log.i("PhraseEditorFragment", "setValues. text: " + text);
if (regexp) {
try {
Phrase.compile(text);
Phrase.compile(user);
Phrase.compile(group);
} catch (PatternSyntaxException e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
return false;
}
}
Phrase phrase = mListener.getPhrase();
if (phrase == null && "".equals(text) && "".equals(user) && "".equals(group)) {
return true;
}
Log.i("PhraseEditorFragment", "updateOrCreatePhrase");
PhraseManager.getInstance().updateOrCreatePhrase(phrase, text, user, group, regexp, sound);
mListener.setPhrase(phrase);
return true;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnPhraseEditorFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnThemeSettingsFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnPhraseEditorFragmentInteractionListener {
public Phrase getPhrase();
public void setPhrase(Phrase phrase);
}
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License, * You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/. * along with this program. If not, see http://www.gnu.org/licenses/.
*/ */
package com.xabber.android.ui; package com.xabber.android.ui.preferences;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -22,25 +22,36 @@ import com.xabber.android.data.Application; ...@@ -22,25 +22,36 @@ import com.xabber.android.data.Application;
import com.xabber.android.data.message.phrase.PhraseManager; import com.xabber.android.data.message.phrase.PhraseManager;
import com.xabber.android.ui.adapter.BaseListEditorAdapter; import com.xabber.android.ui.adapter.BaseListEditorAdapter;
import com.xabber.android.ui.adapter.PhraseListAdapter; import com.xabber.android.ui.adapter.PhraseListAdapter;
import com.xabber.android.ui.helper.BaseListEditor;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
public class PhraseList extends BaseListEditor<Integer> { public class PhraseList extends BaseListEditor<Integer> {
@Override @Override
protected int getAddTextResourceId() { public void onCreate(Bundle savedInstanceState) {
return R.string.phrase_add; super.onCreate(savedInstanceState);
}
@Override getSupportActionBar().setDisplayHomeAsUpEnabled(true);
protected Intent getAddIntent() { }
return PhraseEditor.createIntent(this);
}
@Override @Override
protected Intent getEditIntent(Integer actionWith) { protected int getOptionsMenuId() {
return PhraseEditor.createIntent(this, actionWith); return R.menu.add_phrase;
} }
@Override
protected int getAddActionId() {
return R.id.action_add_phrase;
}
@Override
protected Intent getAddIntent() {
return PhraseAdder.createIntent(this);
}
@Override
protected Intent getEditIntent(Integer actionWith) {
return PhraseEditor.createIntent(this, actionWith);
}
@Override @Override
protected int getRemoveTextResourceId() { protected int getRemoveTextResourceId() {
...@@ -76,7 +87,7 @@ public class PhraseList extends BaseListEditor<Integer> { ...@@ -76,7 +87,7 @@ public class PhraseList extends BaseListEditor<Integer> {
bundle.putInt(key, actionWith); bundle.putInt(key, actionWith);
} }
public static Intent createIntent(Context context) { public static Intent createIntent(Context context) {
return new Intent(context, PhraseList.class); return new Intent(context, PhraseList.class);
} }
......
...@@ -12,71 +12,51 @@ ...@@ -12,71 +12,51 @@
* You should have received a copy of the GNU General Public License, * You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/. * along with this program. If not, see http://www.gnu.org/licenses/.
*/ */
package com.xabber.android.ui.helper; package com.xabber.android.ui.preferences;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity;
import com.xabber.android.data.ActivityManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
/** public class PreferenceEditor extends ManagedActivity
* Base class for all PreferenceActivities. implements PreferencesFragment.OnPreferencesFragmentInteractionListener {
*
* Adds custom activity logic.
*
* @author alexander.ivanov
*
*/
public abstract class ManagedPreferenceActivity extends PreferenceActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
ActivityManager.getInstance().onCreate(this); super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState); if (isFinishing())
} return;
@Override setContentView(R.layout.activity_preferences);
protected void onResume() {
ActivityManager.getInstance().onResume(this);
super.onResume();
}
@Override if (savedInstanceState == null) {
protected void onPause() { getFragmentManager().beginTransaction()
ActivityManager.getInstance().onPause(this); .add(R.id.preferences_activity_container, new PreferencesFragment()).commit();
super.onPause(); }
}
@Override getSupportActionBar().setDisplayHomeAsUpEnabled(true);
protected void onDestroy() {
ActivityManager.getInstance().onDestroy(this);
super.onDestroy();
}
@Override // Force request sound. This will set default value if not specified.
protected void onNewIntent(Intent intent) { SettingsManager.eventsSound();
ActivityManager.getInstance().onNewIntent(this, intent); SettingsManager.chatsAttentionSound();
super.onNewIntent(intent); }
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
ActivityManager.getInstance().onActivityResult(this, requestCode,
resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public void startActivity(Intent intent) {
ActivityManager.getInstance().updateIntent(this, intent);
super.startActivity(intent);
}
@Override
public void startActivityForResult(Intent intent, int requestCode) {
ActivityManager.getInstance().updateIntent(this, intent);
super.startActivityForResult(intent, requestCode);
}
public static Intent createIntent(Context context) {
return new Intent(context, PreferenceEditor.class);
}
@Override
public String getVersionName() {
try {
return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return "";
}
} }
package com.xabber.android.ui.preferences;
import android.app.Activity;
import android.os.Bundle;
import android.preference.Preference;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class PreferencesFragment extends android.preference.PreferenceFragment {
private OnPreferencesFragmentInteractionListener mListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_editor);
Preference about = getPreferenceScreen().findPreference(getString(R.string.preference_about_key));
about.setSummary(getString(R.string.application_name) + "\n" + mListener.getVersionName());
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnPreferencesFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnPreferencesFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnPreferencesFragmentInteractionListener {
String getVersionName();
}
}
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.android.ui.helper.PreferenceSummaryHelper;
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);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_security)));
getSupportActionBar().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());
}
}
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.ui.ContactList;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class ThemeSettings extends ManagedActivity
implements ThemeSettingsFragment.OnThemeSettingsFragmentInteractionListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
setContentView(R.layout.activity_preferences);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_interface)));
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();
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/preferences_activity_container"
>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_add_account"
android:title="@string/account_add"
app:showAsAction="always"
android:icon="@drawable/ic_add_white_24dp"/>
</menu>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_add_phrase"
android:title="@string/phrase_add"
app:showAsAction="always"
android:icon="@drawable/ic_add_white_24dp"/>
</menu>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_save"
android:title="@string/save"
app:showAsAction="always"
/>
</menu>
\ No newline at end of file
...@@ -26,4 +26,6 @@ ...@@ -26,4 +26,6 @@
<string name="required">Обязательно</string> <string name="required">Обязательно</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_security_otr.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_security_otr.png -->
<string name="auto">Автоматически</string> <string name="auto">Автоматически</string>
<string name="save">Сохранить</string>
</resources> </resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber 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.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<resources>
<style name="Theme" parent="@android:style/Theme.DeviceDefault">
<item name="expanderBackground">@drawable/expander_background_dark</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_dark</item>
<item name="titleAccountBackground">@drawable/title_account_background_light</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style>
<style name="Theme.NoTitleBar" parent="@android:style/Theme.DeviceDefault.NoActionBar">
<item name="expanderBackground">@drawable/expander_background_dark</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_dark</item>
<item name="titleAccountBackground">@drawable/title_account_background_light</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style>
<style name="Theme.Dark" parent="@android:style/Theme.DeviceDefault">
<item name="expanderBackground">@drawable/expander_background_dark</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="titleMainBackground">@drawable/title_main_background_dark</item>
<item name="titleAccountBackground">@drawable/title_account_background_dark</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style>
<style name="Theme.Dark.NoTitleBar" parent="@android:style/Theme.DeviceDefault.NoActionBar">
<item name="expanderBackground">@drawable/expander_background_dark</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_dark</item>
<item name="titleAccountBackground">@drawable/title_account_background_dark</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style>
<style name="Theme.Light" parent="@android:style/Theme.DeviceDefault.Light">
<item name="expanderBackground">@drawable/expander_background_light</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimary</item>
<item name="expanderIndicator">@drawable/expander_indicator_light</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_light</item>
<item name="titleAccountBackground">@drawable/title_account_background_light</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_light</item>
</style>
<style name="Theme.Light.NoTitleBar" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<item name="expanderBackground">@drawable/expander_background_light</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimary</item>
<item name="expanderIndicator">@drawable/expander_indicator_light</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_light</item>
<item name="titleAccountBackground">@drawable/title_account_background_light</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_light</item>
</style>
</resources>
\ No newline at end of file
...@@ -13,30 +13,7 @@ ...@@ -13,30 +13,7 @@
along with this program. If not, see http://www.gnu.org/licenses/. along with this program. If not, see http://www.gnu.org/licenses/.
--> -->
<resources> <resources>
<style name="Theme" parent="Theme.AppCompat">
<style name="Theme" parent="@android:style/Theme">
<item name="expanderBackground">@drawable/expander_background_dark</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_dark</item>
<item name="titleAccountBackground">@drawable/title_account_background_light</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style>
<style name="Theme.NoTitleBar" parent="@android:style/Theme.NoTitleBar">
<item name="expanderBackground">@drawable/expander_background_dark</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_dark</item>
<item name="titleAccountBackground">@drawable/title_account_background_light</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style>
<style name="Theme.Dark" parent="@android:style/Theme.Black">
<item name="expanderBackground">@drawable/expander_background_dark</item> <item name="expanderBackground">@drawable/expander_background_dark</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item> <item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item> <item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
...@@ -46,38 +23,4 @@ ...@@ -46,38 +23,4 @@
<item name="titleAccountBackground">@drawable/title_account_background_dark</item> <item name="titleAccountBackground">@drawable/title_account_background_dark</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item> <item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style> </style>
<style name="Theme.Dark.NoTitleBar" parent="@android:style/Theme.Black.NoTitleBar">
<item name="expanderBackground">@drawable/expander_background_dark</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_dark</item>
<item name="titleAccountBackground">@drawable/title_account_background_dark</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style>
<style name="Theme.Light" parent="@android:style/Theme.Light">
<item name="expanderBackground">@drawable/expander_background_light</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimary</item>
<item name="expanderIndicator">@drawable/expander_indicator_light</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_light</item>
<item name="titleAccountBackground">@drawable/title_account_background_light</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_light</item>
</style>
<style name="Theme.Light.NoTitleBar" parent="@android:style/Theme.Light.NoTitleBar">
<item name="expanderBackground">@drawable/expander_background_light</item>
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimary</item>
<item name="expanderIndicator">@drawable/expander_indicator_light</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="titleMainBackground">@drawable/title_main_background_light</item>
<item name="titleAccountBackground">@drawable/title_account_background_light</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_light</item>
</style>
</resources> </resources>
\ No newline at end of file
...@@ -26,4 +26,6 @@ ...@@ -26,4 +26,6 @@
<string name="required">Required</string> <string name="required">Required</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_security_otr.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_security_otr.png -->
<string name="auto">Automatically</string> <string name="auto">Automatically</string>
<string name="save">Save</string>
</resources> </resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:title="@string/chats_show_avatars"
android:key="@string/chats_show_avatars_key"
android:defaultValue="@bool/chats_show_avatars_default"
/>
<CheckBoxPreference
android:title="@string/chats_send_by_enter"
android:key="@string/chats_send_by_enter_key"
android:defaultValue="@bool/chats_send_by_enter_default"
/>
<ListPreference
android:title="@string/chats_show_status_change"
android:summary="@string/chats_show_status_change"
android:key="@string/chats_show_status_change_key"
android:entries="@array/chats_show_status_change_entries"
android:entryValues="@array/chats_show_status_change_entryvalues"
android:defaultValue="@string/chats_show_status_change_default"
/>
<ListPreference
android:title="@string/chats_hide_keyboard"
android:key="@string/chats_hide_keyboard_key"
android:entries="@array/chats_hide_keyboard_entries"
android:entryValues="@array/chats_hide_keyboard_entryvalues"
android:defaultValue="@string/chats_hide_keyboard_default"
/>
<ListPreference
android:title="@string/chats_font_size"
android:key="@string/chats_font_size_key"
android:entries="@array/chats_font_size_entries"
android:entryValues="@array/chats_font_size_entryvalues"
android:defaultValue="@string/chats_font_size_default"
/>
<ListPreference
android:title="@string/chats_divide"
android:key="@string/chats_divide_key"
android:entries="@array/chats_divide_entries"
android:entryValues="@array/chats_divide_entryvalues"
android:defaultValue="@string/chats_divide_default"
/>
<CheckBoxPreference
android:title="@string/chats_state_notification"
android:key="@string/chats_state_notification_key"
android:defaultValue="@bool/chats_state_notification_default"
/>
<CheckBoxPreference
android:title="@string/chats_attention"
android:key="@string/chats_attention_key"
android:defaultValue="@bool/chats_attention_default"
/>
<RingtonePreference
android:title="@string/chats_attention_sound"
android:key="@string/chats_attention_sound_key"
android:defaultValue="@string/chats_attention_sound_default"
android:ringtoneType="ringtone"
android:dependency="@string/chats_attention_key"
android:showSilent="true"
android:showDefault="true"
/>
</PreferenceScreen>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:title="@string/connection_start_at_boot"
android:key="@string/connection_start_at_boot_key"
android:defaultValue="@bool/connection_start_at_boot_default"
/>
<ListPreference
android:title="@string/connection_go_away"
android:key="@string/connection_go_away_key"
android:entries="@array/connection_go_away_entries"
android:entryValues="@array/connection_go_away_entryvalues"
android:defaultValue="@string/connection_go_away_default"
/>
<ListPreference
android:title="@string/connection_go_xa"
android:key="@string/connection_go_xa_key"
android:entries="@array/connection_go_xa_entries"
android:entryValues="@array/connection_go_xa_entryvalues"
android:defaultValue="@string/connection_go_xa_default"
/>
<CheckBoxPreference
android:title="@string/connection_wifi_lock"
android:key="@string/connection_wifi_lock_key"
android:defaultValue="@bool/connection_wifi_lock_default"
/>
<CheckBoxPreference
android:title="@string/connection_wake_lock"
android:key="@string/connection_wake_lock_key"
android:defaultValue="@bool/connection_wake_lock_default"
/>
<CheckBoxPreference
android:title="@string/connection_load_vcard"
android:key="@string/connection_load_vcard_key"
android:defaultValue="@bool/connection_load_vcard_default"
/>
<PreferenceCategory
android:title="@string/connection_priority"
>
<CheckBoxPreference
android:title="@string/connection_adjust_priority"
android:key="@string/connection_adjust_priority_key"
android:defaultValue="@bool/connection_adjust_priority_default"
/>
<com.xabber.android.ui.widget.PriorityPreference
android:key="@string/connection_priority_chat_key"
android:defaultValue="@string/connection_priority_chat_default"
android:dependency="@string/connection_adjust_priority_key"
android:title="@string/chat"
android:singleLine="true"
/>
<com.xabber.android.ui.widget.PriorityPreference
android:key="@string/connection_priority_available_key"
android:defaultValue="@string/connection_priority_available_default"
android:dependency="@string/connection_adjust_priority_key"
android:title="@string/available"
android:singleLine="true"
/>
<com.xabber.android.ui.widget.PriorityPreference
android:key="@string/connection_priority_away_key"
android:defaultValue="@string/connection_priority_away_default"
android:dependency="@string/connection_adjust_priority_key"
android:title="@string/away"
android:singleLine="true"
/>
<com.xabber.android.ui.widget.PriorityPreference
android:key="@string/connection_priority_xa_key"
android:defaultValue="@string/connection_priority_xa_default"
android:dependency="@string/connection_adjust_priority_key"
android:title="@string/xa"
android:singleLine="true"
/>
<com.xabber.android.ui.widget.PriorityPreference
android:key="@string/connection_priority_dnd_key"
android:defaultValue="@string/connection_priority_dnd_default"
android:dependency="@string/connection_adjust_priority_key"
android:title="@string/dnd"
android:singleLine="true"
/>
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:title="@string/debug_log"
android:key="@string/debug_log_key"
android:defaultValue="@bool/debug_log_default"
/>
<com.xabber.android.ui.preferences.CacheClearDialog
android:title="@string/cache_clear"
android:key="@string/cache_clear_key"
android:dialogMessage="@string/cache_clear_warning"/>
</PreferenceScreen>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?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
This diff is collapsed.
This diff is collapsed.
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