Skip to content

Commit

Permalink
add 'show system apps' option
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr328 committed Nov 27, 2020
1 parent 8d7e766 commit c6dd126
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
minSdkVersion(29)
targetSdkVersion(30)

versionCode = 5
versionName = "v5"
versionCode = 6
versionName = "v6"
}

buildFeatures {
Expand Down
28 changes: 27 additions & 1 deletion app/src/main/java/com/github/kr328/clipboard/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.ProgressBar;
Expand All @@ -25,6 +27,8 @@ public class MainActivity extends Activity {
private ListView appsList;
private ProgressBar loading;

private boolean showSystemApps = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -54,6 +58,28 @@ protected void onDestroy() {
threads.shutdownNow();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);

return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if ( item.getItemId() == R.id.systemApps ) {
item.setChecked(!item.isChecked());

showSystemApps = item.isChecked();

loadApps();

return true;
}

return super.onMenuItemSelected(featureId, item);
}

private void loadApps() {
threads.submit(() -> {
updateLoading(false);
Expand All @@ -64,7 +90,7 @@ private void loadApps() {
final HashSet<String> whitelist = new HashSet<>(Arrays.asList(service.queryPackages()));

final List<App> apps = pm.getInstalledApplications(0).stream()
.filter((info) -> (info.flags & ApplicationInfo.FLAG_SYSTEM) == 0)
.filter((info) -> showSystemApps || (info.flags & ApplicationInfo.FLAG_SYSTEM) == 0)
.map((info) -> App.fromApplicationInfo(info, pm, whitelist.contains(info.packageName)))
.sorted()
.collect(Collectors.toList());
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/systemApps"
android:title="@string/system_apps"
android:checkable="true"
android:checked="false" />
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<string name="notification_exception">Installation Failure</string>
<string name="notification_exception_content">ClipboardWhitelist installation error, click here to check.</string>
<string name="notice">Notice</string>
<string name="system_apps">System Apps</string>
<string name="application_clipboard_detect">Applications cannot detect that the clipboard is accessible in the background and they may still assume that clipboard is unavailable.</string>
</resources>
4 changes: 2 additions & 2 deletions module/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ android {
minSdkVersion(29)
targetSdkVersion(30)

versionCode = 5
versionName = "v5"
versionCode = 6
versionName = "v6"

multiDexEnabled = false

Expand Down

0 comments on commit c6dd126

Please sign in to comment.