aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-12-28 00:45:35 -0800
committerAllan Wang <me@allanwang.ca>2019-12-28 00:45:35 -0800
commit006bc3d1a4798859fdce3c49f8a8690c823f1d7f (patch)
treee17b662c7357dff060b5963dac6f3ef09ef922a9 /app/src/main
parent765aba2b34a33d67acccb90789b818817fec2181 (diff)
downloadfrost-006bc3d1a4798859fdce3c49f8a8690c823f1d7f.tar.gz
frost-006bc3d1a4798859fdce3c49f8a8690c823f1d7f.tar.bz2
frost-006bc3d1a4798859fdce3c49f8a8690c823f1d7f.zip
Add additional options content
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt65
-rw-r--r--app/src/main/res/layout/view_nav_header.xml17
-rw-r--r--app/src/main/res/values/dimens.xml2
-rw-r--r--app/src/main/res/values/styles.xml19
4 files changed, 97 insertions, 6 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
index 3543300d..dee94046 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -22,6 +22,7 @@ import android.content.Context
import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.PointF
+import android.graphics.drawable.Drawable
import android.graphics.drawable.RippleDrawable
import android.net.Uri
import android.os.Bundle
@@ -33,6 +34,7 @@ import android.webkit.WebChromeClient
import android.webkit.WebView
import android.widget.FrameLayout
import android.widget.ImageView
+import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.widget.Toolbar
@@ -47,11 +49,11 @@ import ca.allanwang.kau.searchview.bindSearchView
import ca.allanwang.kau.ui.ProgressAnimator
import ca.allanwang.kau.utils.adjustAlpha
import ca.allanwang.kau.utils.colorToForeground
+import ca.allanwang.kau.utils.dimenPixelSize
import ca.allanwang.kau.utils.drawable
import ca.allanwang.kau.utils.fadeScaleTransition
import ca.allanwang.kau.utils.gone
import ca.allanwang.kau.utils.invisible
-import ca.allanwang.kau.utils.isVisible
import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.restart
import ca.allanwang.kau.utils.setIcon
@@ -63,6 +65,9 @@ import ca.allanwang.kau.utils.toDrawable
import ca.allanwang.kau.utils.visible
import ca.allanwang.kau.utils.withMinAlpha
import com.afollestad.materialdialogs.checkbox.checkBoxPrompt
+import com.bumptech.glide.Glide
+import com.bumptech.glide.request.target.CustomTarget
+import com.bumptech.glide.request.transition.Transition
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.tabs.TabLayout
@@ -483,7 +488,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
)
)
var showOptions = false
- val animator: ProgressAnimator = ProgressAnimator.ofFloat { }
+ val animator: ProgressAnimator = ProgressAnimator.ofFloat { }
background.setOnClickListener {
animator.reset()
if (showOptions) {
@@ -499,7 +504,10 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
} else {
animator.apply {
- optionsContainer.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
+ optionsContainer.measure(
+ View.MeasureSpec.UNSPECIFIED,
+ View.MeasureSpec.UNSPECIFIED
+ )
withAnimator(
optionsContainer.height.toFloat(),
optionsContainer.measuredHeight.toFloat()
@@ -516,6 +524,19 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
showOptions = !showOptions
animator.start()
}
+
+ fun TextView.setOptionsIcon(iicon: IIcon) {
+ setCompoundDrawablesRelativeWithIntrinsicBounds(
+ iicon.toDrawable(this@BaseMainActivity, sizeDp = 20),
+ null,
+ null,
+ null
+ )
+ }
+
+ optionsLogout.setOptionsIcon(GoogleMaterial.Icon.gmd_exit_to_app)
+ optionsAddAccount.setOptionsIcon(GoogleMaterial.Icon.gmd_add)
+ optionsManageAccount.setOptionsIcon(GoogleMaterial.Icon.gmd_settings)
}
}
@@ -536,6 +557,44 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
avatarPrimary.setAccount(orderedAccounts.getOrNull(0), true)
avatarSecondary.setAccount(orderedAccounts.getOrNull(1), false)
avatarTertiary.setAccount(orderedAccounts.getOrNull(2), false)
+ optionsAccountsContainer.removeAllViews()
+ name.text = orderedAccounts.getOrNull(0)?.name
+ val glide = Glide.with(root)
+ val accountSize = dimenPixelSize(R.dimen.drawer_account_avatar_size)
+ orderedAccounts.forEach {
+ val tv =
+ TextView(
+ this@BaseMainActivity,
+ null,
+ 0,
+ R.style.Main_DrawerAccountUserOptions
+ )
+ glide.load(profilePictureUrl(it.id)).transform(FrostGlide.circleCrop)
+ .into(object : CustomTarget<Drawable>(accountSize, accountSize) {
+ override fun onLoadCleared(placeholder: Drawable?) {
+ tv.setCompoundDrawablesRelativeWithIntrinsicBounds(
+ placeholder,
+ null,
+ null,
+ null
+ )
+ }
+
+ override fun onResourceReady(
+ resource: Drawable,
+ transition: Transition<in Drawable>?
+ ) {
+ tv.setCompoundDrawablesRelativeWithIntrinsicBounds(
+ resource,
+ null,
+ null,
+ null
+ )
+ }
+ })
+ tv.text = it.name
+ optionsAccountsContainer.addView(tv)
+ }
}
private fun closeDrawer() {
diff --git a/app/src/main/res/layout/view_nav_header.xml b/app/src/main/res/layout/view_nav_header.xml
index af918736..38df36d7 100644
--- a/app/src/main/res/layout/view_nav_header.xml
+++ b/app/src/main/res/layout/view_nav_header.xml
@@ -8,6 +8,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
+ android:elevation="2dp"
android:layout_height="160dp">
<androidx.appcompat.widget.AppCompatImageView
@@ -86,6 +87,18 @@
android:visibility="gone"
tools:visibility="visible">
+ <LinearLayout
+ android:id="@+id/options_accounts_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" />
+
+ <TextView
+ android:id="@+id/options_logout"
+ style="@style/Main.DrawerAccountOptions"
+ android:text="@string/kau_logout"
+ tools:drawableStart="@drawable/abc_vector_test" />
+
<TextView
android:id="@+id/options_add_account"
style="@style/Main.DrawerAccountOptions"
@@ -93,9 +106,9 @@
tools:drawableStart="@drawable/abc_vector_test" />
<TextView
- android:id="@+id/options_logout"
+ android:id="@+id/options_manage_account"
style="@style/Main.DrawerAccountOptions"
- android:text="@string/kau_logout"
+ android:text="@string/kau_manage_account"
tools:drawableStart="@drawable/abc_vector_test" />
</LinearLayout>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 1f66683d..c81aee3c 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -13,4 +13,6 @@
<dimen name="toolbar_icon_size">24dp</dimen>
<dimen name="dialog_corner_radius">8dp</dimen>
+
+ <dimen name="drawer_account_avatar_size">32dp</dimen>
</resources>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index b194a975..38c5de7d 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -157,11 +157,28 @@
<item name="android:layout_height">40dp</item>
</style>
- <style name="Main.DrawerAccountOptions" parent="Main.DrawerMargins">
+ <!-- Expected icon size is 20dp to match NavigationView -->
+ <style name="Main.DrawerAccountOptions" parent="">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:drawablePadding">16dp</item>
+ <item name="android:paddingStart">24dp</item>
+ <item name="android:paddingEnd">24dp</item>
+ <item name="android:paddingTop">16dp</item>
+ <item name="android:paddingBottom">16dp</item>
<item name="android:gravity">center_vertical</item>
</style>
+ <!-- Avatar size is 32dp (R.dimen.drawer_account_avatar_size) -->
+ <style name="Main.DrawerAccountUserOptions" parent="">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:paddingTop">10dp</item>
+ <item name="android:paddingBottom">10dp</item>
+ <item name="android:drawablePadding">10dp</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:paddingStart">18dp</item>
+ <item name="android:paddingEnd">24dp</item>
+ </style>
+
</resources>