diff --git a/.gitignore b/.gitignore index 33866320..679ff4d2 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ /app/alphaStagenet /app/prodStagenet /app/.cxx +/monerujo.id diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java index 540b1795..a328bf8a 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java @@ -59,7 +59,7 @@ import com.m2049r.xmrwallet.model.NetworkType; import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.model.WalletManager; 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.Helper; import com.m2049r.xmrwallet.util.KeyStoreHelper; @@ -78,7 +78,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; @@ -707,11 +706,11 @@ public class LoginActivity extends BaseActivity break; case NetworkType_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; case NetworkType_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; default: throw new IllegalStateException("NetworkType unknown: " + net); diff --git a/app/src/main/java/com/m2049r/xmrwallet/TxFragment.java b/app/src/main/java/com/m2049r/xmrwallet/TxFragment.java index 22e199b9..9d1a69d2 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/TxFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/TxFragment.java @@ -36,10 +36,12 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; +import com.google.android.material.transition.MaterialContainerTransform; import com.m2049r.xmrwallet.data.UserNotes; import com.m2049r.xmrwallet.model.TransactionInfo; import com.m2049r.xmrwallet.model.Transfer; import com.m2049r.xmrwallet.model.Wallet; +import com.m2049r.xmrwallet.util.ThemeHelper; import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.widget.Toolbar; @@ -300,7 +302,7 @@ public class TxFragment extends Fragment { } tvTxXmrToKey.setText(key); tvDestinationBtc.setText(userNotes.xmrtoDestination); - tvTxAmountBtc.setText(userNotes.xmrtoAmount + " "+ userNotes.xmrtoCurrency); + tvTxAmountBtc.setText(userNotes.xmrtoAmount + " " + userNotes.xmrtoCurrency); switch (userNotes.xmrtoTag) { case "xmrto": tvXmrToSupport.setVisibility(View.GONE); @@ -329,6 +331,11 @@ public class TxFragment extends Fragment { public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); 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 diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java index 9b51c095..9973f54c 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java @@ -60,7 +60,7 @@ import com.m2049r.xmrwallet.model.TransactionInfo; import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.model.WalletManager; 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.MoneroThreadPoolExecutor; 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); break; case NetworkType_Testnet: - toolbar.setBackgroundResource(ColorHelper.getThemedResourceId(this, R.attr.colorPrimaryDark)); + toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark)); break; case NetworkType_Stagenet: - toolbar.setBackgroundResource(ColorHelper.getThemedResourceId(this, R.attr.colorPrimaryDark)); + toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark)); break; default: throw new IllegalStateException("Unsupported Network: " + WalletManager.getInstance().getNetworkType()); @@ -548,10 +548,10 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste } @Override - public void onTxDetailsRequest(TransactionInfo info) { + public void onTxDetailsRequest(View view, TransactionInfo info) { Bundle args = new Bundle(); args.putParcelable(TxFragment.ARG_INFO, info); - replaceFragment(new TxFragment(), null, args); + replaceFragmentWithTransition(view, new TxFragment(), null, args); } @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) { if (extras != null) { newFragment.setArguments(extras); diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java b/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java index 0669e0a0..eee13d92 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java @@ -42,6 +42,7 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import com.github.brnunes.swipeablerecyclerview.SwipeableRecyclerViewTouchListener; +import com.google.android.material.transition.MaterialElevationScale; import com.m2049r.xmrwallet.layout.TransactionInfoAdapter; import com.m2049r.xmrwallet.model.TransactionInfo; import com.m2049r.xmrwallet.model.Wallet; @@ -332,7 +333,13 @@ public class WalletFragment extends Fragment // Callbacks from TransactionInfoAdapter @Override 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 @@ -478,7 +485,7 @@ public class WalletFragment extends Fragment void onSendRequest(); - void onTxDetailsRequest(TransactionInfo info); + void onTxDetailsRequest(View view, TransactionInfo info); boolean isSynced(); diff --git a/app/src/main/java/com/m2049r/xmrwallet/layout/NodeInfoAdapter.java b/app/src/main/java/com/m2049r/xmrwallet/layout/NodeInfoAdapter.java index ba1b0238..5d8c52d6 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/layout/NodeInfoAdapter.java +++ b/app/src/main/java/com/m2049r/xmrwallet/layout/NodeInfoAdapter.java @@ -30,7 +30,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.m2049r.xmrwallet.R; 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 java.net.HttpURLConnection; @@ -182,7 +182,7 @@ public class NodeInfoAdapter extends RecyclerView.Adapter= STALE_NODE_HOURS) - view.setTextColor(ColorHelper.getThemedColor(view.getContext(), R.attr.colorError)); + view.setTextColor(ThemeHelper.getThemedColor(view.getContext(), R.attr.colorError)); else - view.setTextColor(ColorHelper.getThemedColor(view.getContext(), android.R.attr.textColorPrimary)); + view.setTextColor(ThemeHelper.getThemedColor(view.getContext(), android.R.attr.textColorPrimary)); } } diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/ColorHelper.java b/app/src/main/java/com/m2049r/xmrwallet/util/ThemeHelper.java similarity index 61% rename from app/src/main/java/com/m2049r/xmrwallet/util/ColorHelper.java rename to app/src/main/java/com/m2049r/xmrwallet/util/ThemeHelper.java index 520e1609..20f8c484 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/ColorHelper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/ThemeHelper.java @@ -17,19 +17,26 @@ package com.m2049r.xmrwallet.util; import android.content.Context; -import android.content.res.TypedArray; 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) { - TypedArray styledAttributes = ctx.getTheme().obtainStyledAttributes(R.style.MyMaterialTheme, new int[]{attrId}); - return styledAttributes.getResourceId(0, 0); + final TypedValue typedValue = new TypedValue(); + if (ctx.getTheme().resolveAttribute(attrId, typedValue, true)) + return typedValue.resourceId; + else + return 0; } + @ColorInt static public int getThemedColor(Context ctx, int attrId) { - TypedArray styledAttributes = ctx.getTheme().obtainStyledAttributes(R.style.MyMaterialTheme, new int[]{attrId}); - return styledAttributes.getColor(0, Color.BLACK); + final TypedValue typedValue = new TypedValue(); + if (ctx.getTheme().resolveAttribute(attrId, typedValue, true)) + return typedValue.data; + else + return Color.BLACK; } } diff --git a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeView.java b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeView.java index b35a0b6a..f2a301cd 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeView.java +++ b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeView.java @@ -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.ExchangeCallback; 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.ServiceHelper; @@ -180,7 +180,7 @@ public class ExchangeView extends LinearLayout { // make progress circle gray pbExchange.getIndeterminateDrawable(). - setColorFilter(ColorHelper.getThemedColor(getContext(), R.attr.colorPrimaryVariant), + setColorFilter(ThemeHelper.getThemedColor(getContext(), R.attr.colorPrimaryVariant), android.graphics.PorterDuff.Mode.MULTIPLY); sCurrencyA.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { diff --git a/app/src/main/res/layout/fragment_tx_info.xml b/app/src/main/res/layout/fragment_tx_info.xml index 307ae8b6..fef5b62d 100644 --- a/app/src/main/res/layout/fragment_tx_info.xml +++ b/app/src/main/res/layout/fragment_tx_info.xml @@ -4,7 +4,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" - android:fillViewport="true"> + android:fillViewport="true" + android:transitionName="@string/tx_details_transition_name"> diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml index a6b3daec..89c72327 100644 --- a/app/src/main/res/values/integers.xml +++ b/app/src/main/res/values/integers.xml @@ -1,2 +1,4 @@ - \ No newline at end of file + + 300 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6157b4b6..258287b6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -471,4 +471,8 @@ Ethereum Litecoin + + tx_transition_%1$s + tx_transition + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 9359a130..27bd042c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -36,7 +36,7 @@