diff options
author | Allan Wang <me@allanwang.ca> | 2019-12-26 16:14:44 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-12-26 16:14:44 -0800 |
commit | 42a23c00ae98a0e4a6f493b7d6ce9a23d717e5f6 (patch) | |
tree | 64234418a0b7e29925411a3c9270ebd64f8d6192 /app/src | |
parent | ee68ef07ca0f0afd00bfe32f7e7dbba8ef6a6ae2 (diff) | |
download | frost-42a23c00ae98a0e4a6f493b7d6ce9a23d717e5f6.tar.gz frost-42a23c00ae98a0e4a6f493b7d6ce9a23d717e5f6.tar.bz2 frost-42a23c00ae98a0e4a6f493b7d6ce9a23d717e5f6.zip |
Remove material drawer dependency
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt | 26 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt | 298 | ||||
-rw-r--r-- | app/src/main/res/values/styles.xml | 9 |
3 files changed, 153 insertions, 180 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt index ea0de778..a5cba69b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt @@ -28,8 +28,6 @@ import com.bugsnag.android.Bugsnag import com.bugsnag.android.Configuration import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.signature.ApplicationVersionSignature -import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader -import com.mikepenz.materialdrawer.util.DrawerImageLoader import com.pitchedapps.frost.db.FrostDatabase import com.pitchedapps.frost.glide.GlideApp import com.pitchedapps.frost.services.scheduleNotificationsFromPrefs @@ -79,18 +77,18 @@ class FrostApp : Application() { * Drawer profile loading logic * Reload the image on every version update */ - DrawerImageLoader.init(object : AbstractDrawerImageLoader() { - override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) { - val c = imageView.context - val request = GlideApp.with(c) - val old = request.load(uri).apply(RequestOptions().placeholder(placeholder)) - request.load(uri).apply( - RequestOptions() - .signature(ApplicationVersionSignature.obtain(c)) - ) - .thumbnail(old).into(imageView) - } - }) +// DrawerImageLoader.init(object : AbstractDrawerImageLoader() { +// override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) { +// val c = imageView.context +// val request = GlideApp.with(c) +// val old = request.load(uri).apply(RequestOptions().placeholder(placeholder)) +// request.load(uri).apply( +// RequestOptions() +// .signature(ApplicationVersionSignature.obtain(c)) +// ) +// .thumbnail(old).into(imageView) +// } +// }) if (BuildConfig.DEBUG) { registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks { override fun onActivityPaused(activity: Activity) {} 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 858f8590..fef7bfe5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -21,7 +21,6 @@ import android.app.ActivityOptions import android.content.Intent import android.content.res.ColorStateList import android.graphics.PointF -import android.graphics.drawable.ColorDrawable import android.net.Uri import android.os.Bundle import android.view.Menu @@ -30,7 +29,6 @@ import android.webkit.ValueCallback import android.webkit.WebChromeClient import android.webkit.WebView import android.widget.FrameLayout -import androidx.annotation.StringRes import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentPagerAdapter @@ -47,26 +45,12 @@ import ca.allanwang.kau.utils.setMenuIcons import ca.allanwang.kau.utils.showIf import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.tint -import ca.allanwang.kau.utils.toast import ca.allanwang.kau.utils.withMinAlpha -import co.zsmb.materialdrawerkt.builders.Builder -import co.zsmb.materialdrawerkt.builders.accountHeader -import co.zsmb.materialdrawerkt.builders.drawer -import co.zsmb.materialdrawerkt.draweritems.badgeable.primaryItem -import co.zsmb.materialdrawerkt.draweritems.badgeable.secondaryItem -import co.zsmb.materialdrawerkt.draweritems.divider -import co.zsmb.materialdrawerkt.draweritems.profile.profile -import co.zsmb.materialdrawerkt.draweritems.profile.profileSetting import com.afollestad.materialdialogs.checkbox.checkBoxPrompt import com.google.android.material.appbar.AppBarLayout import com.google.android.material.tabs.TabLayout -import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial -import com.mikepenz.iconics.utils.colorInt -import com.mikepenz.iconics.utils.paddingDp -import com.mikepenz.materialdrawer.AccountHeader -import com.mikepenz.materialdrawer.Drawer import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R import com.pitchedapps.frost.contracts.FileChooserContract @@ -75,14 +59,12 @@ import com.pitchedapps.frost.contracts.MainActivityContract import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.db.CookieDao import com.pitchedapps.frost.db.GenericDao -import com.pitchedapps.frost.db.currentCookie import com.pitchedapps.frost.db.getTabs import com.pitchedapps.frost.enums.MainActivityLayout import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.parsers.FrostSearch import com.pitchedapps.frost.facebook.parsers.SearchParser -import com.pitchedapps.frost.facebook.profilePictureUrl import com.pitchedapps.frost.fragments.BaseFragment import com.pitchedapps.frost.fragments.WebFragment import com.pitchedapps.frost.services.scheduleNotificationsFromPrefs @@ -104,8 +86,6 @@ import com.pitchedapps.frost.utils.cookies import com.pitchedapps.frost.utils.frostChangelog import com.pitchedapps.frost.utils.frostEvent import com.pitchedapps.frost.utils.frostNavigationBar -import com.pitchedapps.frost.utils.launchLogin -import com.pitchedapps.frost.utils.launchNewTask import com.pitchedapps.frost.utils.launchWebOverlay import com.pitchedapps.frost.utils.setFrostColors import com.pitchedapps.frost.views.BadgedIcon @@ -150,8 +130,8 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, protected var lastPosition = -1 override var videoViewer: FrostVideoViewer? = null - private lateinit var drawer: Drawer - private lateinit var drawerHeader: AccountHeader + // private lateinit var drawer: Drawer +// private lateinit var drawerHeader: AccountHeader private var lastAccessTime = -1L override var searchView: SearchView? = null @@ -192,7 +172,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, ) } } - setupDrawer(savedInstanceState) +// setupDrawer(savedInstanceState) L.i { "Main started in ${System.currentTimeMillis() - start} ms" } initFab() lastAccessTime = System.currentTimeMillis() @@ -249,138 +229,138 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } } - private fun setupDrawer(savedInstanceState: Bundle?) { - val navBg = Prefs.bgColor.withMinAlpha(200).toLong() - val navHeader = Prefs.headerColor.withMinAlpha(200) - drawer = drawer { - toolbar = this@BaseMainActivity.toolbar - savedInstance = savedInstanceState - translucentStatusBar = false - sliderBackgroundColor = navBg - drawerHeader = accountHeader { - textColor = Prefs.iconColor.toLong() - backgroundDrawable = ColorDrawable(navHeader) - selectionSecondLineShown = false - cookies().forEach { (id, name) -> - profile(name = name ?: "") { - iconUrl = profilePictureUrl(id) - textColor = Prefs.textColor.toLong() - selectedTextColor = Prefs.textColor.toLong() - selectedColor = 0x00000001.toLong() - identifier = id - } - } - profileSetting(nameRes = R.string.kau_logout) { - iicon = GoogleMaterial.Icon.gmd_exit_to_app - iconColor = Prefs.textColor.toLong() - textColor = Prefs.textColor.toLong() - identifier = -2L - } - profileSetting(nameRes = R.string.kau_add_account) { - iconDrawable = - IconicsDrawable( - this@BaseMainActivity, - GoogleMaterial.Icon.gmd_add - ).actionBar().paddingDp(5) - .colorInt(Prefs.textColor) - textColor = Prefs.textColor.toLong() - identifier = -3L - } - profileSetting(nameRes = R.string.kau_manage_account) { - iicon = GoogleMaterial.Icon.gmd_settings - iconColor = Prefs.textColor.toLong() - textColor = Prefs.textColor.toLong() - identifier = -4L - } - onProfileChanged { _, profile, current -> - if (current) launchWebOverlay(FbItem.PROFILE.url) - else when (profile.identifier) { - -2L -> { - // TODO no backpressure support - this@BaseMainActivity.launch { - val currentCookie = cookieDao.currentCookie() - if (currentCookie == null) { - toast(R.string.account_not_found) - FbCookie.reset() - launchLogin(cookies(), true) - } else { - materialDialog { - title(R.string.kau_logout) - message( - text = - String.format( - string(R.string.kau_logout_confirm_as_x), - currentCookie.name ?: Prefs.userId.toString() - ) - ) - positiveButton(R.string.kau_yes) { - this@BaseMainActivity.launch { - FbCookie.logout(this@BaseMainActivity) - } - } - negativeButton(R.string.kau_no) - } - } - } - } - -3L -> launchNewTask<LoginActivity>(clearStack = false) - -4L -> launchNewTask<SelectorActivity>(cookies(), false) - else -> { - this@BaseMainActivity.launch { - FbCookie.switchUser(profile.identifier) - tabsForEachView { _, view -> view.badgeText = null } - refreshAll() - } - } - } - false - } - } - drawerHeader.setActiveProfile(Prefs.userId) - primaryFrostItem(FbItem.FEED_MOST_RECENT) - primaryFrostItem(FbItem.FEED_TOP_STORIES) - primaryFrostItem(FbItem.ACTIVITY_LOG) - divider() - primaryFrostItem(FbItem.PHOTOS) - primaryFrostItem(FbItem.GROUPS) - primaryFrostItem(FbItem.FRIENDS) - primaryFrostItem(FbItem.CHAT) - primaryFrostItem(FbItem.PAGES) - divider() - primaryFrostItem(FbItem.EVENTS) - primaryFrostItem(FbItem.BIRTHDAYS) - primaryFrostItem(FbItem.ON_THIS_DAY) - divider() - primaryFrostItem(FbItem.NOTES) - primaryFrostItem(FbItem.SAVED) - primaryFrostItem(FbItem.MARKETPLACE) - } - } - - private fun Builder.primaryFrostItem(item: FbItem) = this.primaryItem(item.titleId) { - iicon = item.icon - iconColor = Prefs.textColor.toLong() - textColor = Prefs.textColor.toLong() - selectedIconColor = Prefs.textColor.toLong() - selectedTextColor = Prefs.textColor.toLong() - selectedColor = 0x00000001.toLong() - identifier = item.titleId.toLong() - onClick { _ -> - frostEvent("Drawer Tab", "name" to item.name) - launchWebOverlay(item.url) - false - } - } - - private fun Builder.secondaryFrostItem(@StringRes title: Int, onClick: () -> Unit) = - this.secondaryItem(title) { - textColor = Prefs.textColor.toLong() - selectedIconColor = Prefs.textColor.toLong() - selectedTextColor = Prefs.textColor.toLong() - selectedColor = 0x00000001.toLong() - identifier = title.toLong() - onClick { _ -> onClick(); false } - } +// private fun setupDrawer(savedInstanceState: Bundle?) { +// val navBg = Prefs.bgColor.withMinAlpha(200).toLong() +// val navHeader = Prefs.headerColor.withMinAlpha(200) +// drawer = drawer { +// toolbar = this@BaseMainActivity.toolbar +// savedInstance = savedInstanceState +// translucentStatusBar = false +// sliderBackgroundColor = navBg +// drawerHeader = accountHeader { +// textColor = Prefs.iconColor.toLong() +// backgroundDrawable = ColorDrawable(navHeader) +// selectionSecondLineShown = false +// cookies().forEach { (id, name) -> +// profile(name = name ?: "") { +// iconUrl = profilePictureUrl(id) +// textColor = Prefs.textColor.toLong() +// selectedTextColor = Prefs.textColor.toLong() +// selectedColor = 0x00000001.toLong() +// identifier = id +// } +// } +// profileSetting(nameRes = R.string.kau_logout) { +// iicon = GoogleMaterial.Icon.gmd_exit_to_app +// iconColor = Prefs.textColor.toLong() +// textColor = Prefs.textColor.toLong() +// identifier = -2L +// } +// profileSetting(nameRes = R.string.kau_add_account) { +// iconDrawable = +// IconicsDrawable( +// this@BaseMainActivity, +// GoogleMaterial.Icon.gmd_add +// ).actionBar().paddingDp(5) +// .colorInt(Prefs.textColor) +// textColor = Prefs.textColor.toLong() +// identifier = -3L +// } +// profileSetting(nameRes = R.string.kau_manage_account) { +// iicon = GoogleMaterial.Icon.gmd_settings +// iconColor = Prefs.textColor.toLong() +// textColor = Prefs.textColor.toLong() +// identifier = -4L +// } +// onProfileChanged { _, profile, current -> +// if (current) launchWebOverlay(FbItem.PROFILE.url) +// else when (profile.identifier) { +// -2L -> { +// // TODO no backpressure support +// this@BaseMainActivity.launch { +// val currentCookie = cookieDao.currentCookie() +// if (currentCookie == null) { +// toast(R.string.account_not_found) +// FbCookie.reset() +// launchLogin(cookies(), true) +// } else { +// materialDialog { +// title(R.string.kau_logout) +// message( +// text = +// String.format( +// string(R.string.kau_logout_confirm_as_x), +// currentCookie.name ?: Prefs.userId.toString() +// ) +// ) +// positiveButton(R.string.kau_yes) { +// this@BaseMainActivity.launch { +// FbCookie.logout(this@BaseMainActivity) +// } +// } +// negativeButton(R.string.kau_no) +// } +// } +// } +// } +// -3L -> launchNewTask<LoginActivity>(clearStack = false) +// -4L -> launchNewTask<SelectorActivity>(cookies(), false) +// else -> { +// this@BaseMainActivity.launch { +// FbCookie.switchUser(profile.identifier) +// tabsForEachView { _, view -> view.badgeText = null } +// refreshAll() +// } +// } +// } +// false +// } +// } +// drawerHeader.setActiveProfile(Prefs.userId) +// primaryFrostItem(FbItem.FEED_MOST_RECENT) +// primaryFrostItem(FbItem.FEED_TOP_STORIES) +// primaryFrostItem(FbItem.ACTIVITY_LOG) +// divider() +// primaryFrostItem(FbItem.PHOTOS) +// primaryFrostItem(FbItem.GROUPS) +// primaryFrostItem(FbItem.FRIENDS) +// primaryFrostItem(FbItem.CHAT) +// primaryFrostItem(FbItem.PAGES) +// divider() +// primaryFrostItem(FbItem.EVENTS) +// primaryFrostItem(FbItem.BIRTHDAYS) +// primaryFrostItem(FbItem.ON_THIS_DAY) +// divider() +// primaryFrostItem(FbItem.NOTES) +// primaryFrostItem(FbItem.SAVED) +// primaryFrostItem(FbItem.MARKETPLACE) +// } +// } + +// private fun Builder.primaryFrostItem(item: FbItem) = this.primaryItem(item.titleId) { +// iicon = item.icon +// iconColor = Prefs.textColor.toLong() +// textColor = Prefs.textColor.toLong() +// selectedIconColor = Prefs.textColor.toLong() +// selectedTextColor = Prefs.textColor.toLong() +// selectedColor = 0x00000001.toLong() +// identifier = item.titleId.toLong() +// onClick { _ -> +// frostEvent("Drawer Tab", "name" to item.name) +// launchWebOverlay(item.url) +// false +// } +// } +// +// private fun Builder.secondaryFrostItem(@StringRes title: Int, onClick: () -> Unit) = +// this.secondaryItem(title) { +// textColor = Prefs.textColor.toLong() +// selectedIconColor = Prefs.textColor.toLong() +// selectedTextColor = Prefs.textColor.toLong() +// selectedColor = 0x00000001.toLong() +// identifier = title.toLong() +// onClick { _ -> onClick(); false } +// } private fun refreshAll() { L.d { "Refresh all" } @@ -549,10 +529,10 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } override fun backConsumer(): Boolean { - if (drawer.isDrawerOpen) { - drawer.closeDrawer() - return true - } +// if (drawer.isDrawerOpen) { +// drawer.closeDrawer() +// return true +// } if (currentFragment.onBackPressed()) return true if (Prefs.exitConfirmation) { materialDialog { diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 90978724..4d22ee79 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,6 +1,6 @@ <resources> - <style name="FrostThemeBase" parent="MaterialDrawerTheme.ActionBar"> + <style name="FrostTheme" parent="Theme.MaterialComponents.NoActionBar"> <item name="colorPrimary">@color/facebook_blue</item> <item name="colorPrimaryDark">@color/facebook_blue_dark</item> <item name="colorAccent">@android:color/white</item> @@ -11,12 +11,7 @@ <item name="md_corner_radius">@dimen/dialog_corner_radius</item> </style> - <style name="FrostTheme" parent="@style/FrostThemeBase"> - <item name="windowActionBar">false</item> - <item name="windowNoTitle">true</item> - </style> - - <style name="FrostTheme.Light" parent="MaterialDrawerTheme.Light.DarkToolbar"> + <style name="FrostTheme.Light" parent="Theme.MaterialComponents.Light.NoActionBar"> <item name="colorPrimary">@color/facebook_blue</item> <item name="colorPrimaryDark">@color/facebook_blue_dark</item> <item name="colorAccent">@android:color/black</item> |