Merge "Migrate to CompoundButton" into main
This commit is contained in:
@@ -52,13 +52,13 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.BaseExpandableListAdapter;
|
import android.widget.BaseExpandableListAdapter;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ExpandableListView;
|
import android.widget.ExpandableListView;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -456,10 +456,10 @@ public class TrustedCredentialsFragment extends ObservableFragment
|
|||||||
return "Group" + getUserIdByGroup(groupPosition);
|
return "Group" + getUserIdByGroup(groupPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ViewHolder {
|
private static class ViewHolder {
|
||||||
private TextView mSubjectPrimaryView;
|
private TextView mSubjectPrimaryView;
|
||||||
private TextView mSubjectSecondaryView;
|
private TextView mSubjectSecondaryView;
|
||||||
private Switch mSwitch;
|
private CompoundButton mSwitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,8 +21,8 @@ import android.util.AttributeSet;
|
|||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Switch;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
@@ -88,7 +88,7 @@ public class ShortcutPreference extends Preference {
|
|||||||
mSettingsEditable ? outValue.resourceId : /* Remove background */ 0);
|
mSettingsEditable ? outValue.resourceId : /* Remove background */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Switch switchWidget =
|
CompoundButton switchWidget =
|
||||||
holder.itemView.findViewById(com.android.settingslib.R.id.switchWidget);
|
holder.itemView.findViewById(com.android.settingslib.R.id.switchWidget);
|
||||||
if (switchWidget != null) {
|
if (switchWidget != null) {
|
||||||
// Consumes move events to ignore drag actions.
|
// Consumes move events to ignore drag actions.
|
||||||
|
@@ -29,9 +29,9 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.fragment.app.ListFragment;
|
import androidx.fragment.app.ListFragment;
|
||||||
@@ -244,14 +244,12 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
public static class AppListAdapter extends BaseAdapter {
|
public static class AppListAdapter extends BaseAdapter {
|
||||||
private final Resources mResources;
|
private final Resources mResources;
|
||||||
private final LayoutInflater mInflater;
|
private final LayoutInflater mInflater;
|
||||||
private final AppOpsState mState;
|
|
||||||
|
|
||||||
List<AppOpEntry> mList;
|
List<AppOpEntry> mList;
|
||||||
|
|
||||||
public AppListAdapter(Context context, AppOpsState state) {
|
public AppListAdapter(Context context) {
|
||||||
mResources = context.getResources();
|
mResources = context.getResources();
|
||||||
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mState = state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(List<AppOpEntry> data) {
|
public void setData(List<AppOpEntry> data) {
|
||||||
@@ -294,7 +292,7 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
((TextView) view.findViewById(R.id.op_name)).setText(
|
((TextView) view.findViewById(R.id.op_name)).setText(
|
||||||
item.getTimeText(mResources, false));
|
item.getTimeText(mResources, false));
|
||||||
view.findViewById(R.id.op_time).setVisibility(View.GONE);
|
view.findViewById(R.id.op_time).setVisibility(View.GONE);
|
||||||
((Switch) view.findViewById(R.id.op_switch)).setChecked(
|
((CompoundButton) view.findViewById(R.id.op_switch)).setChecked(
|
||||||
item.getPrimaryOpMode() == AppOpsManager.MODE_ALLOWED);
|
item.getPrimaryOpMode() == AppOpsManager.MODE_ALLOWED);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
@@ -318,7 +316,7 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
// Create an empty adapter we will use to display the loaded data.
|
// Create an empty adapter we will use to display the loaded data.
|
||||||
mAdapter = new AppListAdapter(getActivity(), mState);
|
mAdapter = new AppListAdapter(getActivity());
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
|
|
||||||
// Start out with a progress indicator.
|
// Start out with a progress indicator.
|
||||||
@@ -332,7 +330,7 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
AppOpEntry entry = mAdapter.getItem(position);
|
AppOpEntry entry = mAdapter.getItem(position);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
// We treat this as tapping on the check box, toggling the app op state.
|
// We treat this as tapping on the check box, toggling the app op state.
|
||||||
Switch sw = v.findViewById(R.id.op_switch);
|
CompoundButton sw = v.findViewById(R.id.op_switch);
|
||||||
boolean checked = !sw.isChecked();
|
boolean checked = !sw.isChecked();
|
||||||
sw.setChecked(checked);
|
sw.setChecked(checked);
|
||||||
AppOpsManager.OpEntry op = entry.getOpEntry(0);
|
AppOpsManager.OpEntry op = entry.getOpEntry(0);
|
||||||
|
@@ -47,7 +47,7 @@ import android.service.autofill.AutofillServiceInfo;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Switch;
|
import android.widget.CompoundButton;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
@@ -969,7 +969,7 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stores a reference to the switch view.
|
// Stores a reference to the switch view.
|
||||||
private @Nullable Switch mSwitch;
|
private @Nullable CompoundButton mSwitch;
|
||||||
|
|
||||||
// Switch text for on and off states
|
// Switch text for on and off states
|
||||||
private @NonNull boolean mChecked = false;
|
private @NonNull boolean mChecked = false;
|
||||||
@@ -1022,7 +1022,7 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl
|
|||||||
// Setup the switch.
|
// Setup the switch.
|
||||||
View checkableView =
|
View checkableView =
|
||||||
view.itemView.findViewById(com.android.settingslib.R.id.switchWidget);
|
view.itemView.findViewById(com.android.settingslib.R.id.switchWidget);
|
||||||
if (checkableView instanceof Switch switchView) {
|
if (checkableView instanceof CompoundButton switchView) {
|
||||||
switchView.setChecked(mChecked);
|
switchView.setChecked(mChecked);
|
||||||
switchView.setOnClickListener(mListener);
|
switchView.setOnClickListener(mListener);
|
||||||
|
|
||||||
|
@@ -31,9 +31,9 @@ import android.util.Log;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
@@ -67,7 +67,7 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final ViewGroup mWidgetContainer;
|
final ViewGroup mWidgetContainer;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final Switch mSwitch;
|
final CompoundButton mSwitch;
|
||||||
final ImageView mAddIcon;
|
final ImageView mAddIcon;
|
||||||
final ProgressBar mProgressBar;
|
final ProgressBar mProgressBar;
|
||||||
|
|
||||||
@@ -173,10 +173,6 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
|||||||
mAppName.setContentDescription(contentDescription);
|
mAppName.setContentDescription(contentDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIcon(int drawableRes) {
|
|
||||||
mAppIcon.setImageResource(drawableRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIcon(Drawable icon) {
|
void setIcon(Drawable icon) {
|
||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
return;
|
return;
|
||||||
@@ -219,7 +215,8 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSwitch(Switch.OnCheckedChangeListener listener, boolean enabled, boolean checked) {
|
void updateSwitch(CompoundButton.OnCheckedChangeListener listener, boolean enabled,
|
||||||
|
boolean checked) {
|
||||||
if (mSwitch != null && mWidgetContainer != null) {
|
if (mSwitch != null && mWidgetContainer != null) {
|
||||||
mWidgetContainer.setFocusable(false);
|
mWidgetContainer.setFocusable(false);
|
||||||
mWidgetContainer.setClickable(false);
|
mWidgetContainer.setClickable(false);
|
||||||
|
@@ -22,7 +22,6 @@ import android.util.AttributeSet;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -32,7 +31,7 @@ import com.android.settings.R;
|
|||||||
*/
|
*/
|
||||||
public class FaceEnrollAccessibilityToggle extends LinearLayout {
|
public class FaceEnrollAccessibilityToggle extends LinearLayout {
|
||||||
|
|
||||||
private Switch mSwitch;
|
private final CompoundButton mSwitch;
|
||||||
|
|
||||||
public FaceEnrollAccessibilityToggle(Context context) {
|
public FaceEnrollAccessibilityToggle(Context context) {
|
||||||
this(context, null /* attrs */);
|
this(context, null /* attrs */);
|
||||||
@@ -76,7 +75,7 @@ public class FaceEnrollAccessibilityToggle extends LinearLayout {
|
|||||||
mSwitch.setOnCheckedChangeListener(listener);
|
mSwitch.setOnCheckedChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Switch getSwitch() {
|
public CompoundButton getSwitch() {
|
||||||
return mSwitch;
|
return mSwitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,8 +32,8 @@ import android.view.View;
|
|||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -342,8 +342,8 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
|
|||||||
TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption);
|
TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption);
|
||||||
TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead);
|
TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead);
|
||||||
TextView messagePairing = (TextView) view.findViewById(R.id.pairing_code_message);
|
TextView messagePairing = (TextView) view.findViewById(R.id.pairing_code_message);
|
||||||
Switch contactSharing = (Switch) view.findViewById(
|
CompoundButton contactSharing =
|
||||||
R.id.phonebook_sharing_message_confirm_pin);
|
view.findViewById(R.id.phonebook_sharing_message_confirm_pin);
|
||||||
view.findViewById(R.id.phonebook_sharing).setVisibility(
|
view.findViewById(R.id.phonebook_sharing).setVisibility(
|
||||||
mPairingController.isContactSharingVisible() ? View.VISIBLE : View.GONE);
|
mPairingController.isContactSharingVisible() ? View.VISIBLE : View.GONE);
|
||||||
mPairingController.setContactSharingState();
|
mPairingController.setContactSharingState();
|
||||||
|
@@ -35,7 +35,6 @@ import android.view.View;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ import com.android.settings.R;
|
|||||||
public class TareHomePage extends Activity {
|
public class TareHomePage extends Activity {
|
||||||
private static final String TAG = "TareHomePage";
|
private static final String TAG = "TareHomePage";
|
||||||
|
|
||||||
private Switch mOnSwitch;
|
private CompoundButton mOnSwitch;
|
||||||
private Button mRevButton;
|
private Button mRevButton;
|
||||||
private TextView mAlarmManagerView;
|
private TextView mAlarmManagerView;
|
||||||
private TextView mJobSchedulerView;
|
private TextView mJobSchedulerView;
|
||||||
|
@@ -45,7 +45,6 @@ import android.view.View.OnClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.Switch;
|
|
||||||
|
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.MultiSelectListPreference;
|
import androidx.preference.MultiSelectListPreference;
|
||||||
@@ -175,10 +174,6 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
|||||||
panelOpen = open;
|
panelOpen = open;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Preference> getChildren() {
|
|
||||||
return mChildren;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||||
super.onBindViewHolder(view);
|
super.onBindViewHolder(view);
|
||||||
@@ -197,7 +192,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
|||||||
ViewGroup widget = (ViewGroup) view.findViewById(android.R.id.widget_frame);
|
ViewGroup widget = (ViewGroup) view.findViewById(android.R.id.widget_frame);
|
||||||
widget.setEnabled(!isImmutable());
|
widget.setEnabled(!isImmutable());
|
||||||
if (widget.getChildCount() > 0) {
|
if (widget.getChildCount() > 0) {
|
||||||
final Switch toggle = (Switch) widget.getChildAt(0);
|
final CompoundButton toggle = (CompoundButton) widget.getChildAt(0);
|
||||||
toggle.setEnabled(!isImmutable());
|
toggle.setEnabled(!isImmutable());
|
||||||
toggle.setTag(this);
|
toggle.setTag(this);
|
||||||
toggle.setClickable(true);
|
toggle.setClickable(true);
|
||||||
|
Reference in New Issue
Block a user