diff options
author | Allan Wang <me@allanwang.ca> | 2020-01-19 21:25:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-19 21:25:07 -0800 |
commit | a2c491f446add0191ab8f9a93dece8b37c9be984 (patch) | |
tree | 9fa1298e5ff8e3d7435f98133825b36def41a656 | |
parent | 4134ddad6a50498efc77fbad829bea259647c0fc (diff) | |
parent | 172f8209a1e448f1e6cfc304dbb7dfef573da736 (diff) | |
download | frost-a2c491f446add0191ab8f9a93dece8b37c9be984.tar.gz frost-a2c491f446add0191ab8f9a93dece8b37c9be984.tar.bz2 frost-a2c491f446add0191ab8f9a93dece8b37c9be984.zip |
Merge pull request #1621 from AllanWang/intro-ui
Intro ui updates
5 files changed, 41 insertions, 41 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt index 77a58cf2..c76cad16 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt @@ -22,17 +22,12 @@ import android.graphics.Color import android.os.Bundle import android.view.View import android.view.WindowManager -import android.widget.Button -import android.widget.ImageButton import android.widget.ImageView import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter import androidx.viewpager.widget.ViewPager import ca.allanwang.kau.internal.KauBaseActivity -import ca.allanwang.kau.ui.views.RippleCanvas -import ca.allanwang.kau.ui.widgets.InkPageIndicator -import ca.allanwang.kau.utils.bindView import ca.allanwang.kau.utils.blendWith import ca.allanwang.kau.utils.color import ca.allanwang.kau.utils.fadeScaleTransition @@ -43,6 +38,7 @@ import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.statusBarColor import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import com.pitchedapps.frost.R +import com.pitchedapps.frost.databinding.ActivityIntroBinding import com.pitchedapps.frost.intro.BaseIntroFragment import com.pitchedapps.frost.intro.IntroAccountFragment import com.pitchedapps.frost.intro.IntroFragmentAnalytics @@ -68,12 +64,7 @@ import kotlinx.coroutines.launch */ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.OnPageChangeListener { - val ripple: RippleCanvas by bindView(R.id.intro_ripple) - val viewpager: ViewPager by bindView(R.id.intro_viewpager) - lateinit var adapter: IntroPageAdapter - val indicator: InkPageIndicator by bindView(R.id.intro_indicator) - val skip: Button by bindView(R.id.intro_skip) - val next: ImageButton by bindView(R.id.intro_next) + lateinit var binding: ActivityIntroBinding private var barHasNext = true val fragments = listOf( @@ -88,12 +79,16 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_intro) - adapter = IntroPageAdapter(supportFragmentManager, fragments) + binding = ActivityIntroBinding.inflate(layoutInflater) + setContentView(binding.root) + binding.init() + } + + private fun ActivityIntroBinding.init() { viewpager.apply { setPageTransformer(true, this@IntroActivity) addOnPageChangeListener(this@IntroActivity) - adapter = this@IntroActivity.adapter + adapter = IntroPageAdapter(supportFragmentManager, fragments) } indicator.setViewPager(viewpager) next.setIcon(GoogleMaterial.Icon.gmd_navigate_next) @@ -109,10 +104,12 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On fun theme() { statusBarColor = Prefs.headerColor navigationBarColor = Prefs.headerColor - skip.setTextColor(Prefs.textColor) - next.imageTintList = ColorStateList.valueOf(Prefs.textColor) - indicator.setColour(Prefs.textColor) - indicator.invalidate() + with(binding) { + skip.setTextColor(Prefs.textColor) + next.imageTintList = ColorStateList.valueOf(Prefs.textColor) + indicator.setColour(Prefs.textColor) + indicator.invalidate() + } fragments.forEach { it.themeFragment() } setFrostTheme(true) } @@ -141,12 +138,12 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE ) - ripple.ripple(blue, x, y, 600) { + binding.ripple.ripple(blue, x, y, 600) { postDelayed(1000) { finish() } } val lastView: View? = fragments.last().view arrayOf<View?>( - skip, indicator, next, + binding.skip, binding.indicator, binding.next, lastView?.findViewById(R.id.intro_title), lastView?.findViewById(R.id.intro_desc) ).forEach { @@ -186,8 +183,10 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On } override fun onBackPressed() { - if (viewpager.currentItem > 0) viewpager.setCurrentItem(viewpager.currentItem - 1, true) - else finish() + with(binding) { + if (viewpager.currentItem > 0) viewpager.setCurrentItem(viewpager.currentItem - 1, true) + else finish() + } } override fun onPageScrollStateChanged(state: Int) { @@ -204,13 +203,13 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On val hasNext = position != fragments.size - 1 if (barHasNext == hasNext) return barHasNext = hasNext - next.fadeScaleTransition { + binding.next.fadeScaleTransition { setIcon( if (barHasNext) GoogleMaterial.Icon.gmd_navigate_next else GoogleMaterial.Icon.gmd_done, color = Prefs.textColor ) } - skip.animate().scaleXY(if (barHasNext) 1f else 0f) + binding.skip.animate().scaleXY(if (barHasNext) 1f else 0f) } class IntroPageAdapter(fm: FragmentManager, private val fragments: List<BaseIntroFragment>) : diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt index d760d416..64d675e1 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt @@ -56,7 +56,7 @@ class IntroFragmentTheme : BaseIntroFragment(R.layout.intro_theme) { setOnClickListener { v -> Prefs.theme = theme.ordinal (activity as IntroActivity).apply { - ripple.ripple(Prefs.bgColor, v.x + v.pivotX, v.y + v.pivotY) + binding.ripple.ripple(Prefs.bgColor, v.x + v.pivotX, v.y + v.pivotY) theme() } themeList.forEach { it.animate().scaleXY(if (it == this) 1.6f else 0.8f).start() } diff --git a/app/src/main/res/layout/activity_intro.xml b/app/src/main/res/layout/activity_intro.xml index e61a618d..5ea43adf 100644 --- a/app/src/main/res/layout/activity_intro.xml +++ b/app/src/main/res/layout/activity_intro.xml @@ -6,7 +6,7 @@ android:fitsSystemWindows="true"> <ca.allanwang.kau.ui.views.RippleCanvas - android:id="@+id/intro_ripple" + android:id="@+id/ripple" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintBottom_toBottomOf="parent" @@ -15,49 +15,49 @@ app:layout_constraintTop_toTopOf="parent" /> <androidx.constraintlayout.widget.Guideline - android:id="@+id/intro_bar_guide" + android:id="@+id/bar_guide" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintGuide_end="@dimen/intro_bar_height" /> <androidx.viewpager.widget.ViewPager - android:id="@+id/intro_viewpager" + android:id="@+id/viewpager" android:layout_width="0dp" android:layout_height="0dp" - app:layout_constraintBottom_toTopOf="@id/intro_bar_guide" + app:layout_constraintBottom_toTopOf="@id/bar_guide" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - <Button - android:id="@+id/intro_skip" + <TextView + android:id="@+id/skip" style="@style/IntroBarButton" android:layout_width="wrap_content" android:layout_height="0dp" android:text="@string/skip" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/intro_bar_guide" /> + app:layout_constraintTop_toBottomOf="@id/bar_guide" /> <ca.allanwang.kau.ui.widgets.InkPageIndicator - android:id="@+id/intro_indicator" + android:id="@+id/indicator" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/intro_bar_guide" + app:layout_constraintTop_toBottomOf="@id/bar_guide" app:layout_constraintVertical_bias="0.5" /> <ImageButton - android:id="@+id/intro_next" + android:id="@+id/next" style="@style/IntroBarButton" android:layout_width="wrap_content" android:layout_height="0dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toBottomOf="@id/intro_bar_guide" /> + app:layout_constraintTop_toBottomOf="@id/bar_guide" /> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/intro_theme.xml b/app/src/main/res/layout/intro_theme.xml index cd0538dd..0a9d5f63 100644 --- a/app/src/main/res/layout/intro_theme.xml +++ b/app/src/main/res/layout/intro_theme.xml @@ -18,7 +18,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - <Button + <TextView android:id="@+id/intro_theme_light" style="@style/IntroButton" android:layout_width="wrap_content" @@ -32,7 +32,7 @@ app:layout_constraintVertical_bias="0.33" tools:layout_editor_absoluteX="112dp" /> - <Button + <TextView android:id="@+id/intro_theme_dark" style="@style/IntroButton" android:layout_width="wrap_content" @@ -46,7 +46,7 @@ app:layout_constraintVertical_bias="0.33" tools:layout_editor_absoluteX="112dp" /> - <Button + <TextView android:id="@+id/intro_theme_amoled" style="@style/IntroButton" android:layout_width="wrap_content" @@ -60,7 +60,7 @@ app:layout_constraintVertical_bias="0.66" tools:layout_editor_absoluteX="112dp" /> - <Button + <TextView android:id="@+id/intro_theme_glass" style="@style/IntroButton" android:layout_width="wrap_content" diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4775a892..b94f754f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -74,6 +74,7 @@ <style name="IntroBarButton" parent="Widget.AppCompat.Button.Borderless"> <item name="android:elevation">0dp</item> <item name="android:minWidth">100dp</item> + <item name="android:background">?selectableItemBackground</item> <item name="android:layout_marginStart">@dimen/kau_padding_small</item> <item name="android:layout_marginEnd">@dimen/kau_padding_small</item> </style> @@ -94,7 +95,7 @@ <style name="IntroButton" parent="TextAppearance.AppCompat.Button"> <item name="android:elevation">0dp</item> - <item name="android:background">?android:selectableItemBackgroundBorderless</item> + <item name="android:background">?selectableItemBackgroundBorderless</item> <item name="android:padding">@dimen/kau_padding_large</item> </style> |