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 f794cf15c6..04a4c7aff7 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -53,7 +53,7 @@ import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.datamodel.OCFile; 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; @@ -107,9 +107,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); @@ -463,7 +463,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)); @@ -483,7 +483,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);