Added option to enable power menu actions

pull/199/head
M66B 4 years ago
parent 1f8c00388f
commit 10803280c3

@ -399,6 +399,7 @@
<service <service
android:name=".ServicePowerControl" android:name=".ServicePowerControl"
android:enabled="false"
android:label="@string/app_name" android:label="@string/app_name"
android:permission="android.permission.BIND_CONTROLS"> android:permission="android.permission.BIND_CONTROLS">
<intent-filter> <intent-filter>

@ -82,6 +82,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private boolean resumed = false; private boolean resumed = false;
private List<Pair<String, String>> languages = new ArrayList<>(); private List<Pair<String, String>> languages = new ArrayList<>();
private SwitchCompat swPowerMenu;
private SwitchCompat swExternalSearch; private SwitchCompat swExternalSearch;
private SwitchCompat swShortcuts; private SwitchCompat swShortcuts;
private SwitchCompat swFts; private SwitchCompat swFts;
@ -188,6 +189,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
// Get controls // Get controls
swPowerMenu = view.findViewById(R.id.swPowerMenu);
swExternalSearch = view.findViewById(R.id.swExternalSearch); swExternalSearch = view.findViewById(R.id.swExternalSearch);
swShortcuts = view.findViewById(R.id.swShortcuts); swShortcuts = view.findViewById(R.id.swShortcuts);
swFts = view.findViewById(R.id.swFts); swFts = view.findViewById(R.id.swFts);
@ -246,6 +248,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swPowerMenu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
Helper.enableComponent(getContext(), ServicePowerControl.class, checked);
}
});
swExternalSearch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swExternalSearch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -787,6 +796,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
: R.color.lightColorBackground_cards)); : R.color.lightColorBackground_cards));
} }
swPowerMenu.setVisibility(!BuildConfig.PLAY_STORE_RELEASE &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
? View.VISIBLE : View.GONE);
tvFtsIndexed.setText(null); tvFtsIndexed.setText(null);
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(getContext());
@ -920,6 +933,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private void setOptions() { private void setOptions() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swPowerMenu.setChecked(Helper.isComponentEnabled(getContext(), ServicePowerControl.class));
swExternalSearch.setChecked(Helper.isComponentEnabled(getContext(), ActivitySearch.class)); swExternalSearch.setChecked(Helper.isComponentEnabled(getContext(), ActivitySearch.class));
swShortcuts.setChecked(prefs.getBoolean("shortcuts", true)); swShortcuts.setChecked(prefs.getBoolean("shortcuts", true));
swFts.setChecked(prefs.getBoolean("fts", false)); swFts.setChecked(prefs.getBoolean("fts", false));

@ -62,16 +62,26 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPowerMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_power_menu"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCaptionGeneral"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swExternalSearch" android:id="@+id/swExternalSearch"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:enabled="true"
android:text="@string/title_advanced_external_search" android:text="@string/title_advanced_external_search"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCaptionGeneral" app:layout_constraintTop_toBottomOf="@id/swPowerMenu"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -536,6 +536,7 @@
</string> </string>
<string name="title_advanced_aes_key_size" translatable="false">Max AES key size: %1$d</string> <string name="title_advanced_aes_key_size" translatable="false">Max AES key size: %1$d</string>
<string name="title_advanced_power_menu">Add actions to the power menu</string>
<string name="title_advanced_external_search">Allow other apps to search in messages</string> <string name="title_advanced_external_search">Allow other apps to search in messages</string>
<string name="title_advanced_shortcuts">Show frequently used contacts in Android share menu</string> <string name="title_advanced_shortcuts">Show frequently used contacts in Android share menu</string>
<string name="title_advanced_fts">Build search index</string> <string name="title_advanced_fts">Build search index</string>

Loading…
Cancel
Save