Receive & send transition

merge-requests/3/head
wow nero 3 years ago
parent 2fbd152fb3
commit 16870fcbb9
No known key found for this signature in database
GPG Key ID: 4386E69AF260078D

@ -50,6 +50,7 @@ import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.google.android.material.textfield.TextInputLayout; import com.google.android.material.textfield.TextInputLayout;
import com.google.android.material.transition.MaterialContainerTransform;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
@ -64,6 +65,7 @@ import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.model.WalletManager; import com.m2049r.xmrwallet.model.WalletManager;
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.util.ThemeHelper;
import com.m2049r.xmrwallet.widget.ExchangeView; import com.m2049r.xmrwallet.widget.ExchangeView;
import com.m2049r.xmrwallet.widget.Toolbar; import com.m2049r.xmrwallet.widget.Toolbar;
@ -244,6 +246,11 @@ public class ReceiveFragment 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);
} }
private ShareActionProvider shareActionProvider; private ShareActionProvider shareActionProvider;

@ -43,7 +43,6 @@ import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout; import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.navigation.NavigationView; import com.google.android.material.navigation.NavigationView;
@ -60,9 +59,9 @@ 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.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.util.ThemeHelper;
import com.m2049r.xmrwallet.widget.Toolbar; import com.m2049r.xmrwallet.widget.Toolbar;
import java.util.ArrayList; import java.util.ArrayList;
@ -542,8 +541,8 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
} }
@Override @Override
public void onSendRequest() { public void onSendRequest(View view) {
replaceFragment(SendFragment.newInstance(uri), null, null); replaceFragmentWithTransition(view, SendFragment.newInstance(uri), null, null);
uri = null; // only use uri once uri = null; // only use uri once
} }
@ -832,8 +831,18 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
if (extras != null) { if (extras != null) {
newFragment.setArguments(extras); newFragment.setArguments(extras);
} }
int transition;
if (newFragment instanceof TxFragment)
transition = R.string.tx_details_transition_name;
else if (newFragment instanceof ReceiveFragment)
transition = R.string.receive_transition_name;
else if (newFragment instanceof SendFragment)
transition = R.string.send_transition_name;
else
throw new IllegalStateException("expecting known transition");
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.addSharedElement(view, getString(R.string.tx_details_transition_name)) .addSharedElement(view, getString(transition))
.replace(R.id.fragment_container, newFragment) .replace(R.id.fragment_container, newFragment)
.addToBackStack(stackName) .addToBackStack(stackName)
.commit(); .commit();
@ -843,10 +852,11 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
if (extras != null) { if (extras != null) {
newFragment.setArguments(extras); newFragment.setArguments(extras);
} }
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); getSupportFragmentManager()
transaction.replace(R.id.fragment_container, newFragment); .beginTransaction()
transaction.addToBackStack(stackName); .replace(R.id.fragment_container, newFragment)
transaction.commit(); .addToBackStack(stackName)
.commit();
} }
private void onWalletDetails() { private void onWalletDetails() {
@ -983,20 +993,13 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
} }
@Override @Override
public void onWalletReceive() { public void onWalletReceive(View view) {
startReceive(getWallet().getAddress()); final String address = getWallet().getAddress();
}
void startReceive(String address) {
Timber.d("startReceive()"); Timber.d("startReceive()");
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("address", address); b.putString("address", address);
b.putString("name", getWalletName()); b.putString("name", getWalletName());
startReceiveFragment(b); replaceFragmentWithTransition(view, new ReceiveFragment(), null, b);
}
void startReceiveFragment(Bundle extras) {
replaceFragment(new ReceiveFragment(), null, extras);
Timber.d("ReceiveFragment placed"); Timber.d("ReceiveFragment placed");
} }

