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:layout_height="wrap_content"
|
||||||
android:orientation="vertical" >
|
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
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ems="20"
|
|
||||||
android:text="@string/repo_add_url" />
|
android:text="@string/repo_add_url" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/edit_uri"
|
android:id="@+id/edit_uri"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ems="20"
|
|
||||||
android:inputType="textUri"
|
android:inputType="textUri"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="https://" />
|
android:text="https://" />
|
||||||
@ -22,7 +31,6 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ems="20"
|
|
||||||
android:text="@string/repo_add_fingerprint" />
|
android:text="@string/repo_add_fingerprint" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
@ -30,19 +38,17 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:digits="0123456789ABCDEFabcedf: "
|
android:digits="0123456789ABCDEFabcedf: "
|
||||||
android:ems="20"
|
|
||||||
android:inputType="textNoSuggestions"
|
android:inputType="textNoSuggestions"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:typeface="monospace" />
|
android:typeface="monospace" />
|
||||||
|
|
||||||
<TextView
|
<CheckBox
|
||||||
android:id="@+id/repo_alert"
|
android:id="@+id/overwrite_repo"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableLeft="@android:drawable/ic_dialog_alert"
|
android:padding="20dp"
|
||||||
android:gravity="center"
|
android:text="@string/repo_overwrite"
|
||||||
android:textColor="@color/red"
|
android:textAppearance="@android:style/TextAppearance.Medium"
|
||||||
android:textAppearance="@android:style/TextAppearance.Large"
|
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout><!--
|
</LinearLayout><!--
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
<string name="repo_add_url">Repository address</string>
|
<string name="repo_add_url">Repository address</string>
|
||||||
<string name="repo_add_fingerprint">fingerprint (optional)</string>
|
<string name="repo_add_fingerprint">fingerprint (optional)</string>
|
||||||
<string name="repo_exists">This repo already exists!</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
|
<string name="repo_alrt">The list of used repositories has
|
||||||
changed.\nDo you
|
changed.\nDo you
|
||||||
|
@ -43,6 +43,9 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.SimpleAdapter;
|
import android.widget.SimpleAdapter;
|
||||||
@ -284,9 +287,19 @@ public class ManageRepo extends ListActivity {
|
|||||||
List<Repo> repos = getRepos();
|
List<Repo> repos = getRepos();
|
||||||
Repo repo = getRepo(uriString, repos);
|
Repo repo = getRepo(uriString, repos);
|
||||||
if (repo != null) {
|
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.setVisibility(0);
|
||||||
tv.setText(R.string.repo_exists);
|
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 and fingerprint match, then enable existing repo
|
||||||
// TODO if address matches but fingerprint doesn't, handle this with extra widgets
|
// TODO if address matches but fingerprint doesn't, handle this with extra widgets
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user