Adds debug button to new app layout

This commit is contained in:
ericdecanini 2022-08-17 23:33:31 +02:00
parent fc301c8a2e
commit a59011ffd2
2 changed files with 29 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.airbnb.mvrx.activityViewModel
@ -36,6 +37,7 @@ import im.vector.app.core.platform.OnBackPressed
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.platform.VectorMenuProvider
import im.vector.app.core.resources.BuildMeta
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.ui.views.CurrentCallsView
import im.vector.app.core.ui.views.CurrentCallsViewPresenter
@ -71,6 +73,7 @@ class NewHomeDetailFragment @Inject constructor(
private val vectorPreferences: VectorPreferences,
private val spaceStateHandler: SpaceStateHandler,
private val session: Session,
private val buildMeta: BuildMeta,
) : VectorBaseFragment<FragmentNewHomeDetailBinding>(),
KeysBackupBanner.Delegate,
CurrentCallsView.Callback,
@ -125,6 +128,7 @@ class NewHomeDetailFragment @Inject constructor(
setupToolbar()
setupKeysBackupBanner()
setupActiveCallView()
setupDebugButton()
withState(viewModel) {
// Update the navigation view if needed (for when we restore the tabs)
@ -192,6 +196,7 @@ class NewHomeDetailFragment @Inject constructor(
updateTabVisibilitySafely(R.id.bottom_action_notification, vectorPreferences.labAddNotificationTab())
callManager.checkForProtocolsSupportIfNeeded()
refreshSpaceState()
refreshDebugButtonState()
}
private fun refreshSpaceState() {
@ -367,6 +372,17 @@ class NewHomeDetailFragment @Inject constructor(
}
}
private fun setupDebugButton() {
views.debugButton.debouncedClicks {
sharedActionViewModel.post(HomeActivitySharedAction.CloseDrawer)
navigator.openDebug(requireActivity())
}
}
private fun refreshDebugButtonState() {
views.debugButton.isVisible = buildMeta.isDebug && vectorPreferences.developerMode()
}
/* ==========================================================================================
* KeysBackupBanner Listener
* ========================================================================================== */

View File

@ -74,6 +74,19 @@
</com.google.android.material.appbar.MaterialToolbar>
<ImageView
android:id="@+id/debug_button"
style="@style/VectorDebug"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom|end"
android:layout_marginStart="12dp"
android:importantForAccessibility="no"
android:scaleType="center"
android:src="@drawable/ic_settings_x"
app:tint="?colorPrimary"
tools:ignore="MissingPrefix" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>