include repo name in messages in "App Repo" dialog
This should hopefully make things a little clearer to the user.
This commit is contained in:
		
							parent
							
								
									759c3b90fc
								
							
						
					
					
						commit
						89e04cc078
					
				| @ -275,7 +275,7 @@ public class ManageReposActivity extends AppCompatActivity implements LoaderMana | ||||
|                             try { | ||||
|                                 url = normalizeUrl(url); | ||||
|                             } catch (URISyntaxException e) { | ||||
|                                 invalidUrl(); | ||||
|                                 invalidUrl(null); | ||||
|                                 return; | ||||
|                             } | ||||
| 
 | ||||
| @ -364,69 +364,77 @@ public class ManageReposActivity extends AppCompatActivity implements LoaderMana | ||||
|             final Repo repo = !TextUtils.isEmpty(uri) ? RepoProvider.Helper.findByAddress(context, uri) : null; | ||||
| 
 | ||||
|             if (repo == null) { | ||||
|                 repoDoesntExist(); | ||||
|                 repoDoesntExist(repo); | ||||
|             } else { | ||||
|                 if (repo.isSwap) { | ||||
|                     repoIsSwap(); | ||||
|                     repoIsSwap(repo); | ||||
|                 } else if (repo.fingerprint == null && fingerprint.length() > 0) { | ||||
|                     upgradingToSigned(); | ||||
|                     upgradingToSigned(repo); | ||||
|                 } else if (repo.fingerprint != null && !repo.fingerprint.equalsIgnoreCase(fingerprint)) { | ||||
|                     repoFingerprintDoesntMatch(); | ||||
|                     repoFingerprintDoesntMatch(repo); | ||||
|                 } else { | ||||
|                     // Could be either an unsigned repo, and no fingerprint was supplied, | ||||
|                     // or it could be a signed repo with a matching fingerprint. | ||||
|                     if (repo.inuse) { | ||||
|                         repoExistsAndEnabled(); | ||||
|                         repoExistsAndEnabled(repo); | ||||
|                     } else { | ||||
|                         repoExistsAndDisabled(); | ||||
|                         repoExistsAndDisabled(repo); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         private void repoDoesntExist() { | ||||
|             updateUi(AddRepoState.DOESNT_EXIST, 0, false, R.string.repo_add_add, true); | ||||
|         private void repoDoesntExist(Repo repo) { | ||||
|             updateUi(repo, AddRepoState.DOESNT_EXIST, 0, false, R.string.repo_add_add, true); | ||||
|         } | ||||
| 
 | ||||
|         private void repoIsSwap() { | ||||
|             updateUi(AddRepoState.IS_SWAP, 0, false, R.string.repo_add_add, true); | ||||
|         private void repoIsSwap(Repo repo) { | ||||
|             updateUi(repo, AddRepoState.IS_SWAP, 0, false, R.string.repo_add_add, true); | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|          * Same address with different fingerprint, this could be malicious, so display a message | ||||
|          * force the user to manually delete the repo before adding this one. | ||||
|          */ | ||||
|         private void repoFingerprintDoesntMatch() { | ||||
|             updateUi(AddRepoState.EXISTS_FINGERPRINT_MISMATCH, R.string.repo_delete_to_overwrite, | ||||
|         private void repoFingerprintDoesntMatch(Repo repo) { | ||||
|             updateUi(repo, AddRepoState.EXISTS_FINGERPRINT_MISMATCH, | ||||
|                     R.string.repo_delete_to_overwrite, | ||||
|                     true, R.string.overwrite, false); | ||||
|         } | ||||
| 
 | ||||
|         private void invalidUrl() { | ||||
|             updateUi(AddRepoState.INVALID_URL, R.string.invalid_url, true, | ||||
|         private void invalidUrl(Repo repo) { | ||||
|             updateUi(repo, AddRepoState.INVALID_URL, R.string.invalid_url, true, | ||||
|                     R.string.repo_add_add, false); | ||||
|         } | ||||
| 
 | ||||
|         private void repoExistsAndDisabled() { | ||||
|             updateUi(AddRepoState.EXISTS_DISABLED, | ||||
|         private void repoExistsAndDisabled(Repo repo) { | ||||
|             updateUi(repo, AddRepoState.EXISTS_DISABLED, | ||||
|                     R.string.repo_exists_enable, false, R.string.enable, true); | ||||
|         } | ||||
| 
 | ||||
|         private void repoExistsAndEnabled() { | ||||
|             updateUi(AddRepoState.EXISTS_ENABLED, R.string.repo_exists_and_enabled, false, | ||||
|         private void repoExistsAndEnabled(Repo repo) { | ||||
|             updateUi(repo, AddRepoState.EXISTS_ENABLED, R.string.repo_exists_and_enabled, false, | ||||
|                     R.string.ok, true); | ||||
|         } | ||||
| 
 | ||||
|         private void upgradingToSigned() { | ||||
|             updateUi(AddRepoState.EXISTS_UPGRADABLE_TO_SIGNED, R.string.repo_exists_add_fingerprint, | ||||
|         private void repoExistsAddMirror(Repo repo) { | ||||
|             updateUi(repo, AddRepoState.EXISTS_ADD_MIRROR, R.string.repo_exists_add_mirror, false, | ||||
|                     R.string.repo_add_mirror, true); | ||||
|         } | ||||
| 
 | ||||
|         private void upgradingToSigned(Repo repo) { | ||||
|             updateUi(repo, AddRepoState.EXISTS_UPGRADABLE_TO_SIGNED, R.string.repo_exists_add_fingerprint, | ||||
|                     false, R.string.add_key, true); | ||||
|         } | ||||
| 
 | ||||
|         private void updateUi(AddRepoState state, int messageRes, boolean redMessage, int addTextRes, boolean addEnabled) { | ||||
|         @DebugLog | ||||
|         private void updateUi(Repo repo, AddRepoState state, int messageRes, boolean redMessage, int addTextRes, | ||||
|                               boolean addEnabled) { | ||||
|             if (addRepoState != state) { | ||||
|                 addRepoState = state; | ||||
| 
 | ||||
|                 if (messageRes > 0) { | ||||
|                     overwriteMessage.setText(messageRes); | ||||
|                     overwriteMessage.setText(String.format(getString(messageRes), repo.name)); | ||||
|                     overwriteMessage.setVisibility(View.VISIBLE); | ||||
|                     if (redMessage) { | ||||
|                         overwriteMessage.setTextColor(getResources().getColor(R.color.red)); | ||||
|  | ||||
| @ -134,12 +134,10 @@ This often occurs with apps installed via Google Play or other sources, if they | ||||
| 
 | ||||
|     <string name="repo_add_url">Repository address</string> | ||||
|     <string name="repo_add_fingerprint">Fingerprint (optional)</string> | ||||
|     <string name="repo_exists_add_fingerprint">This repo is already setup, this will add new key information.</string> | ||||
|     <string name="repo_exists_enable">This repo is already setup, confirm that you want to re-enable it.</string> | ||||
|     <string name="repo_exists_and_enabled">The incoming repo is already setup and enabled.</string> | ||||
|     <string name="repo_delete_to_overwrite">You must first delete this repo before you can add one with a different | ||||
|         key. | ||||
|     </string> | ||||
|     <string name="repo_exists_add_fingerprint">%1$s is already setup, this will add new key information.</string> | ||||
|     <string name="repo_exists_enable">%1$s is already setup, confirm that you want to re-enable it.</string> | ||||
|     <string name="repo_exists_and_enabled">%1$s is already setup and enabled.</string> | ||||
|     <string name="repo_delete_to_overwrite">First delete %1$s in order to add this with a conflicting key.</string> | ||||
|     <string name="bad_fingerprint">Bad fingerprint</string> | ||||
|     <string name="invalid_url">This is not a valid URL.</string> | ||||
|     <string name="malformed_repo_uri">Ignoring malformed repo URI: %s</string> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Hans-Christoph Steiner
						Hans-Christoph Steiner