Skip to content

Commit bd24ef8

Browse files
committed
- Fix avatar size layout
- Add helper for Address Book
1 parent aef6231 commit bd24ef8

File tree

9 files changed

+65
-11
lines changed

9 files changed

+65
-11
lines changed

app/src/main/java/io/scalaproject/vault/AddressBookFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
164164

165165
@Override
166166
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
167-
inflater.inflate(R.menu.node_menu, menu);
167+
inflater.inflate(R.menu.address_book_menu, menu);
168168
super.onCreateOptionsMenu(menu, inflater);
169169
}
170170

app/src/main/java/io/scalaproject/vault/WalletActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
346346
case R.id.action_help_send:
347347
HelpFragment.display(getSupportFragmentManager(), R.string.help_send);
348348
return true;
349+
case R.id.action_help_address_book:
350+
HelpFragment.display(getSupportFragmentManager(), R.string.help_address_book);
351+
return true;
349352
case R.id.action_rename:
350353
onAccountRename();
351354
return true;

app/src/main/java/io/scalaproject/vault/layout/ContactInfoAdapter.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import androidx.recyclerview.widget.RecyclerView;
2727

2828
import android.graphics.Bitmap;
29+
import android.util.TypedValue;
2930
import android.view.LayoutInflater;
3031
import android.view.View;
3132
import android.view.ViewGroup;
@@ -153,10 +154,20 @@ public void onClick(View v) {
153154
}
154155

155156
Bitmap avatar = contactItem.getAvatar();
156-
if(avatar != null)
157+
if(avatar != null) {
158+
int dim = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, itemView.getResources().getDisplayMetrics());
159+
ivAvatar.getLayoutParams().height = dim;
160+
ivAvatar.getLayoutParams().width = dim;
161+
157162
ivAvatar.setImageBitmap(contactItem.getAvatar());
158-
else
163+
}
164+
else {
165+
int dim = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, itemView.getResources().getDisplayMetrics());
166+
ivAvatar.getLayoutParams().height = dim;
167+
ivAvatar.getLayoutParams().width = dim;
168+
159169
ivAvatar.setImageBitmap(Helper.getBitmap(context, R.drawable.ic_contact_avatar));
170+
}
160171
}
161172

162173
@Override

app/src/main/java/io/scalaproject/vault/layout/TransactionInfoAdapter.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import android.view.View;
3232
import android.view.ViewGroup;
3333
import android.widget.ImageView;
34+
import android.widget.LinearLayout;
3435
import android.widget.TextView;
3536

3637
import io.scalaproject.vault.R;
@@ -162,7 +163,11 @@ void bind(int position) {
162163

163164
UserNotes userNotes = new UserNotes(infoItem.notes);
164165

166+
LinearLayout llTxType = itemView.findViewById(R.id.llTxType);
167+
165168
// just in case
169+
llTxType.setBackgroundTintList(itemView.getResources().getColorStateList(R.color.bg_grey));
170+
166171
int dim = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, itemView.getResources().getDisplayMetrics());
167172
ivTxType.getLayoutParams().height = dim;
168173
ivTxType.getLayoutParams().width = dim;
@@ -218,6 +223,8 @@ void bind(int position) {
218223
else {
219224
this.tvPaymentId.setText(Helper.getTruncatedString(contact.getName(), 20));
220225

226+
llTxType.setBackgroundTintList(itemView.getResources().getColorStateList(R.color.bg_lighter));
227+
221228
Bitmap avatar = contact.getAvatar();
222229
if(avatar != null) {
223230
dim = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, itemView.getResources().getDisplayMetrics());
@@ -226,6 +233,13 @@ void bind(int position) {
226233

227234
ivTxType.setImageBitmap(avatar);
228235
}
236+
else {
237+
dim = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, itemView.getResources().getDisplayMetrics());
238+
ivTxType.getLayoutParams().height = dim;
239+
ivTxType.getLayoutParams().width = dim;
240+
241+
ivTxType.setImageBitmap(Helper.getBitmap(itemView.getContext(), R.drawable.ic_contact_avatar));
242+
}
229243
}
230244

231245
this.tvDateTime.setText(getDateTime(infoItem.timestamp));

app/src/main/res/drawable/ic_contact_avatar.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:width="24dp"
4-
android:height="24dp"
3+
android:width="96dp"
4+
android:height="96dp"
55
android:viewportWidth="24"
66
android:viewportHeight="24">
77

app/src/main/res/layout/item_contact.xml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@
1515
android:layout_height="wrap_content"
1616
android:background="@drawable/corner_radius_lighter_small">
1717

18-
<ImageView
19-
android:id="@+id/ivAvatar"
20-
android:layout_width="36dp"
21-
android:layout_height="36dp"
18+
<LinearLayout
19+
android:layout_width="42dp"
20+
android:layout_height="42dp"
2221
android:layout_marginStart="8dp"
2322
android:layout_alignParentStart="true"
2423
android:layout_centerInParent="true"
2524
android:gravity="center"
26-
android:background="@android:color/transparent"
27-
android:src="@drawable/ic_contact_avatar" />
25+
android:orientation="vertical">
26+
27+
<ImageView
28+
android:id="@+id/ivAvatar"
29+
android:layout_width="36dp"
30+
android:layout_height="36dp"
31+
android:background="@android:color/transparent"
32+
android:src="@drawable/ic_contact_avatar" />
33+
34+
</LinearLayout>
2835

2936
<TextView
3037
android:id="@+id/tvName"

app/src/main/res/layout/item_transaction.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
android:orientation="horizontal">
2727

2828
<LinearLayout
29+
android:id="@+id/llTxType"
2930
android:layout_width="32dp"
3031
android:layout_height="32dp"
3132
android:layout_gravity="center"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
5+
<item
6+
android:id="@+id/action_help_address_book"
7+
android:icon="@drawable/ic_help_white_24dp"
8+
android:orderInCategory="500"
9+
android:title="@string/menu_help"
10+
app:showAsAction="ifRoom" />
11+
</menu>

app/src/main/res/values/help.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@
149149
This was the block your transaction was included in.
150150
]]></string>
151151

152+
<string name="help_address_book"><![CDATA[
153+
<h1>Address Book</h1>
154+
<p>The Address Book allows you to store the wallet address and other contact information of addresses you frequently use.</p>
155+
<p>You can specify the name, wallet address, and image for each of your contact.</p>
156+
<p>The Address Book is stored locally on your device and is shared between all your wallets.</p>
157+
]]></string>
158+
152159
<string name="help_send"><![CDATA[
153160
<h1>Send</h1>
154161
<h2>Receiver’s address</h2>

0 commit comments

Comments
 (0)