Add label on node view to indicate which ones use user/pass

This commit is contained in:
pokkst 2022-12-15 11:25:51 -06:00
parent 480cbd11f1
commit df287b1012
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
5 changed files with 40 additions and 17 deletions

View File

@ -107,8 +107,12 @@ public class NodeSelectionAdapter extends RecyclerView.Adapter<NodeSelectionAdap
}
TextView nodeNameTextView = itemView.findViewById(R.id.node_name_textview);
TextView nodeAddressTextView = itemView.findViewById(R.id.node_uri_textview);
TextView authTextView = itemView.findViewById(R.id.authenticated_textview);
nodeNameTextView.setText(node.getName());
nodeAddressTextView.setText(node.getAddress());
if(!node.getPassword().isEmpty()) {
authTextView.setVisibility(View.VISIBLE);
}
ImageView nodeAnonymityNetworkImageView = itemView.findViewById(R.id.anonymity_network_imageview);
if(node.isOnion()) {

View File

@ -105,23 +105,8 @@ public class AddNodeBottomSheetDialog extends BottomSheetDialogFragment {
return;
}
String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]");
JSONArray jsonArray = new JSONArray(nodesArray);
boolean exists = false;
for (int i = 0; i < jsonArray.length(); i++) {
String nodeString = jsonArray.getString(i);
if (nodeString.equals(nodeStringBuilder.toString()))
exists = true;
}
addNodeToSaved(nodeStringBuilder);
if (!exists) {
jsonArray.put(nodeStringBuilder.toString());
} else {
Toast.makeText(getContext(), "Node already exists", Toast.LENGTH_SHORT).show();
return;
}
PrefService.getInstance().edit().putString(Constants.PREF_CUSTOM_NODES, jsonArray.toString()).apply();
if (listener != null) {
listener.onNodeAdded();
}
@ -131,6 +116,26 @@ public class AddNodeBottomSheetDialog extends BottomSheetDialogFragment {
});
}
private void addNodeToSaved(StringBuilder nodeStringBuilder) throws JSONException {
String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]");
JSONArray jsonArray = new JSONArray(nodesArray);
boolean exists = false;
for (int i = 0; i < jsonArray.length(); i++) {
String nodeString = jsonArray.getString(i);
if (nodeString.equals(nodeStringBuilder.toString()))
exists = true;
}
if (!exists) {
jsonArray.put(nodeStringBuilder.toString());
} else {
Toast.makeText(getContext(), "Node already exists", Toast.LENGTH_SHORT).show();
return;
}
PrefService.getInstance().edit().putString(Constants.PREF_CUSTOM_NODES, jsonArray.toString()).apply();
}
private void addPasteListener(View root, EditText editText, int layoutId) {
ImageButton pasteImageButton = root.findViewById(layoutId);
pasteImageButton.setOnClickListener(view1 -> {

View File

@ -23,6 +23,6 @@ public class OnionHelper {
}
public static boolean isI2PHost(String hostname) {
return hostname.endsWith(".b32.i2p");
return hostname.endsWith(".i2p");
}
}

View File

@ -35,6 +35,19 @@
android:text="NODE::"
android:ellipsize="middle"
app:layout_constraintTop_toBottomOf="@id/node_name_textview"
app:layout_constraintBottom_toTopOf="@id/authenticated_textview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:singleLine="true" />
<TextView
android:id="@+id/authenticated_textview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/auth"
android:textColor="@color/oled_addressListColor"
android:ellipsize="middle"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/node_uri_textview"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -126,4 +126,5 @@
<string name="previous_addresses">Previous addresses</string>
<string name="donate_label">Donate to MyNero</string>
<string name="transactions">Transactions</string>
<string name="auth">[ auth ]</string>
</resources>