Skip to content

Commit

Permalink
Disable Google Play link on system apps
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Jun 4, 2015
1 parent 26df5dd commit 951afe1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
28 changes: 19 additions & 9 deletions app/src/main/java/com/javiersantos/mlmanager/AppActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

public class AppActivity extends AppCompatActivity {
// Load Settings
AppPreferences appPreferences;
private AppPreferences appPreferences;

// General variables
AppInfo appInfo;
private AppInfo appInfo;

// Configuration variables
private int UNINSTALL_REQUEST_CODE = 1;
Expand Down Expand Up @@ -75,7 +75,9 @@ public void onClick(View view) {
private void setScreenElements() {
TextView header = (TextView) findViewById(R.id.header);
ImageView icon = (ImageView) findViewById(R.id.app_icon);
ImageView icon_googleplay = (ImageView) findViewById(R.id.app_googleplay);
TextView name = (TextView) findViewById(R.id.app_name);
TextView version = (TextView) findViewById(R.id.app_version);
TextView apk = (TextView) findViewById(R.id.app_apk);
CardView googleplay = (CardView) findViewById(R.id.id_card);
CardView start = (CardView) findViewById(R.id.start_card);
Expand All @@ -87,17 +89,24 @@ private void setScreenElements() {
icon.setImageDrawable(appInfo.getIcon());
name.setText(appInfo.getName());
apk.setText(appInfo.getAPK());
version.setText(appInfo.getVersion());

// Header
header.setBackgroundColor(appPreferences.getPrimaryColorPref());

// CardView
googleplay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(UtilsApp.goToGooglePlay(appInfo.getAPK()));
}
});
if (appInfo.isSystem()) {
icon_googleplay.setVisibility(View.GONE);
googleplay.setForeground(null);
} else {
icon_googleplay.setVisibility(View.VISIBLE);
googleplay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(UtilsApp.goToGooglePlay(appInfo.getAPK()));
}
});
}
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -176,8 +185,9 @@ private void getInitialConfiguration() {
String appData = getIntent().getStringExtra("app_data");
Bitmap bitmap = (Bitmap) this.getIntent().getParcelableExtra("app_icon");
Drawable appIcon = (Drawable) new BitmapDrawable(getResources(), bitmap);
Boolean appIsSystem = getIntent().getExtras().getBoolean("app_isSystem");

appInfo = new AppInfo(appName, appApk, appVersion, appSource, appData, appIcon);
appInfo = new AppInfo(appName, appApk, appVersion, appSource, appData, appIcon, appIsSystem);
}

@Override
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/com/javiersantos/mlmanager/AppInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ public class AppInfo {
private String source;
private String data;
private Drawable icon;
private Boolean system;

public AppInfo(String name, String apk, String version, String source, String data, Drawable icon) {
public AppInfo(String name, String apk, String version, String source, String data, Drawable icon, Boolean isSystem) {
this.name = name;
this.apk = apk;
this.version = version;
this.source = source;
this.data = data;
this.icon = icon;
this.system = isSystem;
}

public String getName() {
Expand All @@ -43,4 +45,8 @@ public Drawable getIcon() {
return icon;
}

public Boolean isSystem() {
return system;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ protected void onProgressUpdate(PackageInfo... values) {
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
appAdapter = new AppAdapter(createList(appListName, appListAPK, appListVersion, appListSource, appListData, appListIcon), context);
appSystemAdapter = new AppAdapter(createList(appSystemListName, appSystemListAPK, appSystemListVersion, appSystemListSource, appSystemListData, appSystemListIcon), context);
appAdapter = new AppAdapter(createList(appListName, appListAPK, appListVersion, appListSource, appListData, appListIcon, false), context);
appSystemAdapter = new AppAdapter(createList(appSystemListName, appSystemListAPK, appSystemListVersion, appSystemListSource, appSystemListData, appSystemListIcon, true), context);

recyclerView.setAdapter(appAdapter);
progressWheel.setVisibility(View.GONE);
Expand All @@ -196,10 +196,10 @@ private void setAppDir() {
}
}

private List<AppInfo> createList(List<String> apps, List<String> apks, List<String> versions, List<String> sources, List<String> data, List<Drawable> icons) {
private List<AppInfo> createList(List<String> apps, List<String> apks, List<String> versions, List<String> sources, List<String> data, List<Drawable> icons, Boolean isSystem) {
List<AppInfo> res = new ArrayList<AppInfo>();
for (int i=0; i < apps.size(); i++) {
AppInfo appInfo = new AppInfo(apps.get(i), apks.get(i), versions.get(i), sources.get(i), data.get(i), icons.get(i));
AppInfo appInfo = new AppInfo(apps.get(i), apks.get(i), versions.get(i), sources.get(i), data.get(i), icons.get(i), isSystem);
res.add(appInfo);
}

Expand Down

0 comments on commit 951afe1

Please sign in to comment.