mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
Merge pull request #754 from owncloud/RadioListOnAccounts
Account list is now a radiobutton list
This commit is contained in:
commit
0df8f178de
4 changed files with 46 additions and 22 deletions
21
res/layout/preference_widget_radiobutton.xml
Normal file
21
res/layout/preference_widget_radiobutton.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2006 The Android Open Source Project
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- Layout used by CheckBoxPreference for the checkbox style. This is inflated
|
||||
inside android.R.layout.preference. -->
|
||||
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+android:id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:focusable="false"
|
||||
android:clickable="false" />
|
|
@ -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;
|
||||
}
|
||||
}
|
20
src/com/owncloud/android/ui/RadioButtonPreference.java
Normal file
20
src/com/owncloud/android/ui/RadioButtonPreference.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue