add setting to hide top toolbar
This commit is contained in:
parent
6ceb5cda8b
commit
dfd9769c53
@ -102,6 +102,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||
private var notificationTabPosition = 0
|
||||
private var onTabSelectedListener: OnTabSelectedListener? = null
|
||||
|
||||
private val preferences by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
|
||||
|
||||
private val emojiInitCallback = object : InitCallback() {
|
||||
override fun onInitialized() {
|
||||
if (!isDestroyed) {
|
||||
@ -171,6 +173,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||
startActivity(composeIntent)
|
||||
}
|
||||
|
||||
val hideTopToolbar = preferences.getBoolean(PrefKeys.HIDE_TOP_TOOLBAR, false)
|
||||
mainToolbar.visible(!hideTopToolbar)
|
||||
|
||||
mainToolbar.menu.add(R.string.action_search).apply {
|
||||
setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||
icon = IconicsDrawable(this@MainActivity, GoogleMaterial.Icon.gmd_search).apply {
|
||||
@ -183,7 +188,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||
}
|
||||
}
|
||||
|
||||
setupDrawer(savedInstanceState)
|
||||
setupDrawer(savedInstanceState, addSearchButton = hideTopToolbar)
|
||||
|
||||
/* Fetch user info while we're doing other things. This has to be done after setting up the
|
||||
* drawer, though, because its callback touches the header in the drawer. */
|
||||
@ -306,7 +311,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun setupDrawer(savedInstanceState: Bundle?) {
|
||||
private fun setupDrawer(savedInstanceState: Bundle?, addSearchButton: Boolean) {
|
||||
|
||||
drawerToggle = ActionBarDrawerToggle(this, mainDrawerLayout, mainToolbar, com.mikepenz.materialdrawer.R.string.material_drawer_open, com.mikepenz.materialdrawer.R.string.material_drawer_close)
|
||||
|
||||
@ -327,8 +332,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||
|
||||
header.accountHeaderBackground.setColorFilter(ContextCompat.getColor(this, R.color.headerBackgroundFilter))
|
||||
header.accountHeaderBackground.setBackgroundColor(ThemeUtils.getColor(this, R.attr.colorBackgroundAccent))
|
||||
val animateAvatars = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.getBoolean("animateGifAvatars", false)
|
||||
val animateAvatars = preferences.getBoolean("animateGifAvatars", false)
|
||||
|
||||
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
|
||||
override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) {
|
||||
@ -440,6 +444,18 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||
onClick = ::logout
|
||||
}
|
||||
)
|
||||
|
||||
if(addSearchButton) {
|
||||
mainDrawer.addItemsAtPosition(4,
|
||||
primaryDrawerItem {
|
||||
nameRes = R.string.action_search
|
||||
iconicsIcon = GoogleMaterial.Icon.gmd_search
|
||||
onClick = {
|
||||
startActivityWithSlideInAnimation(SearchActivity.getIntent(context))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
setSavedInstance(savedInstanceState)
|
||||
}
|
||||
|
||||
@ -472,7 +488,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||
}
|
||||
|
||||
private fun setupTabs(selectNotificationTab: Boolean) {
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
|
||||
val activeTabLayout = if(preferences.getString("mainNavPosition", "top") == "bottom") {
|
||||
val actionBarSize = ThemeUtils.getDimension(this, R.attr.actionBarSize)
|
||||
|
@ -26,6 +26,7 @@ import androidx.preference.PreferenceManager
|
||||
import com.keylesspalace.tusky.appstore.EventHub
|
||||
import com.keylesspalace.tusky.appstore.PreferenceChangedEvent
|
||||
import com.keylesspalace.tusky.fragment.preference.*
|
||||
import com.keylesspalace.tusky.settings.PrefKeys
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
import com.keylesspalace.tusky.util.getNonNullString
|
||||
import dagger.android.DispatchingAndroidInjector
|
||||
@ -129,8 +130,8 @@ class PreferencesActivity : BaseActivity(), SharedPreferences.OnSharedPreference
|
||||
|
||||
}
|
||||
"statusTextSize", "absoluteTimeView", "showBotOverlay", "animateGifAvatars",
|
||||
"useBlurhash", "showCardsInTimelines", "confirmReblogs", "hideMutedUsers",
|
||||
"enableSwipeForTabs", "bigEmojis", "mainNavPosition" -> {
|
||||
"useBlurhash", "showCardsInTimelines", "confirmReblogs", "hideMutedUsers",
|
||||
"enableSwipeForTabs", "bigEmojis", "mainNavPosition", PrefKeys.HIDE_TOP_TOOLBAR -> {
|
||||
restartActivitiesOnExit = true
|
||||
}
|
||||
"language" -> {
|
||||
|
@ -85,6 +85,12 @@ class PreferencesFragment : PreferenceFragmentCompat() {
|
||||
setTitle(R.string.pref_main_nav_position)
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
setDefaultValue(false)
|
||||
key = PrefKeys.HIDE_TOP_TOOLBAR
|
||||
setTitle(R.string.pref_title_hide_top_toolbar)
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
setDefaultValue(false)
|
||||
key = PrefKeys.FAB_HIDE
|
||||
|
@ -22,6 +22,7 @@ object PrefKeys {
|
||||
const val LANGUAGE = "language"
|
||||
const val STATUS_TEXT_SIZE = "statusTextSize"
|
||||
const val MAIN_NAV_POSITION = "mainNavPosition"
|
||||
const val HIDE_TOP_TOOLBAR = "hideTopToolbar"
|
||||
const val ABSOLUTE_TIME_VIEW = "absoluteTimeView"
|
||||
const val SHOW_BOT_OVERLAY = "showBotOverlay"
|
||||
const val ANIMATE_GIF_AVATARS = "animateGifAvatars"
|
||||
|
Loading…
Reference in New Issue
Block a user