|
50 | 50 | import androidx.annotation.PluralsRes; |
51 | 51 | import androidx.annotation.WorkerThread; |
52 | 52 | import androidx.appcompat.app.AppCompatActivity; |
| 53 | +import androidx.appcompat.content.res.AppCompatResources; |
53 | 54 | import androidx.appcompat.view.ActionMode; |
54 | 55 | import androidx.appcompat.widget.Toolbar; |
55 | 56 | import androidx.appcompat.widget.TooltipCompat; |
56 | 57 | import androidx.constraintlayout.widget.ConstraintLayout; |
57 | 58 | import androidx.constraintlayout.widget.ConstraintSet; |
58 | | -import androidx.core.content.res.ResourcesCompat; |
| 59 | +import androidx.core.view.ViewCompat; |
59 | 60 | import androidx.fragment.app.DialogFragment; |
60 | 61 | import androidx.lifecycle.ViewModelProviders; |
61 | 62 | import androidx.recyclerview.widget.ItemTouchHelper; |
62 | 63 | import androidx.recyclerview.widget.LinearLayoutManager; |
63 | 64 | import androidx.recyclerview.widget.RecyclerView; |
64 | 65 | import androidx.transition.TransitionManager; |
65 | 66 |
|
| 67 | +import com.airbnb.lottie.SimpleColorFilter; |
66 | 68 | import com.annimon.stream.Stream; |
| 69 | +import com.google.android.material.animation.ArgbEvaluatorCompat; |
67 | 70 | import com.google.android.material.dialog.MaterialAlertDialogBuilder; |
68 | 71 | import com.google.android.material.snackbar.Snackbar; |
69 | 72 |
|
70 | 73 | import org.greenrobot.eventbus.EventBus; |
71 | 74 | import org.greenrobot.eventbus.Subscribe; |
72 | 75 | import org.greenrobot.eventbus.ThreadMode; |
| 76 | +import org.signal.core.util.DimensionUnit; |
73 | 77 | import org.signal.core.util.concurrent.SignalExecutors; |
74 | 78 | import org.signal.core.util.logging.Log; |
75 | 79 | import org.thoughtcrime.securesms.MainFragment; |
|
81 | 85 | import org.thoughtcrime.securesms.badges.self.expired.ExpiredBadgeBottomSheetDialogFragment; |
82 | 86 | import org.thoughtcrime.securesms.components.RatingManager; |
83 | 87 | import org.thoughtcrime.securesms.components.SearchToolbar; |
| 88 | +import org.thoughtcrime.securesms.components.UnreadPaymentsView; |
84 | 89 | import org.thoughtcrime.securesms.components.menu.ActionItem; |
85 | 90 | import org.thoughtcrime.securesms.components.menu.SignalBottomActionBar; |
86 | 91 | import org.thoughtcrime.securesms.components.menu.SignalContextMenu; |
87 | | -import org.thoughtcrime.securesms.components.UnreadPaymentsView; |
88 | 92 | import org.thoughtcrime.securesms.components.recyclerview.DeleteItemAnimator; |
89 | 93 | import org.thoughtcrime.securesms.components.registration.PulsingFloatingActionButton; |
90 | 94 | import org.thoughtcrime.securesms.components.reminder.DozeReminder; |
@@ -1236,7 +1240,7 @@ protected Toolbar getToolbar(@NonNull View rootView) { |
1236 | 1240 | } |
1237 | 1241 |
|
1238 | 1242 | protected @DrawableRes int getArchiveIconRes() { |
1239 | | - return R.drawable.ic_archive_white_36dp; |
| 1243 | + return R.drawable.ic_archive_24; |
1240 | 1244 | } |
1241 | 1245 |
|
1242 | 1246 | @WorkerThread |
@@ -1332,6 +1336,9 @@ private void goToSinglePayment(@NonNull UUID paymentId) { |
1332 | 1336 |
|
1333 | 1337 | private class ArchiveListenerCallback extends ItemTouchHelper.SimpleCallback { |
1334 | 1338 |
|
| 1339 | + private static final int ARCHIVE_SWIPE_START_COLOR = 0xFF28782A; |
| 1340 | + private static final int ARCHIVE_SWIPE_END_COLOR = 0xFF329635; |
| 1341 | + |
1335 | 1342 | ArchiveListenerCallback() { |
1336 | 1343 | super(0, ItemTouchHelper.RIGHT); |
1337 | 1344 | } |
@@ -1376,35 +1383,61 @@ public void onChildDraw(@NonNull Canvas canvas, @NonNull RecyclerView recyclerVi |
1376 | 1383 | { |
1377 | 1384 | if (viewHolder.itemView instanceof ConversationListItemInboxZero) return; |
1378 | 1385 | if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { |
1379 | | - View itemView = viewHolder.itemView; |
1380 | | - float alpha = 1.0f - Math.abs(dX) / (float) viewHolder.itemView.getWidth(); |
| 1386 | + Resources resources = getResources(); |
| 1387 | + View itemView = viewHolder.itemView; |
| 1388 | + float percentDx = Math.abs(dX) / viewHolder.itemView.getWidth(); |
| 1389 | + int color = ArgbEvaluatorCompat.getInstance().evaluate(Math.min(1f, percentDx * (1 / 0.25f)), ARCHIVE_SWIPE_START_COLOR, ARCHIVE_SWIPE_END_COLOR); |
| 1390 | + float scaleStartPoint = DimensionUnit.DP.toPixels(48f); |
| 1391 | + float scaleEndPoint = DimensionUnit.DP.toPixels(112f); |
| 1392 | + |
| 1393 | + float scale; |
| 1394 | + if (dX < scaleStartPoint) { |
| 1395 | + scale = 0.5f; |
| 1396 | + } else if (dX > scaleEndPoint) { |
| 1397 | + scale = 1f; |
| 1398 | + } else { |
| 1399 | + scale = Math.min(1f, 0.5f + ((dX - scaleStartPoint) / (scaleEndPoint - scaleStartPoint)) * (1f - 0.5f)); |
| 1400 | + } |
1381 | 1401 |
|
1382 | 1402 | if (dX > 0) { |
1383 | | - Resources resources = getResources(); |
1384 | | - |
1385 | 1403 | if (archiveDrawable == null) { |
1386 | | - archiveDrawable = ResourcesCompat.getDrawable(resources, getArchiveIconRes(), requireActivity().getTheme()); |
1387 | | - Objects.requireNonNull(archiveDrawable).setBounds(0, 0, archiveDrawable.getIntrinsicWidth(), archiveDrawable.getIntrinsicHeight()); |
| 1404 | + archiveDrawable = Objects.requireNonNull(AppCompatResources.getDrawable(requireContext(), getArchiveIconRes())); |
| 1405 | + archiveDrawable.setColorFilter(new SimpleColorFilter(Color.WHITE)); |
| 1406 | + archiveDrawable.setBounds(0, 0, archiveDrawable.getIntrinsicWidth(), archiveDrawable.getIntrinsicHeight()); |
1388 | 1407 | } |
1389 | 1408 |
|
1390 | 1409 | canvas.save(); |
1391 | | - canvas.clipRect(itemView.getLeft(), itemView.getTop(), dX, itemView.getBottom()); |
| 1410 | + canvas.clipRect(itemView.getLeft(), itemView.getTop(), itemView.getRight(), itemView.getBottom()); |
| 1411 | + |
| 1412 | + canvas.drawColor(color); |
1392 | 1413 |
|
1393 | | - canvas.drawColor(alpha > 0 ? resources.getColor(R.color.green_500) : Color.WHITE); |
| 1414 | + float gutter = resources.getDimension(R.dimen.dsl_settings_gutter); |
| 1415 | + float extra = resources.getDimension(R.dimen.conversation_list_fragment_archive_padding); |
1394 | 1416 |
|
1395 | | - canvas.translate(itemView.getLeft() + resources.getDimension(R.dimen.conversation_list_fragment_archive_padding), |
| 1417 | + canvas.translate(itemView.getLeft() + gutter + extra, |
1396 | 1418 | itemView.getTop() + (itemView.getBottom() - itemView.getTop() - archiveDrawable.getIntrinsicHeight()) / 2f); |
1397 | 1419 |
|
| 1420 | + canvas.scale(scale, scale, archiveDrawable.getIntrinsicWidth() / 2f, archiveDrawable.getIntrinsicHeight() / 2f); |
| 1421 | + |
1398 | 1422 | archiveDrawable.draw(canvas); |
1399 | 1423 | canvas.restore(); |
| 1424 | + |
| 1425 | + ViewCompat.setElevation(viewHolder.itemView, DimensionUnit.DP.toPixels(4f)); |
| 1426 | + } else if (dX == 0) { |
| 1427 | + ViewCompat.setElevation(viewHolder.itemView, DimensionUnit.DP.toPixels(0f)); |
1400 | 1428 | } |
1401 | 1429 |
|
1402 | | - viewHolder.itemView.setAlpha(alpha); |
1403 | 1430 | viewHolder.itemView.setTranslationX(dX); |
1404 | 1431 | } else { |
1405 | 1432 | super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); |
1406 | 1433 | } |
1407 | 1434 | } |
| 1435 | + |
| 1436 | + @Override |
| 1437 | + public void clearView(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { |
| 1438 | + super.clearView(recyclerView, viewHolder); |
| 1439 | + ViewCompat.setElevation(viewHolder.itemView, 0); |
| 1440 | + } |
1408 | 1441 | } |
1409 | 1442 |
|
1410 | 1443 | private class ScrollListener extends RecyclerView.OnScrollListener { |
|
0 commit comments