diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8f7c03f..f5bcb9c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -8,10 +8,11 @@
-
+
+
-
= location[0] && x <= location[0] + mHomeLayout.getWidth() &&
+ y >= location[1] && y <= location[1] + mHomeLayout.getHeight()) {
+
+ // Check each child view in the home layout
+ for (int i = 0; i < mHomeLayout.getChildCount(); i++) {
+ View child = mHomeLayout.getChildAt(i);
+ child.getLocationOnScreen(location);
+
+ if (x >= location[0] && x <= location[0] + child.getWidth() &&
+ y >= location[1] && y <= location[1] + child.getHeight()) {
+ return child;
+ }
+ }
+ }
+
+ return null; // No specific view found, it's empty space
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -252,6 +285,20 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
detector = new Gestures(this, this);
+ // Initialize long press detector for empty areas
+ longPressDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
+ @Override
+ public void onLongPress(MotionEvent e) {
+ // Check if the touch is on an empty area (not on an app)
+ View touchedView = findViewAt(e.getX(), e.getY());
+ if (!(touchedView instanceof AppTextView)) {
+ // Show launcher settings on long press in free space
+ dialogs = new GlobalSettingsDialog(LauncherActivity.this, LauncherActivity.this);
+ dialogs.show();
+ }
+ }
+ });
+
// initGestures();
// Check permissions before loading apps
@@ -599,7 +646,7 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
// show app setting
showPopup((String) view.getTag(), (AppTextView) view);
} else if (view instanceof FlowLayout) {
- // show launcher setting
+ // show launcher setting for FlowLayout (this handles long press on FlowLayout itself)
dialogs = new GlobalSettingsDialog(this, this);
dialogs.show();
}
@@ -607,9 +654,9 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
}
private void showPopup(String activityName, AppTextView view) {
- // show app settings popup instead of popup menu
+ // show app settings dialog instead of popup menu
AppSettingsPopup popup = new AppSettingsPopup(this, activityName, view, this);
- popup.showAsDropDown(view);
+ popup.show();
}
//reset the app color to default color;
@@ -1152,17 +1199,15 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
@Override
public void onSwipe(Gestures.Direction direction) {
if (direction == Gestures.Direction.SWIPE_UP) {
+ // Open search bar on swipe up (down to up gesture)
searching = true;
mSearchBox.setText("");
mSearchBox.setVisibility(View.VISIBLE);
mSearchBox.requestFocus();
imm.showSoftInput(mSearchBox, InputMethodManager.SHOW_IMPLICIT);
} else if (direction == Gestures.Direction.SWIPE_DOWN) {
- if (searching) {
- mSearchBox.setVisibility(View.GONE);
- imm.hideSoftInputFromWindow(mSearchBox.getWindowToken(), 0);
- onResume();
- }
+ // Open notification panel on swipe down (up to down gesture)
+ NotificationPanelManager.expandNotificationPanel(this);
}
}
@@ -1172,12 +1217,7 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
DeviceAdminManager.lockDevice(this);
}
- @Override
- public void onLongPress() {
- // Show launcher settings on long press in free space
- dialogs = new GlobalSettingsDialog(this, this);
- dialogs.show();
- }
+
static class SearchTask extends AsyncTask> {
@Override
diff --git a/app/src/main/java/io/github/sankalp/lunox/dialogs/AppSettingsPopup.java b/app/src/main/java/io/github/sankalp/lunox/dialogs/AppSettingsPopup.java
index 03a09df..9a0f4ad 100644
--- a/app/src/main/java/io/github/sankalp/lunox/dialogs/AppSettingsPopup.java
+++ b/app/src/main/java/io/github/sankalp/lunox/dialogs/AppSettingsPopup.java
@@ -18,12 +18,12 @@
package io.github.sankalp.lunox.dialogs;
+import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
-import android.view.Gravity;
-import android.view.LayoutInflater;
+import android.os.Bundle;
import android.view.View;
-import android.widget.PopupWindow;
+import android.view.Window;
import android.widget.TextView;
import io.github.sankalp.lunox.LauncherActivity;
@@ -32,9 +32,9 @@ import io.github.sankalp.lunox.utils.DbUtils;
import io.github.sankalp.lunox.views.textview.AppTextView;
/**
- * App settings popup that shows options for individual apps
+ * App settings dialog that shows options for individual apps
*/
-public class AppSettingsPopup extends PopupWindow implements View.OnClickListener {
+public class AppSettingsPopup extends Dialog implements View.OnClickListener {
private final LauncherActivity launcherActivity;
private final Context context;
@@ -51,46 +51,43 @@ public class AppSettingsPopup extends PopupWindow implements View.OnClickListene
this.activityName = activityName;
this.appTextView = appTextView;
this.launcherActivity = launcherActivity;
-
- initPopup();
}
- private void initPopup() {
- LayoutInflater inflater = LayoutInflater.from(context);
- View contentView = inflater.inflate(R.layout.dialog_app_settings, null);
- setContentView(contentView);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // no old title: Last Launcher use Activity class not AppCompatActivity so it show very old title
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(R.layout.dialog_app_settings);
- // Set popup properties
- setWidth(android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
- setHeight(android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
- setFocusable(true);
- setOutsideTouchable(true);
-
- // Set background to match the dialog style with border
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
- setBackgroundDrawable(context.getResources().getDrawable(R.drawable.popup_background, null));
- } else {
- setBackgroundDrawable(context.getResources().getDrawable(R.drawable.popup_background));
+ // Set the dialog background to match popup style with border
+ Window window = getWindow();
+ if (window != null) {
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ window.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.popup_background, null));
+ } else {
+ window.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.popup_background));
+ }
}
// Set up click listeners
- contentView.findViewById(R.id.app_settings_color).setOnClickListener(this);
- contentView.findViewById(R.id.app_settings_rename).setOnClickListener(this);
+ findViewById(R.id.app_settings_color).setOnClickListener(this);
+ findViewById(R.id.app_settings_rename).setOnClickListener(this);
- freezeSize = contentView.findViewById(R.id.app_settings_freeze_size);
+ freezeSize = findViewById(R.id.app_settings_freeze_size);
freezeSize.setOnClickListener(this);
- contentView.findViewById(R.id.app_settings_app_info).setOnClickListener(this);
- contentView.findViewById(R.id.app_settings_reset_color).setOnClickListener(this);
+ findViewById(R.id.app_settings_app_info).setOnClickListener(this);
+ findViewById(R.id.app_settings_reset_color).setOnClickListener(this);
- hideApp = contentView.findViewById(R.id.app_settings_hide);
+ hideApp = findViewById(R.id.app_settings_hide);
hideApp.setOnClickListener(this);
- resetToDefault = contentView.findViewById(R.id.app_settings_reset_to_default);
+ resetToDefault = findViewById(R.id.app_settings_reset_to_default);
resetToDefault.setOnClickListener(this);
resetToDefault.setTextColor(Color.parseColor("#E53935"));
- uninstallApp = contentView.findViewById(R.id.app_settings_uninstall);
+ uninstallApp = findViewById(R.id.app_settings_uninstall);
uninstallApp.setOnClickListener(this);
uninstallApp.setTextColor(Color.parseColor("#E53935"));
@@ -105,48 +102,44 @@ public class AppSettingsPopup extends PopupWindow implements View.OnClickListene
if (appTextView.isShortcut()) {
uninstallApp.setText(R.string.remove);
hideApp.setVisibility(View.GONE);
- contentView.findViewById(R.id.app_settings_rename).setVisibility(View.GONE);
- contentView.findViewById(R.id.app_settings_app_info).setVisibility(View.GONE);
+ findViewById(R.id.app_settings_rename).setVisibility(View.GONE);
+ findViewById(R.id.app_settings_app_info).setVisibility(View.GONE);
} else {
hideApp.setTextColor(Color.parseColor("#E53935"));
}
}
- public void showAsDropDown(View anchor) {
- showAsDropDown(anchor, 0, 0, Gravity.START);
- }
-
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.app_settings_color) {
launcherActivity.changeColorSize(activityName, appTextView);
- dismiss();
+ cancel();
} else if (id == R.id.app_settings_rename) {
launcherActivity.renameApp(activityName, appTextView.getText().toString());
- dismiss();
+ cancel();
} else if (id == R.id.app_settings_freeze_size) {
launcherActivity.freezeAppSize(activityName);
- dismiss();
+ cancel();
} else if (id == R.id.app_settings_app_info) {
launcherActivity.showAppInfo(activityName);
- dismiss();
+ cancel();
} else if (id == R.id.app_settings_reset_color) {
launcherActivity.resetAppColor(activityName);
- dismiss();
+ cancel();
} else if (id == R.id.app_settings_hide) {
launcherActivity.hideApp(activityName);
- dismiss();
+ cancel();
} else if (id == R.id.app_settings_reset_to_default) {
launcherActivity.resetApp(activityName);
- dismiss();
+ cancel();
} else if (id == R.id.app_settings_uninstall) {
if (appTextView.isShortcut()) {
launcherActivity.removeShortcut(appTextView);
} else {
launcherActivity.uninstallApp(activityName);
}
- dismiss();
+ cancel();
}
}
}
diff --git a/app/src/main/java/io/github/sankalp/lunox/utils/Gestures.java b/app/src/main/java/io/github/sankalp/lunox/utils/Gestures.java
index 5e7497e..656570e 100644
--- a/app/src/main/java/io/github/sankalp/lunox/utils/Gestures.java
+++ b/app/src/main/java/io/github/sankalp/lunox/utils/Gestures.java
@@ -79,11 +79,6 @@ public class Gestures extends GestureDetector.SimpleOnGestureListener {
return true;
}
- @Override
- public void onLongPress(MotionEvent e) {
- this.listener.onLongPress();
- }
-
public enum Direction {
SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT
@@ -93,8 +88,6 @@ public class Gestures extends GestureDetector.SimpleOnGestureListener {
void onSwipe(Direction direction);
void onDoubleTap();
-
- void onLongPress();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/sankalp/lunox/utils/NotificationPanelManager.java b/app/src/main/java/io/github/sankalp/lunox/utils/NotificationPanelManager.java
new file mode 100644
index 0000000..b5de678
--- /dev/null
+++ b/app/src/main/java/io/github/sankalp/lunox/utils/NotificationPanelManager.java
@@ -0,0 +1,113 @@
+/*
+ * Last Launcher
+ * Copyright (C) 2019,2020 Shubham Tyagi
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package io.github.sankalp.lunox.utils;
+
+import android.content.Context;
+import android.os.Build;
+import android.util.Log;
+
+import java.lang.reflect.Method;
+
+/**
+ * Utility class to manage notification panel expansion
+ */
+public class NotificationPanelManager {
+
+ private static final String TAG = "NotificationPanelManager";
+
+ /**
+ * Attempts to expand the notification panel using reflection
+ * @param context The application context
+ * @return true if successful, false otherwise
+ */
+ public static boolean expandNotificationPanel(Context context) {
+ try {
+ // Get the StatusBarManager service
+ Object statusBarService = context.getSystemService("statusbar");
+
+ if (statusBarService == null) {
+ Log.w(TAG, "StatusBar service not available");
+ return false;
+ }
+
+ Class> statusBarManager = Class.forName("android.app.StatusBarManager");
+ Method expandMethod;
+
+ // Different method names for different Android versions
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ // Android 4.2+ uses expandNotificationsPanel
+ expandMethod = statusBarManager.getMethod("expandNotificationsPanel");
+ } else {
+ // Older versions use expand
+ expandMethod = statusBarManager.getMethod("expand");
+ }
+
+ expandMethod.setAccessible(true);
+ expandMethod.invoke(statusBarService);
+
+ Log.d(TAG, "Notification panel expanded successfully");
+ return true;
+
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to expand notification panel: " + e.getMessage());
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * Attempts to collapse the notification panel using reflection
+ * @param context The application context
+ * @return true if successful, false otherwise
+ */
+ public static boolean collapseNotificationPanel(Context context) {
+ try {
+ // Get the StatusBarManager service
+ Object statusBarService = context.getSystemService("statusbar");
+
+ if (statusBarService == null) {
+ Log.w(TAG, "StatusBar service not available");
+ return false;
+ }
+
+ Class> statusBarManager = Class.forName("android.app.StatusBarManager");
+ Method collapseMethod;
+
+ // Different method names for different Android versions
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ // Android 4.2+ uses collapsePanels
+ collapseMethod = statusBarManager.getMethod("collapsePanels");
+ } else {
+ // Older versions use collapse
+ collapseMethod = statusBarManager.getMethod("collapse");
+ }
+
+ collapseMethod.setAccessible(true);
+ collapseMethod.invoke(statusBarService);
+
+ Log.d(TAG, "Notification panel collapsed successfully");
+ return true;
+
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to collapse notification panel: " + e.getMessage());
+ e.printStackTrace();
+ return false;
+ }
+ }
+}
diff --git a/app/src/main/res/drawable/popup_background.xml b/app/src/main/res/drawable/popup_background.xml
index f8a3461..58c3bea 100644
--- a/app/src/main/res/drawable/popup_background.xml
+++ b/app/src/main/res/drawable/popup_background.xml
@@ -7,7 +7,7 @@
diff --git a/app/src/main/res/layout/dialog_app_settings.xml b/app/src/main/res/layout/dialog_app_settings.xml
index 4561238..ffd44c9 100644
--- a/app/src/main/res/layout/dialog_app_settings.xml
+++ b/app/src/main/res/layout/dialog_app_settings.xml
@@ -26,8 +26,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="10dp">
+ android:background="@android:color/black"
+ android:orientation="vertical">