From 4ba3b75f858251099f18f07be700f9900128f8e1 Mon Sep 17 00:00:00 2001 From: Aditya Wasan Date: Tue, 15 Sep 2020 21:53:12 +0530 Subject: Update on-boarding UI (#1099) * Add onboarding flow from v2 Signed-off-by: Aditya Wasan * Minor fixes Signed-off-by: Aditya Wasan * Add changelog entry Signed-off-by: Aditya Wasan * Remove old activity from manifest Signed-off-by: Aditya Wasan * Remove view type prefix from view ids Signed-off-by: Aditya Wasan * Review fixes Signed-off-by: Aditya Wasan * Treewide: Reformat code Signed-off-by: Aditya Wasan * Moar review fixes Signed-off-by: Aditya Wasan * Revert "Treewide: Reformat code" This reverts commit 348ef0050942526a55890b245afec8d7fee4d81e. Signed-off-by: Harsh Shandilya * onboarding: cleanup OnboardingActivity init Signed-off-by: Harsh Shandilya * Remove unused layout Signed-off-by: Harsh Shandilya * Remove unnecessary ConstraintLayout Signed-off-by: Harsh Shandilya * Shorten animation duration Signed-off-by: Harsh Shandilya * onboarding: use viewBinding extension in fragments Signed-off-by: Harsh Shandilya Co-authored-by: Harsh Shandilya --- .../com/zeapo/pwdstore/utils/FragmentExtensions.kt | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 app/src/main/java/com/zeapo/pwdstore/utils/FragmentExtensions.kt (limited to 'app/src/main/java/com/zeapo/pwdstore/utils/FragmentExtensions.kt') diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/FragmentExtensions.kt b/app/src/main/java/com/zeapo/pwdstore/utils/FragmentExtensions.kt new file mode 100644 index 00000000..01103d19 --- /dev/null +++ b/app/src/main/java/com/zeapo/pwdstore/utils/FragmentExtensions.kt @@ -0,0 +1,52 @@ +package com.zeapo.pwdstore.utils + +import android.content.pm.PackageManager +import android.view.View +import androidx.annotation.IdRes +import androidx.core.content.ContextCompat +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.commit +import com.zeapo.pwdstore.R + +fun Fragment.isPermissionGranted(permission: String): Boolean { + return ContextCompat.checkSelfPermission(requireActivity(), permission) == PackageManager.PERMISSION_GRANTED +} + +fun Fragment.finish() = requireActivity().finish() + +fun FragmentManager.performTransaction(destinationFragment: Fragment, @IdRes containerViewId: Int = android.R.id.content) { + this.commit { + beginTransaction() + setCustomAnimations( + R.animator.slide_in_left, + R.animator.slide_out_left, + R.animator.slide_in_right, + R.animator.slide_out_right) + replace(containerViewId, destinationFragment) + } +} + +fun FragmentManager.performTransactionWithBackStack(destinationFragment: Fragment, @IdRes containerViewId: Int = android.R.id.content) { + this.commit { + beginTransaction() + addToBackStack(destinationFragment.tag) + setCustomAnimations( + R.animator.slide_in_left, + R.animator.slide_out_left, + R.animator.slide_in_right, + R.animator.slide_out_right) + replace(containerViewId, destinationFragment) + } +} + +fun FragmentManager.performSharedElementTransaction(destinationFragment: Fragment, views: List, @IdRes containerViewId: Int = android.R.id.content) { + this.commit { + beginTransaction() + for (view in views) { + addSharedElement(view, view.transitionName) + } + addToBackStack(destinationFragment.tag) + replace(containerViewId, destinationFragment) + } +} -- cgit v1.2.3