11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Ashish Pandey
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tic Tac Toe app
2 |
3 | [](https://github.com/ashish7zeph/android-kotlin-TicTacToe-game/blob/master/LICENSE)
4 | [](https://github.com/ashish7zeph/android-kotlin-TicTacToe-game/graphs/contributors)
5 | [](https://kotlinlang.org/)
6 |
7 | [](https://www.android.com/)
8 |
9 | ## Overview
10 |
11 | Build a Tic Tac Toe android app with kotlin support
12 |
13 | It is the regular Tic Tac Toe game with two gameplay modes `Multiplayer` for two players and another `Single Player` for one player playing against a computer algorithm
14 |
15 | Its a fun game!!
16 |
17 | ## Features
18 |
19 | * Single player mode
20 | * Multi player mode
21 | * Splash screen
22 | * Animation styles
23 | * Minimal Design
24 | * Simplified Theme
25 | * Responsive BackPress
26 |
27 | ## Platform
28 | -> Android Studio
29 | -> With Kotlin Support
30 |
31 | ## Instructions
32 |
33 | 1. Clone or download the repo: `https://github.com/ashish7zeph/android-kotlin-TicTacToe-game`
34 | 2. Navigate to the folder `android-kotlin-TicTacToe-game`
35 | 3. Navigate to the folder `android-kotlin-TicTacToe-game/app/src/` to access developers content
36 | 3. Navigate to the folder `apk` for users to access apk
37 | 4. Copy the apk from folder `apk` to an android phone
38 | 5. Install the apk
39 |
40 | The app is finally installed on your Android mobile device !!
41 | To directly download the apk visit the [link](https://github.com/ashish7zeph/android-kotlin-TicTacToe-game/tree/master/apk)
42 |
43 | # Screenshots:
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | ## Kotlin Android Activity
52 |
53 | Kotlin code of the splash screen activity in this project is shown below. For kotlin code of other activities visit the [link](https://github.com/ashish7zeph/android-kotlin-TicTacToe-game/tree/master/app/src/main/java/com/zeph7/tictactoe)
54 |
55 | ```kotlin
56 | package com.zeph7.tictactoe
57 |
58 | import android.content.Intent
59 | import android.support.v7.app.AppCompatActivity
60 | import android.os.Bundle
61 | import android.os.Handler
62 | import android.view.Window
63 | import android.view.WindowManager
64 | import android.view.animation.AnimationUtils
65 | import kotlinx.android.synthetic.main.activity_splash.*
66 |
67 | class SplashActivity : AppCompatActivity() {
68 |
69 | override fun onCreate(savedInstanceState: Bundle?) {
70 | super.onCreate(savedInstanceState)
71 |
72 | window.requestFeature(Window.FEATURE_NO_TITLE)
73 |
74 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
75 | WindowManager.LayoutParams.FLAG_FULLSCREEN)
76 |
77 | setContentView(R.layout.activity_splash)
78 |
79 | val anim = AnimationUtils.loadAnimation(applicationContext, R.anim.zoom)
80 | imageViewLogo.startAnimation(anim)
81 |
82 | Handler().postDelayed({
83 | startActivity(Intent(this@SplashActivity, MainActivity::class.java))
84 | }, 5000)
85 | }
86 | }
87 | ```
88 |
--------------------------------------------------------------------------------
/apk/Tic Tac Toe.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/apk/Tic Tac Toe.apk
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 26
9 | defaultConfig {
10 | applicationId "com.zeph7.tictactoe"
11 | minSdkVersion 16
12 | targetSdkVersion 26
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
28 | implementation 'com.android.support:appcompat-v7:26.1.0'
29 | implementation 'com.android.support.constraint:constraint-layout:1.1.2'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33 | }
34 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/zeph7/tictactoe/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zeph7.tictactoe
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.zeph7.tictactoe", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
28 |
31 |
32 |
35 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zeph7/tictactoe/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zeph7.tictactoe
2 |
3 | import android.content.Intent
4 | import android.support.v7.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.transition.Explode
7 | import android.view.Window
8 | import android.view.WindowManager
9 | import android.view.animation.AnimationUtils
10 | import android.widget.Toast
11 | import kotlinx.android.synthetic.main.activity_main.*
12 |
13 | class MainActivity : AppCompatActivity() {
14 |
15 | override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 | window.requestFeature(Window.FEATURE_NO_TITLE)
18 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
19 | WindowManager.LayoutParams.FLAG_FULLSCREEN)
20 | window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)
21 | setContentView(R.layout.activity_main)
22 |
23 | val animClockwise = AnimationUtils.loadAnimation(applicationContext, R.anim.clockwise)
24 | val animMove = AnimationUtils.loadAnimation(applicationContext, R.anim.move)
25 | val animFade = AnimationUtils.loadAnimation(applicationContext, R.anim.fade)
26 | val animSlide = AnimationUtils.loadAnimation(applicationContext, R.anim.slide)
27 | val animZoom = AnimationUtils.loadAnimation(applicationContext, R.anim.zoom)
28 | val animZoom2 = AnimationUtils.loadAnimation(applicationContext, R.anim.zoom2)
29 | val animBlink = AnimationUtils.loadAnimation(applicationContext, R.anim.blink)
30 | imgTicTacToe.startAnimation(animBlink)
31 | zephGames.startAnimation(animClockwise)
32 |
33 | btnSingle.setOnClickListener{
34 | btnSingle.startAnimation(animZoom2)
35 | startActivity(Intent(this@MainActivity, SecondActivity::class.java))
36 | }
37 |
38 | btnMulti.setOnClickListener{
39 | btnMulti.startAnimation(animZoom2)
40 | startActivity(Intent(this@MainActivity, ThirdActivity::class.java))
41 | }
42 |
43 | imgTicTacToe.setOnClickListener{
44 | imgTicTacToe.startAnimation(animBlink)
45 | }
46 |
47 | zephGames.setOnClickListener{
48 | zephGames.startAnimation(animClockwise)
49 | }
50 |
51 | // back ImageView
52 | imageViewBack.setOnClickListener {
53 | finish()
54 | moveTaskToBack(true)
55 | }
56 |
57 | // quit ImageView
58 | imageViewQuit.setOnClickListener {
59 | finish()
60 | moveTaskToBack(true)
61 | }
62 |
63 | }
64 |
65 | // for handling back button of the Android Device
66 | override fun onBackPressed() {
67 | super.onBackPressed()
68 | moveTaskToBack(true)
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zeph7/tictactoe/SecondActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zeph7.tictactoe
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.support.v7.app.AppCompatActivity
6 | import android.os.Bundle
7 | import android.view.Window
8 | import android.view.WindowManager
9 | import android.view.animation.AnimationUtils
10 | import kotlinx.android.synthetic.main.activity_third.*
11 | import java.text.FieldPosition
12 | import java.util.*
13 | import kotlin.collections.ArrayList
14 |
15 | class SecondActivity : AppCompatActivity() {
16 |
17 | override fun onCreate(savedInstanceState: Bundle?) {
18 | super.onCreate(savedInstanceState)
19 | window.requestFeature(Window.FEATURE_NO_TITLE)
20 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
21 | WindowManager.LayoutParams.FLAG_FULLSCREEN)
22 | setContentView(R.layout.activity_second)
23 |
24 | val anim = AnimationUtils.loadAnimation(applicationContext, R.anim.move)
25 | imageViewGameOn.startAnimation(anim)
26 |
27 | var board = arrayListOf("", "", "", "", "", "", "", "", "")
28 |
29 | button0.setOnClickListener {
30 | if (board[0] == "") {
31 | button0.text = "X"
32 | board[0] = "X"
33 | if(!isBoardFull(board) && !result(board, "X")) {
34 | val position = getComputerMove(board)
35 | board[position] = "O"
36 | displayComputerButton(position)
37 | }
38 | }
39 | resultOut(board)
40 | }
41 |
42 | button1.setOnClickListener {
43 | if (board[1] == "") {
44 | button1.text = "X"
45 | board[1] = "X"
46 | if(!isBoardFull(board) && !result(board, "X")) {
47 | val position = getComputerMove(board)
48 | board[position] = "O"
49 | displayComputerButton(position)
50 | }
51 | }
52 | resultOut(board)
53 | }
54 |
55 | button2.setOnClickListener {
56 | if (board[2] == "") {
57 | button2.text = "X"
58 | board[2] = "X"
59 | if(!isBoardFull(board) && !result(board, "X")) {
60 | val position = getComputerMove(board)
61 | board[position] = "O"
62 | displayComputerButton(position)
63 | }
64 | }
65 | resultOut(board)
66 | }
67 |
68 | button3.setOnClickListener {
69 | if (board[3] == "") {
70 | button3.text = "X"
71 | board[3] = "X"
72 | if(!isBoardFull(board) && !result(board, "X")) {
73 | val position = getComputerMove(board)
74 | board[position] = "O"
75 | displayComputerButton(position)
76 | }
77 | }
78 | resultOut(board)
79 | }
80 |
81 | button4.setOnClickListener {
82 | if (board[4] == "") {
83 | button4.text = "X"
84 | board[4] = "X"
85 | if(!isBoardFull(board) && !result(board, "X")) {
86 | val position = getComputerMove(board)
87 | board[position] = "O"
88 | displayComputerButton(position)
89 | }
90 | }
91 | resultOut(board)
92 | }
93 |
94 | button5.setOnClickListener {
95 | if (board[5] == "") {
96 | button5.text = "X"
97 | board[5] = "X"
98 | if(!isBoardFull(board) && !result(board, "X")) {
99 | val position = getComputerMove(board)
100 | board[position] = "O"
101 | displayComputerButton(position)
102 | }
103 | }
104 | resultOut(board)
105 | }
106 |
107 | button6.setOnClickListener {
108 | if (board[6] == "") {
109 | button6.text = "X"
110 | board[6] = "X"
111 | if(!isBoardFull(board) && !result(board, "X")) {
112 | val position = getComputerMove(board)
113 | board[position] = "O"
114 | displayComputerButton(position)
115 | }
116 | }
117 | resultOut(board)
118 | }
119 |
120 | button7.setOnClickListener {
121 | if (board[7] == "") {
122 | button7.text = "X"
123 | board[7] = "X"
124 | if(!isBoardFull(board) && !result(board, "X")) {
125 | val position = getComputerMove(board)
126 | board[position] = "O"
127 | displayComputerButton(position)
128 | }
129 | }
130 | resultOut(board)
131 | }
132 |
133 | button8.setOnClickListener {
134 | if (board[8] == "") {
135 | button8.text = "X"
136 | board[8] = "X"
137 | if(!isBoardFull(board) && !result(board, "X")) {
138 | val position = getComputerMove(board)
139 | board[position] = "O"
140 | displayComputerButton(position)
141 | }
142 | }
143 | resultOut(board)
144 | }
145 |
146 | buttonReset.setOnClickListener{
147 | startActivity(Intent(this@SecondActivity, SecondActivity::class.java))
148 | }
149 |
150 | // back ImageView
151 | imageViewBack.setOnClickListener{
152 | startActivity(Intent(this@SecondActivity, MainActivity::class.java))
153 | }
154 |
155 | // quit ImageView
156 | imageViewQuit.setOnClickListener {
157 | finish()
158 | moveTaskToBack(true) //to quit app
159 | }
160 |
161 | }
162 |
163 | private fun getComputerMove(board: ArrayList): Int {
164 |
165 | //check if computer can win in this move
166 | for (i in 0..board.count()-1){
167 | var copy: ArrayList = getBoardCopy(board)
168 | if(copy[i] == "") copy[i] = "O"
169 | if(result(copy, "O")) return i
170 | }
171 |
172 | //check if player could win in the next move
173 | for (i in 0..board.count()-1){
174 | var copy2 = getBoardCopy(board)
175 | if(copy2[i] == "") copy2[i] = "X"
176 | if(result(copy2, "X")) return i
177 | }
178 |
179 | //try to take corners if its free
180 | var move = choseRandomMove(board, arrayListOf(0, 2, 6, 8))
181 | if(move != -1)
182 | return move
183 |
184 | //try to take center if its free
185 | if(board[4] == "") return 4
186 |
187 | //move on one of the sides
188 | return choseRandomMove(board, arrayListOf(1, 3, 5, 7))
189 | }
190 |
191 |
192 | private fun choseRandomMove(board: ArrayList, list: ArrayList): Int {
193 | var possibleMoves = arrayListOf()
194 | for (i in list){
195 | if(board[i] == "") possibleMoves.add(i)
196 | }
197 | if(possibleMoves.isEmpty()) return -1
198 | else {
199 | var index = Random().nextInt(possibleMoves.count())
200 | return possibleMoves[index]
201 | }
202 | }
203 |
204 | private fun getBoardCopy(board: ArrayList): ArrayList {
205 | var bd = arrayListOf("", "", "", "", "", "", "", "", "")
206 | for (i in 0..board.count()-1) {
207 | bd[i] = board[i]
208 | }
209 | return bd
210 | }
211 |
212 | private fun isBoardFull(board: ArrayList): Boolean {
213 | for (i in board)
214 | if(i != "X" && i != "O") return false
215 | return true
216 | }
217 |
218 |
219 | private fun resultOut(board: ArrayList){
220 | if(result(board, "X")){
221 | startActivity(Intent(this@SecondActivity, WonActivity::class.java).putExtra("player", "YOU"))
222 | }else if(result(board, "O")){
223 | startActivity(Intent(this@SecondActivity, WonActivity::class.java).putExtra("player", "COMPUTER"))
224 | }
225 | if(isBoardFull(board)){
226 | startActivity(Intent(this@SecondActivity, WonActivity::class.java).putExtra("player", "Tie"))
227 | }
228 | }
229 |
230 |
231 | private fun result(bd: ArrayList, s: String): Boolean =
232 | if(bd[0] == s && bd[1] == s && bd[2] == s) true
233 | else if(bd[3] == s && bd[4] == s && bd[5] == s) true
234 | else if(bd[6] == s && bd[7] == s && bd[8] == s) true
235 | else if(bd[0] == s && bd[3] == s && bd[6] == s) true
236 | else if(bd[1] == s && bd[4] == s && bd[7] == s) true
237 | else if(bd[2] == s && bd[5] == s && bd[8] == s) true
238 | else if(bd[0] == s && bd[4] == s && bd[8] == s) true
239 | else if(bd[2] == s && bd[4] == s && bd[6] == s) true
240 | else false
241 |
242 |
243 | private fun displayComputerButton(position: Int){
244 | if(position == 0) button0.text = "O"
245 | else if(position == 1) button1.text = "O"
246 | else if(position == 2) button2.text = "O"
247 | else if(position == 3) button3.text = "O"
248 | else if(position == 4) button4.text = "O"
249 | else if(position == 5) button5.text = "O"
250 | else if(position == 6) button6.text = "O"
251 | else if(position == 7) button7.text = "O"
252 | else if(position == 8) button8.text = "O"
253 | }
254 |
255 |
256 | // for handling back buttton of the Android Device
257 | override fun onBackPressed() {
258 | super.onBackPressed()
259 | startActivity(Intent(this@SecondActivity, MainActivity::class.java))
260 | }
261 |
262 | }
263 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zeph7/tictactoe/SplashActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zeph7.tictactoe
2 |
3 | import android.content.Intent
4 | import android.support.v7.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.os.Handler
7 | import android.view.Window
8 | import android.view.WindowManager
9 | import android.view.animation.AnimationUtils
10 | import kotlinx.android.synthetic.main.activity_splash.*
11 |
12 | class SplashActivity : AppCompatActivity() {
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 |
17 | window.requestFeature(Window.FEATURE_NO_TITLE)
18 |
19 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
20 | WindowManager.LayoutParams.FLAG_FULLSCREEN)
21 |
22 | setContentView(R.layout.activity_splash)
23 |
24 | val anim = AnimationUtils.loadAnimation(applicationContext, R.anim.zoom)
25 | imageViewLogo.startAnimation(anim)
26 |
27 | Handler().postDelayed({
28 | startActivity(Intent(this@SplashActivity, MainActivity::class.java))
29 | }, 5000)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zeph7/tictactoe/ThirdActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zeph7.tictactoe
2 |
3 | import android.content.Intent
4 | import android.support.v7.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.view.Window
7 | import android.view.WindowManager
8 | import android.view.animation.AnimationUtils
9 | import kotlinx.android.synthetic.main.activity_third.*
10 | import kotlin.system.exitProcess
11 |
12 | class ThirdActivity : AppCompatActivity() {
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | window.requestFeature(Window.FEATURE_NO_TITLE)
17 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
18 | WindowManager.LayoutParams.FLAG_FULLSCREEN)
19 | setContentView(R.layout.activity_third)
20 |
21 | val anim = AnimationUtils.loadAnimation(applicationContext, R.anim.move)
22 | imageViewGameOn.startAnimation(anim)
23 |
24 | var chance = "X"
25 | var board = arrayListOf("", "", "", "", "", "", "", "", "")
26 |
27 | button0.setOnClickListener {
28 | if (board[0] != "")
29 | else if (chance == "X") {
30 | button0.text = "X"
31 | board[0] = "X"
32 | chance = "O"
33 | } else {
34 | button0.text = "O"
35 | board[0] = "O"
36 | chance = "X"
37 | }
38 | resultOut(board)
39 | }
40 |
41 | button1.setOnClickListener {
42 | if (board[1] != "")
43 | else if (chance == "X") {
44 | button1.text = "X"
45 | board[1] = "X"
46 | chance = "O"
47 | } else {
48 | button1.text = "O"
49 | board[1] = "O"
50 | chance = "X"
51 | }
52 | resultOut(board)
53 | }
54 |
55 | button2.setOnClickListener {
56 | if (board[2] != "")
57 | else if (chance == "X") {
58 | button2.text = "X"
59 | board[2] = "X"
60 | chance = "O"
61 | } else {
62 | button2.text = "O"
63 | board[2] = "O"
64 | chance = "X"
65 | }
66 | resultOut(board)
67 | }
68 |
69 | button3.setOnClickListener {
70 | if (board[3] != "")
71 | else if (chance == "X") {
72 | button3.text = "X"
73 | board[3] = "X"
74 | chance = "O"
75 | } else {
76 | button3.text = "O"
77 | board[3] = "O"
78 | chance = "X"
79 | }
80 | resultOut(board)
81 | }
82 |
83 | button4.setOnClickListener {
84 | if (board[4] != "")
85 | else if (chance == "X") {
86 | button4.text = "X"
87 | board[4] = "X"
88 | chance = "O"
89 | } else {
90 | button4.text = "O"
91 | board[4] = "O"
92 | chance = "X"
93 | }
94 | resultOut(board)
95 | }
96 |
97 | button5.setOnClickListener {
98 | if (board[5] != "")
99 | else if (chance == "X") {
100 | button5.text = "X"
101 | board[5] = "X"
102 | chance = "O"
103 | } else {
104 | button5.text = "O"
105 | board[5] = "O"
106 | chance = "X"
107 | }
108 | resultOut(board)
109 | }
110 |
111 | button6.setOnClickListener {
112 | if (board[6] != "")
113 | else if (chance == "X") {
114 | button6.text = "X"
115 | board[6] = "X"
116 | chance = "O"
117 | } else {
118 | button6.text = "O"
119 | board[6] = "O"
120 | chance = "X"
121 | }
122 | resultOut(board)
123 | }
124 |
125 | button7.setOnClickListener {
126 | if (board[7] != "")
127 | else if (chance == "X") {
128 | button7.text = "X"
129 | board[7] = "X"
130 | chance = "O"
131 | } else {
132 | button7.text = "O"
133 | board[7] = "O"
134 | chance = "X"
135 | }
136 | resultOut(board)
137 | }
138 |
139 | button8.setOnClickListener {
140 | if (board[8] != "")
141 | else if (chance == "X") {
142 | button8.text = "X"
143 | board[8] = "X"
144 | chance = "O"
145 | } else {
146 | button8.text = "O"
147 | board[8] = "O"
148 | chance = "X"
149 | }
150 | resultOut(board)
151 | }
152 |
153 | buttonReset.setOnClickListener{
154 | startActivity(Intent(this@ThirdActivity, ThirdActivity::class.java))
155 | }
156 |
157 | // back ImageView
158 | imageViewBack.setOnClickListener{
159 | startActivity(Intent(this@ThirdActivity, MainActivity::class.java))
160 | }
161 |
162 | // quit ImageView
163 | imageViewQuit.setOnClickListener {
164 | finish()
165 | moveTaskToBack(true) //to quit app
166 | }
167 |
168 | }
169 |
170 | private fun resultOut(board: ArrayList){
171 | if(result(board, "X")){
172 | startActivity(Intent(this@ThirdActivity, WonActivity::class.java).putExtra("player", "X"))
173 | }else if(result(board, "O")){
174 | startActivity(Intent(this@ThirdActivity, WonActivity::class.java).putExtra("player", "O"))
175 | }
176 | if(isBoardFull(board)){
177 | startActivity(Intent(this@ThirdActivity, WonActivity::class.java).putExtra("player", "Tie"))
178 | }
179 | }
180 |
181 | private fun isBoardFull(board: ArrayList): Boolean {
182 | for (i in board)
183 | if(i != "X" && i != "O") return false
184 | return true
185 | }
186 |
187 | private fun result(bd: ArrayList, s: String): Boolean =
188 | if(bd[0] == s && bd[1] == s && bd[2] == s) true
189 | else if(bd[3] == s && bd[4] == s && bd[5] == s) true
190 | else if(bd[6] == s && bd[7] == s && bd[8] == s) true
191 | else if(bd[0] == s && bd[3] == s && bd[6] == s) true
192 | else if(bd[1] == s && bd[4] == s && bd[7] == s) true
193 | else if(bd[2] == s && bd[5] == s && bd[8] == s) true
194 | else if(bd[0] == s && bd[4] == s && bd[8] == s) true
195 | else if(bd[2] == s && bd[4] == s && bd[6] == s) true
196 | else false
197 |
198 | // for handling back buttton of the Android Device
199 | override fun onBackPressed() {
200 | super.onBackPressed()
201 | startActivity(Intent(this@ThirdActivity, MainActivity::class.java))
202 | }
203 |
204 | }
205 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zeph7/tictactoe/WonActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zeph7.tictactoe
2 |
3 | import android.content.Intent
4 | import android.support.v7.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.os.Handler
7 | import android.view.Window
8 | import android.view.WindowManager
9 | import android.view.animation.AnimationUtils
10 | import kotlinx.android.synthetic.main.activity_won.*
11 |
12 | class WonActivity : AppCompatActivity() {
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | window.requestFeature(Window.FEATURE_NO_TITLE)
17 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
18 | WindowManager.LayoutParams.FLAG_FULLSCREEN)
19 | setContentView(R.layout.activity_won)
20 |
21 | val player = intent.getStringExtra("player")
22 | if(player == "Tie") textViewWon.text = "TIE"
23 | else textViewWon.text = "$player WON"
24 |
25 | val anim = AnimationUtils.loadAnimation(applicationContext, R.anim.zoom)
26 | textViewWon.startAnimation(anim)
27 |
28 | Handler().postDelayed({
29 | startActivity(Intent(this@WonActivity, MainActivity::class.java))
30 | }, 3000)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/blink.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/clockwise.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
18 |
19 |
20 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/move.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/zoom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
16 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/zoom2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-hdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-mdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/board.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/board.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/board2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/board2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/drawable-hdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/drawable-hdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/drawable-mdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/drawable-mdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/drawable-xhdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/drawable-xhdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/drawable-xxhdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/drawable-xxhdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/drawable-xxxhdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/drawable-xxxhdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/gameon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/gameon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/particle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/particle.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/tac.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/tac.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/tic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/tic.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/tic2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/tic2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/tic3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/tic3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/tictactoe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-v24/tictactoe.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-xhdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-xxhdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_launcher_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/drawable-xxxhdpi/ic_launcher_.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/font/muli_bold.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/font/muli_extralight.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
25 |
26 |
41 |
42 |
54 |
55 |
67 |
68 |
79 |
80 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
25 |
26 |
39 |
40 |
53 |
54 |
69 |
70 |
83 |
84 |
97 |
98 |
112 |
113 |
126 |
127 |
139 |
140 |
154 |
155 |
168 |
169 |
178 |
179 |
188 |
189 |
190 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
23 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_third.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
25 |
26 |
39 |
40 |
53 |
54 |
69 |
70 |
83 |
84 |
97 |
98 |
112 |
113 |
126 |
127 |
139 |
140 |
154 |
155 |
168 |
169 |
178 |
179 |
188 |
189 |
190 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_won.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
21 |
22 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/tic3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/app/src/main/res/tic3.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #04bbf9
4 | #04bbf9
5 | #cdccff
6 | #c7e5f2
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/font_certs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | @array/com_google_android_gms_fonts_certs_dev
5 | @array/com_google_android_gms_fonts_certs_prod
6 |
7 |
8 |
9 | MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexAcKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkwHQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0cxb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrPzgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXclaXjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05aIskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+aayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUWEv9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs=
10 |
11 |
12 |
13 |
14 | MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/preloaded_fonts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | @font/muli_bold
5 | @font/muli_extralight
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Tic Tac Toe
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/zeph7/tictactoe/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zeph7.tictactoe
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.1.51'
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.1'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jul 12 01:19:01 IST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/screenshots/img1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/screenshots/img1.jpg
--------------------------------------------------------------------------------
/screenshots/img2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/screenshots/img2.jpg
--------------------------------------------------------------------------------
/screenshots/img3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/screenshots/img3.jpg
--------------------------------------------------------------------------------
/screenshots/img4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeph7/android-kotlin-TicTacToe-game/354f2b78bb68c6490fe4e329c07933ae6a219b9a/screenshots/img4.jpg
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------