Change debug text in menu
This commit is contained in:
parent
300e19a9c5
commit
5022b7f256
2 changed files with 338 additions and 276 deletions
|
@ -1,24 +1,28 @@
|
||||||
/* Copyright 2020 Tusky Contributors
|
/*
|
||||||
|
* Husky -- A Pleroma client for Android
|
||||||
*
|
*
|
||||||
* This file is a part of Tusky.
|
* Copyright (C) 2021 The Husky Developers
|
||||||
|
* Copyright (C) 2020 Tusky Contributors
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
* This program is distributed in the hope that it will be useful,
|
||||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* Public License for more details.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with Tusky; if not,
|
* You should have received a copy of the GNU General Public License
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.keylesspalace.tusky
|
package com.keylesspalace.tusky
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.ColorStateList
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
@ -59,10 +63,10 @@ import com.keylesspalace.tusky.components.notifications.NotificationHelper
|
||||||
import com.keylesspalace.tusky.components.preference.PreferencesActivity
|
import com.keylesspalace.tusky.components.preference.PreferencesActivity
|
||||||
import com.keylesspalace.tusky.components.scheduled.ScheduledTootActivity
|
import com.keylesspalace.tusky.components.scheduled.ScheduledTootActivity
|
||||||
import com.keylesspalace.tusky.components.search.SearchActivity
|
import com.keylesspalace.tusky.components.search.SearchActivity
|
||||||
|
import com.keylesspalace.tusky.core.utils.ApplicationUtils
|
||||||
import com.keylesspalace.tusky.db.AccountEntity
|
import com.keylesspalace.tusky.db.AccountEntity
|
||||||
import com.keylesspalace.tusky.db.AppDatabase
|
import com.keylesspalace.tusky.db.AppDatabase
|
||||||
import com.keylesspalace.tusky.entity.Account
|
import com.keylesspalace.tusky.entity.Account
|
||||||
import com.keylesspalace.tusky.entity.Notification
|
|
||||||
import com.keylesspalace.tusky.fragment.SFragment
|
import com.keylesspalace.tusky.fragment.SFragment
|
||||||
import com.keylesspalace.tusky.interfaces.AccountSelectionListener
|
import com.keylesspalace.tusky.interfaces.AccountSelectionListener
|
||||||
import com.keylesspalace.tusky.interfaces.ActionButtonActivity
|
import com.keylesspalace.tusky.interfaces.ActionButtonActivity
|
||||||
|
@ -88,14 +92,12 @@ import dagger.android.DispatchingAndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.Callback
|
|
||||||
import retrofit2.Response
|
|
||||||
import java.io.IOException
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInjector {
|
class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInjector {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
||||||
|
|
||||||
|
@ -162,7 +164,10 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
forwardShare(intent)
|
forwardShare(intent)
|
||||||
} else {
|
} else {
|
||||||
// No account was provided, show the chooser
|
// No account was provided, show the chooser
|
||||||
showAccountChooserDialog(getString(R.string.action_share_as), true, object : AccountSelectionListener {
|
showAccountChooserDialog(
|
||||||
|
getString(R.string.action_share_as),
|
||||||
|
true,
|
||||||
|
object : AccountSelectionListener {
|
||||||
override fun onAccountSelected(account: AccountEntity) {
|
override fun onAccountSelected(account: AccountEntity) {
|
||||||
val requestedId = account.id
|
val requestedId = account.id
|
||||||
if(requestedId == activeAccount.id) {
|
if(requestedId == activeAccount.id) {
|
||||||
|
@ -181,7 +186,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
showNotificationTab = true
|
showNotificationTab = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.statusBarColor = Color.TRANSPARENT // don't draw a status bar, the DrawerLayout and the MaterialDrawerLayout have their own
|
window.statusBarColor =
|
||||||
|
Color.TRANSPARENT // don't draw a status bar, the DrawerLayout and the MaterialDrawerLayout have their own
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
ViewPager2Fix.reduceVelocity(viewPager, 2.0f);
|
ViewPager2Fix.reduceVelocity(viewPager, 2.0f);
|
||||||
|
|
||||||
|
@ -346,7 +352,12 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
header = AccountHeaderView(this).apply {
|
header = AccountHeaderView(this).apply {
|
||||||
headerBackgroundScaleType = ImageView.ScaleType.CENTER_CROP
|
headerBackgroundScaleType = ImageView.ScaleType.CENTER_CROP
|
||||||
currentHiddenInList = true
|
currentHiddenInList = true
|
||||||
onAccountHeaderListener = { _: View?, profile: IProfile, current: Boolean -> handleProfileClick(profile, current) }
|
onAccountHeaderListener = { _: View?, profile: IProfile, current: Boolean ->
|
||||||
|
handleProfileClick(
|
||||||
|
profile,
|
||||||
|
current
|
||||||
|
)
|
||||||
|
}
|
||||||
addProfile(ProfileSettingDrawerItem().apply {
|
addProfile(ProfileSettingDrawerItem().apply {
|
||||||
identifier = DRAWER_ITEM_ADD_ACCOUNT
|
identifier = DRAWER_ITEM_ADD_ACCOUNT
|
||||||
nameRes = R.string.add_account_name
|
nameRes = R.string.add_account_name
|
||||||
|
@ -358,8 +369,18 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
closeDrawerOnProfileListClick = true
|
closeDrawerOnProfileListClick = true
|
||||||
}
|
}
|
||||||
|
|
||||||
header.accountHeaderBackground.setColorFilter(ContextCompat.getColor(this, R.color.headerBackgroundFilter))
|
header.accountHeaderBackground.setColorFilter(
|
||||||
header.accountHeaderBackground.setBackgroundColor(ThemeUtils.getColor(this, R.attr.colorBackgroundAccent))
|
ContextCompat.getColor(
|
||||||
|
this,
|
||||||
|
R.color.headerBackgroundFilter
|
||||||
|
)
|
||||||
|
)
|
||||||
|
header.accountHeaderBackground.setBackgroundColor(
|
||||||
|
ThemeUtils.getColor(
|
||||||
|
this,
|
||||||
|
R.attr.colorBackgroundAccent
|
||||||
|
)
|
||||||
|
)
|
||||||
val animateAvatars = preferences.getBoolean("animateGifAvatars", false)
|
val animateAvatars = preferences.getBoolean("animateGifAvatars", false)
|
||||||
|
|
||||||
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
|
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
|
||||||
|
@ -447,8 +468,18 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
startActivityWithSlideInAnimation(AnnouncementsActivity.newIntent(context))
|
startActivityWithSlideInAnimation(AnnouncementsActivity.newIntent(context))
|
||||||
}
|
}
|
||||||
badgeStyle = BadgeStyle().apply {
|
badgeStyle = BadgeStyle().apply {
|
||||||
textColor = ColorHolder.fromColor(ThemeUtils.getColor(this@MainActivity, R.attr.colorOnPrimary))
|
textColor = ColorHolder.fromColor(
|
||||||
color = ColorHolder.fromColor(ThemeUtils.getColor(this@MainActivity, R.attr.colorPrimary))
|
ThemeUtils.getColor(
|
||||||
|
this@MainActivity,
|
||||||
|
R.attr.colorOnPrimary
|
||||||
|
)
|
||||||
|
)
|
||||||
|
color = ColorHolder.fromColor(
|
||||||
|
ThemeUtils.getColor(
|
||||||
|
this@MainActivity,
|
||||||
|
R.attr.colorPrimary
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DividerDrawerItem(),
|
DividerDrawerItem(),
|
||||||
|
@ -456,7 +487,10 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
nameRes = R.string.action_view_account_preferences
|
nameRes = R.string.action_view_account_preferences
|
||||||
iconRes = R.drawable.ic_account_settings
|
iconRes = R.drawable.ic_account_settings
|
||||||
onClick = {
|
onClick = {
|
||||||
val intent = PreferencesActivity.newIntent(context, PreferencesActivity.ACCOUNT_PREFERENCES)
|
val intent = PreferencesActivity.newIntent(
|
||||||
|
context,
|
||||||
|
PreferencesActivity.ACCOUNT_PREFERENCES
|
||||||
|
)
|
||||||
startActivityWithSlideInAnimation(intent)
|
startActivityWithSlideInAnimation(intent)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -464,7 +498,10 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
nameRes = R.string.action_view_preferences
|
nameRes = R.string.action_view_preferences
|
||||||
iconicsIcon = GoogleMaterial.Icon.gmd_settings
|
iconicsIcon = GoogleMaterial.Icon.gmd_settings
|
||||||
onClick = {
|
onClick = {
|
||||||
val intent = PreferencesActivity.newIntent(context, PreferencesActivity.GENERAL_PREFERENCES)
|
val intent = PreferencesActivity.newIntent(
|
||||||
|
context,
|
||||||
|
PreferencesActivity.GENERAL_PREFERENCES
|
||||||
|
)
|
||||||
startActivityWithSlideInAnimation(intent)
|
startActivityWithSlideInAnimation(intent)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -497,12 +534,13 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
setSavedInstance(savedInstanceState)
|
setSavedInstance(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) {
|
if(ApplicationUtils.isDebug()) {
|
||||||
|
Timber.d("Flavor: ${BuildConfig.FLAVOR}")
|
||||||
|
|
||||||
mainDrawer.addItems(
|
mainDrawer.addItems(
|
||||||
secondaryDrawerItem {
|
secondaryDrawerItem {
|
||||||
nameText = "debug"
|
nameText = getString(R.string.debug_status)
|
||||||
isEnabled = false
|
isEnabled = false
|
||||||
textColor = ColorStateList.valueOf(Color.GREEN)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -514,11 +552,11 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabs(selectNotificationTab: Boolean) {
|
private fun setupTabs(selectNotificationTab: Boolean) {
|
||||||
|
|
||||||
val activeTabLayout = if(preferences.getString("mainNavPosition", "top") == "bottom") {
|
val activeTabLayout = if(preferences.getString("mainNavPosition", "top") == "bottom") {
|
||||||
val actionBarSize = ThemeUtils.getDimension(this, R.attr.actionBarSize)
|
val actionBarSize = ThemeUtils.getDimension(this, R.attr.actionBarSize)
|
||||||
val fabMargin = resources.getDimensionPixelSize(R.dimen.fabMargin)
|
val fabMargin = resources.getDimensionPixelSize(R.dimen.fabMargin)
|
||||||
(composeButton.layoutParams as CoordinatorLayout.LayoutParams).bottomMargin = actionBarSize + fabMargin
|
(composeButton.layoutParams as CoordinatorLayout.LayoutParams).bottomMargin =
|
||||||
|
actionBarSize + fabMargin
|
||||||
tabLayout.hide()
|
tabLayout.hide()
|
||||||
bottomTabLayout
|
bottomTabLayout
|
||||||
} else {
|
} else {
|
||||||
|
@ -532,7 +570,10 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
|
|
||||||
val adapter = MainPagerAdapter(tabs, this)
|
val adapter = MainPagerAdapter(tabs, this)
|
||||||
viewPager.adapter = adapter
|
viewPager.adapter = adapter
|
||||||
TabLayoutMediator(activeTabLayout, viewPager, TabConfigurationStrategy { _: TabLayout.Tab?, _: Int -> }).attach()
|
TabLayoutMediator(
|
||||||
|
activeTabLayout,
|
||||||
|
viewPager,
|
||||||
|
TabConfigurationStrategy { _: TabLayout.Tab?, _: Int -> }).attach()
|
||||||
activeTabLayout.removeAllTabs()
|
activeTabLayout.removeAllTabs()
|
||||||
for(i in tabs.indices) {
|
for(i in tabs.indices) {
|
||||||
val tab = activeTabLayout.newTab()
|
val tab = activeTabLayout.newTab()
|
||||||
|
@ -565,7 +606,10 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
onTabSelectedListener = object : OnTabSelectedListener {
|
onTabSelectedListener = object : OnTabSelectedListener {
|
||||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||||
if(tab.position == notificationTabPosition) {
|
if(tab.position == notificationTabPosition) {
|
||||||
NotificationHelper.clearNotificationsForActiveAccount(this@MainActivity, accountManager)
|
NotificationHelper.clearNotificationsForActiveAccount(
|
||||||
|
this@MainActivity,
|
||||||
|
accountManager
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
mainToolbar.title = tabs[tab.position].title(this@MainActivity)
|
mainToolbar.title = tabs[tab.position].title(this@MainActivity)
|
||||||
|
@ -673,7 +717,10 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
loadDrawerAvatar(me.avatar, false)
|
loadDrawerAvatar(me.avatar, false)
|
||||||
|
|
||||||
accountManager.updateActiveAccount(me)
|
accountManager.updateActiveAccount(me)
|
||||||
NotificationHelper.createNotificationChannelsForAccount(accountManager.activeAccount!!, this)
|
NotificationHelper.createNotificationChannelsForAccount(
|
||||||
|
accountManager.activeAccount!!,
|
||||||
|
this
|
||||||
|
)
|
||||||
|
|
||||||
initPullNotifications()
|
initPullNotifications()
|
||||||
|
|
||||||
|
@ -714,10 +761,15 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
|
|
||||||
override fun onLoadStarted(placeholder: Drawable?) {
|
override fun onLoadStarted(placeholder: Drawable?) {
|
||||||
if(placeholder != null) {
|
if(placeholder != null) {
|
||||||
mainToolbar.navigationIcon = FixedSizeDrawable(placeholder, navIconSize, navIconSize)
|
mainToolbar.navigationIcon =
|
||||||
|
FixedSizeDrawable(placeholder, navIconSize, navIconSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
|
|
||||||
|
override fun onResourceReady(
|
||||||
|
resource: Drawable,
|
||||||
|
transition: Transition<in Drawable>?
|
||||||
|
) {
|
||||||
mainToolbar.navigationIcon = resource
|
mainToolbar.navigationIcon = resource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,12 +795,17 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAnnouncementsBadge() {
|
private fun updateAnnouncementsBadge() {
|
||||||
mainDrawer.updateBadge(DRAWER_ITEM_ANNOUNCEMENTS, StringHolder(if (unreadAnnouncementsCount <= 0) null else unreadAnnouncementsCount.toString()))
|
mainDrawer.updateBadge(
|
||||||
|
DRAWER_ITEM_ANNOUNCEMENTS,
|
||||||
|
StringHolder(if(unreadAnnouncementsCount <= 0) null else unreadAnnouncementsCount.toString())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateProfiles() {
|
private fun updateProfiles() {
|
||||||
val profiles: MutableList<IProfile> = accountManager.getAllAccountsOrderedByActive().map { acc ->
|
val profiles: MutableList<IProfile> =
|
||||||
val emojifiedName = EmojiCompat.get().process(acc.displayName.emojify(acc.emojis, header, true))
|
accountManager.getAllAccountsOrderedByActive().map { acc ->
|
||||||
|
val emojifiedName =
|
||||||
|
EmojiCompat.get().process(acc.displayName.emojify(acc.emojis, header, true))
|
||||||
|
|
||||||
ProfileDrawerItem().apply {
|
ProfileDrawerItem().apply {
|
||||||
isSelected = acc.isActive
|
isSelected = acc.isActive
|
||||||
|
|
|
@ -612,4 +612,9 @@
|
||||||
<string name="drafts_failed_loading_reply">Failed loading Reply information</string>
|
<string name="drafts_failed_loading_reply">Failed loading Reply information</string>
|
||||||
<string name="draft_deleted">Draft deleted</string>
|
<string name="draft_deleted">Draft deleted</string>
|
||||||
<string name="drafts_toot_reply_removed">The Toot you drafted a reply to has been removed</string>
|
<string name="drafts_toot_reply_removed">The Toot you drafted a reply to has been removed</string>
|
||||||
|
|
||||||
|
<!-- Debug strings -->
|
||||||
|
<string name="debug_status">Debug build</string>
|
||||||
|
<string name="debug_status_message">A debug build has enabled logs and debugging information for the application. Information might leak. Please use it carefully.</string>
|
||||||
|
<string name="debug_status_message_close">Close</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue