From 42a23c00ae98a0e4a6f493b7d6ce9a23d717e5f6 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 26 Dec 2019 16:14:44 -0800 Subject: Remove material drawer dependency --- .../main/kotlin/com/pitchedapps/frost/FrostApp.kt | 26 +- .../frost/activities/BaseMainActivity.kt | 298 ++++++++++----------- app/src/main/res/values/styles.xml | 9 +- 3 files changed, 153 insertions(+), 180 deletions(-) (limited to 'app/src/main') 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(clearStack = false) - -4L -> launchNewTask(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(clearStack = false) +// -4L -> launchNewTask(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 @@ - - - - + + + + + + + + + + + -- cgit v1.2.3 From 454872d712a0496e97b7138b30cc2fccac037b2f Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 26 Dec 2019 17:04:17 -0800 Subject: Remove extra vars and reattach onBackPress --- .../frost/activities/BaseMainActivity.kt | 143 +++++++++++---------- .../res/layout/activity_main_drawer_wrapper.xml | 1 + 2 files changed, 76 insertions(+), 68 deletions(-) (limited to 'app/src/main') 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 f61e7f3e..3fa65ba3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -118,18 +118,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, override val frameWrapper: FrameLayout get() = drawerWrapperBinding.mainContainer lateinit var drawerWrapperBinding: ActivityMainDrawerWrapperBinding lateinit var contentBinding: ActivityMainContentBinding - val viewPager: FrostViewPager get() = contentBinding.viewpager - val fab: FloatingActionButton get() =contentBinding.fab - val toolbar: Toolbar get() = contentBinding.toolbar val cookieDao: CookieDao by inject() val genericDao: GenericDao by inject() - /* - * Components with the same id in multiple layout files - */ - val tabs: TabLayout get() = contentBinding.tabs - val appBar: AppBarLayout get() = contentBinding.appbar - interface ActivityMainContentBinding { val root: View val toolbar: Toolbar @@ -142,8 +133,6 @@ 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 var lastAccessTime = -1L override var searchView: SearchView? = null @@ -180,15 +169,18 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } } drawerWrapperBinding.mainContainer.addView(contentBinding.root) - setFrostColors { - toolbar(toolbar) - themeWindow = false - header(appBar) - background(viewPager) + with(contentBinding) { + setFrostColors { + toolbar(toolbar) + themeWindow = false + header(appbar) + background(viewpager) + } + setSupportActionBar(toolbar) + viewpager.adapter = adapter + tabs.setBackgroundColor(Prefs.mainActivityLayout.backgroundColor()) + } - setSupportActionBar(toolbar) - viewPager.adapter = adapter - tabs.setBackgroundColor(Prefs.mainActivityLayout.backgroundColor()) onNestedCreate(savedInstanceState) L.i { "Main finished loading UI in ${System.currentTimeMillis() - start} ms" } launch { @@ -212,7 +204,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } // setupDrawer(savedInstanceState) L.i { "Main started in ${System.currentTimeMillis() - start} ms" } - initFab() + contentBinding.initFab() lastAccessTime = System.currentTimeMillis() } @@ -224,46 +216,52 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, private var hasFab = false private var shouldShow = false - private fun initFab() { + private fun ActivityMainContentBinding.initFab() { hasFab = false shouldShow = false fab.backgroundTintList = ColorStateList.valueOf(Prefs.headerColor.withMinAlpha(200)) fab.hide() - appBar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> + appbar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> if (!hasFab) return@OnOffsetChangedListener val percent = abs(verticalOffset.toFloat() / appBarLayout.totalScrollRange) val shouldShow = percent < 0.2 - if (this.shouldShow != shouldShow) { - this.shouldShow = shouldShow + if (this@BaseMainActivity.shouldShow != shouldShow) { + this@BaseMainActivity.shouldShow = shouldShow fab.showIf(shouldShow) } }) } override fun showFab(iicon: IIcon, clickEvent: () -> Unit) { - hasFab = true - fab.setOnClickListener { clickEvent() } - if (shouldShow) { - if (fab.isShown) { - fab.fadeScaleTransition { - setIcon(iicon, Prefs.iconColor) + with(contentBinding) { + hasFab = true + fab.setOnClickListener { clickEvent() } + if (shouldShow) { + if (fab.isShown) { + fab.fadeScaleTransition { + setIcon(iicon, Prefs.iconColor) + } + return } - return } + fab.setIcon(iicon, Prefs.iconColor) + fab.showIf(shouldShow) } - fab.setIcon(iicon, Prefs.iconColor) - fab.showIf(shouldShow) } override fun hideFab() { - hasFab = false - fab.setOnClickListener(null) - fab.hide() + with(contentBinding) { + hasFab = false + fab.setOnClickListener(null) + fab.hide() + } } fun tabsForEachView(action: (position: Int, view: BadgedIcon) -> Unit) { - (0 until tabs.tabCount).asSequence().forEach { i -> - action(i, tabs.getTabAt(i)!!.customView as BadgedIcon) + with(contentBinding) { + (0 until tabs.tabCount).asSequence().forEach { i -> + action(i, tabs.getTabAt(i)!!.customView as BadgedIcon) + } } } @@ -407,7 +405,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) - toolbar.tint(Prefs.iconColor) + contentBinding.toolbar.tint(Prefs.iconColor) setMenuIcons( menu, Prefs.iconColor, R.id.action_settings to GoogleMaterial.Icon.gmd_settings, @@ -522,8 +520,6 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } } - private val STATE_FORCE_FALLBACK = "frost_state_force_fallback" - override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) adapter.saveInstanceState(outState) @@ -563,14 +559,18 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } override fun collapseAppBar() { - appBar.post { appBar.setExpanded(false) } + with(contentBinding) { + appbar.post { appbar.setExpanded(false) } + } } override fun backConsumer(): Boolean { -// if (drawer.isDrawerOpen) { -// drawer.closeDrawer() -// return true -// } + with (drawerWrapperBinding) { + if (drawer.isDrawerOpen(navigation)) { + drawer.closeDrawer(navigation) + return true + } + } if (currentFragment.onBackPressed()) return true if (Prefs.exitConfirmation) { materialDialog { @@ -588,7 +588,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } inline val currentFragment - get() = supportFragmentManager.findFragmentByTag("android:switcher:${R.id.container}:${viewPager.currentItem}") as BaseFragment + get() = supportFragmentManager.findFragmentByTag("android:switcher:${R.id.container}:${contentBinding.viewpager.currentItem}") as BaseFragment override fun reloadFragment(fragment: BaseFragment) { runOnUiThread { adapter.reloadFragment(fragment) } @@ -607,25 +607,27 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, this.pages.clear() this.pages.addAll(pages) notifyDataSetChanged() - tabs.removeAllTabs() - this.pages.forEachIndexed { index, fbItem -> - tabs.addTab( - tabs.newTab() - .setCustomView(BadgedIcon(this@BaseMainActivity).apply { - iicon = fbItem.icon - }.also { - it.setAllAlpha(if (index == 0) SELECTED_TAB_ALPHA else UNSELECTED_TAB_ALPHA) - }) - ) - } - lastPosition = 0 - viewPager.setCurrentItem(0, false) - viewPager.offscreenPageLimit = pages.size - viewPager.post { - if (!fragmentChannel.isClosedForSend) { - fragmentChannel.offer(0) + with(contentBinding) { + tabs.removeAllTabs() + this@SectionsPagerAdapter.pages.forEachIndexed { index, fbItem -> + tabs.addTab( + tabs.newTab() + .setCustomView(BadgedIcon(this@BaseMainActivity).apply { + iicon = fbItem.icon + }.also { + it.setAllAlpha(if (index == 0) SELECTED_TAB_ALPHA else UNSELECTED_TAB_ALPHA) + }) + ) } - } // trigger hook so title is set + lastPosition = 0 + viewpager.setCurrentItem(0, false) + viewpager.offscreenPageLimit = pages.size + viewpager.post { + if (!fragmentChannel.isClosedForSend) { + fragmentChannel.offer(0) + } + } // trigger hook so title is set + } } fun saveInstanceState(outState: Bundle) { @@ -670,14 +672,19 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } } + private val lowerVideoPaddingPointF = PointF() + override val lowerVideoPadding: PointF - get() = + get() { if (Prefs.mainActivityLayout == MainActivityLayout.BOTTOM_BAR) - PointF(0f, toolbar.height.toFloat()) + lowerVideoPaddingPointF.set(0f, contentBinding.toolbar.height.toFloat()) else - PointF(0f, 0f) + lowerVideoPaddingPointF.set(0f, 0f) + return lowerVideoPaddingPointF + } companion object { + private const val STATE_FORCE_FALLBACK = "frost_state_force_fallback" const val SELECTED_TAB_ALPHA = 255f const val UNSELECTED_TAB_ALPHA = 128f } diff --git a/app/src/main/res/layout/activity_main_drawer_wrapper.xml b/app/src/main/res/layout/activity_main_drawer_wrapper.xml index 4eebf56a..1af2e639 100644 --- a/app/src/main/res/layout/activity_main_drawer_wrapper.xml +++ b/app/src/main/res/layout/activity_main_drawer_wrapper.xml @@ -1,6 +1,7 @@ -- cgit v1.2.3 From 44524ce6eea7b0d0998bbabc8d72ea8b43f55f02 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 27 Dec 2019 00:28:33 -0800 Subject: Add nav items programmatically --- .../frost/activities/BaseMainActivity.kt | 89 +++++++++++++++++++++- .../pitchedapps/frost/activities/MainActivity.kt | 18 +++-- .../com/pitchedapps/frost/utils/WebContextMenu.kt | 5 +- .../kotlin/com/pitchedapps/frost/web/FrostJSI.kt | 4 +- app/src/main/res/drawable/nav_item_background.xml | 14 ++++ .../res/layout/activity_main_drawer_wrapper.xml | 9 ++- app/src/main/res/values/strings.xml | 4 +- app/src/main/res/values/styles.xml | 11 +++ 8 files changed, 138 insertions(+), 16 deletions(-) create mode 100644 app/src/main/res/drawable/nav_item_background.xml (limited to 'app/src/main') 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 3fa65ba3..5e79c93f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -18,9 +18,11 @@ package com.pitchedapps.frost.activities import android.annotation.SuppressLint import android.app.ActivityOptions +import android.content.Context import android.content.Intent import android.content.res.ColorStateList import android.graphics.PointF +import android.graphics.drawable.RippleDrawable import android.net.Uri import android.os.Bundle import android.view.Menu @@ -30,6 +32,8 @@ import android.webkit.ValueCallback import android.webkit.WebChromeClient import android.webkit.WebView import android.widget.FrameLayout +import androidx.annotation.ColorInt +import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentPagerAdapter @@ -37,6 +41,8 @@ import ca.allanwang.kau.searchview.SearchItem import ca.allanwang.kau.searchview.SearchView import ca.allanwang.kau.searchview.SearchViewHolder import ca.allanwang.kau.searchview.bindSearchView +import ca.allanwang.kau.utils.adjustAlpha +import ca.allanwang.kau.utils.drawable import ca.allanwang.kau.utils.fadeScaleTransition import ca.allanwang.kau.utils.materialDialog import ca.allanwang.kau.utils.restart @@ -45,6 +51,7 @@ 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.toDrawable import ca.allanwang.kau.utils.withMinAlpha import com.afollestad.materialdialogs.checkbox.checkBoxPrompt import com.google.android.material.appbar.AppBarLayout @@ -204,6 +211,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } // setupDrawer(savedInstanceState) L.i { "Main started in ${System.currentTimeMillis() - start} ms" } + drawerWrapperBinding.initDrawer() contentBinding.initFab() lastAccessTime = System.currentTimeMillis() } @@ -216,6 +224,85 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, private var hasFab = false private var shouldShow = false + private class FrostMenuBuilder(private val context: Context, private val menu: Menu) { + private var order: Int = 0 + private var groupId: Int = 13 + private val items: MutableList = mutableListOf() + + fun primaryFrostItem(fbItem: FbItem) { + val item = menu.add(groupId, fbItem.ordinal, order++, context.string(fbItem.titleId)) + item.icon = fbItem.icon.toDrawable(context, 18) + } + + fun divider() { + groupId++ + } + + fun secondaryFrostItem(fbItem: FbItem) { + menu.add(groupId, fbItem.ordinal, order++, context.string(fbItem.titleId)) + } + } + + private fun ActivityMainDrawerWrapperBinding.initDrawer() { + + fun createNavDrawable(@ColorInt foregroundColor: Int): RippleDrawable { + val drawable = drawable(R.drawable.nav_item_background) as RippleDrawable + drawable.setColor( + ColorStateList( + arrayOf(intArrayOf()), + intArrayOf(foregroundColor.adjustAlpha(0.16f)) + ) + ) + return drawable + } + + val toggle = ActionBarDrawerToggle( + this@BaseMainActivity, drawer, contentBinding.toolbar, + R.string.open, + R.string.close + ) + toggle.isDrawerSlideAnimationEnabled = false + drawer.addDrawerListener(toggle) + toggle.syncState() + + val foregroundColor = ColorStateList.valueOf(Prefs.textColor) + + with(navigation) { + FrostMenuBuilder(this@BaseMainActivity, menu).apply { + 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) + } + setNavigationItemSelectedListener { + val item = FbItem.values[it.itemId] + frostEvent("Drawer Tab", "name" to item.name) + drawer.closeDrawer(navigation) + launchWebOverlay(item.url) + false + } + val navBg = Prefs.bgColor.withMinAlpha(200) + setBackgroundColor(navBg) + itemBackground = createNavDrawable(Prefs.accentColor) + itemTextColor = foregroundColor + itemIconTintList = foregroundColor + + } + } + private fun ActivityMainContentBinding.initFab() { hasFab = false shouldShow = false @@ -565,7 +652,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } override fun backConsumer(): Boolean { - with (drawerWrapperBinding) { + with(drawerWrapperBinding) { if (drawer.isDrawerOpen(navigation)) { drawer.closeDrawer(navigation) return true diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt index fc9eca37..e0053402 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt @@ -37,12 +37,14 @@ class MainActivity : BaseMainActivity() { override val headerBadgeChannel = BroadcastChannel(Channel.CONFLATED) override fun onNestedCreate(savedInstanceState: Bundle?) { - setupTabs() - setupViewPager() + with(contentBinding) { + setupTabs() + setupViewPager() + } } - private fun setupViewPager() { - viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() { + private fun ActivityMainContentBinding.setupViewPager() { + viewpager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() { override fun onPageSelected(position: Int) { super.onPageSelected(position) if (lastPosition == position) { @@ -75,9 +77,9 @@ class MainActivity : BaseMainActivity() { }) } - private fun setupTabs() { - viewPager.addOnPageChangeListener(TabLayout.TabLayoutOnPageChangeListener(tabs)) - tabs.addOnTabSelectedListener(object : TabLayout.ViewPagerOnTabSelectedListener(viewPager) { + private fun ActivityMainContentBinding.setupTabs() { + viewpager.addOnPageChangeListener(TabLayout.TabLayoutOnPageChangeListener(tabs)) + tabs.addOnTabSelectedListener(object : TabLayout.ViewPagerOnTabSelectedListener(viewpager) { override fun onTabReselected(tab: TabLayout.Tab) { super.onTabReselected(tab) currentFragment.onTabClick() @@ -88,7 +90,7 @@ class MainActivity : BaseMainActivity() { (tab.customView as BadgedIcon).badgeText = null } }) - headerBadgeChannel.subscribeDuringJob(this, Dispatchers.IO) { html -> + headerBadgeChannel.subscribeDuringJob(this@MainActivity, Dispatchers.IO) { html -> try { val doc = Jsoup.parse(html) if (doc.select("[data-sigil=count]").isEmpty()) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt index 9089d891..becc9f02 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt @@ -47,7 +47,10 @@ fun Context.showWebContextMenu(wc: WebContext) { } onDismiss { // showing the dialog interrupts the touch down event, so we must ensure that the viewpager's swipe is enabled - (this@showWebContextMenu as? MainActivity)?.viewPager?.enableSwipe = true + (this@showWebContextMenu as? MainActivity) + ?.contentBinding + ?.viewpager + ?.enableSwipe = true } } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 0988e331..c8e551a3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -88,7 +88,7 @@ class FrostJSI(val web: FrostWebView) { */ @JavascriptInterface fun longClick(start: Boolean) { - activity?.viewPager?.enableSwipe = !start + activity?.contentBinding?.viewpager?.enableSwipe = !start if (web.frostWebClient.urlSupportsRefresh) { web.parent.swipeEnabled = !start } @@ -151,7 +151,7 @@ class FrostJSI(val web: FrostWebView) { @JavascriptInterface fun allowHorizontalScrolling(enable: Boolean) { - activity?.viewPager?.enableSwipe = enable + activity?.contentBinding?.viewpager?.enableSwipe = enable (context as? WebOverlayActivityBase)?.swipeBack?.disallowIntercept = !enable } } diff --git a/app/src/main/res/drawable/nav_item_background.xml b/app/src/main/res/drawable/nav_item_background.xml new file mode 100644 index 00000000..7c7a7209 --- /dev/null +++ b/app/src/main/res/drawable/nav_item_background.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main_drawer_wrapper.xml b/app/src/main/res/layout/activity_main_drawer_wrapper.xml index 1af2e639..d5efcf0d 100644 --- a/app/src/main/res/layout/activity_main_drawer_wrapper.xml +++ b/app/src/main/res/layout/activity_main_drawer_wrapper.xml @@ -1,9 +1,11 @@ + android:fitsSystemWindows="true" + tools:openDrawer="end"> + android:layout_gravity="start" + android:theme="@style/ThemeOverlay.Frost.NavigationView" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dda6c789..96957c4c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -40,12 +40,14 @@ Show All Results - Frost is a fully themable, fully functional alternative to the official Facebook app, made from scratch and proudly open sourced. Frost FAQ + Open + Close + An error occurred in the html extraction. The request has been cancelled. The request has timed out. diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c5179bb1..3cbad6d7 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -128,5 +128,16 @@ fixed + + + + + + + + + -- cgit v1.2.3 From 765aba2b34a33d67acccb90789b818817fec2181 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 27 Dec 2019 18:01:03 -0800 Subject: Prepare for nav option entries --- .../frost/activities/BaseMainActivity.kt | 181 ++++++++++++++++----- app/src/main/res/drawable/nav_item_background.xml | 2 +- app/src/main/res/layout/view_nav_header.xml | 103 ++++++++++++ app/src/main/res/values/styles.xml | 42 ++++- 4 files changed, 273 insertions(+), 55 deletions(-) create mode 100644 app/src/main/res/layout/view_nav_header.xml (limited to 'app/src/main') 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 5e79c93f..3543300d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -32,18 +32,26 @@ import android.webkit.ValueCallback import android.webkit.WebChromeClient import android.webkit.WebView import android.widget.FrameLayout +import android.widget.ImageView import androidx.annotation.ColorInt import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.widget.Toolbar +import androidx.core.view.updateLayoutParams +import androidx.drawerlayout.widget.DrawerLayout import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentPagerAdapter import ca.allanwang.kau.searchview.SearchItem import ca.allanwang.kau.searchview.SearchView import ca.allanwang.kau.searchview.SearchViewHolder 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.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 @@ -52,6 +60,7 @@ import ca.allanwang.kau.utils.showIf import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.tint 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.google.android.material.appbar.AppBarLayout @@ -68,7 +77,9 @@ import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.databinding.ActivityMainBinding import com.pitchedapps.frost.databinding.ActivityMainBottomTabsBinding import com.pitchedapps.frost.databinding.ActivityMainDrawerWrapperBinding +import com.pitchedapps.frost.databinding.ViewNavHeaderBinding import com.pitchedapps.frost.db.CookieDao +import com.pitchedapps.frost.db.CookieEntity import com.pitchedapps.frost.db.GenericDao import com.pitchedapps.frost.db.getTabs import com.pitchedapps.frost.enums.MainActivityLayout @@ -76,8 +87,11 @@ 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.glide.FrostGlide +import com.pitchedapps.frost.glide.GlideApp import com.pitchedapps.frost.services.scheduleNotificationsFromPrefs import com.pitchedapps.frost.utils.ACTIVITY_SETTINGS import com.pitchedapps.frost.utils.BiometricUtils @@ -300,6 +314,8 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, itemTextColor = foregroundColor itemIconTintList = foregroundColor + val header = NavHeader() + addHeaderView(header.root) } } @@ -439,51 +455,126 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, // 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 inner class NavHeader { + + private var orderedAccounts: List = cookies() + private var pendingUpdate: Boolean = false + private val binding = ViewNavHeaderBinding.inflate(layoutInflater) + val root: View get() = binding.root + + init { + setPrimary(Prefs.userId) + binding.updateAccounts() + with(drawerWrapperBinding) { + drawer.addDrawerListener(object : DrawerLayout.SimpleDrawerListener() { + override fun onDrawerClosed(drawerView: View) { + if (drawer !== navigation) return + if (!pendingUpdate) return + pendingUpdate = false + binding.updateAccounts() + } + }) + } + with(binding) { + optionsContainer.setBackgroundColor( + Prefs.bgColor.withMinAlpha(200).colorToForeground( + 0.1f + ) + ) + var showOptions = false + val animator: ProgressAnimator = ProgressAnimator.ofFloat { } + background.setOnClickListener { + animator.reset() + if (showOptions) { + animator.apply { + withAnimator(optionsContainer.height.toFloat(), 0f) { + optionsContainer.updateLayoutParams { + height = it.toInt() + } + } + withEndAction { + optionsContainer.gone() + } + } + } else { + animator.apply { + optionsContainer.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED) + withAnimator( + optionsContainer.height.toFloat(), + optionsContainer.measuredHeight.toFloat() + ) { + optionsContainer.updateLayoutParams { + height = it.toInt() + } + } + withStartAction { + optionsContainer.visible() + } + } + } + showOptions = !showOptions + animator.start() + } + } + } + + private fun setPrimary(id: Long) { + val (primaries, others) = orderedAccounts.partition { it.id == id } + if (primaries.size != 1) { + L._e(null) { "Updating account primaries, could not find specified id" } + } + orderedAccounts = primaries + others + } + + /** + * Syncs UI to match [orderedAccounts]. + * + * We keep this separate as we usually only want to update when the drawer is hidden. + */ + private fun ViewNavHeaderBinding.updateAccounts() { + avatarPrimary.setAccount(orderedAccounts.getOrNull(0), true) + avatarSecondary.setAccount(orderedAccounts.getOrNull(1), false) + avatarTertiary.setAccount(orderedAccounts.getOrNull(2), false) + } + + private fun closeDrawer() { + with(drawerWrapperBinding) { + drawer.closeDrawer(navigation) + } + } + + private fun ImageView.setAccount( + cookie: CookieEntity?, + primary: Boolean + ) { + if (cookie == null) { + invisible() + setOnClickListener(null) + } else { + visible() + GlideApp.with(this) + .load(profilePictureUrl(cookie.id)) + .transform(FrostGlide.circleCrop) + .into(this) + setOnClickListener { + if (primary) { + launchWebOverlay(FbItem.PROFILE.url) + } else { + setPrimary(cookie.id) + pendingUpdate = true + closeDrawer() + launch { + FbCookie.switchUser(cookie.id) + tabsForEachView { _, view -> view.badgeText = null } + refreshAll() + } + } + closeDrawer() + } + } + } + } private fun refreshAll() { L.d { "Refresh all" } diff --git a/app/src/main/res/drawable/nav_item_background.xml b/app/src/main/res/drawable/nav_item_background.xml index 7c7a7209..415dd9f2 100644 --- a/app/src/main/res/drawable/nav_item_background.xml +++ b/app/src/main/res/drawable/nav_item_background.xml @@ -3,7 +3,7 @@ android:color="#f0f"> + android:right="16dp"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 3cbad6d7..b194a975 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -107,13 +107,13 @@ @style/AppTheme.PopupOverlay - - - - - - - - - + + + + + + + + + + + + + + + -- cgit v1.2.3 From 006bc3d1a4798859fdce3c49f8a8690c823f1d7f Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 28 Dec 2019 00:45:35 -0800 Subject: Add additional options content --- .../frost/activities/BaseMainActivity.kt | 65 +++++++++++++++++++++- app/src/main/res/layout/view_nav_header.xml | 17 +++++- app/src/main/res/values/dimens.xml | 2 + app/src/main/res/values/styles.xml | 19 ++++++- 4 files changed, 97 insertions(+), 6 deletions(-) (limited to 'app/src/main') 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(accountSize, accountSize) { + override fun onLoadCleared(placeholder: Drawable?) { + tv.setCompoundDrawablesRelativeWithIntrinsicBounds( + placeholder, + null, + null, + null + ) + } + + override fun onResourceReady( + resource: Drawable, + transition: Transition? + ) { + 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 @@ + + + + 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 @@ 24dp 8dp + + 32dp 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 @@ 40dp - + + + -- cgit v1.2.3 From 57a668d8aebc3f323ee8885fdd8b1396b0ff5b1c Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 29 Dec 2019 15:23:48 -0800 Subject: Finish adding remaining click events --- .../frost/activities/BaseMainActivity.kt | 215 ++++++++++----------- app/src/main/res/layout/view_nav_header.xml | 20 +- app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/styles.xml | 10 +- 4 files changed, 116 insertions(+), 130 deletions(-) (limited to 'app/src/main') 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 dee94046..62138b19 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -35,7 +35,6 @@ 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 import androidx.core.view.updateLayoutParams @@ -62,6 +61,7 @@ import ca.allanwang.kau.utils.showIf import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.tint import ca.allanwang.kau.utils.toDrawable +import ca.allanwang.kau.utils.toast import ca.allanwang.kau.utils.visible import ca.allanwang.kau.utils.withMinAlpha import com.afollestad.materialdialogs.checkbox.checkBoxPrompt @@ -86,6 +86,7 @@ import com.pitchedapps.frost.databinding.ViewNavHeaderBinding import com.pitchedapps.frost.db.CookieDao import com.pitchedapps.frost.db.CookieEntity 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 @@ -116,6 +117,8 @@ 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 @@ -262,18 +265,18 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } } - private fun ActivityMainDrawerWrapperBinding.initDrawer() { - - fun createNavDrawable(@ColorInt foregroundColor: Int): RippleDrawable { - val drawable = drawable(R.drawable.nav_item_background) as RippleDrawable - drawable.setColor( - ColorStateList( - arrayOf(intArrayOf()), - intArrayOf(foregroundColor.adjustAlpha(0.16f)) - ) + private fun createNavDrawable(): RippleDrawable { + val drawable = drawable(R.drawable.nav_item_background) as RippleDrawable + drawable.setColor( + ColorStateList( + arrayOf(intArrayOf()), + intArrayOf(Prefs.accentColor.adjustAlpha(0.16f)) ) - return drawable - } + ) + return drawable + } + + private fun ActivityMainDrawerWrapperBinding.initDrawer() { val toggle = ActionBarDrawerToggle( this@BaseMainActivity, drawer, contentBinding.toolbar, @@ -315,7 +318,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } val navBg = Prefs.bgColor.withMinAlpha(200) setBackgroundColor(navBg) - itemBackground = createNavDrawable(Prefs.accentColor) + itemBackground = createNavDrawable() itemTextColor = foregroundColor itemIconTintList = foregroundColor @@ -373,94 +376,6 @@ 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(clearStack = false) -// -4L -> launchNewTask(cookies(), false) -// else -> { -// this@BaseMainActivity.launch { -// FbCookie.switchUser(profile.identifier) -// tabsForEachView { _, view -> view.badgeText = null } -// refreshAll() -// } -// } -// } -// false -// } -// } - private inner class NavHeader { private var orderedAccounts: List = cookies() @@ -498,6 +413,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, height = it.toInt() } } + withAnimator(arrow.rotation, 0f) { + arrow.rotation = it + } withEndAction { optionsContainer.gone() } @@ -516,6 +434,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, height = it.toInt() } } + withAnimator(arrow.rotation, 180f) { + arrow.rotation = it + } withStartAction { optionsContainer.visible() } @@ -525,18 +446,67 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, animator.start() } + val textColor = Prefs.textColor + fun TextView.setOptionsIcon(iicon: IIcon) { setCompoundDrawablesRelativeWithIntrinsicBounds( - iicon.toDrawable(this@BaseMainActivity, sizeDp = 20), + iicon.toDrawable(this@BaseMainActivity, color = textColor, sizeDp = 20), null, null, null ) + setTextColor(textColor) + background = createNavDrawable() } - optionsLogout.setOptionsIcon(GoogleMaterial.Icon.gmd_exit_to_app) - optionsAddAccount.setOptionsIcon(GoogleMaterial.Icon.gmd_add) - optionsManageAccount.setOptionsIcon(GoogleMaterial.Icon.gmd_settings) + with(optionsLogout) { + setOptionsIcon(GoogleMaterial.Icon.gmd_exit_to_app) + setOnClickListener { + 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) + } + } + } + } + } + with(optionsAddAccount) { + setOptionsIcon(GoogleMaterial.Icon.gmd_add) + setOnClickListener { + launchNewTask(clearStack = false) + } + } + with(optionsManageAccount) { + setOptionsIcon(GoogleMaterial.Icon.gmd_settings) + setOnClickListener { + launchNewTask(cookies(), false) + } + } + arrow.setImageDrawable( + GoogleMaterial.Icon.gmd_arrow_drop_down.toDrawable( + this@BaseMainActivity, + color = Prefs.textColor + ) + ) } } @@ -559,9 +529,12 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, avatarTertiary.setAccount(orderedAccounts.getOrNull(2), false) optionsAccountsContainer.removeAllViews() name.text = orderedAccounts.getOrNull(0)?.name + name.setTextColor(Prefs.textColor) val glide = Glide.with(root) val accountSize = dimenPixelSize(R.dimen.drawer_account_avatar_size) - orderedAccounts.forEach { + val textColor = Prefs.textColor + val navBackground = createNavDrawable() + orderedAccounts.forEach { cookie -> val tv = TextView( this@BaseMainActivity, @@ -569,7 +542,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, 0, R.style.Main_DrawerAccountUserOptions ) - glide.load(profilePictureUrl(it.id)).transform(FrostGlide.circleCrop) + glide.load(profilePictureUrl(cookie.id)).transform(FrostGlide.circleCrop) .into(object : CustomTarget(accountSize, accountSize) { override fun onLoadCleared(placeholder: Drawable?) { tv.setCompoundDrawablesRelativeWithIntrinsicBounds( @@ -592,7 +565,12 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, ) } }) - tv.text = it.name + tv.text = cookie.name + tv.setTextColor(textColor) + tv.background = navBackground + tv.setOnClickListener { + switchAccount(cookie.id) + } optionsAccountsContainer.addView(tv) } } @@ -620,19 +598,24 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, if (primary) { launchWebOverlay(FbItem.PROFILE.url) } else { - setPrimary(cookie.id) - pendingUpdate = true - closeDrawer() - launch { - FbCookie.switchUser(cookie.id) - tabsForEachView { _, view -> view.badgeText = null } - refreshAll() - } + switchAccount(cookie.id) } closeDrawer() } } } + + private fun switchAccount(id: Long) { + if (Prefs.userId == id) return + setPrimary(id) + pendingUpdate = true + closeDrawer() + launch { + FbCookie.switchUser(id) + tabsForEachView { _, view -> view.badgeText = null } + refreshAll() + } + } } private fun refreshAll() { diff --git a/app/src/main/res/layout/view_nav_header.xml b/app/src/main/res/layout/view_nav_header.xml index 38df36d7..a5dc05d6 100644 --- a/app/src/main/res/layout/view_nav_header.xml +++ b/app/src/main/res/layout/view_nav_header.xml @@ -8,10 +8,10 @@ + android:layout_height="160dp" + android:elevation="2dp"> - @@ -84,6 +84,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" + android:paddingTop="8dp" + android:paddingBottom="8dp" android:visibility="gone" tools:visibility="visible"> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index c81aee3c..b2df756d 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -15,4 +15,5 @@ 8dp 32dp + 24dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 38c5de7d..f17d005c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -141,8 +141,8 @@ @@ -162,8 +162,8 @@ match_parent wrap_content 16dp - 24dp - 24dp + @dimen/drawer_nav_horizontal_margins + @dimen/drawer_nav_horizontal_margins 16dp 16dp center_vertical @@ -178,7 +178,7 @@ 10dp center_vertical 18dp - 24dp + @dimen/drawer_nav_horizontal_margins -- cgit v1.2.3 From e1688a91ca8129af202c4680784f1ab2f302d4ac Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 29 Dec 2019 15:27:34 -0800 Subject: Fix lint --- app/src/main/res/layout/view_nav_header.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/res/layout/view_nav_header.xml b/app/src/main/res/layout/view_nav_header.xml index a5dc05d6..ff70e48c 100644 --- a/app/src/main/res/layout/view_nav_header.xml +++ b/app/src/main/res/layout/view_nav_header.xml @@ -99,19 +99,22 @@ android:id="@+id/options_logout" style="@style/Main.DrawerAccountOptions" android:text="@string/kau_logout" - tools:drawableStart="@drawable/abc_vector_test" /> + tools:drawableStart="@drawable/abc_vector_test" + tools:ignore="PrivateResource" /> + tools:drawableStart="@drawable/abc_vector_test" + tools:ignore="PrivateResource" /> + tools:drawableStart="@drawable/abc_vector_test" + tools:ignore="PrivateResource" /> -- cgit v1.2.3 From 597c884d88b8716d49e0abb00674ce44699df08b Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 29 Dec 2019 15:43:20 -0800 Subject: Clean up obsolete usages --- app/build.gradle | 2 -- app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt | 16 ---------------- .../com/pitchedapps/frost/activities/AboutActivity.kt | 1 - .../com/pitchedapps/frost/activities/DebugActivity.kt | 1 - app/src/main/res/layout/activity_debug.xml | 4 +++- app/src/main/res/layout/view_main_fab.xml | 7 ------- app/src/main/res/layout/view_main_tab_layout.xml | 10 ---------- app/src/main/res/layout/view_main_toolbar.xml | 8 -------- app/src/main/res/layout/view_main_viewpager.xml | 7 ------- buildSrc/src/main/kotlin/Versions.kt | 2 -- 10 files changed, 3 insertions(+), 55 deletions(-) delete mode 100644 app/src/main/res/layout/view_main_fab.xml delete mode 100644 app/src/main/res/layout/view_main_tab_layout.xml delete mode 100644 app/src/main/res/layout/view_main_toolbar.xml delete mode 100644 app/src/main/res/layout/view_main_viewpager.xml (limited to 'app/src/main') diff --git a/app/build.gradle b/app/build.gradle index f9e916ba..3fab8853 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -289,8 +289,6 @@ dependencies { testImplementation "com.squareup.okhttp3:mockwebserver:${Versions.okhttp}" androidTestImplementation "com.squareup.okhttp3:mockwebserver:${Versions.okhttp}" -// implementation "co.zsmb:materialdrawer-kt:${Versions.materialDrawerKt}" - implementation kau.Dependencies.bugsnag implementation "com.davemorrissey.labs:subsampling-scale-image-view:${Versions.scaleImageView}" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt index 75efe637..b33f00e2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt @@ -67,22 +67,6 @@ class FrostApp : Application() { scheduleNotificationsFromPrefs() - /** - * 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) -// } -// }) if (BuildConfig.DEBUG) { registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks { override fun onActivityPaused(activity: Activity) {} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt index 0ef70bcd..17b475da 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt @@ -74,7 +74,6 @@ class AboutActivity : AboutActivityBase(null, { "kau", "kotterknife", "materialdialogs", - "materialdrawer", "subsamplingscaleimageview" ) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt index e0dc409b..c8177604 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt @@ -34,7 +34,6 @@ import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.createFreshDir import com.pitchedapps.frost.utils.setFrostColors import kotlinx.android.synthetic.main.activity_debug.* -import kotlinx.android.synthetic.main.view_main_fab.* import kotlinx.coroutines.CoroutineExceptionHandler import java.io.File import kotlin.coroutines.resume diff --git a/app/src/main/res/layout/activity_debug.xml b/app/src/main/res/layout/activity_debug.xml index c3818749..d2f9a397 100644 --- a/app/src/main/res/layout/activity_debug.xml +++ b/app/src/main/res/layout/activity_debug.xml @@ -31,6 +31,8 @@ - + diff --git a/app/src/main/res/layout/view_main_fab.xml b/app/src/main/res/layout/view_main_fab.xml deleted file mode 100644 index e9fe9981..00000000 --- a/app/src/main/res/layout/view_main_fab.xml +++ /dev/null @@ -1,7 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/view_main_tab_layout.xml b/app/src/main/res/layout/view_main_tab_layout.xml deleted file mode 100644 index 1218b4f7..00000000 --- a/app/src/main/res/layout/view_main_tab_layout.xml +++ /dev/null @@ -1,10 +0,0 @@ - - diff --git a/app/src/main/res/layout/view_main_toolbar.xml b/app/src/main/res/layout/view_main_toolbar.xml deleted file mode 100644 index 054eaac3..00000000 --- a/app/src/main/res/layout/view_main_toolbar.xml +++ /dev/null @@ -1,8 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/view_main_viewpager.xml b/app/src/main/res/layout/view_main_viewpager.xml deleted file mode 100644 index 0c3f314c..00000000 --- a/app/src/main/res/layout/view_main_viewpager.xml +++ /dev/null @@ -1,7 +0,0 @@ - - \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 9d8e8ca7..fb7d764e 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -19,8 +19,6 @@ object Versions { const val jsoup = "1.12.1" // https://github.com/square/leakcanary/releases const val leakCanary = "1.6.2" - // https://github.com/zsmb13/MaterialDrawerKt/releases - const val materialDrawerKt = "3.0.0-rc01" // https://github.com/square/okhttp/releases const val okhttp = "4.2.2" // https://developer.android.com/jetpack/androidx/releases/room -- cgit v1.2.3