Fake menu :(

This commit is contained in:
Lucas Lima 2020-08-10 01:20:27 -03:00
parent a37d361ccd
commit 598c106f4f
No known key found for this signature in database
GPG key ID: C5EEF4C30BFBF8D7
4 changed files with 140 additions and 103 deletions

View file

@ -14,6 +14,7 @@ import android.view.WindowManager
import androidx.activity.viewModels
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.TooltipCompat
import androidx.core.os.HandlerCompat.postDelayed
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
@ -34,9 +35,9 @@ import dev.lucasnlm.antimine.control.ControlDialogFragment
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.models.Analytics
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.custom.CustomLevelDialogFragment
import dev.lucasnlm.antimine.history.HistoryActivity
import dev.lucasnlm.antimine.instant.InstantAppManager
import dev.lucasnlm.antimine.custom.CustomLevelDialogFragment
import dev.lucasnlm.antimine.level.view.EndGameDialogFragment
import dev.lucasnlm.antimine.level.view.LevelFragment
import dev.lucasnlm.antimine.preferences.PreferencesActivity
@ -44,6 +45,9 @@ import dev.lucasnlm.antimine.share.viewmodel.ShareViewModel
import dev.lucasnlm.antimine.stats.StatsActivity
import dev.lucasnlm.antimine.theme.ThemeActivity
import kotlinx.android.synthetic.main.activity_game.*
import kotlinx.android.synthetic.main.activity_game.minesCount
import kotlinx.android.synthetic.main.activity_game.timer
import kotlinx.android.synthetic.main.activity_tv_game.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
@ -249,14 +253,25 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
}
}
@ExperimentalCoroutinesApi
@FlowPreview
private fun bindToolbar() {
setSupportActionBar(toolbar)
toolbar.title = ""
menu.apply {
TooltipCompat.setTooltipText(this, getString(R.string.open_menu))
setColorFilter(minesCount.currentTextColor)
setOnClickListener {
drawer.openDrawer(GravityCompat.START)
}
}
supportActionBar?.apply {
title = ""
setDisplayHomeAsUpEnabled(true)
setHomeButtonEnabled(true)
retry.apply {
TooltipCompat.setTooltipText(this, getString(R.string.new_game))
setColorFilter(minesCount.currentTextColor)
setOnClickListener {
lifecycleScope.launch {
viewModel.startNewGame()
}
}
}
}

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M4,18h16c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,16c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM4,13h16c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,11c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM3,7c0,0.55 0.45,1 1,1h16c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,6c-0.55,0 -1,0.45 -1,1z"/>
</vector>

View file

@ -1,113 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
android:fitsSystemWindows="true">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/menu"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/open_menu"
android:padding="14dp"
ads:layout_constraintLeft_toLeftOf="parent"
ads:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/menu" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="0dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/AppTheme.AppBarOverlay"
tools:targetApi="lollipop" />
<TextView
android:id="@+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawableStart="@drawable/timer"
android:drawableLeft="@drawable/timer"
android:drawablePadding="8dp"
android:drawableTint="?android:attr/textColorPrimary"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:minEms="2"
android:text="@string/default_time_value"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size"
android:textStyle="bold"
android:visibility="gone"
ads:layout_constraintBottom_toBottomOf="@id/menu"
ads:layout_constraintHorizontal_chainStyle="packed"
ads:layout_constraintLeft_toRightOf="@id/menu"
ads:layout_constraintRight_toLeftOf="@id/minesCount"
ads:layout_constraintTop_toTopOf="@id/menu"
tools:targetApi="m"
tools:text="10:00"
tools:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/toolbar"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/minesCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableStart="@drawable/mine"
android:drawableLeft="@drawable/mine"
android:drawablePadding="8dp"
android:drawableTint="?android:attr/textColorPrimary"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:minEms="3"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size"
android:textStyle="bold"
android:visibility="gone"
ads:layout_constraintBottom_toBottomOf="@id/menu"
ads:layout_constraintHorizontal_chainStyle="packed"
ads:layout_constraintLeft_toRightOf="@id/timer"
ads:layout_constraintRight_toLeftOf="@id/retry"
ads:layout_constraintTop_toTopOf="@id/menu"
tools:targetApi="m"
tools:text="99"
tools:visibility="visible" />
<TextView
android:id="@+id/timer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawableStart="@drawable/timer"
android:drawableLeft="@drawable/timer"
android:drawablePadding="8dp"
android:drawableTint="?android:attr/textColorPrimary"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:minEms="2"
android:text="@string/default_time_value"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size"
android:textStyle="bold"
android:visibility="gone"
tools:targetApi="m"
tools:text="10:00"
tools:visibility="visible" />
<ImageView
android:id="@+id/retry"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/retry"
android:padding="14dp"
ads:layout_constraintRight_toRightOf="parent"
ads:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/retry" />
<TextView
android:id="@+id/minesCount"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:drawableStart="@drawable/mine"
android:drawableLeft="@drawable/mine"
android:drawablePadding="8dp"
android:drawableTint="?android:attr/textColorPrimary"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:minEms="3"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size"
android:textStyle="bold"
android:visibility="gone"
tools:targetApi="m"
tools:text="99"
tools:visibility="visible" />
<FrameLayout
android:id="@+id/levelContainer"
android:layout_width="0dp"
android:layout_height="0dp"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintLeft_toLeftOf="parent"
ads:layout_constraintRight_toRightOf="parent"
ads:layout_constraintTop_toBottomOf="@id/menu" />
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/install"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:contentDescription="@string/install"
android:visibility="gone"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintRight_toRightOf="parent"
app:backgroundTint="@color/install_button"
app:elevation="10dp"
app:pressedTranslationZ="6dp"
app:srcCompat="@drawable/install"
tools:visibility="visible" />
<FrameLayout
android:id="@+id/levelContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/install"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="16dp"
android:contentDescription="@string/install"
android:visibility="gone"
app:backgroundTint="@color/install_button"
app:elevation="10dp"
app:pressedTranslationZ="6dp"
app:srcCompat="@drawable/install"
tools:visibility="visible"/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
@ -116,7 +122,6 @@
android:layout_gravity="start"
android:clipToPadding="true"
android:fitsSystemWindows="true"
ads:menu="@menu/nav_menu"
app:itemTextColor="?android:attr/textColorPrimary" />
ads:menu="@menu/nav_menu" />
</androidx.drawerlayout.widget.DrawerLayout>

View file

@ -5,10 +5,13 @@
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:background">@color/background</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight">
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
@ -40,6 +43,8 @@
<item name="colorPrimaryDark">#9E9E9E</item>
<item name="colorAccent">#D32F2F</item>
<item name="android:background">#FFFFFF</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
@ -51,8 +56,10 @@
<item name="colorPrimaryDark">#212121</item>
<item name="colorAccent">#FFFFFF</item>
<item name="android:background">#212121</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:elevation">0dp</item>
</style>
<style name="CustomDarkTheme.NoActionBar" parent="ThemeOverlay.AppCompat.Dark">