前言
这里是遇到了MANAGE STORAGE的按钮使用遥控器移动的时候无法聚焦到这个按钮,自然也就无法点击。它只能聚焦到这一整个整体,因此我就设置当点击到这一整个整体时,就相应MANAGE STORAGE按钮的点击事件。
图片
代码
packages/apps/Settings/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
@@ -62,7 +62,13 @@ public class StorageSummaryDonutPreference extends Preference implements View.On
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
- view.itemView.setClickable(false);
+ view.itemView.setClickable(true);
+ view.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onDeleteHelperButtonClick(v);
+ }
+ });
final DonutView donut = (DonutView) view.findViewById(R.id.donut);
if (donut != null) {
@@ -78,14 +84,18 @@ public class StorageSummaryDonutPreference extends Preference implements View.On
@Override
public void onClick(View v) {
if (v != null && R.id.deletion_helper_button == v.getId()) {
- final Context context = getContext();
- final MetricsFeatureProvider metricsFeatureProvider =
- FeatureFactory.getFactory(context).getMetricsFeatureProvider();
- metricsFeatureProvider.logClickedPreference(this,
- getExtras().getInt(DashboardFragment.CATEGORY));
- metricsFeatureProvider.action(context, SettingsEnums.STORAGE_FREE_UP_SPACE_NOW);
- final Intent intent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
- context.startActivity(intent);
+ onDeleteHelperButtonClick(v);
}
}
+
+ private void onDeleteHelperButtonClick(View v) {
+ final Context context = getContext();
+ final MetricsFeatureProvider metricsFeatureProvider =
+ FeatureFactory.getFactory(context).getMetricsFeatureProvider();
+ metricsFeatureProvider.logClickedPreference(this,
+ getExtras().getInt(DashboardFragment.CATEGORY));
+ metricsFeatureProvider.action(context, SettingsEnums.STORAGE_FREE_UP_SPACE_NOW);
+ final Intent intent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
+ context.startActivity(intent);
+ }
}