├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── x-web.png
│ │ ├── ic_launcher-web.png
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── oo.png
│ │ │ │ ├── x.png
│ │ │ │ ├── splash_image.jpg
│ │ │ │ ├── round.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── splash_image.jpg
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ └── layout
│ │ │ │ ├── activity_splash_screen.xml
│ │ │ │ ├── activity_afterstart.xml
│ │ │ │ ├── dialog_layout_exit.xml
│ │ │ │ ├── dialog_layout.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── content_afterstart.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── jetray
│ │ │ └── tictactoe
│ │ │ ├── SplashScreen.java
│ │ │ ├── MainActivity.java
│ │ │ └── Afterstart.java
│ ├── test
│ │ └── java
│ │ │ └── jetray
│ │ │ └── tictactoe
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── jetray
│ │ └── tictactoe
│ │ └── ApplicationTest.java
├── release
│ ├── tic_tac_toe.apk
│ └── output.json
├── proguard-rules.pro
└── build.gradle
├── _config.yml
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── README.md
├── gitignore
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/x-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/x-web.png
--------------------------------------------------------------------------------
/app/release/tic_tac_toe.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/release/tic_tac_toe.apk
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/oo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/drawable/oo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/drawable/x.png
--------------------------------------------------------------------------------
/app/src/main/res/splash_image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/splash_image.jpg
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/splash_image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/drawable/splash_image.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karansthr/Tic-Tac-Toe/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":2},"path":"app-release.apk","properties":{"packageId":"jetray.tictactoe","split":"","minSdkVersion":"19"}}]
--------------------------------------------------------------------------------
/app/src/main/res/drawable/round.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jan 28 21:59:20 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 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #9fC202
4 | #8CC202
5 | #353331
6 | #A8A4A0
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 10dp
6 | 16dp
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/jetray/tictactoe/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package jetray.tictactoe;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/jetray/tictactoe/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package jetray.tictactoe;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Tic Tac Toe
3 | player1 name
4 | player2 name
5 | Settings
6 | About
7 | Exit
8 | studying Computer Science & Engineering at SKIT ,Jaipur
9 | Tic Tac Toe
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /root/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
28 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.2"
6 |
7 | defaultConfig {
8 | applicationId "jetray.tictactoe"
9 | minSdkVersion 19
10 | targetSdkVersion 26
11 | versionCode 2
12 | versionName "1.2"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | testCompile 'junit:junit:4.12'
26 | compile 'com.android.support:appcompat-v7:26+'
27 | compile 'com.android.support:design:26+'
28 | }
29 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash_screen.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tic Tac Toe
2 | Tic-tac-toe is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game.
3 | To add this project to android studio.
4 |
5 | #### Features
6 | - Single Player with Difficulty levels
7 | - Two Player
8 |
9 | #### Getting started
10 | - In android studio goto file
11 | - Select new > Import from version control
12 | - Choose git / github (git option recommanded )
13 | - Paste url to repository i.e https://github.com/karansthr/Tic-Tac-Toe.git
14 | - Click on clone.
15 |
16 | Play Store https://play.google.com/store/apps/details?id=jetray.tictactoe
17 |
18 | []
19 |
20 | []
21 |
22 | []
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_afterstart.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
17 |
18 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # IntelliJ
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | # Uncomment the following line if you do not want to check your keystore files in.
45 | #*.jks
46 |
47 | # External native build folder generated in Android Studio 2.2 and later
48 | .externalNativeBuild
49 |
50 | # Google Services (e.g. APIs or Firebase)
51 | google-services.json
52 |
53 | # Freeline
54 | freeline.py
55 | freeline/
56 | freeline_project_description.json
57 |
58 | # fastlane
59 | fastlane/report.xml
60 | fastlane/Preview.html
61 | fastlane/screenshots
62 | fastlane/test_output
63 | fastlane/readme.md
64 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
16 |
17 |
18 |
23 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/jetray/tictactoe/SplashScreen.java:
--------------------------------------------------------------------------------
1 | package jetray.tictactoe;
2 |
3 | import android.content.Intent;
4 | import android.os.Build;
5 | import android.os.Handler;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.view.View;
9 | import android.view.Window;
10 | import android.view.WindowManager;
11 | import android.widget.ImageView;
12 |
13 | public class SplashScreen extends AppCompatActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_splash_screen);
19 |
20 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
21 | Window w = getWindow(); // in Activity's onCreate() for instance
22 | w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
23 | }
24 |
25 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
26 |
27 |
28 |
29 | new Handler().postDelayed(new Runnable() {
30 | @Override
31 | public void run() {
32 | Intent intent = new Intent(SplashScreen.this, MainActivity.class);
33 | startActivity(intent);
34 | finish();
35 | }
36 | }, 4000);
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_layout_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
66 |
67 |
76 |
77 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
68 |
69 |
78 |
79 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
25 |
26 |
27 |
36 |
37 |
38 |
45 |
46 |
47 |
56 |
57 |
66 |
67 |
68 |
69 |
70 |
71 |
80 |
81 |
82 |
87 |
88 |
89 |
98 |
99 |
108 |
109 |
110 |
111 |
117 |
118 |
123 |
124 |
130 |
131 |
137 |
138 |
139 |
140 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
164 |
165 |
166 |
167 |
168 |
169 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_afterstart.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
23 |
24 |
35 |
36 |
41 |
42 | `
43 |
44 |
56 |
57 |
58 |
59 |
65 |
66 |
75 |
76 |
77 |
82 |
83 |
92 |
93 |
94 |
95 |
96 |
102 |
103 |
109 |
110 |
114 |
115 |
121 |
122 |
126 |
127 |
133 |
134 |
135 |
136 |
137 |
138 |
142 |
143 |
144 |
149 |
150 |
156 |
157 |
161 |
162 |
168 |
169 |
173 |
174 |
180 |
181 |
182 |
183 |
184 |
188 |
189 |
194 |
195 |
201 |
202 |
206 |
207 |
213 |
214 |
218 |
219 |
225 |
226 |
227 |
228 |
229 |
230 |
237 |
238 |
239 |
246 |
247 |
248 |
259 |
260 |
261 |
262 |
263 |
264 |
--------------------------------------------------------------------------------
/app/src/main/java/jetray/tictactoe/MainActivity.java:
--------------------------------------------------------------------------------
1 | package jetray.tictactoe;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.text.Editable;
7 | import android.text.TextWatcher;
8 | import android.view.animation.AlphaAnimation;
9 | import android.view.inputmethod.EditorInfo;
10 | import android.widget.AdapterView;
11 | import android.widget.CheckBox;
12 | import android.widget.EditText;
13 | import android.widget.LinearLayout;
14 | import android.widget.Spinner;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | import android.view.View;
20 | import android.widget.ArrayAdapter;
21 |
22 | public class MainActivity extends AppCompatActivity {
23 |
24 | public EditText plyr1;
25 | public EditText plyr2;
26 |
27 | public Spinner difficulty;
28 | public CharSequence player1 = "Player 1";
29 | public CharSequence player2 = "Player 2";
30 |
31 | public CharSequence cloneplayer2;
32 | boolean player1ax = true;
33 | boolean selectedSinglePlayer;
34 | boolean easy = true;
35 | boolean medium = false;
36 | boolean hard = false;
37 | boolean impossible = false;
38 | public CheckBox p1x, p1o, p2x, p2o, singleplayer, twoplayer;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 |
43 |
44 | super.onCreate(savedInstanceState);
45 | setContentView(R.layout.activity_main);
46 |
47 | //apply the animation ( fade In ) to your LAyout
48 |
49 | if (getIntent().getBooleanExtra("EXIT", false)) {
50 | finish();
51 | }
52 |
53 | addItemToDifficultySpinner();
54 |
55 | plyr1 = (EditText) findViewById(R.id.playerone);
56 | plyr2 = (EditText) findViewById(R.id.playertwo);
57 |
58 |
59 | p1x = (CheckBox) findViewById(R.id.player1x);
60 | p1o = (CheckBox) findViewById(R.id.player1o);
61 | p2x = (CheckBox) findViewById(R.id.player2x);
62 | p2o = (CheckBox) findViewById(R.id.player2o);
63 | singleplayer = (CheckBox) findViewById(R.id.splayer);
64 | twoplayer = (CheckBox) findViewById(R.id.tplayer);
65 |
66 | p1x.setOnClickListener(checkboxClickListener);
67 | p1o.setOnClickListener(checkboxClickListener);
68 | p2x.setOnClickListener(checkboxClickListener);
69 | p2o.setOnClickListener(checkboxClickListener);
70 | singleplayer.setOnClickListener(checkboxClickListener);
71 | twoplayer.setOnClickListener(checkboxClickListener);
72 |
73 | difficulty.setEnabled(false);
74 |
75 |
76 | p1x.setChecked(true);
77 | p2o.setChecked(true);
78 | twoplayer.setChecked(true);
79 |
80 |
81 | plyr1.addTextChangedListener(new TextWatcher() { /*this code take player1's name characterwise i.e it takes one character at a time and
82 | saved to string variable player1*/
83 | @Override
84 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
85 | }
86 |
87 | @Override
88 | public void onTextChanged(CharSequence s, int start, int before, int count) {
89 | player1 = s.toString();
90 | }
91 |
92 | @Override
93 | public void afterTextChanged(Editable s) {
94 | }
95 | });
96 |
97 |
98 | plyr2.addTextChangedListener(new TextWatcher() {
99 |
100 | @Override
101 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
102 |
103 | }
104 |
105 | @Override
106 | public void onTextChanged(CharSequence s, int start, int before, int count) {
107 | player2 = s.toString();
108 | }
109 |
110 | @Override
111 | public void afterTextChanged(Editable s) {
112 |
113 | }
114 | });
115 |
116 | }
117 |
118 |
119 | public void addItemToDifficultySpinner() {
120 | difficulty = (Spinner) findViewById(R.id.difficulty);
121 |
122 | List list = new ArrayList();
123 | list.add("Easy");
124 | list.add("Medium");
125 | list.add("Hard");
126 | list.add("Impossible");
127 |
128 | ArrayAdapter dataAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, list);
129 | dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
130 | difficulty.setAdapter(dataAdapter);
131 |
132 |
133 | difficulty.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
134 | @Override
135 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
136 | String temp = parent.getItemAtPosition(position).toString();
137 |
138 | switch (temp) {
139 | case "Easy":
140 | easy = true;
141 | medium = false;
142 | hard = false;
143 | impossible = false;
144 | break;
145 | case "Medium":
146 | easy = false;
147 | medium = true;
148 | hard = false;
149 | impossible = false;
150 | break;
151 | case "Hard":
152 | easy = false;
153 | medium = false;
154 | hard = true;
155 | impossible = false;
156 | break;
157 | case "Impossible":
158 | easy = false;
159 | medium = false;
160 | hard = false;
161 | impossible = true;
162 | break;
163 | }
164 |
165 | }
166 |
167 | @Override
168 | public void onNothingSelected(AdapterView> parent) {
169 | medium = true;
170 | easy = false;
171 | hard = false;
172 | impossible = false;
173 | }
174 | });
175 | }
176 |
177 |
178 | View.OnClickListener checkboxClickListener = new View.OnClickListener() {
179 | @Override
180 | public void onClick(View view) {
181 | boolean checked = ((CheckBox) view).isChecked();
182 | if (checked) {
183 | switch (view.getId()) {
184 | case R.id.player1x:
185 | p1o.setChecked(false);
186 | p2x.setChecked(false);
187 | p2o.setChecked(true);
188 | player1ax = true;
189 | break;
190 | case R.id.player1o:
191 | p1x.setChecked(false);
192 | p2o.setChecked(false);
193 | p2x.setChecked(true);
194 | player1ax = false;
195 | break;
196 | case R.id.player2x:
197 | p2o.setChecked(false);
198 | p1x.setChecked(false);
199 | p1o.setChecked(true);
200 | player1ax = false;
201 | break;
202 | case R.id.player2o:
203 | p2x.setChecked(false);
204 | p1o.setChecked(false);
205 | p1x.setChecked(true);
206 | player1ax = true;
207 | break;
208 | case R.id.splayer:
209 | twoplayer.setChecked(false);
210 | selectedSinglePlayer = true;
211 | cloneplayer2 = player2;
212 | plyr2.setText("CPU");
213 |
214 | plyr1.setImeOptions(EditorInfo.IME_ACTION_DONE);
215 | plyr1.setImeActionLabel("DONE", EditorInfo.IME_ACTION_DONE);
216 |
217 |
218 | difficulty.setEnabled(true);
219 | break;
220 | case R.id.tplayer:
221 | singleplayer.setChecked(false);
222 | selectedSinglePlayer = false;
223 | plyr2.setText(cloneplayer2);
224 | plyr1.setImeOptions(EditorInfo.IME_ACTION_NEXT);
225 | plyr1.setImeActionLabel("NEXT", EditorInfo.IME_ACTION_NEXT);
226 | difficulty.setEnabled(false);
227 | break;
228 | }
229 |
230 | } else {
231 | switch (view.getId()) {
232 | case R.id.player1x:
233 | p1o.setChecked(true);
234 | p2x.setChecked(true);
235 | p2o.setChecked(false);
236 | player1ax = false;
237 | break;
238 | case R.id.player1o:
239 | p1x.setChecked(true);
240 | p2o.setChecked(true);
241 | p2x.setChecked(false);
242 | player1ax = true;
243 | break;
244 | case R.id.player2x:
245 | p2o.setChecked(true);
246 | p1x.setChecked(true);
247 | p1o.setChecked(false);
248 | player1ax = true;
249 | break;
250 | case R.id.player2o:
251 | p2x.setChecked(true);
252 | p1o.setChecked(true);
253 | p1x.setChecked(false);
254 | player1ax = false;
255 | break;
256 | case R.id.splayer:
257 | twoplayer.setChecked(true);
258 | selectedSinglePlayer = false;
259 | plyr2.setText(cloneplayer2);
260 | difficulty.setEnabled(false);
261 | plyr1.setImeOptions(EditorInfo.IME_ACTION_NEXT);
262 | plyr1.setImeActionLabel("NEXT", EditorInfo.IME_ACTION_NEXT);
263 | break;
264 | case R.id.tplayer:
265 | singleplayer.setChecked(true);
266 | selectedSinglePlayer = true;
267 | plyr2.setText("CPU");
268 | plyr1.setImeOptions(EditorInfo.IME_ACTION_DONE);
269 | plyr1.setImeActionLabel("DONE", EditorInfo.IME_ACTION_DONE);
270 | difficulty.setEnabled(true);
271 | break;
272 | }
273 |
274 | }
275 |
276 | }
277 | };
278 |
279 |
280 | public void startgame(View view) {
281 |
282 | if (!selectedSinglePlayer)
283 | if (player2.length() == 0)
284 | player2 = "player 2";
285 | if (player1.length() == 0)
286 | player1 = "player 1";
287 |
288 | CharSequence[] players = {player1, player2};
289 | Intent i = new Intent(this, Afterstart.class);
290 | i.putExtra("easy", easy);
291 | i.putExtra("medium", medium);
292 | i.putExtra("hard", hard);
293 | i.putExtra("impossible", impossible);
294 | i.putExtra("playersnames", players);
295 | i.putExtra("player1ax", player1ax);
296 | i.putExtra("selectedsingleplayer", selectedSinglePlayer);
297 | startActivity(i);
298 | }
299 |
300 | }
--------------------------------------------------------------------------------
/app/src/main/java/jetray/tictactoe/Afterstart.java:
--------------------------------------------------------------------------------
1 | package jetray.tictactoe;
2 |
3 | import android.app.Dialog;
4 | import android.content.Intent;
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 | import android.os.Handler;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.View;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 | import android.view.Window;
14 | import android.view.WindowManager;
15 | import android.widget.Button;
16 | import android.widget.ImageView;
17 | import android.widget.TextView;
18 | import android.widget.Toast;
19 |
20 | import java.util.Random;
21 |
22 | public class Afterstart extends AppCompatActivity {
23 |
24 | boolean easy;
25 | boolean medium;
26 | boolean hard;
27 | boolean impossible;
28 | Random r = new Random();
29 |
30 | int flag = 0, ax = 10, zero = 1, sensorflag = 0, win = 0, i, game = 1, prevrow, prevcol;
31 | int summ = 0, ctrflag = 0, night = 0, resetchecker = 1, currentgamedonechecker = 0;
32 | int score1 = 0, score2 = 0, drawchecker = 0;
33 | static int[][] tracker = new int[3][3];
34 | int[] sum = new int[8];
35 | static int[][] buttonpressed = new int[3][3];
36 |
37 | boolean player1ax;
38 | boolean selectedsingleplayer;
39 |
40 | TextView p1;
41 | TextView p2;
42 | CharSequence player1 = "Player 1";
43 | CharSequence player2 = "Player 2";
44 |
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 |
49 |
50 | super.onCreate(savedInstanceState);
51 | setContentView(R.layout.content_afterstart);
52 |
53 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
54 | setSupportActionBar(toolbar);
55 |
56 | CharSequence[] players = getIntent().getCharSequenceArrayExtra("playersnames");
57 | player1ax = getIntent().getBooleanExtra("player1ax", true);
58 | selectedsingleplayer = getIntent().getBooleanExtra("selectedsingleplayer", true);
59 |
60 | easy = getIntent().getBooleanExtra("easy", false);
61 | medium = getIntent().getBooleanExtra("medium", false);
62 | hard = getIntent().getBooleanExtra("hard", false);
63 | impossible = getIntent().getBooleanExtra("impossible", false);
64 |
65 |
66 | if (player1ax) {
67 | ax = 1;
68 | zero = 10;
69 | }
70 |
71 |
72 | player1 = players[0];
73 | player2 = players[1];
74 | p1 = (TextView) findViewById(R.id.playerone);
75 | p2 = (TextView) findViewById(R.id.playertwo);
76 |
77 | p1.setText(player1);
78 | p2.setText(player2);
79 |
80 | Toast.makeText(this, "" + player1 + "\'s turn", Toast.LENGTH_SHORT).show();
81 |
82 | }
83 |
84 |
85 | public void kzz(View view) {
86 |
87 |
88 | if (win == 0 && buttonpressed[0][0] == 0) {
89 | if (flag % 2 == 0)
90 | tracker[0][0] = ax;
91 | else
92 | tracker[0][0] = zero;
93 |
94 | printBoard();
95 | winchecker();
96 | cpuplay();
97 | flag++;
98 | buttonpressed[0][0]++;
99 | }
100 | }
101 |
102 |
103 | public void kzo(View view) {
104 |
105 | if (win == 0 && buttonpressed[0][1] == 0) {
106 | if (flag % 2 == 0) tracker[0][1] = ax;
107 | else tracker[0][1] = zero;
108 |
109 | printBoard();
110 | winchecker();
111 | cpuplay();
112 | buttonpressed[0][1]++;
113 | flag++;
114 | }
115 | }
116 |
117 | public void kzt(View view) {
118 | if (win == 0 && buttonpressed[0][2] == 0) {
119 | if (flag % 2 == 0) tracker[0][2] = ax;
120 | else tracker[0][2] = zero;
121 |
122 | printBoard();
123 | winchecker();
124 | cpuplay();
125 | buttonpressed[0][2]++;
126 | flag++;
127 | }
128 | }
129 |
130 | public void koz(View v) {
131 | if (win == 0 && buttonpressed[1][0] == 0) {
132 | if (flag % 2 == 0) tracker[1][0] = ax;
133 | else tracker[1][0] = zero;
134 |
135 | printBoard();
136 | winchecker();
137 | cpuplay();
138 |
139 | ++buttonpressed[1][0];
140 | flag++;
141 | }
142 | }
143 |
144 | public void koo(View v) {
145 | if (win == 0 && buttonpressed[1][1] == 0) {
146 | if (flag % 2 == 0) tracker[1][1] = ax;
147 | else tracker[1][1] = zero;
148 | printBoard();
149 | winchecker();
150 | cpuplay();
151 | ++buttonpressed[1][1];
152 | flag++;
153 | }
154 | }
155 |
156 | public void kot(View v) {
157 | if (win == 0 && buttonpressed[1][2] == 0) {
158 | if (flag % 2 == 0) tracker[1][2] = ax;
159 | else tracker[1][2] = zero;
160 |
161 | printBoard();
162 | winchecker();
163 | cpuplay();
164 | ++buttonpressed[1][2];
165 | flag++;
166 | }
167 | }
168 |
169 | public void ktz(View v) {
170 | if (win == 0 && buttonpressed[2][0] == 0) {
171 | if (flag % 2 == 0) tracker[2][0] = ax;
172 | else tracker[2][0] = zero;
173 |
174 | printBoard();
175 | winchecker();
176 | cpuplay();
177 | ++buttonpressed[2][0];
178 | flag++;
179 | }
180 | }
181 |
182 | public void kto(View v) {
183 | if (win == 0 && buttonpressed[2][1] == 0) {
184 | if (flag % 2 == 0) tracker[2][1] = ax;
185 | else tracker[2][1] = zero;
186 | printBoard();
187 | winchecker();
188 | cpuplay();
189 | ++buttonpressed[2][1];
190 | flag++;
191 | }
192 | }
193 |
194 | public void ktt(View v) {
195 | if (win == 0 && buttonpressed[2][2] == 0) {
196 | if (flag % 2 == 0) tracker[2][2] = ax;
197 | else tracker[2][2] = zero;
198 |
199 | printBoard();
200 | winchecker();
201 | cpuplay();
202 | ++buttonpressed[2][2];
203 | flag++;
204 | }
205 | }
206 |
207 | public void cpuplay() {
208 | if ((selectedsingleplayer) && (win == 0)) {
209 |
210 |
211 | if (ifcpuwin()) ;
212 | else if (ifopowin()) ;
213 | else if (emptycentre()) ;
214 | else if (emptycorner()) ;
215 | else emptyany();
216 |
217 |
218 | /*** final Handler handler = new Handler();
219 | Timer t = new Timer();
220 | t.schedule(new TimerTask() {
221 | public void run() {
222 | handler.post(new Runnable() {
223 | public void run() {
224 |
225 | //add code to be executed after a pause
226 |
227 | }
228 | });
229 | }
230 | }, 80);****/
231 | printBoard();
232 | winchecker();
233 |
234 | flag++;
235 | return;
236 | }
237 | }
238 |
239 | public boolean ifcpuwin() {
240 | if (!easy) {
241 | for (i = 0; i < 8; i++) {
242 | if (sum[i] == 2 * zero) {
243 | if (i == 0) {
244 | for (int x = 0; x < 3; x++)
245 | if (tracker[0][x] == 0)
246 | tracker[0][x] = zero;
247 | }
248 |
249 | if (i == 1) {
250 | for (int x = 0; x < 3; x++)
251 | if (tracker[1][x] == 0)
252 | tracker[1][x] = zero;
253 | }
254 | if (i == 2) {
255 | for (int x = 0; x < 3; x++)
256 | if (tracker[2][x] == 0)
257 | tracker[2][x] = zero;
258 | }
259 |
260 | if (i == 3) {
261 | for (int x = 0; x < 3; x++)
262 | if (tracker[x][0] == 0)
263 | tracker[x][0] = zero;
264 | }
265 |
266 | if (i == 4) {
267 |
268 | for (int x = 0; x < 3; x++)
269 | if (tracker[x][1] == 0)
270 | tracker[x][1] = zero;
271 | }
272 |
273 | if (i == 5) {
274 |
275 | for (int x = 0; x < 3; x++)
276 | if (tracker[x][2] == 0)
277 | tracker[x][2] = zero;
278 | }
279 | if (i == 6) {
280 |
281 | for (int y = 0; y < 3; y++)
282 | for (int x = 0; x < 3; x++)
283 | if (x == y)
284 | if (tracker[x][y] == 0)
285 | tracker[x][y] = zero;
286 | }
287 | if (i == 7) {
288 | if (tracker[0][2] == 0)
289 | tracker[0][2] = zero;
290 | else if (tracker[1][1] == 0)
291 | tracker[1][1] = zero;
292 | else tracker[2][0] = zero;
293 |
294 | }
295 | return true;
296 | }
297 | }
298 | }
299 | return false;
300 | }
301 |
302 |
303 | public boolean ifopowin() {
304 | if ((!easy) || (!medium)) {
305 |
306 | for (i = 0; i < 8; i++) {
307 | if (sum[i] == 2 * ax) {
308 | if (i == 0) {
309 | for (int x = 0; x < 3; x++)
310 | if (tracker[0][x] == 0) {
311 | tracker[0][x] = zero;
312 | buttonpressed[0][x]++;
313 | }
314 | }
315 |
316 | if (i == 1) {
317 | for (int x = 0; x < 3; x++)
318 | if (tracker[1][x] == 0) {
319 | tracker[1][x] = zero;
320 | buttonpressed[1][x]++;
321 | }
322 | }
323 | if (i == 2) {
324 | for (int x = 0; x < 3; x++)
325 | if (tracker[2][x] == 0) {
326 | tracker[2][x] = zero;
327 | buttonpressed[2][x]++;
328 | }
329 | }
330 |
331 | if (i == 3) {
332 | for (int x = 0; x < 3; x++)
333 | if (tracker[x][0] == 0) {
334 | tracker[x][0] = zero;
335 | buttonpressed[x][0]++;
336 | }
337 | }
338 |
339 | if (i == 4) {
340 |
341 | for (int x = 0; x < 3; x++)
342 | if (tracker[x][1] == 0) {
343 | tracker[x][1] = zero;
344 | buttonpressed[x][1]++;
345 | }
346 | }
347 |
348 | if (i == 5) {
349 |
350 | for (int x = 0; x < 3; x++)
351 | if (tracker[x][2] == 0) {
352 | tracker[x][2] = zero;
353 | buttonpressed[x][2]++;
354 | }
355 | }
356 | if (i == 6) {
357 |
358 | for (int y = 0; y < 3; y++)
359 | for (int x = 0; x < 3; x++)
360 | if (x == y)
361 | if (tracker[x][y] == 0) {
362 | tracker[x][y] = zero;
363 | buttonpressed[x][y]++;
364 | }
365 |
366 |
367 | }
368 | if (i == 7) {
369 | if (tracker[0][2] == 0) {
370 | tracker[0][2] = zero;
371 | buttonpressed[0][2]++;
372 | } else if (tracker[1][1] == 0) {
373 | tracker[1][1] = zero;
374 | buttonpressed[1][1]++;
375 | } else {
376 | tracker[2][0] = zero;
377 | buttonpressed[2][0]++;
378 | }
379 |
380 |
381 | }
382 | return true;
383 | }
384 | }
385 |
386 | }
387 | return false;
388 | }
389 |
390 | public boolean emptycentre() {
391 | if (impossible || hard) {
392 | if (tracker[1][1] == 0) {
393 | tracker[1][1] = zero;
394 | buttonpressed[1][1]++;
395 | return true;
396 | }
397 | }
398 | return false;
399 | }
400 |
401 | public boolean emptycorner() {
402 |
403 |
404 | if (hard || impossible)
405 | if (((tracker[0][0] + tracker[2][2]) == 2 * ax) || ((tracker[0][2] + tracker[2][0]) == 2 * ax)) {
406 | for (int k = 0; k < 3; k++)
407 | for (int j = 0; j < 3; j++)
408 | if ((k + j) % 2 == 1) {
409 | if (tracker[k][j] == 0)
410 | tracker[k][j] = zero;
411 | buttonpressed[k][j]++;
412 | return true;
413 | }
414 | }
415 |
416 |
417 | if (impossible)
418 | if (sum[6] == zero || sum[7] == zero) {
419 | if (sum[6] == zero) {
420 | if ((sum[0] + sum[3]) > (sum[2] + sum[5])) {
421 | tracker[0][0] = zero;
422 | buttonpressed[0][0]++;
423 | } else {
424 | tracker[2][2] = zero;
425 | buttonpressed[2][2]++;
426 | }
427 | return true;
428 | }
429 |
430 | if (sum[7] == zero) {
431 | if ((sum[0] + sum[5]) > (sum[3] + sum[2])) {
432 | tracker[0][2] = zero;
433 | buttonpressed[0][2]++;
434 | } else {
435 | tracker[2][0] = zero;
436 | buttonpressed[2][0]++;
437 | }
438 | return true;
439 | }
440 |
441 | }
442 |
443 |
444 | for (int i = 0; i < 3; i++) {
445 | if (tracker[0][i] == ax) {
446 | if (tracker[0][0] == 0) {
447 | tracker[0][0] = zero;
448 | buttonpressed[0][0]++;
449 | return true;
450 | }
451 | if (tracker[0][2] == 0) {
452 | tracker[0][2] = zero;
453 | buttonpressed[0][2]++;
454 | return true;
455 | }
456 | }
457 | }
458 |
459 | for (int i = 0; i < 3; i++) {
460 |
461 | if (tracker[2][i] == ax) {
462 | if (tracker[2][0] == 0) {
463 | tracker[2][0] = zero;
464 | buttonpressed[2][0]++;
465 | return true;
466 | }
467 | if (tracker[2][2] == 0) {
468 | tracker[2][2] = zero;
469 | buttonpressed[2][2]++;
470 | return true;
471 | }
472 | }
473 | }
474 | for (int i = 0; i < 3; i++) {
475 | if (tracker[i][0] == ax) {
476 | if (tracker[0][0] == 0) {
477 | tracker[0][0] = zero;
478 | buttonpressed[0][0]++;
479 | return true;
480 | }
481 | if (tracker[2][0] == 0) {
482 | tracker[2][0] = zero;
483 | buttonpressed[2][0]++;
484 | return true;
485 | }
486 | }
487 | }
488 | for (int i = 0; i < 3; i++) {
489 | if (tracker[i][2] == ax) {
490 | if (tracker[0][2] == 0) {
491 | tracker[0][2] = zero;
492 | buttonpressed[0][2]++;
493 | return true;
494 | }
495 | if (tracker[2][2] == 0) {
496 | tracker[2][2] = zero;
497 | buttonpressed[2][2]++;
498 | return true;
499 | }
500 | }
501 | }
502 | return false;
503 |
504 | }
505 |
506 | public void emptyany() {
507 |
508 | if (ctrflag == 0)
509 | while (true) {
510 | int x = rand();
511 | int y = rand();
512 |
513 | if (tracker[x][y] == 0) {
514 | tracker[x][y] = zero;
515 | buttonpressed[x][y]++;
516 | return;
517 |
518 | }
519 | }
520 |
521 | for (int x = 0; x < 3; x++)
522 | for (int y = 0; y < 3; y++)
523 | if (tracker[x][y] == 0) {
524 | tracker[x][y] = zero;
525 | buttonpressed[x][y]++;
526 | return;
527 | }
528 |
529 |
530 | }
531 |
532 | public int rand() {
533 | return r.nextInt(3);
534 | }
535 |
536 | public void printBoard() {
537 | ImageView q1, q2, q3, q4, q5, q6, q7, q8, q9;
538 |
539 | q1 = (ImageView) findViewById(R.id.tzz);
540 | q2 = (ImageView) findViewById(R.id.tzo);
541 | q3 = (ImageView) findViewById(R.id.tzt);
542 | q4 = (ImageView) findViewById(R.id.toz);
543 | q5 = (ImageView) findViewById(R.id.too);
544 | q6 = (ImageView) findViewById(R.id.tot);
545 | q7 = (ImageView) findViewById(R.id.ttz);
546 | q8 = (ImageView) findViewById(R.id.tto);
547 | q9 = (ImageView) findViewById(R.id.ttt);
548 |
549 |
550 | if (tracker[0][0] == 1) q1.setImageResource(R.drawable.x);
551 | if (tracker[0][0] == 10) q1.setImageResource(R.drawable.oo);
552 |
553 |
554 | if (tracker[0][1] == 1) q2.setImageResource(R.drawable.x);
555 | if (tracker[0][1] == 10) q2.setImageResource(R.drawable.oo);
556 |
557 |
558 | if (tracker[0][2] == 1) q3.setImageResource(R.drawable.x);
559 | if (tracker[0][2] == 10) q3.setImageResource(R.drawable.oo);
560 |
561 |
562 | if (tracker[1][0] == 1) q4.setImageResource(R.drawable.x);
563 | if (tracker[1][0] == 10) q4.setImageResource(R.drawable.oo);
564 |
565 | if (tracker[1][1] == 1) q5.setImageResource(R.drawable.x);
566 | if (tracker[1][1] == 10) q5.setImageResource(R.drawable.oo);
567 |
568 |
569 | if (tracker[1][2] == 1) q6.setImageResource(R.drawable.x);
570 | if (tracker[1][2] == 10) q6.setImageResource(R.drawable.oo);
571 |
572 | if (tracker[2][0] == 1) q7.setImageResource(R.drawable.x);
573 | if (tracker[2][0] == 10) q7.setImageResource(R.drawable.oo);
574 |
575 |
576 | if (tracker[2][1] == 1) q8.setImageResource(R.drawable.x);
577 | if (tracker[2][1] == 10) q8.setImageResource(R.drawable.oo);
578 |
579 | if (tracker[2][2] == 1) q9.setImageResource(R.drawable.x);
580 | if (tracker[2][2] == 10) q9.setImageResource(R.drawable.oo);
581 |
582 | resetchecker++;
583 | }
584 |
585 |
586 | public void showDialog(String whoWon, String scoreWon, String whoLose, String scoreLose) {
587 |
588 | final Dialog dialog = new Dialog(Afterstart.this);
589 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
590 | dialog.setContentView(R.layout.dialog_layout);
591 | // TextView playerOneScore = dialog.findViewById(R.id.player_one_score);
592 | // TextView playerTwoScore = dialog.findViewById(R.id.player_two_score);
593 | TextView titleText = dialog.findViewById(R.id.title_text);
594 | dialog.setCancelable(false);
595 | dialog.show();
596 |
597 | titleText.setText(whoWon);
598 | // playerOneScore.setText(whoWon+" Score -> "+scoreWon);
599 | // playerTwoScore.setText(whoLose+"Score -> "+scoreLose);
600 |
601 | Button resetButton = dialog.findViewById(R.id.reset_button);
602 | Button playAgainButton = dialog.findViewById(R.id.play_again_button);
603 |
604 | resetButton.setOnClickListener(new View.OnClickListener() {
605 | @Override
606 | public void onClick(View view) {
607 | dialog.dismiss();
608 | doreset();
609 | }
610 | });
611 |
612 | playAgainButton.setOnClickListener(new View.OnClickListener() {
613 | @Override
614 | public void onClick(View view) {
615 | dialog.dismiss();
616 | playmore();
617 | }
618 | });
619 | }
620 |
621 | public void winchecker() {
622 | ctrflag++;
623 | sum[0] = tracker[0][0] + tracker[0][1] + tracker[0][2];
624 | sum[1] = tracker[1][0] + tracker[1][1] + tracker[1][2];
625 | sum[2] = tracker[2][0] + tracker[2][1] + tracker[2][2];
626 | sum[3] = tracker[0][0] + tracker[1][0] + tracker[2][0];
627 | sum[4] = tracker[0][1] + tracker[1][1] + tracker[2][1];
628 | sum[5] = tracker[0][2] + tracker[1][2] + tracker[2][2];
629 | sum[6] = tracker[0][0] + tracker[1][1] + tracker[2][2];
630 | sum[7] = tracker[0][2] + tracker[1][1] + tracker[2][0];
631 |
632 |
633 | currentgamedonechecker++;
634 | resetchecker++;
635 |
636 | for (int i = 0; i < 8; i++)
637 | if (sum[i] == 3 || sum[i] == 30) {
638 | win++;
639 | if ((sum[i] == 3) && (ax == 1)) {
640 | score1++;
641 | TextView q1 = (TextView) findViewById(R.id.p1score);
642 | q1.setText("" + score1);
643 | showDialog("" + player1 + " won!", "" + score1, "" + player2, "" + score2);
644 |
645 | }
646 | if ((sum[i] == 3) && (zero == 1)) {
647 | score2++;
648 | TextView q1 = (TextView) findViewById(R.id.p2score);
649 | q1.setText("" + score2);
650 | showDialog("" + player2 + " won!", "" + score2, "" + player1, "" + score1);
651 |
652 | }
653 | if ((sum[i] == 30) && (ax == 10)) {
654 | score1++;
655 | TextView q1 = (TextView) findViewById(R.id.p1score);
656 | q1.setText("" + score1);
657 | showDialog("" + player1 + " won!", "" + score1, "" + player2, "" + score2);
658 |
659 | }
660 | if ((sum[i] == 30) && (zero == 10)) {
661 | score2++;
662 | TextView q1 = (TextView) findViewById(R.id.p2score);
663 | q1.setText("" + score2);
664 | showDialog("" + player2 + " won!", "" + score2, "" + player1, "" + score1);
665 |
666 | }
667 |
668 | }
669 |
670 | if ((ctrflag == 9) && (win == 0)) {
671 | showDialog("This is a draw !", "" + score1, "" + player2, "" + score2);
672 |
673 | drawchecker++;
674 | }
675 |
676 |
677 | } //end winchecker()
678 |
679 | private void playmore() {
680 | if ((drawchecker > 0) || (win > 0)) {
681 | game++;
682 | TextView qq = (TextView) findViewById(R.id.gamenumber);
683 | qq.setText("" + game);
684 |
685 | for (int i = 0; i < 8; i++)
686 | sum[i] = 0;
687 |
688 | drawchecker = 0;
689 |
690 |
691 | ImageView q1, q2, q3, q4, q5, q6, q7, q8, q9;
692 | q1 = (ImageView) findViewById(R.id.tzz);
693 | q2 = (ImageView) findViewById(R.id.tzo);
694 | q3 = (ImageView) findViewById(R.id.tzt);
695 | q4 = (ImageView) findViewById(R.id.toz);
696 | q5 = (ImageView) findViewById(R.id.too);
697 | q6 = (ImageView) findViewById(R.id.tot);
698 | q7 = (ImageView) findViewById(R.id.ttz);
699 | q8 = (ImageView) findViewById(R.id.tto);
700 | q9 = (ImageView) findViewById(R.id.ttt);
701 | q1.setImageDrawable(null);
702 | q2.setImageDrawable(null);
703 | q3.setImageDrawable(null);
704 | q4.setImageDrawable(null);
705 | q5.setImageDrawable(null);
706 | q6.setImageDrawable(null);
707 | q7.setImageDrawable(null);
708 | q8.setImageDrawable(null);
709 | q9.setImageDrawable(null);
710 |
711 | for (int i = 0; i < 3; i++)
712 | for (int j = 0; j < 3; j++)
713 | buttonpressed[i][j] = 0;
714 |
715 | for (int i = 0; i < 3; i++)
716 | for (int j = 0; j < 3; j++)
717 | tracker[i][j] = 0;
718 |
719 |
720 | if ((game + 1) % 2 == 0)
721 | Toast.makeText(this, "" + player1 + "\'s turn", Toast.LENGTH_SHORT).show();
722 | else
723 | Toast.makeText(this, "" + player2 + "\'s turn", Toast.LENGTH_SHORT).show();
724 | win = 0;
725 | summ = 0;
726 | ctrflag = 0;
727 | flag = (game + 1) % 2;
728 | currentgamedonechecker = 0;
729 |
730 | if (selectedsingleplayer && (game % 2 == 0))
731 | cpuplay();
732 | }
733 | }
734 |
735 |
736 | public void doreset() {
737 |
738 | TextView qq = (TextView) findViewById(R.id.gamenumber);
739 | qq.setText("" + 1);
740 |
741 |
742 | for (int i = 0; i < 3; i++)
743 | for (int j = 0; j < 3; j++)
744 | tracker[i][j] = 0;
745 |
746 | for (int i = 0; i < 3; i++)
747 | for (int j = 0; j < 3; j++)
748 | buttonpressed[i][j] = 0;
749 |
750 | ImageView q1, q2, q3, q4, q5, q6, q7, q8, q9;
751 |
752 | q1 = (ImageView) findViewById(R.id.tzz);
753 | q2 = (ImageView) findViewById(R.id.tzo);
754 | q3 = (ImageView) findViewById(R.id.tzt);
755 | q4 = (ImageView) findViewById(R.id.toz);
756 | q5 = (ImageView) findViewById(R.id.too);
757 | q6 = (ImageView) findViewById(R.id.tot);
758 | q7 = (ImageView) findViewById(R.id.ttz);
759 | q8 = (ImageView) findViewById(R.id.tto);
760 | q9 = (ImageView) findViewById(R.id.ttt);
761 | q1.setImageDrawable(null);
762 | q2.setImageDrawable(null);
763 | q3.setImageDrawable(null);
764 | q4.setImageDrawable(null);
765 | q5.setImageDrawable(null);
766 | q6.setImageDrawable(null);
767 | q7.setImageDrawable(null);
768 | q8.setImageDrawable(null);
769 | q9.setImageDrawable(null);
770 |
771 |
772 | win = 0;
773 | drawchecker = 0;
774 | summ = 0;
775 | resetchecker = 0;
776 | ctrflag = 0;
777 | score1 = 0;
778 | score2 = 0;
779 | game = 1;
780 | flag = 0;
781 | currentgamedonechecker = 0;
782 | TextView qqq = (TextView) findViewById(R.id.p1score);
783 | qqq.setText("" + score1);
784 | TextView qqqq = (TextView) findViewById(R.id.p2score);
785 | qqqq.setText("" + score2);
786 |
787 | Toast.makeText(this, "" + player1 + "\'s turn", Toast.LENGTH_SHORT).show();
788 |
789 |
790 | }
791 |
792 |
793 | // @Override
794 | // public boolean onCreateOptionsMenu(Menu menu) {
795 | // // Inflate the menu; this adds items to the action bar if it is present.
796 | // getMenuInflater().inflate(R.menu.menu_main, menu);
797 | // return true;
798 | // }
799 |
800 | private void showExitDialog() {
801 | final Dialog dialog = new Dialog(Afterstart.this);
802 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
803 | dialog.setContentView(R.layout.dialog_layout_exit);
804 | dialog.setCancelable(false);
805 |
806 | dialog.show();
807 |
808 | Button exit = dialog.findViewById(R.id.yes_button);
809 | final Button dismiss = dialog.findViewById(R.id.no_button);
810 |
811 | exit.setOnClickListener(new View.OnClickListener() {
812 | @Override
813 | public void onClick(View view) {
814 | doreset();
815 | finish();
816 | }
817 | });
818 |
819 | dismiss.setOnClickListener(new View.OnClickListener() {
820 | @Override
821 | public void onClick(View view) {
822 | dialog.dismiss();
823 | }
824 | });
825 | }
826 |
827 | @Override
828 | public void onBackPressed() {
829 | showExitDialog();
830 | }
831 |
832 | // @Override
833 | // public boolean onOptionsItemSelected(MenuItem item) {
834 | // // Handle action bar item clicks here. The action bar will
835 | // // automatically handle clicks on the Home/Up button, so long
836 | // // as you specify a parent activity in AndroidManifest.xml.
837 | // int id = item.getItemId();
838 | //
839 | // //noinspection SimplifiableIfStatement
840 | // if (id == R.id.exit) {
841 | // Intent intent = new Intent(getApplicationContext(), MainActivity.class);
842 | // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
843 | // intent.putExtra("EXIT", true);
844 | // doreset();
845 | // startActivity(intent);
846 | // }
847 | //
848 | // if (id == R.id.daynightmode) {
849 | //
850 | // if (night % 2 == 0) {
851 | // View view = this.getWindow().getDecorView();
852 | // view.setBackgroundColor(Color.parseColor("#000000"));
853 | // item.setTitle("Day Mode");
854 | // } else {
855 | // View view = this.getWindow().getDecorView();
856 | // view.setBackgroundColor(Color.parseColor("#FFFFFF"));
857 | // item.setTitle("Night Mode");
858 | // }
859 | // night++;
860 | // }
861 | //
862 | //
863 | // return super.onOptionsItemSelected(item);
864 | // }
865 | }
866 |
867 |
868 |
--------------------------------------------------------------------------------