Don't refill description and other static stuff when returning from install/uninstall
This commit is contained in:
		
							parent
							
								
									93326a90d1
								
							
						
					
					
						commit
						419ea5510d
					
				@ -172,6 +172,7 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
    private boolean stateRetained;
 | 
					    private boolean stateRetained;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    LinearLayout headerView;
 | 
					    LinearLayout headerView;
 | 
				
			||||||
 | 
					    View infoView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Context mctx = this;
 | 
					    private Context mctx = this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -202,6 +203,20 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
        ApkListAdapter la = new ApkListAdapter(this, null);
 | 
					        ApkListAdapter la = new ApkListAdapter(this, null);
 | 
				
			||||||
        setListAdapter(la);
 | 
					        setListAdapter(la);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mPm = getPackageManager();
 | 
				
			||||||
 | 
					        // Get the preferences we're going to use in this Activity...
 | 
				
			||||||
 | 
					        AppDetails old = (AppDetails) getLastNonConfigurationInstance();
 | 
				
			||||||
 | 
					        if (old != null) {
 | 
				
			||||||
 | 
					            copyState(old);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            if (!reset()) {
 | 
				
			||||||
 | 
					                finish();
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            resetRequired = false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        startViews();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean pref_expert;
 | 
					    private boolean pref_expert;
 | 
				
			||||||
@ -212,23 +227,6 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
    private Signature mInstalledSignature;
 | 
					    private Signature mInstalledSignature;
 | 
				
			||||||
    private String mInstalledSigID;
 | 
					    private String mInstalledSigID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    protected void onStart() {
 | 
					 | 
				
			||||||
        super.onStart();
 | 
					 | 
				
			||||||
        mPm = getPackageManager();
 | 
					 | 
				
			||||||
        // Get the preferences we're going to use in this Activity...
 | 
					 | 
				
			||||||
        SharedPreferences prefs = PreferenceManager
 | 
					 | 
				
			||||||
                .getDefaultSharedPreferences(getBaseContext());
 | 
					 | 
				
			||||||
        pref_expert = prefs.getBoolean("expert", false);
 | 
					 | 
				
			||||||
        pref_permissions = prefs.getBoolean("showPermissions", false);
 | 
					 | 
				
			||||||
        AppDetails old = (AppDetails) getLastNonConfigurationInstance();
 | 
					 | 
				
			||||||
        if (old != null) {
 | 
					 | 
				
			||||||
            copyState(old);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            resetRequired = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onResume() {
 | 
					    protected void onResume() {
 | 
				
			||||||
        super.onResume();
 | 
					        super.onResume();
 | 
				
			||||||
@ -239,7 +237,11 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            resetRequired = false;
 | 
					            resetRequired = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        resetViews();
 | 
					        SharedPreferences prefs = PreferenceManager
 | 
				
			||||||
 | 
					                .getDefaultSharedPreferences(getBaseContext());
 | 
				
			||||||
 | 
					        pref_expert = prefs.getBoolean("expert", false);
 | 
				
			||||||
 | 
					        pref_permissions = prefs.getBoolean("showPermissions", false);
 | 
				
			||||||
 | 
					        updateViews();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        MenuManager.create(this).invalidateOptionsMenu();
 | 
					        MenuManager.create(this).invalidateOptionsMenu();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -343,11 +345,10 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void resetViews() {
 | 
					    private void startViews() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Repopulate the list...
 | 
					        // Populate the list...
 | 
				
			||||||
        ApkListAdapter la = (ApkListAdapter) getListAdapter();
 | 
					        ApkListAdapter la = (ApkListAdapter) getListAdapter();
 | 
				
			||||||
        la.items.clear();
 | 
					 | 
				
			||||||
        for (DB.Apk apk : app.apks)
 | 
					        for (DB.Apk apk : app.apks)
 | 
				
			||||||
            la.addItem(apk);
 | 
					            la.addItem(apk);
 | 
				
			||||||
        la.notifyDataSetChanged();
 | 
					        la.notifyDataSetChanged();
 | 
				
			||||||
@ -356,7 +357,7 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
        // ends, and the description) into the appropriate place, if we're in
 | 
					        // ends, and the description) into the appropriate place, if we're in
 | 
				
			||||||
        // landscape mode. In portrait mode, we put it in the listview's
 | 
					        // landscape mode. In portrait mode, we put it in the listview's
 | 
				
			||||||
        // header..
 | 
					        // header..
 | 
				
			||||||
        View infoView = View.inflate(this, R.layout.appinfo, null);
 | 
					        infoView = View.inflate(this, R.layout.appinfo, null);
 | 
				
			||||||
        LinearLayout landparent = (LinearLayout) findViewById(R.id.landleft);
 | 
					        LinearLayout landparent = (LinearLayout) findViewById(R.id.landleft);
 | 
				
			||||||
        headerView.removeAllViews();
 | 
					        headerView.removeAllViews();
 | 
				
			||||||
        if (landparent != null) {
 | 
					        if (landparent != null) {
 | 
				
			||||||
@ -382,15 +383,11 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
        tv = (TextView) findViewById(R.id.license);
 | 
					        tv = (TextView) findViewById(R.id.license);
 | 
				
			||||||
        tv.setText(app.license);
 | 
					        tv.setText(app.license);
 | 
				
			||||||
        tv = (TextView) findViewById(R.id.status);
 | 
					        tv = (TextView) findViewById(R.id.status);
 | 
				
			||||||
        if (app.installedVersion == null)
 | 
					 | 
				
			||||||
            tv.setText(getString(R.string.details_notinstalled));
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
            tv.setText(getString(R.string.details_installed,
 | 
					 | 
				
			||||||
                    app.installedVersion));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tv = (TextView) infoView.findViewById(R.id.description);
 | 
					        tv = (TextView) infoView.findViewById(R.id.description);
 | 
				
			||||||
        tv.setMovementMethod(LinkMovementMethod.getInstance());
 | 
					        tv.setMovementMethod(LinkMovementMethod.getInstance());
 | 
				
			||||||
        tv.setTextIsSelectable(true);
 | 
					        tv.setTextIsSelectable(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Need this to add the unimplemented support for ordered and unordered
 | 
					        // Need this to add the unimplemented support for ordered and unordered
 | 
				
			||||||
        // lists to Html.fromHtml().
 | 
					        // lists to Html.fromHtml().
 | 
				
			||||||
        class HtmlTagHandler implements TagHandler {
 | 
					        class HtmlTagHandler implements TagHandler {
 | 
				
			||||||
@ -421,14 +418,54 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
        tv.setText(Html.fromHtml(app.detail_description, null,
 | 
					        tv.setText(Html.fromHtml(app.detail_description, null,
 | 
				
			||||||
                new HtmlTagHandler()));
 | 
					                new HtmlTagHandler()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tv = (TextView) infoView.findViewById(R.id.appid);
 | 
				
			||||||
 | 
					        tv.setText(app.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tv = (TextView) infoView.findViewById(R.id.summary);
 | 
					        tv = (TextView) infoView.findViewById(R.id.summary);
 | 
				
			||||||
        tv.setText(app.summary);
 | 
					        tv.setText(app.summary);
 | 
				
			||||||
        tv.setTextIsSelectable(true);
 | 
					        tv.setTextIsSelectable(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tv = (TextView) infoView.findViewById(R.id.permissions_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        CommaSeparatedList permsList = app.apks.get(0).detail_permissions;
 | 
				
			||||||
 | 
					        if (permsList == null) {
 | 
				
			||||||
 | 
					            tv.setText(getString(R.string.no_permissions) + '\n');
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Iterator<String> permissions = permsList.iterator();
 | 
				
			||||||
 | 
					            StringBuilder sb = new StringBuilder();
 | 
				
			||||||
 | 
					            while (permissions.hasNext()) {
 | 
				
			||||||
 | 
					                String permissionName = permissions.next();
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    Permission permission = new Permission(this, permissionName);
 | 
				
			||||||
 | 
					                    sb.append("\t• " + permission.getName() + '\n');
 | 
				
			||||||
 | 
					                } catch (NameNotFoundException e) {
 | 
				
			||||||
 | 
					                    Log.d( "FDroid",
 | 
				
			||||||
 | 
					                            "Can't find permission '" + permissionName + "'");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            tv.setText(sb.toString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        tv = (TextView) infoView.findViewById(R.id.permissions);
 | 
				
			||||||
 | 
					        tv.setText(getString(
 | 
				
			||||||
 | 
					                R.string.permissions_for_long, app.apks.get(0).version));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void updateViews() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Refresh the list...
 | 
				
			||||||
 | 
					        ApkListAdapter la = (ApkListAdapter) getListAdapter();
 | 
				
			||||||
 | 
					        la.notifyDataSetChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        TextView tv = (TextView) findViewById(R.id.status);
 | 
				
			||||||
 | 
					        if (app.installedVersion == null)
 | 
				
			||||||
 | 
					            tv.setText(getString(R.string.details_notinstalled));
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            tv.setText(getString(R.string.details_installed,
 | 
				
			||||||
 | 
					                    app.installedVersion));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tv = (TextView) infoView.findViewById(R.id.appid);
 | 
					        tv = (TextView) infoView.findViewById(R.id.appid);
 | 
				
			||||||
        if (pref_expert) {
 | 
					        if (pref_expert) {
 | 
				
			||||||
            tv.setVisibility(View.VISIBLE);
 | 
					            tv.setVisibility(View.VISIBLE);
 | 
				
			||||||
            tv.setText(app.id);
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            tv.setVisibility(View.GONE);
 | 
					            tv.setVisibility(View.GONE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -441,34 +478,18 @@ public class AppDetails extends ListActivity {
 | 
				
			|||||||
            tv.setVisibility(View.GONE);
 | 
					            tv.setVisibility(View.GONE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tv = (TextView) infoView.findViewById(R.id.permissions_list);
 | 
					 | 
				
			||||||
        if (pref_permissions) {
 | 
					        if (pref_permissions) {
 | 
				
			||||||
            CommaSeparatedList permsList = app.apks.get(0).detail_permissions;
 | 
					 | 
				
			||||||
            if (permsList == null) {
 | 
					 | 
				
			||||||
                tv.setText(getString(R.string.no_permissions) + '\n');
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                Iterator<String> permissions = permsList.iterator();
 | 
					 | 
				
			||||||
                StringBuilder sb = new StringBuilder();
 | 
					 | 
				
			||||||
                while (permissions.hasNext()) {
 | 
					 | 
				
			||||||
                    String permissionName = permissions.next();
 | 
					 | 
				
			||||||
                    try {
 | 
					 | 
				
			||||||
                        Permission permission = new Permission(this, permissionName);
 | 
					 | 
				
			||||||
                        sb.append("\t• " + permission.getName() + '\n');
 | 
					 | 
				
			||||||
                    } catch (NameNotFoundException e) {
 | 
					 | 
				
			||||||
                        Log.d( "FDroid",
 | 
					 | 
				
			||||||
                                "Can't find permission '" + permissionName + "'");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                tv.setText(sb.toString());
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            tv = (TextView) infoView.findViewById(R.id.permissions);
 | 
					            tv = (TextView) infoView.findViewById(R.id.permissions);
 | 
				
			||||||
            tv.setText(getString(
 | 
					            tv.setVisibility(View.VISIBLE);
 | 
				
			||||||
                    R.string.permissions_for_long, app.apks.get(0).version));
 | 
					            tv = (TextView) infoView.findViewById(R.id.permissions_list);
 | 
				
			||||||
 | 
					            tv.setVisibility(View.VISIBLE);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            tv.setVisibility(View.GONE);
 | 
					 | 
				
			||||||
            tv = (TextView) infoView.findViewById(R.id.permissions);
 | 
					            tv = (TextView) infoView.findViewById(R.id.permissions);
 | 
				
			||||||
            tv.setVisibility(View.GONE);
 | 
					            tv.setVisibility(View.GONE);
 | 
				
			||||||
 | 
					            tv = (TextView) infoView.findViewById(R.id.permissions_list);
 | 
				
			||||||
 | 
					            tv.setVisibility(View.GONE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 | 
				
			|||||||
@ -647,8 +647,7 @@ public class DB {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (Apk apk : app.apks) {
 | 
					        for (Apk apk : app.apks) {
 | 
				
			||||||
            boolean isPopulated = apk.detail_hash != null;
 | 
					            if (apk.detail_hash == null) {
 | 
				
			||||||
            if (!isPopulated) {
 | 
					 | 
				
			||||||
                populateApkDetails(apk, apkRepo);
 | 
					                populateApkDetails(apk, apkRepo);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user