fix #1642
This commit is contained in:
parent
083e3ead75
commit
28863cf88f
@ -74,7 +74,6 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
private Repo repo;
|
||||
private long repoId;
|
||||
private View repoView;
|
||||
|
||||
private String shareUrl;
|
||||
|
||||
/**
|
||||
@ -83,9 +82,7 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
* Flex, there was a thing called "ViewStates" for exactly this. Wonder if
|
||||
* that exists in Android?
|
||||
*/
|
||||
private static void setMultipleViewVisibility(View parent,
|
||||
int[] viewIds,
|
||||
int visibility) {
|
||||
private static void setMultipleViewVisibility(View parent, int[] viewIds, int visibility) {
|
||||
for (int viewId : viewIds) {
|
||||
parent.findViewById(viewId).setVisibility(visibility);
|
||||
}
|
||||
@ -97,13 +94,13 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
((FDroidApp) getApplication()).applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.repodetails);
|
||||
setContentView(R.layout.activity_repo_details);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
repoView = findViewById(R.id.repoView);
|
||||
repoView = findViewById(R.id.repo_view);
|
||||
|
||||
repoId = getIntent().getLongExtra(ARG_REPO_ID, 0);
|
||||
final String[] projection = {
|
||||
@ -115,7 +112,7 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
};
|
||||
repo = RepoProvider.Helper.findById(this, repoId, projection);
|
||||
|
||||
TextView inputUrl = (TextView) findViewById(R.id.input_repo_url);
|
||||
TextView inputUrl = findViewById(R.id.input_repo_url);
|
||||
inputUrl.setText(repo.address);
|
||||
|
||||
if (repo.address.startsWith("content://")) {
|
||||
@ -170,8 +167,7 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
|
||||
private void processIntent(Intent i) {
|
||||
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) {
|
||||
Parcelable[] rawMsgs =
|
||||
i.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
|
||||
Parcelable[] rawMsgs = i.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
|
||||
NdefMessage msg = (NdefMessage) rawMsgs[0];
|
||||
String url = new String(msg.getRecords()[0].getPayload());
|
||||
Utils.debugLog(TAG, "Got this URL: " + url);
|
||||
@ -310,9 +306,9 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
|
||||
private void setupCredentials(View parent, Repo repo) {
|
||||
|
||||
TextView usernameLabel = (TextView) parent.findViewById(R.id.label_username);
|
||||
TextView username = (TextView) parent.findViewById(R.id.text_username);
|
||||
Button changePassword = (Button) parent.findViewById(R.id.button_edit_credentials);
|
||||
TextView usernameLabel = parent.findViewById(R.id.label_username);
|
||||
TextView username = parent.findViewById(R.id.text_username);
|
||||
Button changePassword = parent.findViewById(R.id.button_edit_credentials);
|
||||
|
||||
if (TextUtils.isEmpty(repo.username)) {
|
||||
usernameLabel.setVisibility(View.GONE);
|
||||
@ -328,13 +324,11 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void updateRepoView() {
|
||||
|
||||
if (repo.hasBeenUpdated()) {
|
||||
updateViewForExistingRepo(repoView);
|
||||
} else {
|
||||
updateViewForNewRepo(repoView);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateViewForNewRepo(View repoView) {
|
||||
@ -346,34 +340,36 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
setMultipleViewVisibility(repoView, SHOW_IF_EXISTS, View.VISIBLE);
|
||||
setMultipleViewVisibility(repoView, HIDE_IF_EXISTS, View.GONE);
|
||||
|
||||
TextView name = (TextView) repoView.findViewById(R.id.text_repo_name);
|
||||
TextView numApps = (TextView) repoView.findViewById(R.id.text_num_apps);
|
||||
TextView lastUpdated = (TextView) repoView.findViewById(R.id.text_last_update);
|
||||
TextView name = repoView.findViewById(R.id.text_repo_name);
|
||||
TextView numApps = repoView.findViewById(R.id.text_num_apps);
|
||||
TextView lastUpdated = repoView.findViewById(R.id.text_last_update);
|
||||
|
||||
if (repo.mirrors != null) {
|
||||
TextView officialMirrorsLabel = (TextView) repoView.findViewById(R.id.label_official_mirrors);
|
||||
TextView officialMirrorsLabel = repoView.findViewById(R.id.label_official_mirrors);
|
||||
officialMirrorsLabel.setVisibility(View.VISIBLE);
|
||||
TextView officialMirrorsText = (TextView) repoView.findViewById(R.id.text_official_mirrors);
|
||||
TextView officialMirrorsText = repoView.findViewById(R.id.text_official_mirrors);
|
||||
officialMirrorsText.setVisibility(View.VISIBLE);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String url : repo.mirrors) {
|
||||
builder.append("◦ ");
|
||||
builder.append("• ");
|
||||
builder.append(url);
|
||||
builder.append('\n');
|
||||
}
|
||||
builder.setLength(Math.max(builder.length() - 1, 0));
|
||||
officialMirrorsText.setText(builder.toString());
|
||||
}
|
||||
if (repo.userMirrors != null) {
|
||||
TextView userMirrorsLabel = (TextView) repoView.findViewById(R.id.label_user_mirrors);
|
||||
TextView userMirrorsLabel = repoView.findViewById(R.id.label_user_mirrors);
|
||||
userMirrorsLabel.setVisibility(View.VISIBLE);
|
||||
TextView userMirrorsText = (TextView) repoView.findViewById(R.id.text_user_mirrors);
|
||||
TextView userMirrorsText = repoView.findViewById(R.id.text_user_mirrors);
|
||||
userMirrorsText.setVisibility(View.VISIBLE);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String url : repo.userMirrors) {
|
||||
builder.append("◦ ");
|
||||
builder.append("• ");
|
||||
builder.append(url);
|
||||
builder.append('\n');
|
||||
}
|
||||
builder.setLength(Math.max(builder.length() - 1, 0));
|
||||
userMirrorsText.setText(builder.toString());
|
||||
}
|
||||
|
||||
@ -419,11 +415,10 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void showChangePasswordDialog(final View parentView) {
|
||||
|
||||
final View view = getLayoutInflater().inflate(R.layout.login, null);
|
||||
final AlertDialog credentialsDialog = new AlertDialog.Builder(this).setView(view).create();
|
||||
final EditText nameInput = (EditText) view.findViewById(R.id.edit_name);
|
||||
final EditText passwordInput = (EditText) view.findViewById(R.id.edit_password);
|
||||
final EditText nameInput = view.findViewById(R.id.edit_name);
|
||||
final EditText passwordInput = view.findViewById(R.id.edit_password);
|
||||
|
||||
nameInput.setText(repo.username);
|
||||
passwordInput.requestFocus();
|
||||
|
@ -18,7 +18,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/repoView"
|
||||
android:id="@+id/repo_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
@ -85,8 +85,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_official_mirrors"
|
||||
style="@style/CaptionText"
|
||||
android:textColor="@android:color/black"
|
||||
style="@style/BodyText"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- mirrors added by the user -->
|
||||
@ -98,8 +97,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_user_mirrors"
|
||||
style="@style/CaptionText"
|
||||
android:textColor="@android:color/black"
|
||||
style="@style/BodyText"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- The credentials used to access this repo (optional) -->
|
Loading…
x
Reference in New Issue
Block a user