From 611905a5d06e4164ea9d73cc01dc8748c1c08ce9 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 25 Nov 2014 17:42:41 +0100 Subject: [PATCH] - Account list is now a radiobutton list --- res/layout/preference_widget_radiobutton.xml | 21 +++++++++++++++++++ .../ui/LongClickableCheckBoxPreference.java | 17 --------------- .../android/ui/RadioButtonPreference.java | 20 ++++++++++++++++++ .../android/ui/activity/Preferences.java | 10 ++++----- 4 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 res/layout/preference_widget_radiobutton.xml delete mode 100644 src/com/owncloud/android/ui/LongClickableCheckBoxPreference.java create mode 100644 src/com/owncloud/android/ui/RadioButtonPreference.java diff --git a/res/layout/preference_widget_radiobutton.xml b/res/layout/preference_widget_radiobutton.xml new file mode 100644 index 0000000000..85f8f60038 --- /dev/null +++ b/res/layout/preference_widget_radiobutton.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/src/com/owncloud/android/ui/LongClickableCheckBoxPreference.java b/src/com/owncloud/android/ui/LongClickableCheckBoxPreference.java deleted file mode 100644 index 5befe64ad2..0000000000 --- a/src/com/owncloud/android/ui/LongClickableCheckBoxPreference.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.owncloud.android.ui; - -import android.content.Context; -import android.preference.CheckBoxPreference; -import android.view.View; - -public class LongClickableCheckBoxPreference extends CheckBoxPreference implements View.OnLongClickListener { - - public LongClickableCheckBoxPreference(Context context) { - super(context); - } - - @Override - public boolean onLongClick(View v) { - return true; - } -} diff --git a/src/com/owncloud/android/ui/RadioButtonPreference.java b/src/com/owncloud/android/ui/RadioButtonPreference.java new file mode 100644 index 0000000000..8f562b36c3 --- /dev/null +++ b/src/com/owncloud/android/ui/RadioButtonPreference.java @@ -0,0 +1,20 @@ +package com.owncloud.android.ui; + +import android.content.Context; +import android.preference.CheckBoxPreference; +import android.view.View; + +import com.owncloud.android.R; + +public class RadioButtonPreference extends CheckBoxPreference implements View.OnLongClickListener { + + public RadioButtonPreference(Context context) { + super(context, null, android.R.attr.checkBoxPreferenceStyle); + setWidgetLayoutResource(R.layout.preference_widget_radiobutton); + } + + @Override + public boolean onLongClick(View v) { + return true; + } +} diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index 20330931b4..00544e8efc 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -52,7 +52,7 @@ import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.db.DbHandler; import com.owncloud.android.lib.common.utils.Log_OC; -import com.owncloud.android.ui.LongClickableCheckBoxPreference; +import com.owncloud.android.ui.RadioButtonPreference; import com.owncloud.android.utils.DisplayUtils; @@ -102,9 +102,9 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa ListAdapter listAdapter = listView.getAdapter(); Object obj = listAdapter.getItem(position); - if (obj != null && obj instanceof LongClickableCheckBoxPreference) { + if (obj != null && obj instanceof RadioButtonPreference) { mShowContextMenu = true; - mAccountName = ((LongClickableCheckBoxPreference) obj).getKey(); + mAccountName = ((RadioButtonPreference) obj).getKey(); Preferences.this.openContextMenu(listView); @@ -404,7 +404,7 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa else { for (Account a : accounts) { - LongClickableCheckBoxPreference accountPreference = new LongClickableCheckBoxPreference(this); + RadioButtonPreference accountPreference = new RadioButtonPreference(this); accountPreference.setKey(a.name); // Handle internationalized domain names accountPreference.setTitle(DisplayUtils.convertIdn(a.name, false)); @@ -424,7 +424,7 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE); Account accounts[] = am.getAccountsByType(MainApp.getAccountType()); for (Account a : accounts) { - CheckBoxPreference p = (CheckBoxPreference) findPreference(a.name); + RadioButtonPreference p = (RadioButtonPreference) findPreference(a.name); if (key.equals(a.name)) { boolean accountChanged = !p.isChecked(); p.setChecked(true);