Remove menu, action bar, redo
This commit is contained in:
		| @ -12,7 +12,7 @@ | ||||
|             android:logo="@mipmap/ic_launcher" | ||||
|             android:roundIcon="@mipmap/ic_launcher_round" | ||||
|             android:supportsRtl="true" | ||||
|             android:theme="@style/Theme.AppCompat.NoActionBar"> | ||||
|             android:theme="@style/PingPointsTheme"> | ||||
|         <activity | ||||
|                 android:name=".StarterNameActivity" | ||||
|                 android:windowSoftInputMode="adjustResize"> | ||||
|  | ||||
| @ -11,8 +11,6 @@ import android.support.design.widget.Snackbar | ||||
| import android.support.v7.app.AppCompatActivity | ||||
| import android.support.v7.app.AppCompatDelegate | ||||
| import android.text.method.LinkMovementMethod | ||||
| import android.view.Menu | ||||
| import android.view.MenuItem | ||||
| import android.view.View | ||||
| import android.widget.Button | ||||
| import android.widget.ImageView | ||||
| @ -46,15 +44,12 @@ class MatchActivity : AppCompatActivity() { | ||||
|     var buttons: Array<Button> = emptyArray() | ||||
|     var imageViews: Array<ImageView?> = emptyArray() | ||||
|     var tts: TextToSpeech? = null | ||||
|     var undo: MenuItem? = null | ||||
|     var redo: MenuItem? = null | ||||
|     var numSttCancelled:Int = 0 | ||||
|  | ||||
|     override fun onCreate(savedInstanceState: Bundle?) { | ||||
|         super.onCreate(savedInstanceState) | ||||
|         AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) | ||||
|         setContentView(R.layout.activity_match) | ||||
|         setSupportActionBar(findViewById(R.id.toolbar)) | ||||
|  | ||||
|         // Set HTML text for icons credits | ||||
|         findViewById<TextView>(R.id.iconsCredit).run { | ||||
| @ -103,31 +98,8 @@ class MatchActivity : AppCompatActivity() { | ||||
|         updateUI() | ||||
|     } | ||||
|  | ||||
|     override fun onCreateOptionsMenu(menu: Menu): Boolean { | ||||
|         menuInflater.inflate(R.menu.match_menu, menu) | ||||
|         undo = menu.findItem(R.id.action_undo) | ||||
|         redo = menu.findItem(R.id.action_redo) | ||||
|         return super.onCreateOptionsMenu(menu) | ||||
|     } | ||||
|  | ||||
|     override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) { | ||||
|         R.id.action_undo -> { | ||||
|             matchModel?.undo() | ||||
|             updateUI() | ||||
|             true | ||||
|         } | ||||
|         R.id.action_redo -> { | ||||
|             matchModel?.redo() | ||||
|             updateUI() | ||||
|             true | ||||
|         } | ||||
|         else -> { | ||||
|             super.onOptionsItemSelected(item) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     override fun onBackPressed() { | ||||
|         if (matchModel?.playId == 0) | ||||
|         if (matchModel?.pointId == 0) | ||||
|             super.onBackPressed() | ||||
|         else { | ||||
|             matchModel?.undo() | ||||
| @ -137,15 +109,6 @@ class MatchActivity : AppCompatActivity() { | ||||
|  | ||||
|     fun updateUI() { | ||||
|         matchModel?.apply { | ||||
|             undo?.isVisible = when (playId) { | ||||
|                 0 -> false | ||||
|                 else -> true | ||||
|             } | ||||
|             redo?.isVisible = when (playId) { | ||||
|                 history.size - 1 -> false | ||||
|                 else -> true | ||||
|             } | ||||
|  | ||||
|             textScore?.text = getString( | ||||
|                 R.string.score_score, | ||||
|                 players[serviceSide].score, | ||||
|  | ||||
| @ -12,7 +12,7 @@ class MatchModel : ViewModel() { | ||||
|     var relaunchSide: Int = 1 | ||||
|     var ttsEnabled: Boolean = false | ||||
|     var sttEnabled: Boolean = false | ||||
|     var playId: Int = 0 | ||||
|     var pointId: Int = 0 | ||||
|     var history: MutableList<Point> = ArrayList() | ||||
|  | ||||
|     fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) { | ||||
| @ -29,7 +29,7 @@ class MatchModel : ViewModel() { | ||||
|     } | ||||
|  | ||||
|     fun updateScore(scorer: Player) { | ||||
|         playId++ | ||||
|         pointId++ | ||||
|         scorer.score++ | ||||
|         if ((players.sumBy { it.score } % 2 == 0) or (players.all { it.score >= 10 })) { | ||||
|             serviceSide = relaunchSide.also { relaunchSide = serviceSide } | ||||
| @ -45,27 +45,16 @@ class MatchModel : ViewModel() { | ||||
|     } | ||||
|  | ||||
|     fun saveState() { | ||||
|         val play = Point(players.map { it.score }, serviceSide) | ||||
|         if (playId == history.size) { | ||||
|             history.add(play) | ||||
|         val point = Point(players.map { it.score }, serviceSide) | ||||
|         if (pointId == history.size) { | ||||
|             history.add(point) | ||||
|         } else { | ||||
|             history[playId] = play | ||||
|             history = history.subList(0, playId+1).toMutableList() | ||||
|             history[pointId] = point | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun undo() { | ||||
|         playId-- | ||||
|         reloadState() | ||||
|     } | ||||
|  | ||||
|     fun redo() { | ||||
|         playId++ | ||||
|         reloadState() | ||||
|     } | ||||
|  | ||||
|     fun reloadState() { | ||||
|         history[playId].let{ | ||||
|         history[pointId--].let{ | ||||
|             players.zip(it.score).forEach{(player, score) -> player.score = score} | ||||
|             serviceSide = it.serviceSide | ||||
|             relaunchSide = when(serviceSide) { | ||||
|  | ||||
| @ -32,7 +32,6 @@ class StarterNameActivity : AppCompatActivity() { | ||||
|     override fun onCreate(savedInstanceState: Bundle?) { | ||||
|         super.onCreate(savedInstanceState) | ||||
|         setContentView(R.layout.activity_starter_name) | ||||
|         setSupportActionBar(findViewById(R.id.toolbar)) | ||||
|  | ||||
|         // Find views | ||||
|         player1NameInput = findViewById(R.id.player1Name) | ||||
|  | ||||
| @ -20,7 +20,6 @@ class VictoryActivity : AppCompatActivity() { | ||||
|         super.onCreate(savedInstanceState) | ||||
|         AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) | ||||
|         setContentView(R.layout.activity_victory) | ||||
|         setSupportActionBar(findViewById(R.id.toolbar)) | ||||
|  | ||||
|         val previousMatch = getPreferences(Context.MODE_PRIVATE) | ||||
|  | ||||
|  | ||||
| @ -1,5 +0,0 @@ | ||||
| <vector android:autoMirrored="true" android:height="24dp" | ||||
|     android:tint="#FFFFFF" android:viewportHeight="24.0" | ||||
|     android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <path android:fillColor="#FF000000" android:pathData="M18.4,10.6C16.55,8.99 14.15,8 11.5,8c-4.65,0 -8.58,3.03 -9.96,7.22L3.9,16c1.05,-3.19 4.05,-5.5 7.6,-5.5 1.95,0 3.73,0.72 5.12,1.88L13,16h9V7l-3.6,3.6z"/> | ||||
| </vector> | ||||
| @ -1,5 +0,0 @@ | ||||
| <vector android:autoMirrored="true" android:height="24dp" | ||||
|     android:tint="#FFFFFF" android:viewportHeight="24.0" | ||||
|     android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <path android:fillColor="#FF000000" android:pathData="M12.5,8c-2.65,0 -5.05,0.99 -6.9,2.6L2,7v9h9l-3.62,-3.62c1.39,-1.16 3.16,-1.88 5.12,-1.88 3.54,0 6.55,2.31 7.6,5.5l2.37,-0.78C21.08,11.03 17.15,8 12.5,8z"/> | ||||
| </vector> | ||||
| @ -12,16 +12,6 @@ | ||||
|             android:layout_height="match_parent" | ||||
|             android:orientation="vertical"> | ||||
|  | ||||
|         <android.support.v7.widget.Toolbar | ||||
|                 android:id="@+id/toolbar" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="?attr/actionBarSize" | ||||
|                 android:layout_marginBottom="8dp" | ||||
|                 android:background="@color/colorPrimary" | ||||
|                 android:elevation="4dp" | ||||
|                 android:theme="@style/ThemeOverlay.AppCompat.ActionBar" | ||||
|                 app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_weight="0"/> | ||||
|  | ||||
|         <LinearLayout | ||||
|                 android:id="@+id/linearLayoutText" | ||||
|                 android:layout_width="match_parent" | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
|  | ||||
| <android.support.design.widget.CoordinatorLayout | ||||
|         android:id="@+id/myCoordinatorLayout" | ||||
|         xmlns:tools="http://schemas.android.com/tools" android:id="@+id/myCoordinatorLayout" | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         android:layout_width="match_parent" | ||||
| @ -15,24 +15,13 @@ | ||||
|         android:layout_height="match_parent" | ||||
|         tools:context=".StarterNameActivity"> | ||||
|  | ||||
|         <android.support.v7.widget.Toolbar | ||||
|                 android:id="@+id/toolbar" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="?attr/actionBarSize" | ||||
|                 android:layout_marginBottom="8dp" | ||||
|                 android:background="@color/colorPrimary" | ||||
|                 android:elevation="4dp" | ||||
|                 android:theme="@style/ThemeOverlay.AppCompat.ActionBar" | ||||
|                 app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> | ||||
|  | ||||
|         <TextView | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:id="@+id/WhoStarts" android:text="@string/who_starts" | ||||
|                 android:layout_marginTop="8dp" | ||||
|                 app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp" | ||||
|                 android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/toolbar"/> | ||||
|                 android:layout_marginTop="8dp" app:layout_constraintTop_toTopOf="parent"/> | ||||
|         <RadioGroup | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="wrap_content" | ||||
|  | ||||
| @ -12,16 +12,6 @@ | ||||
|             android:layout_height="match_parent" | ||||
|             android:orientation="vertical"> | ||||
|  | ||||
|         <android.support.v7.widget.Toolbar | ||||
|                 android:id="@+id/toolbar" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="?attr/actionBarSize" | ||||
|                 android:layout_marginBottom="8dp" | ||||
|                 android:background="@color/colorPrimary" | ||||
|                 android:elevation="4dp" | ||||
|                 android:theme="@style/ThemeOverlay.AppCompat.ActionBar" | ||||
|                 app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_weight="0"/> | ||||
|  | ||||
|         <LinearLayout | ||||
|                 android:id="@+id/linearLayoutText" | ||||
|                 android:layout_width="match_parent" | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
|  | ||||
| <android.support.design.widget.CoordinatorLayout | ||||
|         android:id="@+id/coordinatorLayout" | ||||
|         xmlns:tools="http://schemas.android.com/tools" android:id="@+id/coordinatorLayout" | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         android:layout_width="match_parent" | ||||
| @ -15,24 +15,13 @@ | ||||
|         android:layout_height="match_parent" | ||||
|         tools:context=".StarterNameActivity"> | ||||
|  | ||||
|         <android.support.v7.widget.Toolbar | ||||
|                 android:id="@+id/toolbar" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="?attr/actionBarSize" | ||||
|                 android:layout_marginBottom="8dp" | ||||
|                 android:background="@color/colorPrimary" | ||||
|                 android:elevation="4dp" | ||||
|                 android:theme="@style/ThemeOverlay.AppCompat.ActionBar" | ||||
|                 app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> | ||||
|  | ||||
|         <TextView | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:id="@+id/WhoStarts" android:text="@string/who_starts" | ||||
|                 android:layout_marginTop="8dp" | ||||
|                 app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp" | ||||
|                 android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/toolbar"/> | ||||
|                 android:layout_marginTop="8dp" app:layout_constraintTop_toTopOf="parent"/> | ||||
|         <LinearLayout | ||||
|                 android:orientation="horizontal" | ||||
|                 android:layout_width="match_parent" | ||||
|  | ||||
| @ -15,25 +15,16 @@ | ||||
|             android:layout_height="match_parent" | ||||
|             tools:context=".VictoryActivity"> | ||||
|  | ||||
|         <android.support.v7.widget.Toolbar | ||||
|                 android:id="@+id/toolbar" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="?attr/actionBarSize" | ||||
|                 android:layout_marginBottom="8dp" | ||||
|                 android:background="@color/colorPrimary" | ||||
|                 android:elevation="4dp" | ||||
|                 android:theme="@style/ThemeOverlay.AppCompat.ActionBar" | ||||
|                 app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_weight="0"/> | ||||
|         <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:id="@+id/congrats" | ||||
|                 android:textAppearance="@style/TextAppearance.AppCompat.Headline" | ||||
|                 android:layout_marginTop="13dp" app:layout_constraintTop_toBottomOf="@+id/toolbar" | ||||
|                 android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" | ||||
|                 android:layout_marginRight="8dp" android:layout_marginStart="8dp" | ||||
|                 app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp" | ||||
|                 android:text="@string/congrats"/> | ||||
|                 android:text="@string/congrats" android:layout_marginTop="8dp" | ||||
|                 app:layout_constraintTop_toTopOf="parent"/> | ||||
|         <LinearLayout | ||||
|                 android:orientation="horizontal" | ||||
|                 android:layout_width="match_parent" | ||||
|  | ||||
| @ -1,20 +0,0 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
|  | ||||
| <menu xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|       xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|  | ||||
|     <item | ||||
|             android:id="@+id/action_undo" | ||||
|             android:icon="@drawable/ic_undo" | ||||
|             android:title="@string/undo" | ||||
|             app:showAsAction="ifRoom" | ||||
|             android:visible="false" /> | ||||
|  | ||||
|     <item | ||||
|             android:id="@+id/action_redo" | ||||
|             android:icon="@drawable/ic_redo" | ||||
|             android:title="@string/redo" | ||||
|             app:showAsAction="ifRoom" | ||||
|             android:visible="false" /> | ||||
|  | ||||
| </menu> | ||||
| @ -1,8 +1,16 @@ | ||||
| <resources> | ||||
|  | ||||
|     <style name="AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> | ||||
|  | ||||
|     <style name="PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> | ||||
|     <!-- the theme applied to the application or activity --> | ||||
|     <style name="PingPointsTheme" parent="Base.V22.Theme.AppCompat"> | ||||
|         <item name="android:actionBarStyle">@style/ColoredActionBarBackground</item> | ||||
|         <!-- Support library compatibility --> | ||||
|         <item name="actionBarStyle">@style/ColoredActionBarBackground</item> | ||||
|     </style> | ||||
|     <style name="ColoredActionBarBackground" | ||||
|            parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> | ||||
|         <item name="android:background">@color/colorPrimaryDark</item> | ||||
|         <!-- Support library compatibility --> | ||||
|         <item name="background">@color/colorPrimaryDark</item> | ||||
|     </style> | ||||
|     <style name="ScoreButton"> | ||||
|         <item name="colorButtonNormal">@color/colorAccent</item> | ||||
|     </style> | ||||
|  | ||||
		Reference in New Issue
	
	Block a user