Tweaking UI & some bugfixing on the way (#729)

This commit is contained in:
m2049r 2021-03-13 13:12:46 +01:00 committed by GitHub
parent c5a035437b
commit a7b178e024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 73 additions and 30 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@
/app/alphaStagenet /app/alphaStagenet
/app/prodStagenet /app/prodStagenet
/app/.cxx /app/.cxx
/monerujo.id

View File

@ -59,7 +59,7 @@ import com.m2049r.xmrwallet.model.NetworkType;
import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.model.WalletManager; import com.m2049r.xmrwallet.model.WalletManager;
import com.m2049r.xmrwallet.service.WalletService; import com.m2049r.xmrwallet.service.WalletService;
import com.m2049r.xmrwallet.util.ColorHelper; import com.m2049r.xmrwallet.util.ThemeHelper;
import com.m2049r.xmrwallet.util.DayNightMode; import com.m2049r.xmrwallet.util.DayNightMode;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.KeyStoreHelper; import com.m2049r.xmrwallet.util.KeyStoreHelper;
@ -78,7 +78,6 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -707,11 +706,11 @@ public class LoginActivity extends BaseActivity
break; break;
case NetworkType_Testnet: case NetworkType_Testnet:
toolbar.setSubtitle(getString(R.string.connect_testnet)); toolbar.setSubtitle(getString(R.string.connect_testnet));
toolbar.setBackgroundResource(ColorHelper.getThemedResourceId(this, R.attr.colorPrimaryDark)); toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark));
break; break;
case NetworkType_Stagenet: case NetworkType_Stagenet:
toolbar.setSubtitle(getString(R.string.connect_stagenet)); toolbar.setSubtitle(getString(R.string.connect_stagenet));
toolbar.setBackgroundResource(ColorHelper.getThemedResourceId(this, R.attr.colorPrimaryDark)); toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark));
break; break;
default: default:
throw new IllegalStateException("NetworkType unknown: " + net); throw new IllegalStateException("NetworkType unknown: " + net);

View File

