✨ feat(ui, dialogs, utils): add search bar gesture preference, new GlobalSettingsDialog option, and DbUtils methods
This commit is contained in:
6 files changed
+72
-2
No files matched your search
@@ -1157,16 +1157,26 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
|
||||
@Override
|
||||
public void onSwipe(Gestures.Direction direction) {
|
||||
if (direction == Gestures.Direction.SWIPE_RIGHT) {
|
||||
if (DbUtils.isSearchBarGestureEnabled() && !searching) {
|
||||
searching = true;
|
||||
mSearchBox.setText("");
|
||||
mSearchBox.setVisibility(View.VISIBLE);
|
||||
mSearchBox.requestFocus();
|
||||
mSearchBox.animate().alpha(1.0f).setDuration(150).start();
|
||||
imm.showSoftInput(mSearchBox, InputMethodManager.SHOW_IMPLICIT);
|
||||
// Optionally, dim the background or add a visual cue
|
||||
}
|
||||
} else if (direction == Gestures.Direction.SWIPE_LEFT) {
|
||||
if (searching) {
|
||||
mSearchBox.animate().alpha(0.0f).setDuration(150).withEndAction(() -> {
|
||||
mSearchBox.setVisibility(View.GONE);
|
||||
mSearchBox.setAlpha(1.0f);
|
||||
}).start();
|
||||
imm.hideSoftInputFromWindow(mSearchBox.getWindowToken(), 0);
|
||||
onResume();
|
||||
// Reset app list to default state and padding
|
||||
mHomeLayout.setPadding(DbUtils.getPaddingLeft(), DbUtils.getPaddingTop(), DbUtils.getPaddingRight(), DbUtils.getPaddingBottom());
|
||||
sortApps(DbUtils.getSortsTypes());
|
||||
searching = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
private final Context context;
|
||||
private TextView freezeSize;
|
||||
private TextView doubleTapLockButton;
|
||||
private TextView searchBarGestureButton;
|
||||
|
||||
public GlobalSettingsDialog(Context context, LauncherActivity launcherActivity) {
|
||||
super(context);
|
||||
@@ -110,6 +111,10 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
doubleTapLockButton = findViewById(R.id.settings_double_tap_lock);
|
||||
doubleTapLockButton.setOnClickListener(this);
|
||||
|
||||
// Search bar gesture toggle
|
||||
searchBarGestureButton = findViewById(R.id.settings_search_bar_gesture);
|
||||
searchBarGestureButton.setOnClickListener(this);
|
||||
updateSearchBarGestureButtonText();
|
||||
|
||||
//reflect the DB value
|
||||
if (DbUtils.isSizeFrozen()) {
|
||||
@@ -158,6 +163,8 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
launcherActivity.recreate();
|
||||
} else if (id == R.id.settings_double_tap_lock) {
|
||||
toggleDoubleTapToLock();
|
||||
} else if (id == R.id.settings_search_bar_gesture) {
|
||||
toggleSearchBarGesture();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,4 +408,20 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
popupMenu.show();
|
||||
}
|
||||
|
||||
private void toggleSearchBarGesture() {
|
||||
boolean enabled = DbUtils.isSearchBarGestureEnabled();
|
||||
DbUtils.setSearchBarGestureEnabled(!enabled);
|
||||
updateSearchBarGestureButtonText();
|
||||
}
|
||||
|
||||
private void updateSearchBarGestureButtonText() {
|
||||
if (DbUtils.isSearchBarGestureEnabled()) {
|
||||
searchBarGestureButton.setText(R.string.search_bar_gesture);
|
||||
searchBarGestureButton.setAlpha(1.0f);
|
||||
} else {
|
||||
searchBarGestureButton.setText(context.getString(R.string.search_bar_gesture) + " (Off)");
|
||||
searchBarGestureButton.setAlpha(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,6 +62,7 @@ public class DbUtils {
|
||||
private static final String APPS_COLORS_DEFAULT = "apps_color_default";
|
||||
private static final String APPS_SORTS_TYPE = "apps_sorts_types";
|
||||
private static final String DOUBLE_TAP_TO_LOCK = "double_tap_to_lock";
|
||||
private static final String SEARCH_BAR_GESTURE = "search_bar_gesture";
|
||||
|
||||
|
||||
public static void init(Context context) {
|
||||
@@ -394,6 +395,20 @@ public class DbUtils {
|
||||
SpUtils.getInstance().putBoolean(DOUBLE_TAP_TO_LOCK, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if search bar gesture is enabled
|
||||
*/
|
||||
public static boolean isSearchBarGestureEnabled() {
|
||||
return SpUtils.getInstance().getBoolean(SEARCH_BAR_GESTURE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set search bar gesture preference
|
||||
*/
|
||||
public static void setSearchBarGestureEnabled(boolean enabled) {
|
||||
SpUtils.getInstance().putBoolean(SEARCH_BAR_GESTURE, enabled);
|
||||
}
|
||||
|
||||
// a simple ciphered counter: "opening counter" is a private thing
|
||||
// rest is on device security
|
||||
private static String codeCount(int count) {
|
||||
|
||||
@@ -225,6 +225,23 @@
|
||||
android:background="#DEDEDE"
|
||||
android:foregroundGravity="center_vertical|center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_search_bar_gesture"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="@string/search_bar_gesture"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="170dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="center|center_horizontal|center_vertical"
|
||||
android:background="#DEDEDE"
|
||||
android:foregroundGravity="center_vertical|center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_backup"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -110,4 +110,6 @@
|
||||
<!-- Accessibility service description -->
|
||||
<string name="accessibility_service_description">Lunox Accessibility Service for lock screen functionality. This service allows double tap to lock the screen.</string>
|
||||
<string name="set_as_default_launcher">Set as default launcher</string>
|
||||
|
||||
<string name="search_bar_gesture">Enable Search Bar Gesture</string>
|
||||
</resources>
|
||||
@@ -8,8 +8,11 @@
|
||||
- Added Swipe Up to Open Notifications Panel
|
||||
- Fixed Launcher Settings now work on all empty area
|
||||
- Added Double Tap to Lock Screen Feature
|
||||
|
||||
- Added `Set as Default Launcher` option
|
||||
- Added Toggle button for search bar gesture
|
||||
|
||||
* Project Shource codes Changes.
|
||||
|
||||
- SDK targets 28-> 34 (android 13/14)
|
||||
- Instead of Static fields, Instance fields are used in LauncherActivity.java
|
||||
- Remove code duplication from LauncherActivity.java
|
||||
Reference in new issue
Block a user