Skip to content

Commit

Permalink
TouchGestures: Adapt to S style
Browse files Browse the repository at this point in the history
 * Use Theme.SubSettingsBase for theme
 * Replace PreferenceActivity with CollapsingToolbarBaseActivity
 * Add Titles to prefernce screen
 * Remove onOptionsItemSelected and where neccessary move to activity

Signed-off-by: Krishnakant Shedge <[email protected]>
  • Loading branch information
TheScarastic authored and KrishnakantShedge committed Dec 10, 2021
1 parent 957128d commit 8ed977a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 46 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<activity
android:name=".TouchscreenGestureSettings"
android:label="@string/touchscreen_gesture_settings_title"
android:theme="@style/AppTheme">
android:theme="@style/Theme.SubSettingsBase">
</activity>

<activity
Expand Down
16 changes: 0 additions & 16 deletions res/values/colors.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.android.touch.gestures;

import android.app.Activity;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class ScreenOffLaunchGestureActivity extends Activity {
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
import com.android.settingslib.collapsingtoolbar.R;

public class ScreenOffLaunchGestureActivity extends CollapsingToolbarBaseActivity {

static final String ACTION_KEY = "action";

Expand Down
32 changes: 5 additions & 27 deletions src/com/android/touch/gestures/TouchscreenGestureSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package com.android.touch.gestures;

import android.app.ActionBar;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
Expand All @@ -27,11 +26,9 @@
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.UserHandle;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;

import android.preference.PreferenceActivity;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragment;
Expand All @@ -45,7 +42,9 @@

import java.lang.System;

public class TouchscreenGestureSettings extends PreferenceActivity
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;

public class TouchscreenGestureSettings extends CollapsingToolbarBaseActivity
implements PreferenceFragment.OnPreferenceStartFragmentCallback {

@Override
Expand All @@ -54,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {

if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.replace(android.R.id.content, getNewFragment())
.replace(R.id.content_frame, getNewFragment())
.commit();
}
}
Expand All @@ -69,7 +68,7 @@ public boolean onPreferenceStartFragment(PreferenceFragment preferenceFragment,
Fragment instantiate = Fragment.instantiate(this, preference.getFragment(),
preference.getExtras());
getFragmentManager().beginTransaction().replace(
android.R.id.content, instantiate).addToBackStack(preference.getKey()).commit();
R.id.content_frame, instantiate).addToBackStack(preference.getKey()).commit();

return true;
}
Expand All @@ -80,25 +79,14 @@ public static class MainSettingsFragment extends PreferenceFragment {
private static final String TOUCHSCREEN_GESTURE_TITLE = KEY_TOUCHSCREEN_GESTURE + "_%s_title";

private TouchscreenGesture[] mTouchscreenGestures;
private ActionBar actionBar;

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

Resources res = getResources();
Window win = getActivity().getWindow();

win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
win.setNavigationBarColor(res.getColor(R.color.primary_color));
win.setNavigationBarDividerColor(res.getColor(R.color.primary_color));

setPreferencesFromResource(R.xml.touchscreen_gesture_settings, rootKey);

actionBar = getActivity().getActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);

if (isTouchscreenGesturesSupported(getContext())) {
initTouchscreenGestures();
}
Expand Down Expand Up @@ -236,14 +224,4 @@ public void onDestroy() {
super.onDestroy();
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
}

0 comments on commit 8ed977a

Please sign in to comment.