mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 05:07:40 +00:00
Fix Sftp preferences not working
In version 1.1.0 of androidx, preferences do nothing on click if they are not selectable. Added a new property "inSelectionMode" that we can use instead of the built-in "selectable".
This commit is contained in:
parent
caeb59eb3d
commit
d8cbc38532
@ -197,7 +197,7 @@ public class SftpSettingsFragment
|
||||
|
||||
for (int i = 0, count = preferenceCategory.getPreferenceCount(); i < count; i++) {
|
||||
StoragePreference preference = (StoragePreference) preferenceCategory.getPreference(i);
|
||||
preference.setSelectable(true);
|
||||
preference.setInSelectionMode(true);
|
||||
preference.checkbox.setChecked(selectedItems.get(i, false));
|
||||
}
|
||||
}
|
||||
@ -443,7 +443,7 @@ public class SftpSettingsFragment
|
||||
if (actionMode != null) {
|
||||
for (int i = 0, count = preferenceCategory.getPreferenceCount(); i < count; i++) {
|
||||
StoragePreference preference = (StoragePreference) preferenceCategory.getPreference(i);
|
||||
preference.setSelectable(true);
|
||||
preference.setInSelectionMode(true);
|
||||
if (storagePreference.equals(preference)) {
|
||||
preference.checkbox.setChecked(true);
|
||||
}
|
||||
@ -499,7 +499,7 @@ public class SftpSettingsFragment
|
||||
|
||||
for (int i = 0, count = preferenceCategory.getPreferenceCount(); i < count; i++) {
|
||||
StoragePreference preference = (StoragePreference) preferenceCategory.getPreference(i);
|
||||
preference.setSelectable(false);
|
||||
preference.setInSelectionMode(false);
|
||||
preference.checkbox.setChecked(false);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,14 @@ public class StoragePreference extends DialogPreference {
|
||||
private OnLongClickListener onLongClickListener;
|
||||
|
||||
@BindView(R.id.checkbox) CheckBox checkbox;
|
||||
public boolean inSelectionMode;
|
||||
|
||||
public void setInSelectionMode(boolean inSelectionMode) {
|
||||
if (this.inSelectionMode != inSelectionMode) {
|
||||
this.inSelectionMode = inSelectionMode;
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public StoragePreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -50,7 +58,7 @@ public class StoragePreference extends DialogPreference {
|
||||
setDialogLayoutResource(R.layout.fragment_storage_preference_dialog);
|
||||
setWidgetLayoutResource(R.layout.preference_checkbox);
|
||||
setPersistent(false);
|
||||
setSelectable(false);
|
||||
inSelectionMode = false;
|
||||
}
|
||||
|
||||
public StoragePreference(Context context) {
|
||||
@ -109,7 +117,7 @@ public class StoragePreference extends DialogPreference {
|
||||
|
||||
ButterKnife.bind(this, holder.itemView);
|
||||
|
||||
checkbox.setVisibility(isSelectable() ? View.VISIBLE : View.INVISIBLE);
|
||||
checkbox.setVisibility(inSelectionMode ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
holder.itemView.setOnLongClickListener(v -> {
|
||||
if (onLongClickListener != null) {
|
||||
@ -122,7 +130,7 @@ public class StoragePreference extends DialogPreference {
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
if (isSelectable()) {
|
||||
if (inSelectionMode) {
|
||||
checkbox.setChecked(!checkbox.isChecked());
|
||||
} else {
|
||||
super.onClick();
|
||||
|
Loading…
x
Reference in New Issue
Block a user