Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/.idea
/*/build
/*/obfuscation
/*/global
/*/playStore
/build
/settings.json
/app/app_config.json
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
applicationId "io.github.ratul.topactivity"
minSdkVersion 24
targetSdkVersion 36
versionCode 20
versionCode 22
versionName "1.5.9"
}

Expand Down
7 changes: 6 additions & 1 deletion app/src/global/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="PackageVisibilityPolicy,QueryAllPackagesPermission" />

<application>
<service
Expand Down
2 changes: 1 addition & 1 deletion app/src/global/res/xml/accessibility.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:accessibilityEventTypes="typeWindowStateChanged|typeWindowsChanged|typeWindowContentChanged"
android:accessibilityEventTypes="typeWindowStateChanged|typeWindowsChanged"
android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagReportViewIds"
android:canRetrieveWindowContent="true"
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="PackageVisibilityPolicy,QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

import androidx.annotation.NonNull;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import io.github.ratul.topactivity.App;
import io.github.ratul.topactivity.R;
import io.github.ratul.topactivity.receivers.NotificationReceiver;
Expand All @@ -42,6 +45,7 @@
* Created by Ratul on 04/05/2022.
*/
public class WindowUtil {
private static final Map<String, String> appLabelCache = new ConcurrentHashMap<>();
private static WindowManager.LayoutParams layoutParams;
private static WindowManager windowManager;
private static PackageManager packageManager;
Expand Down Expand Up @@ -164,11 +168,23 @@ private static void init(@NonNull Context context) {
}

private static String getAppName(@NonNull String pkg) {
// Check cache first
String label = appLabelCache.get(pkg);
if (label != null) {
return label;
}

// If not in cache, get the label
try {
return packageManager.getApplicationLabel(
label = packageManager.getApplicationLabel(
packageManager.getApplicationInfo(pkg, 0)).toString();
} catch (PackageManager.NameNotFoundException ignored) {
return "Unknown";
// Store result in cache
appLabelCache.put(pkg, label);
return label;
} catch (PackageManager.NameNotFoundException e) {
// Return default and cache the default to avoid repeated lookups
appLabelCache.put(pkg, "Current Activity");
return "Current Activity";
}
}
}
9 changes: 9 additions & 0 deletions app/src/playStore/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
</intent>
</queries>
</manifest>