add CheckBox to enable overwriting of existing repos when adding new ones
The "Add" button is disabled until the user turns overwrite on. It should prevent accidental overwriting, but I imagine this could be handled better.
This commit is contained in:
parent
14c525e7ff
commit
36da418660
@ -4,17 +4,26 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repo_alert"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@android:drawable/ic_dialog_alert"
|
||||
android:gravity="center"
|
||||
android:text="@string/repo_exists"
|
||||
android:textAppearance="@android:style/TextAppearance.Large"
|
||||
android:textColor="@color/red"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="20"
|
||||
android:text="@string/repo_add_url" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_uri"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="20"
|
||||
android:inputType="textUri"
|
||||
android:maxLines="1"
|
||||
android:text="https://" />
|
||||
@ -22,7 +31,6 @@
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="20"
|
||||
android:text="@string/repo_add_fingerprint" />
|
||||
|
||||
<EditText
|
||||
@ -30,19 +38,17 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits="0123456789ABCDEFabcedf: "
|
||||
android:ems="20"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:maxLines="1"
|
||||
android:typeface="monospace" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repo_alert"
|
||||
<CheckBox
|
||||
android:id="@+id/overwrite_repo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@android:drawable/ic_dialog_alert"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/red"
|
||||
android:textAppearance="@android:style/TextAppearance.Large"
|
||||
android:padding="20dp"
|
||||
android:text="@string/repo_overwrite"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout><!--
|
||||
|
@ -72,6 +72,7 @@
|
||||
<string name="repo_add_url">Repository address</string>
|
||||
<string name="repo_add_fingerprint">fingerprint (optional)</string>
|
||||
<string name="repo_exists">This repo already exists!</string>
|
||||
<string name="repo_overwrite">Overwrite the existing repo?</string>
|
||||
|
||||
<string name="repo_alrt">The list of used repositories has
|
||||
changed.\nDo you
|
||||
|
@ -43,6 +43,9 @@ import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
@ -284,9 +287,19 @@ public class ManageRepo extends ListActivity {
|
||||
List<Repo> repos = getRepos();
|
||||
Repo repo = getRepo(uriString, repos);
|
||||
if (repo != null) {
|
||||
final TextView tv = (TextView) view.findViewById(R.id.repo_alert);
|
||||
TextView tv = (TextView) view.findViewById(R.id.repo_alert);
|
||||
tv.setVisibility(0);
|
||||
tv.setText(R.string.repo_exists);
|
||||
final Button addButton = alrt.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
addButton.setEnabled(false);
|
||||
final CheckBox overwriteCheckBox = (CheckBox) view.findViewById(R.id.overwrite_repo);
|
||||
overwriteCheckBox.setVisibility(0);
|
||||
overwriteCheckBox.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
addButton.setEnabled(overwriteCheckBox.isChecked());
|
||||
}
|
||||
});
|
||||
// TODO if address and fingerprint match, then enable existing repo
|
||||
// TODO if address matches but fingerprint doesn't, handle this with extra widgets
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user