Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
gradle upgrade, show version in title
Browse files Browse the repository at this point in the history
  • Loading branch information
g4rb4g3 committed May 21, 2021
1 parent 80d0b5c commit f20187f
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 26 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "g4rb4g3.at.ctsteststarter"
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName "2.0.5"
versionCode 206
versionName "2.0.6"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package g4rb4g3.at.ctsteststarter;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class LaunchableApplicationInfo extends ApplicationInfo {
public boolean isLaunchable;
public boolean isSystemApp;
public boolean isKeyMapped;
public String version;

public LaunchableApplicationInfo(ApplicationInfo applicationInfo, boolean isLaunchable) {
public LaunchableApplicationInfo(ApplicationInfo applicationInfo, boolean isLaunchable, Context context) {
super(applicationInfo);
this.isLaunchable = isLaunchable;
this.isSystemApp = (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(applicationInfo.packageName, 0);
this.version = packageInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
}
8 changes: 4 additions & 4 deletions app/src/main/java/g4rb4g3/at/ctsteststarter/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private void showAppOptions(final LaunchableApplicationInfo info, final int posi
items.add(getString(R.string.uninstall));
}
new AlertDialog.Builder(this)
.setTitle(info.name)
.setTitle(info.name + " " + info.version)
.setIcon(info.loadIcon(mPackageManager))
.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss())
.setAdapter(items, (dialog, which) -> {
Expand Down Expand Up @@ -289,7 +289,7 @@ private class LoadApplications extends AsyncTask<Void, Void, Void> {

@Override
protected Void doInBackground(Void... params) {
List<LaunchableApplicationInfo> appList = checkForLaunchIntent(mPackageManager.getInstalledApplications(PackageManager.GET_META_DATA));
List<LaunchableApplicationInfo> appList = checkForLaunchIntent(mPackageManager.getInstalledApplications(PackageManager.GET_META_DATA), MainActivity.this);
mListAdapter = new ApplicationAdapter(MainActivity.this, R.layout.app_list_item, appList);
return null;
}
Expand All @@ -312,7 +312,7 @@ protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}

private List<LaunchableApplicationInfo> checkForLaunchIntent(List<ApplicationInfo> list) {
private List<LaunchableApplicationInfo> checkForLaunchIntent(List<ApplicationInfo> list, Context context) {
List<String> mappedApps = new ArrayList<>();
Map<String, ?> preferences = getSharedPreferences(PREFERENCES_NAME, MODE_PRIVATE).getAll();
for (Map.Entry<String, ?> entry : preferences.entrySet()) {
Expand All @@ -325,7 +325,7 @@ private List<LaunchableApplicationInfo> checkForLaunchIntent(List<ApplicationInf
for (ApplicationInfo info : list) {
try {
if (!ownPackageName.equals(info.packageName)) {
LaunchableApplicationInfo applicationInfo = new LaunchableApplicationInfo(info, mPackageManager.getLaunchIntentForPackage(info.packageName) != null);
LaunchableApplicationInfo applicationInfo = new LaunchableApplicationInfo(info, mPackageManager.getLaunchIntentForPackage(info.packageName) != null, context);
if (!mShowAllApps && !applicationInfo.isLaunchable) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:7.0.0-beta02'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip

0 comments on commit f20187f

Please sign in to comment.