@ -36,10 +36,12 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.google.android.material.transition.MaterialContainerTransform;
import com.m2049r.xmrwallet.data.UserNotes; import com.m2049r.xmrwallet.data.UserNotes;
import com.m2049r.xmrwallet.model.TransactionInfo; import com.m2049r.xmrwallet.model.TransactionInfo;
import com.m2049r.xmrwallet.model.Transfer; import com.m2049r.xmrwallet.model.Transfer;
import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.util.ThemeHelper;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.widget.Toolbar; import com.m2049r.xmrwallet.widget.Toolbar;
@ -300,7 +302,7 @@ public class TxFragment extends Fragment {
} }
tvTxXmrToKey.setText(key); tvTxXmrToKey.setText(key);
tvDestinationBtc.setText(userNotes.xmrtoDestination); tvDestinationBtc.setText(userNotes.xmrtoDestination);
tvTxAmountBtc.setText(userNotes.xmrtoAmount + " "+ userNotes.xmrtoCurrency); tvTxAmountBtc.setText(userNotes.xmrtoAmount + " " + userNotes.xmrtoCurrency);
switch (userNotes.xmrtoTag) { switch (userNotes.xmrtoTag) {
case "xmrto": case "xmrto":
tvXmrToSupport.setVisibility(View.GONE); tvXmrToSupport.setVisibility(View.GONE);
@ -329,6 +331,11 @@ public class TxFragment extends Fragment {
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setHasOptionsMenu(true); setHasOptionsMenu(true);
final MaterialContainerTransform transform = new MaterialContainerTransform();
transform.setDrawingViewId(R.id.fragment_container);
transform.setDuration(getResources().getInteger(R.integer.tx_item_transition_duration));
transform.setAllContainerColors(ThemeHelper.getThemedColor(getContext(), R.attr.colorSurface));
setSharedElementEnterTransition(transform);
} }
@Override @Override

View File

@ -60,7 +60,7 @@ import com.m2049r.xmrwallet.model.TransactionInfo;
import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.model.WalletManager; import com.m2049r.xmrwallet.model.WalletManager;
import com.m2049r.xmrwallet.service.WalletService; import com.m2049r.xmrwallet.service.WalletService;
import com.m2049r.xmrwallet.util.ColorHelper; import com.m2049r.xmrwallet.util.ThemeHelper;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor; import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor;
import com.m2049r.xmrwallet.widget.Toolbar; import com.m2049r.xmrwallet.widget.Toolbar;
@ -424,10 +424,10 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
toolbar.setBackgroundResource(R.drawable.backgound_toolbar_mainnet); toolbar.setBackgroundResource(R.drawable.backgound_toolbar_mainnet);
break; break;
case NetworkType_Testnet: case NetworkType_Testnet:
toolbar.setBackgroundResource(ColorHelper.getThemedResourceId(this, R.attr.colorPrimaryDark)); toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark));
break; break;
case NetworkType_Stagenet: case NetworkType_Stagenet:
toolbar.setBackgroundResource(ColorHelper.getThemedResourceId(this, R.attr.colorPrimaryDark)); toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark));
break; break;
default: default:
throw new IllegalStateException("Unsupported Network: " + WalletManager.getInstance().getNetworkType()); throw new IllegalStateException("Unsupported Network: " + WalletManager.getInstance().getNetworkType());
@ -548,10 +548,10 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
} }
@Override @Override
public void onTxDetailsRequest(TransactionInfo info) { public void onTxDetailsRequest(View view, TransactionInfo info) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable(TxFragment.ARG_INFO, info); args.putParcelable(TxFragment.ARG_INFO, info);
replaceFragment(new TxFragment(), null, args); replaceFragmentWithTransition(view, new TxFragment(), null, args);
} }
@Override @Override
@ -828,6 +828,17 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
} }
} }
void replaceFragmentWithTransition(View view, Fragment newFragment, String stackName, Bundle extras) {
if (extras != null) {
newFragment.setArguments(extras);
}
getSupportFragmentManager().beginTransaction()
.addSharedElement(view, getString(R.string.tx_details_transition_name))
.replace(R.id.fragment_container, newFragment)
.addToBackStack(stackName)
.commit();
}
void replaceFragment(Fragment newFragment, String stackName, Bundle extras) { void replaceFragment(Fragment newFragment, String stackName, Bundle extras) {
if (extras != null) { if (extras != null) {
newFragment.setArguments(extras); newFragment.setArguments(extras);

View File

@ -42,6 +42,7 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.github.brnunes.swipeablerecyclerview.SwipeableRecyclerViewTouchListener; import com.github.brnunes.swipeablerecyclerview.SwipeableRecyclerViewTouchListener;
import com.google.android.material.transition.MaterialElevationScale;
import com.m2049r.xmrwallet.layout.TransactionInfoAdapter; import com.m2049r.xmrwallet.layout.TransactionInfoAdapter;
import com.m2049r.xmrwallet.model.TransactionInfo; import com.m2049r.xmrwallet.model.TransactionInfo;
import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.model.Wallet;
@ -332,7 +333,13 @@ public class WalletFragment extends Fragment
// Callbacks from TransactionInfoAdapter // Callbacks from TransactionInfoAdapter
@Override @Override
public void onInteraction(final View view, final TransactionInfo infoItem) { public void onInteraction(final View view, final TransactionInfo infoItem) {
activityCallback.onTxDetailsRequest(infoItem); final MaterialElevationScale exitTransition = new MaterialElevationScale(false);
exitTransition.setDuration(getResources().getInteger(R.integer.tx_item_transition_duration));
setExitTransition(exitTransition);
final MaterialElevationScale reenterTransition = new MaterialElevationScale(true);
reenterTransition.setDuration(getResources().getInteger(R.integer.tx_item_transition_duration));
setReenterTransition(reenterTransition);
activityCallback.onTxDetailsRequest(view, infoItem);
} }
// called from activity // called from activity
@ -478,7 +485,7 @@ public class WalletFragment extends Fragment
void onSendRequest(); void onSendRequest();
void onTxDetailsRequest(TransactionInfo info); void onTxDetailsRequest(View view, TransactionInfo info);
boolean isSynced(); boolean isSynced();

View File

@ -30,7 +30,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.data.NodeInfo; import com.m2049r.xmrwallet.data.NodeInfo;
import com.m2049r.xmrwallet.util.ColorHelper; import com.m2049r.xmrwallet.util.ThemeHelper;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@ -182,7 +182,7 @@ public class NodeInfoAdapter extends RecyclerView.Adapter<NodeInfoAdapter.ViewHo
Helper.showTimeDifference(tvIp, nodeItem.getTimestamp()); Helper.showTimeDifference(tvIp, nodeItem.getTimestamp());
} else { } else {
tvIp.setText(getResponseErrorText(context, nodeItem.getResponseCode())); tvIp.setText(getResponseErrorText(context, nodeItem.getResponseCode()));
tvIp.setTextColor(ColorHelper.getThemedColor(tvIp.getContext(), R.attr.colorError)); tvIp.setTextColor(ThemeHelper.getThemedColor(context, R.attr.colorError));
} }
} else { } else {
tvIp.setText(context.getResources().getString(R.string.node_testing, nodeItem.getHostAddress())); tvIp.setText(context.getResources().getString(R.string.node_testing, nodeItem.getHostAddress()));

View File

@ -40,6 +40,7 @@ import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.TimeZone; import java.util.TimeZone;
import timber.log.Timber; import timber.log.Timber;
@ -92,7 +93,8 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
final TransactionInfo newItem = mNewList.get(newItemPosition); final TransactionInfo newItem = mNewList.get(newItemPosition);
return (oldItem.direction == newItem.direction) return (oldItem.direction == newItem.direction)
&& (oldItem.isPending == newItem.isPending) && (oldItem.isPending == newItem.isPending)
&& (oldItem.isFailed == newItem.isFailed); && (oldItem.isFailed == newItem.isFailed)
&& (Objects.equals(oldItem.notes, newItem.notes));
} }
} }
@ -165,7 +167,8 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
} }
void bind(int position) { void bind(int position) {
this.infoItem = infoItems.get(position); infoItem = infoItems.get(position);
itemView.setTransitionName(context.getString(R.string.tx_item_transition_name, infoItem.hash));
UserNotes userNotes = new UserNotes(infoItem.notes); UserNotes userNotes = new UserNotes(infoItem.notes);
if (userNotes.xmrtoKey != null) { if (userNotes.xmrtoKey != null) {

View File

@ -656,8 +656,8 @@ public class Helper {
} }
view.setText(msg); view.setText(msg);
if (hours >= STALE_NODE_HOURS) if (hours >= STALE_NODE_HOURS)
view.setTextColor(ColorHelper.getThemedColor(view.getContext(), R.attr.colorError)); view.setTextColor(ThemeHelper.getThemedColor(view.getContext(), R.attr.colorError));
else else
view.setTextColor(ColorHelper.getThemedColor(view.getContext(), android.R.attr.textColorPrimary)); view.setTextColor(ThemeHelper.getThemedColor(view.getContext(), android.R.attr.textColorPrimary));
} }
} }

