LineageParts: Re-enable PowerMenuActions and adapt to SDK updates

Also:
* Add summary for screenshot long press action
* Remove sound panel from available options
* Disable airplane mode by default matching vendor overlay
* Remove ability to disable restart option

Change-Id: If09012dceddc66d641bf4aa7d3f0ab1e3e9347a7
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8fd484f..f27ae25 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -38,7 +38,7 @@
 
     <uses-permission android:name="lineageos.permission.MANAGE_REMOTE_PREFERENCES" />
 
-    <protected-broadcast android:name="android.intent.action.UPDATE_POWER_MENU" />
+    <protected-broadcast android:name="lineageos.intent.action.UPDATE_POWER_MENU" />
     <protected-broadcast android:name="lineageos.platform.app.profiles.PROFILES_STATE_CHANGED" />
     <protected-broadcast android:name="org.lineageos.lineageparts.PART_CHANGED" />
     <protected-broadcast android:name="org.lineageos.lineageparts.REFRESH_PART" />
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index d880d12..e3aea07 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -90,7 +90,6 @@
         <item>airplane</item>
         <item>users</item>
         <item>bugreport</item>
-        <item>silent</item>
     </string-array>
 
     <!-- Volume key cursor control -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7d19582..1ea7548 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -242,8 +242,8 @@
 
     <!-- Power menu -->
     <string name="power_menu_title">Power menu</string>
-    <string name="power_menu_reboot_title">Restart menu</string>
     <string name="power_menu_screenshot_title">Screenshot</string>
+    <string name="power_menu_screenshot_summary">Long-press for partial screenshot</string>
     <string name="power_menu_airplane_title">Airplane mode</string>
     <string name="power_menu_users_title">User switcher</string>
     <string name="power_menu_settings_title">Settings shortcut</string>
diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml
index ee94d37..37661bb 100644
--- a/res/xml/button_settings.xml
+++ b/res/xml/button_settings.xml
@@ -71,12 +71,10 @@
         android:key="power_key"
         android:title="@string/hardware_keys_power_key_title" >
 
-        <!--
         <PreferenceScreen
             android:key="power_menu"
             android:title="@string/power_menu_title"
             android:fragment="org.lineageos.lineageparts.input.PowerMenuActions" />
-        -->
 
         <SwitchPreference
             android:key="power_end_call"
diff --git a/res/xml/power_menu_settings.xml b/res/xml/power_menu_settings.xml
index ef71d04..1e8fc81 100644
--- a/res/xml/power_menu_settings.xml
+++ b/res/xml/power_menu_settings.xml
@@ -20,19 +20,15 @@
     android:title="@string/power_menu_title">
 
     <CheckBoxPreference
-        android:key="restart"
-        android:title="@string/power_menu_reboot_title"
-        android:defaultValue="true" />
-
-    <CheckBoxPreference
         android:key="screenshot"
         android:title="@string/power_menu_screenshot_title"
+        android:summary="@string/power_menu_screenshot_summary"
         android:defaultValue="false" />
 
     <CheckBoxPreference
         android:key="airplane"
         android:title="@string/power_menu_airplane_title"
-        android:defaultValue="true" />
+        android:defaultValue="false" />
 
     <CheckBoxPreference
         android:key="users"
diff --git a/src/org/lineageos/lineageparts/input/PowerMenuActions.java b/src/org/lineageos/lineageparts/input/PowerMenuActions.java
index 396df7b..20afd4d 100644
--- a/src/org/lineageos/lineageparts/input/PowerMenuActions.java
+++ b/src/org/lineageos/lineageparts/input/PowerMenuActions.java
@@ -27,10 +27,7 @@
 import android.support.v7.preference.CheckBoxPreference;
 import android.support.v7.preference.Preference;
 
-/*
-import com.android.internal.util.lineage.PowerMenuConstants;
-*/
-
+import org.lineageos.internal.util.PowerMenuConstants;
 import org.lineageos.lineageparts.R;
 import org.lineageos.lineageparts.SettingsPreferenceFragment;
 
@@ -40,24 +37,11 @@
 
 import lineageos.providers.LineageSettings;
 
-/*
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_AIRPLANE;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_ASSIST;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_BUGREPORT;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_LOCKDOWN;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_RESTART;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_SCREENSHOT;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_SETTINGS;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_SILENT;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_USERS;
-import static com.android.internal.util.lineage.PowerMenuConstants.GLOBAL_ACTION_KEY_VOICEASSIST;
-*/
+import static org.lineageos.internal.util.PowerMenuConstants.*;
 
-/*
 public class PowerMenuActions extends SettingsPreferenceFragment {
     final static String TAG = "PowerMenuActions";
 
-    private CheckBoxPreference mRebootPref;
     private CheckBoxPreference mScreenshotPref;
     private CheckBoxPreference mAirplanePref;
     private CheckBoxPreference mUsersPref;
@@ -91,9 +75,7 @@
                 continue;
             }
 
-            if (action.equals(GLOBAL_ACTION_KEY_RESTART)) {
-                mRebootPref = (CheckBoxPreference) findPreference(GLOBAL_ACTION_KEY_RESTART);
-            } else if (action.equals(GLOBAL_ACTION_KEY_SCREENSHOT)) {
+            if (action.equals(GLOBAL_ACTION_KEY_SCREENSHOT)) {
                 mScreenshotPref = (CheckBoxPreference) findPreference(GLOBAL_ACTION_KEY_SCREENSHOT);
             } else if (action.equals(GLOBAL_ACTION_KEY_AIRPLANE)) {
                 mAirplanePref = (CheckBoxPreference) findPreference(GLOBAL_ACTION_KEY_AIRPLANE);
@@ -121,10 +103,6 @@
     public void onStart() {
         super.onStart();
 
-        if (mRebootPref != null) {
-            mRebootPref.setChecked(settingsArrayContains(GLOBAL_ACTION_KEY_RESTART));
-        }
-
         if (mScreenshotPref != null) {
             mScreenshotPref.setChecked(settingsArrayContains(GLOBAL_ACTION_KEY_SCREENSHOT));
         }
@@ -183,11 +161,7 @@
     public boolean onPreferenceTreeClick(Preference preference) {
         boolean value;
 
-        if (preference == mRebootPref) {
-            value = mRebootPref.isChecked();
-            updateUserConfig(value, GLOBAL_ACTION_KEY_RESTART);
-
-        } else if (preference == mScreenshotPref) {
+        if (preference == mScreenshotPref) {
             value = mScreenshotPref.isChecked();
             updateUserConfig(value, GLOBAL_ACTION_KEY_SCREENSHOT);
 
@@ -313,8 +287,7 @@
 
     private void updatePowerMenuDialog() {
         Intent u = new Intent();
-        u.setAction(Intent.UPDATE_POWER_MENU);
+        u.setAction(lineageos.content.Intent.ACTION_UPDATE_POWER_MENU);
         mContext.sendBroadcastAsUser(u, UserHandle.ALL);
     }
 }
-*/