if incoming repo already exists and is enabled, show Toast and hide dialog

No need to show the dialog if it won't let you take any action.
This commit is contained in:
Hans-Christoph Steiner 2013-12-02 20:19:50 -05:00
parent c7b076e5ea
commit f9d2fbb0ae
2 changed files with 12 additions and 4 deletions

View File

@ -77,6 +77,7 @@
<string name="repo_exists">This repo already exists!</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_alrt">The list of used repositories has

View File

@ -48,6 +48,7 @@ import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import org.fdroid.fdroid.DB.Repo;
import org.fdroid.fdroid.compat.ActionBarCompat;
@ -307,10 +308,16 @@ public class ManageRepo extends ListActivity {
addButton.setText(R.string.add_key);
positiveAction = PositiveAction.ADD_NEW;
} else if (newFingerprint == null || newFingerprint.equals(repo.fingerprint)) {
// this entry already exists, offer to enable it
overwriteMessage.setText(R.string.repo_exists_enable);
addButton.setText(R.string.enable);
positiveAction = PositiveAction.ENABLE;
// this entry already exists and is not enabled, offer to enable it
if (repo.inuse) {
alrt.dismiss();
Toast.makeText(this, R.string.repo_exists_and_enabled, Toast.LENGTH_LONG).show();
return;
} else {
overwriteMessage.setText(R.string.repo_exists_enable);
addButton.setText(R.string.enable);
positiveAction = PositiveAction.ENABLE;
}
} else {
// same address with different fingerprint, this could be
// malicious, so force the user to manually delete the repo