Finalize receive screen design for 0.4.1 - TODO: Add feature to edit address labels

This commit is contained in:
pokkst 2022-12-03 13:36:30 -06:00
parent 028b8b79b6
commit 713c34da72
No known key found for this signature in database
GPG key ID: 90C2ED85E67A50FF
9 changed files with 84 additions and 36 deletions

View file

@ -37,12 +37,14 @@ import java.util.List;
public class SubaddressAdapter extends RecyclerView.Adapter<SubaddressAdapter.ViewHolder> {
private List<Subaddress> localDataSet;
private SubaddressAdapterListener listener = null;
/**
* Initialize the dataset of the Adapter.
*/
public SubaddressAdapter() {
public SubaddressAdapter(SubaddressAdapterListener listener) {
this.localDataSet = new ArrayList<>();
this.listener = listener;
}
public void submitList(List<Subaddress> dataSet) {
@ -58,7 +60,7 @@ public class SubaddressAdapter extends RecyclerView.Adapter<SubaddressAdapter.Vi
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.address_item, viewGroup, false);
return new ViewHolder(view);
return new ViewHolder(view, listener);
}
// Replace the contents of a view (invoked by the layout manager)
@ -83,14 +85,26 @@ public class SubaddressAdapter extends RecyclerView.Adapter<SubaddressAdapter.Vi
* (custom ViewHolder).
*/
public static class ViewHolder extends RecyclerView.ViewHolder {
private SubaddressAdapterListener listener = null;
public ViewHolder(View view) {
public ViewHolder(View view, SubaddressAdapterListener listener) {
super(view);
this.listener = listener;
}
public void bind(Subaddress subaddress) {
TextView addressTextView = itemView.findViewById(R.id.address_item_address_textview);
TextView addressLabelTextView = itemView.findViewById(R.id.address_label_textview);
addressTextView.setText(subaddress.getAddress());
final String label = subaddress.getDisplayLabel();
final String address = itemView.getContext().getString(R.string.subbaddress_info_subtitle,
subaddress.getAddressIndex(), subaddress.getSquashedAddress());
addressLabelTextView.setText(label.isEmpty() ? address : label);
itemView.setOnClickListener(view -> listener.onSubaddressSelected(subaddress));
}
}
}

View file

@ -70,7 +70,7 @@ public class ReceiveFragment extends Fragment {
}
private void bindObservers(View view) {
SubaddressAdapter adapter = new SubaddressAdapter();
SubaddressAdapter adapter = new SubaddressAdapter(mViewModel::selectAddress);
RecyclerView recyclerView = view.findViewById(R.id.address_list_recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(adapter);
@ -79,7 +79,10 @@ public class ReceiveFragment extends Fragment {
}
private void setAddress(Subaddress subaddress) {
addressLabelTextView.setText(subaddress.getLabel());
final String label = subaddress.getDisplayLabel();
final String address = getContext().getString(R.string.subbaddress_info_subtitle,
subaddress.getAddressIndex(), subaddress.getSquashedAddress());
addressLabelTextView.setText(label.isEmpty() ? address : label);
addressTextView.setText(subaddress.getAddress());
addressImageView.setImageBitmap(generate(subaddress.getAddress(), 256, 256));
copyAddressImageButton.setOnClickListener(view1 -> Helper.clipBoardCopy(getContext(), "address", subaddress.getAddress()));
@ -99,7 +102,7 @@ public class ReceiveFragment extends Fragment {
if (bitMatrix.get(j, i)) {
pixels[i * width + j] = night ? 0xffffffff : 0x00000000;
} else {
pixels[i * height + j] = getResources().getColor(R.color.oled_dialogBackgroundColor);
pixels[i * height + j] = getResources().getColor(R.color.oled_colorBackground);
}
}
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<padding
android:left="8dp"
android:right="8dp" />
<solid android:color="@color/oled_dialogBackgroundColor" />
<corners android:radius="16dp" />
</shape>

View file

@ -4,41 +4,35 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:layout_marginBottom="8dp">
<TextView
android:id="@+id/address_item_address_textview"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Address"
android:textStyle="bold"
android:textSize="16sp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:ellipsize="middle"
android:singleLine="true"
android:textColor="@color/oled_addressListColor"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/address_item_amount_textview"
app:layout_constraintBottom_toTopOf="@id/address_label_textview"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/address_item_amount_textview"
android:layout_width="0dp"
android:id="@+id/address_label_textview"
style="@style/MoneroText.Subaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Amount"
android:text="Label"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textStyle="bold"
android:ellipsize="middle"
app:layout_constraintTop_toBottomOf="@id/address_item_address_textview"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/address_item_index_textview"
android:singleLine="true" />
<TextView
android:id="@+id/address_item_index_textview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Idx"
android:ellipsize="middle"
android:gravity="end"
app:layout_constraintTop_toBottomOf="@id/address_item_address_textview"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/address_item_amount_textview"
app:layout_constraintEnd_toEndOf="parent"
android:singleLine="true" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -53,31 +53,35 @@
<TextView
android:id="@+id/address_textview"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="16dp"
android:textSize="16sp"
android:textStyle="bold"
android:ellipsize="middle"
android:singleLine="true"
android:paddingTop="4dp"
android:paddingBottom="4dp"
app:layout_constraintEnd_toStartOf="@id/copy_address_imagebutton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/copy_address_imagebutton"
app:layout_constraintTop_toBottomOf="@id/monero_qr_imageview"
app:layout_constraintBottom_toTopOf="@id/address_label_textview"
tools:text="ADDRESS" />
<TextView
android:id="@+id/address_label_textview"
android:layout_width="0dp"
android:layout_height="0dp"
style="@style/MoneroText.Subaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:textSize="14sp"
android:ellipsize="middle"
android:singleLine="true"
app:layout_constraintEnd_toStartOf="@id/copy_address_imagebutton"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/address_textview"
app:layout_constraintBottom_toBottomOf="@id/copy_address_imagebutton"
tools:text="ADDRESS" />
tools:text="LABEL" />
<ImageButton
android:id="@+id/copy_address_imagebutton"
@ -94,13 +98,29 @@
app:layout_constraintStart_toEndOf="@id/address_textview"
app:layout_constraintTop_toBottomOf="@id/monero_qr_imageview" />
<TextView
android:id="@+id/address_list_label_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textSize="14sp"
android:ellipsize="middle"
android:singleLine="true"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/address_list_recyclerview"
android:text="@string/previous_addresses" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/address_list_recyclerview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:clipToPadding="false"
android:paddingBottom="128dp"
android:background="@drawable/round_bg"
android:layout_marginTop="64dp"
android:paddingTop="8dp"
android:clipToPadding="true"
android:paddingBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -32,6 +32,7 @@
<color name="oled_locked_utxo">#956E43</color>
<color name="oled_txBackgroundColor">#060606</color>
<color name="oled_dialogBackgroundColor">#0E0E0E</color>
<color name="oled_addressListColor">#353535</color>
<!-- CLASSIC -->

View file

@ -9,7 +9,7 @@
<color name="oled_streetColorA">@color/oled_gradientTopColor</color>
<color name="oled_streetColorB">@color/oled_colorBackground</color>
<color name="oled_toolbarTextColor">@color/oled_colorOnBackground</color>
<color name="oled_favouriteColor">#FFDB72</color>
<color name="oled_favouriteColor">#f38854</color>
<color name="oled_softFavouriteColor">@color/oled_favouriteColor</color>
<color name="oled_positiveColor">#19ED60</color>
<color name="oled_negativeColor">#f38854</color>
@ -33,6 +33,7 @@
<color name="oled_locked_utxo">#B5895A</color>
<color name="oled_txBackgroundColor">#FBFBFB</color>
<color name="oled_dialogBackgroundColor">#E8E8E8</color>
<color name="oled_addressListColor">#bbbbbb</color>
<!-- CLASSIC -->

View file

@ -117,4 +117,6 @@
<string name="wallet_restore_height_label">Restore height</string>
<string name="block_height">Block Height</string>
<string name="use_password_as_seed_offset">Use password as seed offset</string>
<string name="subbaddress_info_subtitle" translatable="false">#%1$d: %2$s</string>
<string name="previous_addresses">Previous addresses</string>
</resources>

View file

@ -70,6 +70,10 @@
<item name="cardElevation">1dp</item>
</style>
<style name="MoneroText.Subaddress">
<item name="android:background">@color/oled_favouriteColor</item>
<item name="android:textColor">?android:colorBackground</item>
</style>
<style name="MoneroText.PosAmount">
<item name="android:textSize">16sp</item>