View File

@ -17,19 +17,26 @@
package com.m2049r.xmrwallet.util; package com.m2049r.xmrwallet.util;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color; import android.graphics.Color;
import android.util.TypedValue;
import com.m2049r.xmrwallet.R; import androidx.annotation.ColorInt;
public class ColorHelper { public class ThemeHelper {
static public int getThemedResourceId(Context ctx, int attrId) { static public int getThemedResourceId(Context ctx, int attrId) {
TypedArray styledAttributes = ctx.getTheme().obtainStyledAttributes(R.style.MyMaterialTheme, new int[]{attrId}); final TypedValue typedValue = new TypedValue();
return styledAttributes.getResourceId(0, 0); if (ctx.getTheme().resolveAttribute(attrId, typedValue, true))
return typedValue.resourceId;
else
return 0;
} }
@ColorInt
static public int getThemedColor(Context ctx, int attrId) { static public int getThemedColor(Context ctx, int attrId) {
TypedArray styledAttributes = ctx.getTheme().obtainStyledAttributes(R.style.MyMaterialTheme, new int[]{attrId}); final TypedValue typedValue = new TypedValue();
return styledAttributes.getColor(0, Color.BLACK); if (ctx.getTheme().resolveAttribute(attrId, typedValue, true))
return typedValue.data;
else
return Color.BLACK;
} }
} }

View File

@ -42,7 +42,7 @@ import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.service.exchange.api.ExchangeApi; import com.m2049r.xmrwallet.service.exchange.api.ExchangeApi;
import com.m2049r.xmrwallet.service.exchange.api.ExchangeCallback; import com.m2049r.xmrwallet.service.exchange.api.ExchangeCallback;
import com.m2049r.xmrwallet.service.exchange.api.ExchangeRate; import com.m2049r.xmrwallet.service.exchange.api.ExchangeRate;
import com.m2049r.xmrwallet.util.ColorHelper; import com.m2049r.xmrwallet.util.ThemeHelper;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.ServiceHelper; import com.m2049r.xmrwallet.util.ServiceHelper;
@ -180,7 +180,7 @@ public class ExchangeView extends LinearLayout {
// make progress circle gray // make progress circle gray
pbExchange.getIndeterminateDrawable(). pbExchange.getIndeterminateDrawable().
setColorFilter(ColorHelper.getThemedColor(getContext(), R.attr.colorPrimaryVariant), setColorFilter(ThemeHelper.getThemedColor(getContext(), R.attr.colorPrimaryVariant),
android.graphics.PorterDuff.Mode.MULTIPLY); android.graphics.PorterDuff.Mode.MULTIPLY);
sCurrencyA.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { sCurrencyA.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

View File

@ -4,7 +4,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:layout_margin="8dp"
android:fillViewport="true"> android:fillViewport="true"
android:transitionName="@string/tx_details_transition_name">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -141,6 +141,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
android:paddingBottom="80dp" android:paddingBottom="80dp"
android:transitionGroup="true"
app:layoutManager="LinearLayoutManager" app:layoutManager="LinearLayoutManager"
tools:listitem="@layout/item_transaction" /> tools:listitem="@layout/item_transaction" />

View File

@ -1,2 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources></resources> <resources>
<integer name="tx_item_transition_duration">300</integer>
</resources>

View File

@ -471,4 +471,8 @@
<item>Ethereum</item> <item>Ethereum</item>
<item>Litecoin</item> <item>Litecoin</item>
</string-array> </string-array>
<string name="tx_item_transition_name" translatable="false">tx_transition_%1$s</string>
<string name="tx_details_transition_name" translatable="false">tx_transition</string>
</resources> </resources>

View File

@ -36,7 +36,7 @@
</style> </style>
<style name="AppCard" parent="Widget.MaterialComponents.CardView"> <style name="AppCard" parent="Widget.MaterialComponents.CardView">
<item name="cardElevation">8dp</item> <item name="cardElevation">4dp</item>
<item name="cardCornerRadius">1dp</item> <item name="cardCornerRadius">1dp</item>
</style> </style>