Loading res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,7 @@ <string name="power_menu_bug_report_devoptions_unavailable">Bug reporting is disabled as development settings aren\'t enabled</string> <string name="power_menu_bug_report_unavailable_for_user">Bug reporting is disabled for non-primary users.</string> <string name="power_menu_emergency_title">Emergency</string> <string name="power_menu_devicecontrols_title">Device controls</string> <string name="power_menu_advanced_restart_title">Advanced restart</string> <string name="power_menu_advanced_restart_summary">When unlocked, include options in the power menu for restarting into recovery or bootloader</string> Loading res/xml/power_menu_settings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,12 @@ android:title="@string/power_menu_emergency_title" android:defaultValue="false" /> <CheckBoxPreference android:key="devicecontrols" android:title="@string/power_menu_devicecontrols_title" android:defaultValue="false" android:enabled="false" /> </PreferenceCategory> <PreferenceCategory Loading src/org/lineageos/lineageparts/input/PowerMenuActions.java +27 −0 Original line number Diff line number Diff line Loading @@ -17,18 +17,21 @@ package org.lineageos.lineageparts.input; import android.Manifest; import android.content.Context; import android.content.pm.UserInfo; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.service.controls.ControlsProviderService; import androidx.preference.CheckBoxPreference; import androidx.preference.Preference; import androidx.preference.PreferenceCategory; import com.android.internal.widget.LockPatternUtils; import com.android.settingslib.applications.ServiceListing; import org.lineageos.internal.util.PowerMenuConstants; import org.lineageos.lineageparts.R; Loading @@ -55,6 +58,7 @@ public class PowerMenuActions extends SettingsPreferenceFragment { private CheckBoxPreference mUsersPref; private CheckBoxPreference mBugReportPref; private CheckBoxPreference mEmergencyPref; private CheckBoxPreference mDeviceControlsPref; private LineageGlobalActions mLineageGlobalActions; Loading Loading @@ -87,6 +91,8 @@ public class PowerMenuActions extends SettingsPreferenceFragment { mBugReportPref = findPreference(GLOBAL_ACTION_KEY_BUGREPORT); } else if (action.equals(GLOBAL_ACTION_KEY_EMERGENCY)) { mEmergencyPref = findPreference(GLOBAL_ACTION_KEY_EMERGENCY); } else if (action.equals(GLOBAL_ACTION_KEY_DEVICECONTROLS)) { mDeviceControlsPref = findPreference(GLOBAL_ACTION_KEY_DEVICECONTROLS); } } Loading Loading @@ -135,6 +141,23 @@ public class PowerMenuActions extends SettingsPreferenceFragment { GLOBAL_ACTION_KEY_EMERGENCY)); } if (mDeviceControlsPref != null) { mDeviceControlsPref.setChecked(mLineageGlobalActions.userConfigContains( GLOBAL_ACTION_KEY_DEVICECONTROLS)); // Enable preference if any device control app is installed ServiceListing serviceListing = new ServiceListing.Builder(mContext) .setIntentAction(ControlsProviderService.SERVICE_CONTROLS) .setPermission(Manifest.permission.BIND_CONTROLS) .setNoun("Controls Provider") .setSetting("controls_providers") .setTag("controls_providers") .build(); serviceListing.addCallback( services -> mDeviceControlsPref.setEnabled(!services.isEmpty())); serviceListing.reload(); } updatePreferences(); } Loading Loading @@ -170,6 +193,10 @@ public class PowerMenuActions extends SettingsPreferenceFragment { value = mEmergencyPref.isChecked(); mLineageGlobalActions.updateUserConfig(value, GLOBAL_ACTION_KEY_EMERGENCY); } else if (preference == mDeviceControlsPref) { value = mDeviceControlsPref.isChecked(); mLineageGlobalActions.updateUserConfig(value, GLOBAL_ACTION_KEY_DEVICECONTROLS); } else { return super.onPreferenceTreeClick(preference); } Loading Loading
res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,7 @@ <string name="power_menu_bug_report_devoptions_unavailable">Bug reporting is disabled as development settings aren\'t enabled</string> <string name="power_menu_bug_report_unavailable_for_user">Bug reporting is disabled for non-primary users.</string> <string name="power_menu_emergency_title">Emergency</string> <string name="power_menu_devicecontrols_title">Device controls</string> <string name="power_menu_advanced_restart_title">Advanced restart</string> <string name="power_menu_advanced_restart_summary">When unlocked, include options in the power menu for restarting into recovery or bootloader</string> Loading
res/xml/power_menu_settings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,12 @@ android:title="@string/power_menu_emergency_title" android:defaultValue="false" /> <CheckBoxPreference android:key="devicecontrols" android:title="@string/power_menu_devicecontrols_title" android:defaultValue="false" android:enabled="false" /> </PreferenceCategory> <PreferenceCategory Loading
src/org/lineageos/lineageparts/input/PowerMenuActions.java +27 −0 Original line number Diff line number Diff line Loading @@ -17,18 +17,21 @@ package org.lineageos.lineageparts.input; import android.Manifest; import android.content.Context; import android.content.pm.UserInfo; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.service.controls.ControlsProviderService; import androidx.preference.CheckBoxPreference; import androidx.preference.Preference; import androidx.preference.PreferenceCategory; import com.android.internal.widget.LockPatternUtils; import com.android.settingslib.applications.ServiceListing; import org.lineageos.internal.util.PowerMenuConstants; import org.lineageos.lineageparts.R; Loading @@ -55,6 +58,7 @@ public class PowerMenuActions extends SettingsPreferenceFragment { private CheckBoxPreference mUsersPref; private CheckBoxPreference mBugReportPref; private CheckBoxPreference mEmergencyPref; private CheckBoxPreference mDeviceControlsPref; private LineageGlobalActions mLineageGlobalActions; Loading Loading @@ -87,6 +91,8 @@ public class PowerMenuActions extends SettingsPreferenceFragment { mBugReportPref = findPreference(GLOBAL_ACTION_KEY_BUGREPORT); } else if (action.equals(GLOBAL_ACTION_KEY_EMERGENCY)) { mEmergencyPref = findPreference(GLOBAL_ACTION_KEY_EMERGENCY); } else if (action.equals(GLOBAL_ACTION_KEY_DEVICECONTROLS)) { mDeviceControlsPref = findPreference(GLOBAL_ACTION_KEY_DEVICECONTROLS); } } Loading Loading @@ -135,6 +141,23 @@ public class PowerMenuActions extends SettingsPreferenceFragment { GLOBAL_ACTION_KEY_EMERGENCY)); } if (mDeviceControlsPref != null) { mDeviceControlsPref.setChecked(mLineageGlobalActions.userConfigContains( GLOBAL_ACTION_KEY_DEVICECONTROLS)); // Enable preference if any device control app is installed ServiceListing serviceListing = new ServiceListing.Builder(mContext) .setIntentAction(ControlsProviderService.SERVICE_CONTROLS) .setPermission(Manifest.permission.BIND_CONTROLS) .setNoun("Controls Provider") .setSetting("controls_providers") .setTag("controls_providers") .build(); serviceListing.addCallback( services -> mDeviceControlsPref.setEnabled(!services.isEmpty())); serviceListing.reload(); } updatePreferences(); } Loading Loading @@ -170,6 +193,10 @@ public class PowerMenuActions extends SettingsPreferenceFragment { value = mEmergencyPref.isChecked(); mLineageGlobalActions.updateUserConfig(value, GLOBAL_ACTION_KEY_EMERGENCY); } else if (preference == mDeviceControlsPref) { value = mDeviceControlsPref.isChecked(); mLineageGlobalActions.updateUserConfig(value, GLOBAL_ACTION_KEY_DEVICECONTROLS); } else { return super.onPreferenceTreeClick(preference); } Loading