UI tweaks for manage repos.

Padding for add repo dialog.
Move cursor to end of text input for new repo dialog.
This commit is contained in:
Peter Serwylo 2013-12-12 10:50:01 +11:00
parent 42d21bcbe9
commit 8306007f84
2 changed files with 13 additions and 5 deletions

View File

@ -2,7 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
android:orientation="vertical"
android:padding="6dp">
<TextView
android:layout_width="match_parent"

View File

@ -46,6 +46,7 @@ import java.util.*;
public class ManageRepo extends ListActivity {
private static final String DEFAULT_NEW_REPO_TEXT = "https://";
private final int ADD_REPO = 1;
private final int UPDATE_REPOS = 2;
@ -275,7 +276,7 @@ public class ManageRepo extends ListActivity {
final EditText fingerprintEditText = (EditText) view.findViewById(R.id.edit_fingerprint);
List<Repo> repos = getRepos();
final Repo repo = getRepoByAddress(newAddress, repos);
final Repo repo = newAddress != null && isImportingRepo ? getRepoByAddress(newAddress, repos) : null;
alrt.setIcon(android.R.drawable.ic_menu_add);
alrt.setTitle(getString(R.string.repo_add_title));
@ -350,10 +351,16 @@ public class ManageRepo extends ListActivity {
}
}
if (newAddress != null)
uriEditText.setText(newAddress);
if (newFingerprint != null)
fingerprintEditText.setText(newFingerprint);
if (newAddress != null) {
// This trick of emptying text then appending,
// rather than just setting in the first place,
// is neccesary to move the cursor to the end of the input.
uriEditText.setText("");
uriEditText.append(newAddress);
}
}
/**
@ -430,7 +437,7 @@ public class ManageRepo extends ListActivity {
}
if (text == null) {
text = "https://";
text = DEFAULT_NEW_REPO_TEXT;
}
return text;
}