Initial commit
43
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.example.android.guesstheword">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_guess_it"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_guess_it_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
|
||||
<!-- Screen locked to landscape for easier play -->
|
||||
<!-- configChanges attribute makes the following actions NOT cause a config change -->
|
||||
<!-- screenOrientation attribute sets the default animation-->
|
||||
<activity android:name=".MainActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
app/src/main/ic_guess_it-web.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2018, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.android.guesstheword
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
/**
|
||||
* Creates an Activity that hosts all of the fragments in the app
|
||||
*/
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.main_activity)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright 2018, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.android.guesstheword.screens.game
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.NavHostFragment.findNavController
|
||||
import com.example.android.guesstheword.R
|
||||
import com.example.android.guesstheword.databinding.GameFragmentBinding
|
||||
|
||||
/**
|
||||
* Fragment where the game is played
|
||||
*/
|
||||
class GameFragment : Fragment() {
|
||||
|
||||
// The current word
|
||||
private var word = ""
|
||||
|
||||
// The current score
|
||||
private var score = 0
|
||||
|
||||
// The list of words - the front of the list is the next word to guess
|
||||
private lateinit var wordList: MutableList<String>
|
||||
|
||||
private lateinit var binding: GameFragmentBinding
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
|
||||
// Inflate view and obtain an instance of the binding class
|
||||
binding = DataBindingUtil.inflate(
|
||||
inflater,
|
||||
R.layout.game_fragment,
|
||||
container,
|
||||
false
|
||||
)
|
||||
|
||||
resetList()
|
||||
nextWord()
|
||||
|
||||
binding.correctButton.setOnClickListener { onCorrect() }
|
||||
binding.skipButton.setOnClickListener { onSkip() }
|
||||
updateScoreText()
|
||||
updateWordText()
|
||||
return binding.root
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the list of words and randomizes the order
|
||||
*/
|
||||
private fun resetList() {
|
||||
wordList = mutableListOf(
|
||||
"queen",
|
||||
"hospital",
|
||||
"basketball",
|
||||
"cat",
|
||||
"change",
|
||||
"snail",
|
||||
"soup",
|
||||
"calendar",
|
||||
"sad",
|
||||
"desk",
|
||||
"guitar",
|
||||
"home",
|
||||
"railway",
|
||||
"zebra",
|
||||
"jelly",
|
||||
"car",
|
||||
"crow",
|
||||
"trade",
|
||||
"bag",
|
||||
"roll",
|
||||
"bubble"
|
||||
)
|
||||
wordList.shuffle()
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game is finished
|
||||
*/
|
||||
private fun gameFinished() {
|
||||
val action = GameFragmentDirections.actionGameToScore(score)
|
||||
findNavController(this).navigate(action)
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves to the next word in the list
|
||||
*/
|
||||
private fun nextWord() {
|
||||
//Select and remove a word from the list
|
||||
if (wordList.isEmpty()) {
|
||||
gameFinished()
|
||||
} else {
|
||||
word = wordList.removeAt(0)
|
||||
}
|
||||
updateWordText()
|
||||
updateScoreText()
|
||||
}
|
||||
|
||||
/** Methods for buttons presses **/
|
||||
|
||||
private fun onSkip() {
|
||||
score--
|
||||
nextWord()
|
||||
}
|
||||
|
||||
private fun onCorrect() {
|
||||
score++
|
||||
nextWord()
|
||||
}
|
||||
|
||||
/** Methods for updating the UI **/
|
||||
|
||||
private fun updateWordText() {
|
||||
binding.wordText.text = word
|
||||
|
||||
}
|
||||
|
||||
private fun updateScoreText() {
|
||||
binding.scoreText.text = score.toString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2018, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.android.guesstheword.screens.score
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import com.example.android.guesstheword.R
|
||||
import com.example.android.guesstheword.databinding.ScoreFragmentBinding
|
||||
|
||||
/**
|
||||
* Fragment where the final score is shown, after the game is over
|
||||
*/
|
||||
class ScoreFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
|
||||
// Inflate view and obtain an instance of the binding class.
|
||||
val binding: ScoreFragmentBinding = DataBindingUtil.inflate(
|
||||
inflater,
|
||||
R.layout.score_fragment,
|
||||
container,
|
||||
false
|
||||
)
|
||||
|
||||
// Get args using by navArgs property delegate
|
||||
val scoreFragmentArgs by navArgs<ScoreFragmentArgs>()
|
||||
binding.scoreText.text = scoreFragmentArgs.score.toString()
|
||||
binding.playAgainButton.setOnClickListener { onPlayAgain() }
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun onPlayAgain() {
|
||||
findNavController().navigate(ScoreFragmentDirections.actionRestart())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2018, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.android.guesstheword.screens.title
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.example.android.guesstheword.R
|
||||
import com.example.android.guesstheword.databinding.TitleFragmentBinding
|
||||
|
||||
/**
|
||||
* Fragment for the starting or title screen of the app
|
||||
*/
|
||||
class TitleFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View {
|
||||
// Inflate the layout for this fragment
|
||||
val binding: TitleFragmentBinding = DataBindingUtil.inflate(
|
||||
inflater, R.layout.title_fragment, container, false)
|
||||
|
||||
binding.playGameButton.setOnClickListener {
|
||||
findNavController().navigate(TitleFragmentDirections.actionTitleToGame())
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
25
app/src/main/res/anim/slide_in_right.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<translate
|
||||
android:duration="700"
|
||||
android:fromXDelta="100%"
|
||||
android:fromYDelta="0%"
|
||||
android:toXDelta="0%"
|
||||
android:toYDelta="0%" />
|
||||
</set>
|
||||
25
app/src/main/res/anim/slide_out_left.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<translate
|
||||
android:duration="700"
|
||||
android:fromXDelta="0%"
|
||||
android:fromYDelta="0%"
|
||||
android:toXDelta="-100%"
|
||||
android:toYDelta="0%" />
|
||||
</set>
|
||||
16
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="742.029"
|
||||
android:viewportHeight="742.029">
|
||||
<group
|
||||
android:translateX="115.014496"
|
||||
android:translateY="115.014496">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M0,0h513.3v513.3h-513.3z" />
|
||||
<path
|
||||
android:fillColor="#6AB343"
|
||||
android:pathData="M339.3,122.5c-7.1,-11.2 -16.8,-20.5 -28.3,-27.2l15.1,-27.6c2.5,-4.5 0.8,-10.1 -3.6,-12.5l-0.1,-0.1c-4.5,-2.4 -10,-0.7 -12.5,3.7l-15.6,28.6c-12.6,-4.4 -25.8,-6.6 -39.1,-6.4c-13.8,0 -26.3,2.1 -37.4,6.3l-15.6,-28.5c-2.5,-4.5 -8.1,-6.1 -12.5,-3.7c-4.5,2.5 -6.1,8.1 -3.7,12.5l0,0l15.4,28c-2.7,1.8 -5.4,3.8 -7.9,5.9c-16.3,13.8 -27.2,30.1 -32.9,49.1l51.1,21.3c2.7,-10 8.3,-19 16,-26c7.7,-6.9 17.5,-10.4 29.3,-10.4c11.3,0 20.3,3.2 27.1,9.6c6.6,5.9 10.3,14.4 10.2,23.3c0.1,7.3 -2,14.4 -6,20.4c-4,5.9 -10.4,12.9 -19.3,20.9c-15.4,13.3 -26.1,25.2 -32,35.6S228,268 228,282.2v14.7c19.2,-7.2 38.6,-7.1 58.2,0v-7.1c0,-10.4 1.9,-19 5.6,-25.8c3.7,-6.8 10.6,-15 20.7,-24.4c13,-12.4 22.8,-24.1 29.3,-34.9c6.5,-10.8 9.8,-23.9 9.8,-39.3C351.7,150.2 347.4,135.3 339.3,122.5z" />
|
||||
</group>
|
||||
</vector>
|
||||
38
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="742.029"
|
||||
android:viewportHeight="742.029">
|
||||
<group
|
||||
android:translateX="115.014496"
|
||||
android:translateY="115.014496">
|
||||
<path
|
||||
android:fillColor="#6ab343"
|
||||
android:pathData="M256.22,464c-23.07,0 -42.89,-8.29 -58.91,-24.64s-24.1,-36.25 -24.1,-59.27 8.12,-42.84 24.14,-58.86 35.83,-24.14 58.87,-24.14 42.95,8.11 59.27,24.1 24.63,35.85 24.63,58.9 -8.27,43 -24.59,59.32S279.26,464 256.22,464Z" />
|
||||
<path
|
||||
android:fillColor="#fff"
|
||||
android:pathData="M256.22,303.09q32.23,0 55.07,22.38t22.83,54.62q0,32.25 -22.83,55.07T256.22,458Q224,458 201.6,435.16t-22.39,-55.07q0,-32.23 22.39,-54.62t54.62,-22.38m0,-12c-24.69,0 -45.92,8.71 -63.11,25.9s-25.9,38.41 -25.9,63.1 8.69,46 25.82,63.48S231.47,470 256.22,470s46.07,-8.87 63.55,-26.35 26.35,-38.87 26.35,-63.56 -8.89,-46 -26.43,-63.18 -38.84,-25.82 -63.47,-25.82Z" />
|
||||
<path
|
||||
android:fillColor="#f5f5f5"
|
||||
android:pathData="M256.38,330.37q-20.9,0 -35.39,14.5t-14.5,35.38A49.13,49.13 0,0 0,221 415.93a47.66,47.66 0,0 0,35.39 14.79,50.5 50.5,0 0,0 50.46,-50.47 47.67,47.67 0,0 0,-14.79 -35.38A49.13,49.13 0,0 0,256.38 330.37Z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M256.64,373.29L256.64,346.43"
|
||||
android:strokeWidth="10"
|
||||
android:strokeColor="#6ab343"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeLineJoin="round" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M262.48,384.63L282.67,396.96"
|
||||
android:strokeWidth="10"
|
||||
android:strokeColor="#6ab343"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeLineJoin="round" />
|
||||
<path
|
||||
android:fillColor="#f5f5f5"
|
||||
android:pathData="M256.62,373.29a7.15,7.15 0,0 0,-7.21 7.21,7.11 7.11,0 0,0 2.1,5.16 6.91,6.91 0,0 0,5.11 2.14,7.31 7.31,0 0,0 7.3,-7.3 6.89,6.89 0,0 0,-2.14 -5.12A7.11,7.11 0,0 0,256.62 373.29Z"
|
||||
android:strokeWidth="7"
|
||||
android:strokeColor="#6ab343" />
|
||||
</group>
|
||||
</vector>
|
||||
128
app/src/main/res/layout/game_fragment.xml
Normal file
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/game_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".screens.game.GameFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/word_is_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:text="@string/word_is"
|
||||
android:textColor="@color/black_text_color"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/word_text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/word_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
||||
android:textColor="@color/black_text_color"
|
||||
android:textSize="34sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/score_text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/word_is_text"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text=""Tuna"" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timer_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textColor="@color/grey_text_color"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/score_text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:text="0:00" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/score_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textColor="@color/grey_text_color"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/guideline"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:text="Score: 2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/skip_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="@string/skip"
|
||||
android:theme="@style/SkipButton"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/correct_button"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintHorizontal_chainStyle="spread_inside"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/guideline" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_end="96dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/correct_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/got_it"
|
||||
android:theme="@style/GoButton"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/skip_button"
|
||||
app:layout_constraintTop_toTopOf="@+id/guideline" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
32
app/src/main/res/layout/main_activity.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/main_navigation" />
|
||||
</merge>
|
||||
74
app/src/main/res/layout/score_fragment.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/score_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".screens.score.ScoreFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/you_scored_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:text="@string/you_scored"
|
||||
android:textColor="@color/black_text_color"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/score_text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/score_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textColor="@color/black_text_color"
|
||||
android:textSize="34sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/play_again_button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/you_scored_text"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="40" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/play_again_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:text="@string/play_again"
|
||||
android:theme="@style/GoButton"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
74
app/src/main/res/layout/title_fragment.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/title_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".screens.title.TitleFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/get_ready_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:text="@string/get_ready"
|
||||
android:textColor="@color/black_text_color"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/title_text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:text="@string/title_text"
|
||||
android:textColor="@color/black_text_color"
|
||||
android:textSize="34sp"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/play_game_button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/get_ready_text"
|
||||
app:layout_constraintVertical_chainStyle="packed" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/play_game_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:text="@string/play_button"
|
||||
android:theme="@style/GoButton"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_guess_it.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_guess_it_round.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_guess_it.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_guess_it_round.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_guess_it.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_guess_it_round.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_guess_it.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_guess_it_round.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_guess_it.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_guess_it_round.png
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_guess_it.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_guess_it_round.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
69
app/src/main/res/navigation/main_navigation.xml
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
app:startDestination="@id/title_destination">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/title_destination"
|
||||
android:name="com.example.android.guesstheword.screens.title.TitleFragment"
|
||||
android:label="title_fragment"
|
||||
tools:layout="@layout/title_fragment">
|
||||
<action
|
||||
android:id="@+id/action_title_to_game"
|
||||
app:destination="@id/game_destination"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:launchSingleTop="true"
|
||||
app:popEnterAnim="@anim/slide_in_right"
|
||||
app:popExitAnim="@anim/slide_out_left" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/game_destination"
|
||||
android:name="com.example.android.guesstheword.screens.game.GameFragment"
|
||||
android:label="game_fragment"
|
||||
tools:layout="@layout/game_fragment">
|
||||
<action
|
||||
android:id="@+id/action_game_to_score"
|
||||
app:destination="@id/score_destination"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:launchSingleTop="true"
|
||||
app:popEnterAnim="@anim/slide_in_right"
|
||||
app:popExitAnim="@anim/slide_out_left"
|
||||
app:popUpTo="@+id/title_destination" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/score_destination"
|
||||
android:name="com.example.android.guesstheword.screens.score.ScoreFragment"
|
||||
android:label="score_fragment"
|
||||
tools:layout="@layout/score_fragment">
|
||||
<action
|
||||
android:id="@+id/action_restart"
|
||||
app:destination="@+id/game_destination"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_right"
|
||||
app:popExitAnim="@anim/slide_out_left"
|
||||
app:popUpTo="@+id/title_destination" />
|
||||
<argument
|
||||
android:name="score"
|
||||
android:defaultValue="0"
|
||||
app:argType="integer" />
|
||||
</fragment>
|
||||
</navigation>
|
||||
29
app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<color name="colorPrimary">#6ab343</color>
|
||||
<color name="colorPrimaryDark">#388310</color>
|
||||
<color name="colorAccent">#D81B60</color>
|
||||
<color name="ok_green_color">#6ab343</color>
|
||||
<color name="selected_green_color">#388310</color>
|
||||
<color name="skip_red_color">#f44336</color>
|
||||
<color name="selected_red_color">#ba000d</color>
|
||||
<color name="black_text_color">#de000000</color>
|
||||
<color name="grey_text_color">#99000000</color>
|
||||
<color name="grey_button_color">#606060</color>
|
||||
<color name="white_text_color">#ffffff</color>
|
||||
</resources>
|
||||
29
app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">Guess the Word</string>
|
||||
<string name="skip">Skip</string>
|
||||
<string name="play_again">Play Again</string>
|
||||
<string name="you_scored">You Scored</string>
|
||||
<string name="title_text">guess the word!</string>
|
||||
<string name="play_button">Play</string>
|
||||
<string name="get_ready">Get ready to</string>
|
||||
<string name="got_it">Got it</string>
|
||||
<string name="word_is">The word is…</string>
|
||||
<string name="quote_format">\"%s\"</string>
|
||||
<string name="score_format">Current Score: %d</string>
|
||||
</resources>
|
||||
41
app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<!-- Button Styles -->
|
||||
<style name="GoButton" parent="Widget.AppCompat.Button.Colored">
|
||||
<item name="colorButtonNormal">@color/ok_green_color</item>
|
||||
<item name="colorControlHighlight">@color/selected_green_color</item>
|
||||
<item name="android:textColor">@color/white_text_color</item>
|
||||
<item name="colorAccent">@color/selected_green_color</item>
|
||||
</style>
|
||||
|
||||
<style name="SkipButton" parent="Widget.AppCompat.Button.Colored">
|
||||
<item name="android:buttonStyle">@style/Widget.AppCompat.Button.Borderless.Colored</item>
|
||||
<item name="android:textColor">@color/grey_button_color</item>
|
||||
<item name="colorControlHighlight">@color/skip_red_color</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||