@ -36,6 +36,7 @@ import android.widget.ProgressBar;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -104,6 +105,13 @@ public class WalletFragment extends Fragment
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_wallet, container, false); View view = inflater.inflate(R.layout.fragment_wallet, container, false);
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);
ivStreetGunther = view.findViewById(R.id.ivStreetGunther); ivStreetGunther = view.findViewById(R.id.ivStreetGunther);
tvStreetView = view.findViewById(R.id.tvStreetView); tvStreetView = view.findViewById(R.id.tvStreetView);
llBalance = view.findViewById(R.id.llBalance); llBalance = view.findViewById(R.id.llBalance);
@ -169,18 +177,8 @@ public class WalletFragment extends Fragment
recyclerView.addOnItemTouchListener(swipeTouchListener); recyclerView.addOnItemTouchListener(swipeTouchListener);
bSend.setOnClickListener(new View.OnClickListener() { bSend.setOnClickListener(v -> activityCallback.onSendRequest(v));
@Override bReceive.setOnClickListener(v -> activityCallback.onWalletReceive(v));
public void onClick(View v) {
activityCallback.onSendRequest();
}
});
bReceive.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activityCallback.onWalletReceive();
}
});
sCurrency.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { sCurrency.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
@ -203,6 +201,16 @@ public class WalletFragment extends Fragment
return view; return view;
} }
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
postponeEnterTransition();
view.getViewTreeObserver().addOnPreDrawListener(() -> {
startPostponedEnterTransition();
return true;
});
}
void showBalance(String balance) { void showBalance(String balance) {
tvBalance.setText(balance); tvBalance.setText(balance);
final boolean streetMode = activityCallback.isStreetMode(); final boolean streetMode = activityCallback.isStreetMode();
@ -483,7 +491,7 @@ public class WalletFragment extends Fragment
long getDaemonHeight(); //mBoundService.getDaemonHeight(); long getDaemonHeight(); //mBoundService.getDaemonHeight();
void onSendRequest(); void onSendRequest(View view);
void onTxDetailsRequest(View view, TransactionInfo info); void onTxDetailsRequest(View view, TransactionInfo info);
@ -497,7 +505,7 @@ public class WalletFragment extends Fragment
String getTxKey(String txId); String getTxKey(String txId);
void onWalletReceive(); void onWalletReceive(View view);
boolean hasWallet(); boolean hasWallet();

@ -36,6 +36,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import com.google.android.material.transition.MaterialContainerTransform;
import com.m2049r.xmrwallet.OnBackPressedListener; import com.m2049r.xmrwallet.OnBackPressedListener;
import com.m2049r.xmrwallet.OnUriScannedListener; import com.m2049r.xmrwallet.OnUriScannedListener;
import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.R;
@ -49,6 +50,7 @@ import com.m2049r.xmrwallet.layout.SpendViewPager;
import com.m2049r.xmrwallet.model.PendingTransaction; import com.m2049r.xmrwallet.model.PendingTransaction;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.Notice; import com.m2049r.xmrwallet.util.Notice;
import com.m2049r.xmrwallet.util.ThemeHelper;
import com.m2049r.xmrwallet.widget.DotBar; import com.m2049r.xmrwallet.widget.DotBar;
import com.m2049r.xmrwallet.widget.Toolbar; import com.m2049r.xmrwallet.widget.Toolbar;
@ -538,10 +540,14 @@ public class SendFragment extends Fragment
enableNavigation(); enableNavigation();
} }
@Override
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

@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:transitionName="@string/receive_transition_name">
<EditText <EditText
android:id="@+id/etDummy" android:id="@+id/etDummy"

@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:transitionName="@string/send_transition_name">
<LinearLayout <LinearLayout
android:id="@+id/llNotice" android:id="@+id/llNotice"

@ -165,6 +165,7 @@
android:layout_weight="1" android:layout_weight="1"
android:enabled="false" android:enabled="false"
android:text="@string/label_wallet_receive" android:text="@string/label_wallet_receive"
android:transitionName="@string/receive_btn_transition_name"
app:icon="@drawable/ic_hand" /> app:icon="@drawable/ic_hand" />
<Button <Button
@ -176,6 +177,7 @@
android:layout_weight="1" android:layout_weight="1"
android:enabled="false" android:enabled="false"
android:text="@string/label_wallet_send" android:text="@string/label_wallet_send"
android:transitionName="@string/send_btn_transition_name"
app:icon="@drawable/ic_send" /> app:icon="@drawable/ic_send" />
</LinearLayout> </LinearLayout>

@ -474,5 +474,9 @@
<string name="tx_item_transition_name" translatable="false">tx_transition_%1$s</string> <string name="tx_item_transition_name" translatable="false">tx_transition_%1$s</string>
<string name="tx_details_transition_name" translatable="false">tx_transition</string> <string name="tx_details_transition_name" translatable="false">tx_transition</string>
<string name="receive_transition_name" translatable="false">receive_transition</string>
<string name="receive_btn_transition_name" translatable="false">receive_btn_transition</string>
<string name="send_transition_name" translatable="false">send_transition</string>
<string name="send_btn_transition_name" translatable="false">send_btn_transition</string>
</resources> </resources>

Loading…
Cancel
Save