Implement default assist app setting
- Add "None" support to AppListPreference - Add DefaultAssistPreference to manage assist; - Add AppListPreferenceWithSettings to show a settings icon; - Implement DefaultAssistPreference based on AppListPreferenceWithSettings; - Move voice input settings into ManageAssist and implement it based on AppListPreferenceWithSettings; Bug:20210110 Change-Id: If283b8b55a46b428ecfa6e45dc2123292b1d4302
This commit is contained in:
59
src/com/android/settings/AppListPreferenceWithSettings.java
Normal file
59
src/com/android/settings/AppListPreferenceWithSettings.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.android.settings;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* An AppListPreference with optional settings button.
|
||||
*/
|
||||
public class AppListPreferenceWithSettings extends AppListPreference {
|
||||
|
||||
private View mSettingsIcon;
|
||||
private ComponentName mSettingsComponent;
|
||||
|
||||
public AppListPreferenceWithSettings(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setWidgetLayoutResource(R.layout.preference_widget_settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindView(View view) {
|
||||
super.onBindView(view);
|
||||
|
||||
mSettingsIcon = view.findViewById(R.id.settings_button);
|
||||
mSettingsIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.setComponent(mSettingsComponent);
|
||||
getContext().startActivity(new Intent(intent));
|
||||
}
|
||||
});
|
||||
|
||||
ViewGroup container = (ViewGroup) mSettingsIcon.getParent();
|
||||
container.setPaddingRelative(0, 0, 0, 0);
|
||||
|
||||
updateSettingsVisibility();
|
||||
}
|
||||
|
||||
private void updateSettingsVisibility() {
|
||||
if (mSettingsIcon == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mSettingsComponent == null) {
|
||||
mSettingsIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
mSettingsIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setSettingsComponent(ComponentName settings) {
|
||||
mSettingsComponent = settings;
|
||||
updateSettingsVisibility();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user