Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdd1d9d5 authored by Joey's avatar Joey Committed by Jesse Chan
Browse files

Settings: add top exclusion to the back gesture



Change-Id: I408e3f57a1d0bfadff64ff3d25b27f41e80bebac
Signed-off-by: default avatarJoey <joey@lineageos.org>
Signed-off-by: default avatarLuca Stefani <luca.stefani.ge1@gmail.com>
Signed-off-by: default avatarJesse Chan <jc@lineageos.org>
parent 9bf69616
Loading
Loading
Loading
Loading
+82 −0
Original line number Diff line number Diff line
@@ -22,6 +22,26 @@
    android:orientation="vertical"
    android:padding="12dp">

    <TextView
        android:textStyle="bold"
        android:layout_marginTop="8dip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="2dp"
        android:layout_marginStart="12dp"
        android:textColor="?android:attr/textColorPrimary"
        android:text="@string/back_sensitivity_title" />

    <TextView
        android:layout_marginTop="22dip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="2dp"
        android:layout_marginStart="12dp"
        android:text="@string/back_sensitivity_message" />

    <SeekBar
        android:id="@+id/back_sensitivity_seekbar"
        android:layout_width="match_parent"
@@ -64,4 +84,66 @@
                  android:ellipsize="marquee" />

    </LinearLayout>

    <TextView
        android:textStyle="bold"
        android:layout_marginTop="8dip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="2dp"
        android:layout_marginStart="12dp"
        android:textColor="?android:attr/textColorPrimary"
        android:text="@string/back_exclusion_title" />

    <TextView
        android:layout_marginTop="22dip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="2dp"
        android:layout_marginStart="12dp"
        android:text="@string/back_exclusion_summary" />

    <SeekBar
        android:id="@+id/back_excluded_top_seekbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:min="0"
        android:max="50"
        android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="2dp"
        android:layout_marginBottom="8dp">

        <TextView android:id="@+id/min_tick"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_weight="1"
                  android:layout_marginBottom="2dp"
                  android:layout_marginStart="12dp"
                  android:gravity="start"
                  android:text="@string/min_label"
                  android:textAppearance="?android:attr/textAppearance"
                  android:singleLine="true"
                  android:ellipsize="marquee" />

        <TextView android:id="@+id/max_tick"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_weight="1"
                  android:layout_marginBottom="2dp"
                  android:layout_marginEnd="12dp"
                  android:gravity="end"
                  android:text="@string/max_label"
                  android:textAppearance="?android:attr/textAppearance"
                  android:singleLine="true"
                  android:ellipsize="marquee" />

    </LinearLayout>
</LinearLayout>
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -163,4 +163,14 @@
    <!-- Black theme for dark mode -->
    <string name="berry_black_theme_title">Pure black</string>
    <string name="berry_black_theme_summary">Pure black background for dark theme</string>

    <!-- Back sensitivity -->
    <string name="back_sensitivity_title">Back sensitivity</string>
    <string name="back_sensitivity_message">Higher sensitivity may conflict with any app gestures along the edges of the screen.</string>

    <!-- Back gesture top exclusion -->
    <string name="back_exclusion_title">Back exclusion at top</string>
    <string name="back_exclusion_summary">Exclude part of the top of the screen from the back gesture area</string>
    <string name="min_label">Min</string>
    <string name="max_label">Max</string>
</resources>
+20 −5
Original line number Diff line number Diff line
@@ -20,15 +20,20 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.ContentResolver;
import android.content.om.IOverlayManager;
import android.os.Bundle;
import android.os.ServiceManager;
import android.view.View;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.TextView;

import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;

import lineageos.providers.LineageSettings;

/**
 * Dialog to set the back gesture's sensitivity in Gesture navigation mode.
 */
@@ -59,17 +64,27 @@ public class GestureNavigationBackSensitivityDialog extends InstrumentedDialogFr
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final View view = getActivity().getLayoutInflater().inflate(
                R.layout.dialog_back_gesture_sensitivity, null);
        final SeekBar seekBar = view.findViewById(R.id.back_sensitivity_seekbar);
        seekBar.setProgress(getArguments().getInt(KEY_BACK_SENSITIVITY));
        final SeekBar sensitivitySeekBar = view.findViewById(R.id.back_sensitivity_seekbar);
        sensitivitySeekBar.setProgress(getArguments().getInt(KEY_BACK_SENSITIVITY));

        final ContentResolver cr = getContext().getContentResolver();
        final int excludedPercentage = LineageSettings.Secure.getInt(cr,
                LineageSettings.Secure.GESTURE_BACK_EXCLUDE_TOP, 0);
        final SeekBar excludedTopSeekBar = view.findViewById(R.id.back_excluded_top_seekbar);
        excludedTopSeekBar.setProgress(excludedPercentage);

        return new AlertDialog.Builder(getContext())
                .setTitle(R.string.back_sensitivity_dialog_title)
                .setMessage(R.string.back_sensitivity_dialog_message)
                .setTitle(R.string.edge_to_edge_navigation_title)
                .setView(view)
                .setPositiveButton(R.string.okay, (dialog, which) -> {
                    int sensitivity = seekBar.getProgress();
                    int sensitivity = sensitivitySeekBar.getProgress();
                    getArguments().putInt(KEY_BACK_SENSITIVITY, sensitivity);
                    SystemNavigationGestureSettings.setBackSensitivity(getActivity(),
                            getOverlayManager(), sensitivity);

                    int excludedTopPercentage = excludedTopSeekBar.getProgress();
                    LineageSettings.Secure.putInt(cr,
                            LineageSettings.Secure.GESTURE_BACK_EXCLUDE_TOP, excludedTopPercentage);
                })
                .create();
    }