Browse Source

首次提交

贾艺驰 4 years ago
commit
f4f02afd22
55 changed files with 2133 additions and 0 deletions
  1. 15 0
      .gitignore
  2. 1 0
      app/.gitignore
  3. 51 0
      app/build.gradle
  4. 21 0
      app/proguard-rules.pro
  5. 26 0
      app/src/androidTest/java/com/jyc/threegames/ExampleInstrumentedTest.java
  6. 47 0
      app/src/main/AndroidManifest.xml
  7. 16 0
      app/src/main/java/com/jyc/threegames/App.java
  8. 48 0
      app/src/main/java/com/jyc/threegames/activity/AdminActivity.java
  9. 154 0
      app/src/main/java/com/jyc/threegames/activity/GameActivity.java
  10. 74 0
      app/src/main/java/com/jyc/threegames/activity/LoginActivity.java
  11. 16 0
      app/src/main/java/com/jyc/threegames/activity/NormalUserActivity.java
  12. 16 0
      app/src/main/java/com/jyc/threegames/activity/ScaleActivity.java
  13. 36 0
      app/src/main/java/com/jyc/threegames/activity/WelcomeActivity.java
  14. 62 0
      app/src/main/java/com/jyc/threegames/activity/base/BaseActivity.java
  15. 104 0
      app/src/main/java/com/jyc/threegames/bean/ControllerMessage.java
  16. 73 0
      app/src/main/java/com/jyc/threegames/bean/GameInfo.java
  17. 11 0
      app/src/main/java/com/jyc/threegames/bean/request/ReqLogin.java
  18. 39 0
      app/src/main/java/com/jyc/threegames/bean/result/ResLogin.java
  19. 65 0
      app/src/main/java/com/jyc/threegames/controller/BaseController.java
  20. 146 0
      app/src/main/java/com/jyc/threegames/controller/LoginController.java
  21. 49 0
      app/src/main/java/com/jyc/threegames/net/HttpsTrustManager.java
  22. 47 0
      app/src/main/java/com/jyc/threegames/net/OkHttpClientHelper.java
  23. 29 0
      app/src/main/java/com/jyc/threegames/net/ResData.java
  24. 26 0
      app/src/main/java/com/jyc/threegames/net/RetrofitHelper.java
  25. 72 0
      app/src/main/java/com/jyc/threegames/net/SimpleRequest.java
  26. 25 0
      app/src/main/java/com/jyc/threegames/net/TokenInterceptor.java
  27. 18 0
      app/src/main/java/com/jyc/threegames/net/api/LoginService.java
  28. 6 0
      app/src/main/res/drawable/border.xml
  29. 243 0
      app/src/main/res/layout/activity_admin.xml
  30. 52 0
      app/src/main/res/layout/activity_game_one.xml
  31. 9 0
      app/src/main/res/layout/activity_game_three.xml
  32. 9 0
      app/src/main/res/layout/activity_game_two.xml
  33. 61 0
      app/src/main/res/layout/activity_login.xml
  34. 11 0
      app/src/main/res/layout/activity_main.xml
  35. 9 0
      app/src/main/res/layout/activity_scale.xml
  36. 30 0
      app/src/main/res/layout/activity_welcome.xml
  37. 9 0
      app/src/main/res/layout/settings_activity.xml
  38. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  39. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher.png
  40. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  41. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  42. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  43. 12 0
      app/src/main/res/values/arrays.xml
  44. 6 0
      app/src/main/res/values/colors.xml
  45. 19 0
      app/src/main/res/values/strings.xml
  46. 10 0
      app/src/main/res/values/styles.xml
  47. 35 0
      app/src/main/res/xml/root_preferences.xml
  48. 17 0
      app/src/test/java/com/jyc/threegames/ExampleUnitTest.java
  49. 25 0
      build.gradle
  50. 19 0
      gradle.properties
  51. BIN
      gradle/wrapper/gradle-wrapper.jar
  52. 6 0
      gradle/wrapper/gradle-wrapper.properties
  53. 172 0
      gradlew
  54. 84 0
      gradlew.bat
  55. 2 0
      settings.gradle

+ 15 - 0
.gitignore

@@ -0,0 +1,15 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+.idea/

+ 1 - 0
app/.gitignore

@@ -0,0 +1 @@
+/build

+ 51 - 0
app/build.gradle

@@ -0,0 +1,51 @@
+apply plugin: 'com.android.application'
+apply plugin: 'com.jakewharton.butterknife'
+
+android {
+    compileSdkVersion 30
+    buildToolsVersion "30.0.0"
+
+    defaultConfig {
+        applicationId "com.jyc.threegames"
+        minSdkVersion 28
+        targetSdkVersion 30
+        versionCode 1
+        versionName "1.0"
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+
+    compileOptions{
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+}
+
+dependencies {
+    implementation fileTree(dir: "libs", include: ["*.jar"])
+    implementation 'androidx.appcompat:appcompat:1.1.0'
+    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+    implementation 'androidx.preference:preference:1.1.0'
+    testImplementation 'junit:junit:4.12'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+
+    implementation 'io.reactivex.rxjava2:rxjava:2.2.8'
+    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
+    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
+    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
+    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
+    implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
+    implementation 'com.squareup.okhttp3:okhttp:3.14.1'
+
+    implementation 'com.jakewharton:butterknife:10.1.0'
+    annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
+
+}

+ 21 - 0
app/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 26 - 0
app/src/androidTest/java/com/jyc/threegames/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package com.jyc.threegames;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+        assertEquals("com.jyc.threegames", appContext.getPackageName());
+    }
+}

+ 47 - 0
app/src/main/AndroidManifest.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.jyc.threegames">
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+
+    <application
+        android:name=".App"
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:persistent="true"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme"
+        android:requestLegacyExternalStorage="true"
+        android:usesCleartextTraffic="true">
+        <activity android:name=".activity.WelcomeActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:name=".activity.ScaleActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait"/>
+        <activity
+            android:name=".activity.GameActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name=".activity.AdminActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name=".activity.LoginActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity android:name=".activity.NormalUserActivity" />
+    </application>
+
+</manifest>

+ 16 - 0
app/src/main/java/com/jyc/threegames/App.java

@@ -0,0 +1,16 @@
+package com.jyc.threegames;
+
+import android.app.Application;
+
+public class App extends Application {
+    public static Application app;
+
+    public static final String SERVER_ADDRESS = "http://192.168.1.100:8080/";
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+
+        app = this;
+    }
+}

+ 48 - 0
app/src/main/java/com/jyc/threegames/activity/AdminActivity.java

@@ -0,0 +1,48 @@
+package com.jyc.threegames.activity;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+import com.jyc.threegames.R;
+import com.jyc.threegames.activity.base.BaseActivity;
+import com.jyc.threegames.bean.GameInfo;
+
+import butterknife.OnClick;
+
+public class AdminActivity extends BaseActivity {
+
+    @Override
+    protected void init(Bundle instance) {
+        super.init(instance);
+    }
+
+    @Override
+    protected int getRootLayout() {
+        return R.layout.activity_admin;
+    }
+
+    @Override
+    protected String getPageTitle() {
+        return "歡迎使用";
+    }
+
+    @OnClick(R.id.gameA)
+    public void goToGameA(){
+        GameActivity.LAUNCH_GAME_ONE(this, GameInfo.EXERCISE(GameInfo.VERSION_GAME_ONE));
+    }
+
+    @OnClick(R.id.gameB)
+    public void goToGameB(){
+        GameActivity.LAUNCH_GAME_ONE(this, GameInfo.EXERCISE(GameInfo.VERSION_GAME_TWO));
+    }
+
+    @OnClick(R.id.gameC)
+    public void goToGameC(){
+        GameActivity.LAUNCH_GAME_ONE(this, GameInfo.EXERCISE(GameInfo.VERSION_GAME_THREE));
+    }
+
+    @OnClick(R.id.scale)
+    public void goToScale(){
+        startActivity(new Intent(this, ScaleActivity.class));
+    }
+}

+ 154 - 0
app/src/main/java/com/jyc/threegames/activity/GameActivity.java

@@ -0,0 +1,154 @@
+package com.jyc.threegames.activity;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.text.Html;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.constraintlayout.widget.ConstraintLayout;
+
+import com.jyc.threegames.R;
+import com.jyc.threegames.activity.base.BaseActivity;
+import com.jyc.threegames.bean.GameInfo;
+
+import java.util.Locale;
+
+import butterknife.BindView;
+
+public class GameActivity extends BaseActivity {
+    private static final String PARAM_GAME_INFO = "gameInfo";
+
+    private static final int PRE_GAME_COUNT_DOWN = 5;
+    private int mCurrentPreGameCountDown = 0;
+    private Handler mPreGameHandler;
+
+    private GameInfo mGameInfo;
+
+    private int mSpecialNumberOne;
+    private int mSpecialNumberTwo;
+
+    @BindView(R.id.pre_game_hint)
+    TextView mTVPreGameHint;
+
+    @BindView(R.id.game_hint)
+    TextView mTVGameHint;
+
+    @BindView(R.id.number)
+    TextView mTVNumber;
+
+    @BindView(R.id.click_area)
+    View mVClickArea;
+
+    @Override
+    protected void init(Bundle instance) {
+        super.init(instance);
+        if (instance == null)
+            mGameInfo = getIntent().getParcelableExtra(PARAM_GAME_INFO);
+        else
+            mGameInfo = instance.getParcelable(PARAM_GAME_INFO);
+
+        startPrePractise();
+    }
+
+    @Override
+    protected void onSaveInstanceState(@NonNull Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putParcelable(PARAM_GAME_INFO, mGameInfo);
+    }
+
+    @Override
+    protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
+        super.onRestoreInstanceState(savedInstanceState);
+        mGameInfo = savedInstanceState.getParcelable(PARAM_GAME_INFO);
+    }
+
+    @Override
+    protected int getRootLayout() {
+        return R.layout.activity_game_one;
+    }
+
+    @Override
+    public void onBackPressed() {
+        super.onBackPressed();
+    }
+
+    private void startPrePractise(){
+        hideAllView();
+
+        mSpecialNumberOne = getRandomNumber();
+        mSpecialNumberTwo = getRandomNumber(mSpecialNumberOne);
+
+        mCurrentPreGameCountDown = PRE_GAME_COUNT_DOWN;
+        mPreGameHandler = new Handler(Looper.getMainLooper(), new Handler.Callback() {
+            @Override
+            public boolean handleMessage(@NonNull Message message) {
+                if (mCurrentPreGameCountDown > 0){
+                    mTVPreGameHint.setVisibility(View.VISIBLE);
+                    mTVPreGameHint.setText(Html.fromHtml(getPrePractiseText(mSpecialNumberOne, mSpecialNumberTwo, mCurrentPreGameCountDown), Html.FROM_HTML_MODE_LEGACY));
+                    mCurrentPreGameCountDown --;
+                    mPreGameHandler.sendEmptyMessageDelayed(0, 1000);
+                }else{
+                    mTVPreGameHint.setVisibility(View.GONE);
+                    startPractise();
+                }
+                return true;
+            }
+        });
+        mPreGameHandler.sendEmptyMessage(0);
+    }
+
+    private String getPrePractiseText(int numberOne, int numberTwo, int countDown){
+        switch (mGameInfo.gameVersion){
+            case GameInfo.VERSION_GAME_ONE:
+                return String.format(Locale.TRADITIONAL_CHINESE,"當屏幕出現數字<font color='#cc0000'>%1$d</font>的時候,<br/>請您以最快的速度按下<br/><br/>正式開始前,會有小段練習<br/><br/><font color='#cc0000'>%2$d</font>秒后進入練習", mSpecialNumberOne, countDown);
+            case GameInfo.VERSION_GAME_TWO:
+                return String.format(Locale.TRADITIONAL_CHINESE,"當數字<font color='#cc0000'>%1$d</font>,<font color='#cc0000'>%2$d</font>連續出現時,<br/><font color='#cc0000'>%1$d</font>出現時不要按下,<br/><font color='#cc0000'>%2$d</font>出現時,<br/>請您以最快的速度按下<br/><br/>正式開始前,會有小段練習<br/><br/><font color='#cc0000'>%3$d</font>秒后進入練習",
+                        numberOne, numberTwo, countDown);
+            case GameInfo.VERSION_GAME_THREE:
+                return String.format(Locale.TRADITIONAL_CHINESE,"除數字<font color='#cc0000'>%1$d</font>以外的數字出現時,<br/>請您以最快的速度按下<br/><br/>正式開始前,會有小段練習<br/><br/><font color='#cc0000'>%2$d</font>秒后進入練習",
+                        numberOne, countDown);
+            default:
+                return "";
+        }
+    }
+
+    private void startPractise(){
+        hideAllView();
+
+        mVClickArea.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+
+            }
+        });
+    }
+
+    private int getRandomNumber(){
+        return (int)(Math.random() * 10);
+    }
+
+    private int getRandomNumber(int number){
+        int value = getRandomNumber();
+        return value == number ? getRandomNumber(number) : value;
+    }
+
+    private void hideAllView(){
+        ConstraintLayout rootView = ((ConstraintLayout)getWindow().getDecorView().findViewById(R.id.root));
+        for (int i = 0; i < rootView.getChildCount(); i ++){
+            if (rootView.getChildAt(i).getId() != R.id.click_area)
+                rootView.getChildAt(i).setVisibility(View.GONE);
+        }
+    }
+
+    public static void LAUNCH_GAME_ONE(Activity context, GameInfo gameInfo){
+        Intent intent = new Intent(context, GameActivity.class);
+        intent.putExtra(PARAM_GAME_INFO, gameInfo);
+        context.startActivity(intent);
+    }
+}

+ 74 - 0
app/src/main/java/com/jyc/threegames/activity/LoginActivity.java

@@ -0,0 +1,74 @@
+package com.jyc.threegames.activity;
+
+import android.Manifest;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.jyc.threegames.R;
+import com.jyc.threegames.activity.base.BaseActivity;
+import com.jyc.threegames.bean.result.ResLogin;
+import com.jyc.threegames.controller.LoginController;
+import com.jyc.threegames.net.SimpleRequest;
+
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+public class LoginActivity extends BaseActivity {
+
+    @BindView(R.id.user_name)
+    EditText mETUserName;
+    @BindView(R.id.pass_word)
+    EditText mETPassWord;
+
+
+
+    @Override
+    protected int getRootLayout() {
+        return R.layout.activity_login;
+    }
+
+    @Override
+    protected String getPageTitle() {
+        return "歡迎使用";
+    }
+
+    @Override
+    protected void init(Bundle instance) {
+        super.init(instance);
+
+        if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ||
+                checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
+            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
+        }
+    }
+
+    @OnClick(R.id.login)
+    public void login(){
+        if (TextUtils.isEmpty(mETUserName.getText().toString().trim()))
+            Toast.makeText(this, "请输入用户名", Toast.LENGTH_SHORT).show();
+        else if(TextUtils.isEmpty(mETPassWord.getText().toString().trim()))
+            Toast.makeText(this, "请输入密码", Toast.LENGTH_SHORT).show();
+        else{
+            Dialog loading = new ProgressDialog(this);
+            loading.setTitle("登录中");
+            loading.show();
+            new SimpleRequest<ResLogin>().request(this, LoginController.getInstance().login(mETUserName.getText().toString().trim(), mETPassWord.getText().toString().trim()), "登录失败!用户名或密码错误", loading, new SimpleRequest.Executor<ResLogin>() {
+                @Override
+                public void execute(ResLogin obj) {
+                    startActivity(new Intent(LoginActivity.this, obj.isAdmin() ? AdminActivity.class : NormalUserActivity.class));
+                    finish();
+                }
+            });
+        }
+    }
+}

+ 16 - 0
app/src/main/java/com/jyc/threegames/activity/NormalUserActivity.java

@@ -0,0 +1,16 @@
+package com.jyc.threegames.activity;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+
+import com.jyc.threegames.R;
+
+public class NormalUserActivity extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+    }
+}

+ 16 - 0
app/src/main/java/com/jyc/threegames/activity/ScaleActivity.java

@@ -0,0 +1,16 @@
+package com.jyc.threegames.activity;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+
+import com.jyc.threegames.R;
+
+public class ScaleActivity extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_scale);
+    }
+}

+ 36 - 0
app/src/main/java/com/jyc/threegames/activity/WelcomeActivity.java

@@ -0,0 +1,36 @@
+package com.jyc.threegames.activity;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+
+import com.jyc.threegames.R;
+import com.jyc.threegames.activity.base.BaseActivity;
+import com.jyc.threegames.controller.LoginController;
+
+public class WelcomeActivity extends BaseActivity {
+
+    @Override
+    protected void init(Bundle instance) {
+        super.init(instance);
+
+        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                if (LoginController.getInstance().restoreLoginInfoFromSDCardFile()){
+                    startActivity(new Intent(WelcomeActivity.this, LoginController.getInstance().isCurrentUserAdmin() ? AdminActivity.class : NormalUserActivity.class));
+                }else
+                    startActivity(new Intent(WelcomeActivity.this, LoginActivity.class));
+                finish();
+            }
+        }, 3000);
+    }
+
+    @Override
+    protected int getRootLayout() {
+        return R.layout.activity_welcome;
+    }
+}

+ 62 - 0
app/src/main/java/com/jyc/threegames/activity/base/BaseActivity.java

@@ -0,0 +1,62 @@
+package com.jyc.threegames.activity.base;
+
+import android.graphics.Color;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.TextView;
+
+import androidx.annotation.LayoutRes;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+
+import com.jyc.threegames.R;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+public abstract class BaseActivity extends AppCompatActivity {
+
+    @Nullable
+    @BindView(R.id.toolbar)
+    Toolbar mToolbar;
+
+    @Nullable
+    @BindView(R.id.title)
+    TextView mTVTitle;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(getRootLayout());
+        ButterKnife.bind(this);
+
+        initSystemBar();
+
+        if (mToolbar != null) {
+            mToolbar.setTitle("");
+            setSupportActionBar(mToolbar);
+        }
+
+        if (mTVTitle != null)
+            mTVTitle.setText(getPageTitle());
+
+        init(savedInstanceState);
+    }
+
+    protected abstract @LayoutRes int getRootLayout();
+
+    protected String getPageTitle(){
+        return "";
+    }
+
+    protected void init(Bundle instance){}
+
+    public void initSystemBar() {
+        Window window = getWindow();
+        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+    }
+}

+ 104 - 0
app/src/main/java/com/jyc/threegames/bean/ControllerMessage.java

@@ -0,0 +1,104 @@
+package com.jyc.threegames.bean;
+
+public class ControllerMessage<T> {
+
+    private ControllerMessage(){}
+
+    public static final int CODE_SUCCESS = 200;
+    public static final int CODE_FAILED = 500;
+
+    private String message = "";
+    private int code;
+    private T object;
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public T getObject() {
+        return object;
+    }
+
+    public void setObject(T object) {
+        this.object = object;
+    }
+
+    public boolean isSuccess(){
+        return this.code == CODE_SUCCESS;
+    }
+
+    public static <T> ControllerMessage<T> getSimpleMessage(boolean success){
+        return new Builder<T>().setSuccess(success).build();
+    }
+
+    public static <T> ControllerMessage<T> getSimpleMessage(boolean success, String message){
+        return new Builder<T>().setSuccess(success).msg(message).build();
+    }
+
+    public static <T> ControllerMessage<T> getSimpleMessage(boolean success, String message, T value){
+        return new Builder<T>().setSuccess(success).msg(message).obj(value).build();
+    }
+
+    public static class Builder<T>{
+
+        private ControllerMessage<T> result;
+
+        public Builder(){
+            result = new ControllerMessage<T>();
+        }
+
+        public ControllerMessage<T> build(){
+            return result;
+        }
+
+        public Builder<T> setSuccess(boolean success){
+            result.setCode(success ? CODE_SUCCESS : CODE_FAILED);
+            return this;
+        }
+
+        public Builder<T> success(){
+            result.setCode(CODE_SUCCESS);
+            return this;
+        }
+
+        public Builder<T> success(String msg){
+            msg(msg);
+            result.setCode(CODE_SUCCESS);
+            return this;
+        }
+
+        public Builder<T> failed(){
+            result.setCode(CODE_FAILED);
+            return this;
+        }
+
+        public Builder<T> failed(String msg){
+            msg(msg);
+            result.setCode(CODE_FAILED);
+            return this;
+        }
+
+        public Builder<T> msg(String msg){
+            result.setMessage(msg);
+            return this;
+        }
+
+        public Builder<T> obj(T object){
+            result.setObject(object);
+            return this;
+        }
+    }
+}
+

+ 73 - 0
app/src/main/java/com/jyc/threegames/bean/GameInfo.java

@@ -0,0 +1,73 @@
+package com.jyc.threegames.bean;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class GameInfo implements Parcelable {
+    public static final int VERSION_GAME_ONE = 1;
+    public static final int VERSION_GAME_TWO = 2;
+    public static final int VERSION_GAME_THREE = 3;
+
+    public int gameVersion;
+    public long intervalDuration; //數字交換間隔
+    public long displayDuration;//顯示時長
+    public int correctNumberOccurrenceNumber;//正確數字出現次數
+    public int errorNumberOccurrenceNumber;//錯誤數字出現次數
+    public long practiseDuration; //用戶熱身時長
+    public int practiseOccurrenceNumber;//用戶熱身數字出現次數
+
+    public GameInfo(int gameVersion, long intervalDuration, long displayDuration, int correctNumberOccurrenceNumber, int errorNumberOccurrenceNumber, long practiseDuration, int practiseOccurrenceNumber) {
+        this.gameVersion = gameVersion;
+        this.intervalDuration = intervalDuration;
+        this.displayDuration = displayDuration;
+        this.correctNumberOccurrenceNumber = correctNumberOccurrenceNumber;
+        this.errorNumberOccurrenceNumber = errorNumberOccurrenceNumber;
+        this.practiseDuration = practiseDuration;
+        this.practiseOccurrenceNumber = practiseOccurrenceNumber;
+    }
+
+    public static GameInfo EXERCISE(int gameVersion){
+        return new GameInfo(gameVersion, 1000, 1000, 5, 5, 1000, 5);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(this.gameVersion);
+        dest.writeLong(this.intervalDuration);
+        dest.writeLong(this.displayDuration);
+        dest.writeInt(this.correctNumberOccurrenceNumber);
+        dest.writeInt(this.errorNumberOccurrenceNumber);
+        dest.writeLong(this.practiseDuration);
+        dest.writeInt(this.practiseOccurrenceNumber);
+    }
+
+    public GameInfo() {
+    }
+
+    protected GameInfo(Parcel in) {
+        this.gameVersion = in.readInt();
+        this.intervalDuration = in.readLong();
+        this.displayDuration = in.readLong();
+        this.correctNumberOccurrenceNumber = in.readInt();
+        this.errorNumberOccurrenceNumber = in.readInt();
+        this.practiseDuration = in.readLong();
+        this.practiseOccurrenceNumber = in.readInt();
+    }
+
+    public static final Creator<GameInfo> CREATOR = new Creator<GameInfo>() {
+        @Override
+        public GameInfo createFromParcel(Parcel source) {
+            return new GameInfo(source);
+        }
+
+        @Override
+        public GameInfo[] newArray(int size) {
+            return new GameInfo[size];
+        }
+    };
+}

+ 11 - 0
app/src/main/java/com/jyc/threegames/bean/request/ReqLogin.java

@@ -0,0 +1,11 @@
+package com.jyc.threegames.bean.request;
+
+public class ReqLogin {
+    public String username;
+    public String password;
+
+    public ReqLogin(String username, String password) {
+        this.username = username;
+        this.password = password;
+    }
+}

+ 39 - 0
app/src/main/java/com/jyc/threegames/bean/result/ResLogin.java

@@ -0,0 +1,39 @@
+package com.jyc.threegames.bean.result;
+
+import java.util.List;
+
+public class ResLogin {
+    public String token;
+    public LoginInfo info;
+
+    public boolean isAdmin(){
+        return info != null && info.haveRole(LoginInfo.ADMIN);
+    }
+
+    public class LoginInfo{
+        public static final String ADMIN = "admin";
+
+        public String password;
+        public long id;
+        public int type;
+        public String nickname;
+        public String avatar;
+        public String alias;
+        public boolean enabled;
+        public String username;
+        public boolean accountNonLocked;
+        public boolean accountNonExpired;
+        public boolean credentialsNonExpired;
+        public List<String> roles;
+
+        public boolean haveRole(String role){
+            if (roles != null)
+                for (String item : roles)
+                    if (item != null && item.equals(role))
+                        return true;
+            return false;
+        }
+    }
+
+
+}

+ 65 - 0
app/src/main/java/com/jyc/threegames/controller/BaseController.java

@@ -0,0 +1,65 @@
+package com.jyc.threegames.controller;
+
+
+import com.jyc.threegames.bean.ControllerMessage;
+import com.jyc.threegames.net.ResData;
+
+import io.reactivex.Observable;
+import io.reactivex.ObservableEmitter;
+import io.reactivex.ObservableOnSubscribe;
+import io.reactivex.annotations.NonNull;
+import io.reactivex.functions.Function;
+
+public abstract class BaseController {
+    Observable<ControllerMessage<Object>> getErrorObservable(final String message){
+        return Observable.create(new ObservableOnSubscribe<ControllerMessage<Object>>() {
+            @Override
+            public void subscribe(@NonNull ObservableEmitter<ControllerMessage<Object>> e) throws Exception {
+                if(!e.isDisposed()){
+                    e.onError(new RuntimeException(message));
+                    e.onComplete();
+                }
+            }
+        });
+    }
+
+    <T>Observable<T> getSimpleSuccessObservable(final T obj){
+        return Observable.create(new ObservableOnSubscribe<T>() {
+            @Override
+            public void subscribe(@NonNull ObservableEmitter<T> e) throws Exception {
+                if (e.isDisposed())
+                    return;
+                e.onNext(obj);
+                e.onComplete();
+            }
+        });
+    }
+
+    <T>Observable<T> getSimpleErrorObservable(final String message){
+        return Observable.create(new ObservableOnSubscribe<T>() {
+            @Override
+            public void subscribe(@NonNull ObservableEmitter<T> e) throws Exception {
+                if (e.isDisposed())
+                    return;
+                e.onError(new RuntimeException(message));
+                e.onComplete();
+            }
+        });
+    }
+
+    Observable<ControllerMessage<Object>> getSimpleSuccessObservable(String message){
+        return getSimpleSuccessObservable(ControllerMessage.getSimpleMessage(true, message));
+    }
+
+    Observable<ControllerMessage<Object>> getSimpleFailedObservable(String paramString)
+    {
+        return getSimpleSuccessObservable(ControllerMessage.getSimpleMessage(false, paramString));
+    }
+
+    protected class SimpleDataHandleFunction<T extends ResData, R extends ControllerMessage> implements Function<T, R>{
+        @Override
+        public R apply(T o) throws Exception {
+            return (R) ControllerMessage.getSimpleMessage(o.isRequestSuccess(), o.message, o.data);
+        }
+    }
+}

+ 146 - 0
app/src/main/java/com/jyc/threegames/controller/LoginController.java

@@ -0,0 +1,146 @@
+package com.jyc.threegames.controller;
+
+import android.os.Environment;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonParser;
+import com.jyc.threegames.App;
+import com.jyc.threegames.bean.ControllerMessage;
+import com.jyc.threegames.bean.request.ReqLogin;
+import com.jyc.threegames.bean.result.ResLogin;
+import com.jyc.threegames.net.ResData;
+import com.jyc.threegames.net.RetrofitHelper;
+import com.jyc.threegames.net.api.LoginService;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import io.reactivex.Observable;
+import io.reactivex.functions.Consumer;
+import io.reactivex.functions.Function;
+
+public class LoginController extends BaseController {
+    private static LoginController mInstance;
+
+    private LoginController(){}
+
+    private ResLogin mLoginInfo;
+
+    private static final String PATH = "/ThreeGames/";
+    private static final String FILE_NAME = "loginInfo";
+
+    public static LoginController getInstance(){
+        if(mInstance == null){
+            synchronized (LoginController.class){
+                if(mInstance == null)
+                    mInstance = new LoginController();
+            }
+        }
+        return mInstance;
+    }
+
+    private static LoginService mService;
+
+    protected static LoginService getLoginService(){
+        if (mService == null){
+            synchronized (LoginController.class){
+                if (mService == null)
+                    mService = RetrofitHelper.getDefaultRetrofit(App.SERVER_ADDRESS).create(LoginService.class);
+            }
+        }
+
+        return mService;
+    }
+
+    public boolean restoreLoginInfoFromSDCardFile(){
+        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+            try {
+                File targetFile = new File(Environment.getExternalStorageDirectory().getCanonicalPath() + PATH + FILE_NAME);
+                if (targetFile.exists() && targetFile.isFile()){
+                    FileInputStream inputStream = new FileInputStream(targetFile);
+                    BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                    StringBuilder sb = new StringBuilder("");
+                    String line;
+                    while ((line = br.readLine()) != null){
+                        sb.append(line);
+                    }
+                    br.close();
+                    inputStream.close();
+                    mLoginInfo = new Gson().fromJson(sb.toString(), ResLogin.class);
+                    return true;
+                }else
+                    return false;
+            }catch (Exception e){
+                e.printStackTrace();
+                Log.e("three_games", "read file error: " + e.getMessage());
+            }
+        }
+        return false;
+    }
+
+    public Observable<ControllerMessage<ResLogin>> login(String userName, String passWord){
+        return getLoginService().login(userName, passWord)
+            .doOnNext(new Consumer<ResData<ResLogin>>() {
+                @Override
+                public void accept(ResData<ResLogin> data) throws Exception {
+                    if (data.isRequestSuccess() && data.data != null && data.data.info != null && !TextUtils.isEmpty(data.data.token)){
+                        mLoginInfo = data.data;
+                        writeLoginInfoToSDCard();
+                    }
+                }
+            })
+            .map(new SimpleDataHandleFunction<ResData<ResLogin>, ControllerMessage<ResLogin>>());
+    }
+
+    private void writeLoginInfoToSDCard(){
+        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+            try {
+                File sdCardDir = Environment.getExternalStorageDirectory();
+                File dir = new File(sdCardDir.getCanonicalPath() + PATH);
+                if (!dir.exists()) {
+                    if (dir.mkdirs()){
+                        continueCreateFile(sdCardDir);
+                    }else
+                        Log.e("three_games", "create sdcard file path error");
+                }else
+                    continueCreateFile(sdCardDir);
+
+            } catch (Exception e){
+                e.printStackTrace();
+                Log.e("three_games", "create sdcard file exception: " + e.getMessage());
+            }
+        }
+    }
+
+    private void continueCreateFile(File sdCardDir) throws Exception{
+        File targetFile = new File(sdCardDir.getCanonicalPath() + PATH + FILE_NAME);
+        targetFile.deleteOnExit();
+        if (targetFile.createNewFile()){
+            String content = new Gson().toJson(mLoginInfo);
+            FileOutputStream outStream = new FileOutputStream(targetFile);
+            outStream.write(content.getBytes());
+            outStream.close();
+        }else
+            Log.e("three_games", "create sdcard file error");
+    }
+
+    public boolean isCurrentUserAdmin(){
+        if (mLoginInfo != null){
+            return mLoginInfo.isAdmin();
+        }
+        return false;
+    }
+
+    public String getToken(){
+        if (mLoginInfo != null && !TextUtils.isEmpty(mLoginInfo.token))
+            return mLoginInfo.token;
+        return "";
+    }
+}

+ 49 - 0
app/src/main/java/com/jyc/threegames/net/HttpsTrustManager.java

@@ -0,0 +1,49 @@
+package com.jyc.threegames.net;
+
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+public class HttpsTrustManager implements X509TrustManager {
+    @Override
+    public void checkClientTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException {
+
+    }
+
+    @Override
+    public void checkServerTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException {
+
+    }
+
+    @Override
+    public X509Certificate[] getAcceptedIssuers() {
+        return new X509Certificate[0];
+    }
+
+    public static SSLSocketFactory createSSLSocketFactory() {
+        SSLSocketFactory sSLSocketFactory = null;
+        try {
+            SSLContext sc = SSLContext.getInstance("TLS");
+            sc.init(null, new TrustManager[]{new HttpsTrustManager()},
+                    new SecureRandom());
+            sSLSocketFactory = sc.getSocketFactory();
+        } catch (Exception e) {
+        }
+        return sSLSocketFactory;
+    }
+
+
+    public   static  class  TrustAllHostnameVerifier implements HostnameVerifier
+    {
+        @Override
+        public boolean verify(String s, SSLSession sslSession) {
+            return true;
+        }
+    }
+}

+ 47 - 0
app/src/main/java/com/jyc/threegames/net/OkHttpClientHelper.java

@@ -0,0 +1,47 @@
+package com.jyc.threegames.net;
+
+import com.jyc.threegames.App;
+
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.Cache;
+import okhttp3.Interceptor;
+import okhttp3.OkHttpClient;
+
+public class OkHttpClientHelper {
+    private static OkHttpClient mOkHttpDefaultClient;
+
+    private static File cacheDirectory = new File(App.app.getApplicationContext().getCacheDir().getAbsolutePath(), "HttpCache");
+    private static Cache cache = new Cache(cacheDirectory, 10 * 1024 * 1024);
+
+    private OkHttpClientHelper() {}
+
+    public static OkHttpClient getDefaultOkHttpClient(Interceptor... interceptors) {
+
+        if (null == mOkHttpDefaultClient) {
+            synchronized (OkHttpClientHelper.class){
+                if (null == mOkHttpDefaultClient){
+                    OkHttpClient.Builder builder = getBuilder();
+
+                    for (Interceptor interceptor : interceptors){
+                        builder.addInterceptor(interceptor);
+                    }
+                    mOkHttpDefaultClient = builder.build();
+                }
+            }
+        }
+        return mOkHttpDefaultClient;
+    }
+
+    public static OkHttpClient.Builder getBuilder(){
+        OkHttpClient.Builder builder = new OkHttpClient.Builder();
+        builder.connectTimeout(20, TimeUnit.SECONDS);
+        builder.writeTimeout(20, TimeUnit.SECONDS);
+        builder.readTimeout(20, TimeUnit.SECONDS);
+        builder.sslSocketFactory(HttpsTrustManager.createSSLSocketFactory(), new HttpsTrustManager());
+        builder.hostnameVerifier(new HttpsTrustManager.TrustAllHostnameVerifier());
+        builder.cache(cache);
+        return builder;
+    }
+}

+ 29 - 0
app/src/main/java/com/jyc/threegames/net/ResData.java

@@ -0,0 +1,29 @@
+package com.jyc.threegames.net;
+
+public class ResData<T> {
+    public static final int CODE_SUCCESS = 200;
+    public static final int CODE_ERROR = 400;
+    public static final int CODE_TOKEN_EXPIRED = 401;
+
+    public int code;
+    public T data;
+    public String message;
+
+    public ResData() {
+
+    }
+
+    public ResData(int code, T data, String message) {
+        this.code = code;
+        this.data = data;
+        this.message = message;
+    }
+
+    public boolean isRequestSuccess(){
+        return code == CODE_SUCCESS;
+    }
+
+    public boolean isTokenExpired(){
+        return code == CODE_TOKEN_EXPIRED;
+    }
+}

+ 26 - 0
app/src/main/java/com/jyc/threegames/net/RetrofitHelper.java

@@ -0,0 +1,26 @@
+package com.jyc.threegames.net;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
+import retrofit2.converter.gson.GsonConverterFactory;
+import retrofit2.converter.scalars.ScalarsConverterFactory;
+
+public class RetrofitHelper {
+    private static OkHttpClient mDefaultClient;
+
+    private RetrofitHelper() {}
+
+    public static Retrofit getDefaultRetrofit(String url){
+        if(mDefaultClient == null)
+            mDefaultClient = OkHttpClientHelper.getDefaultOkHttpClient(new TokenInterceptor());
+
+        return new Retrofit.Builder()
+                .baseUrl(url)
+                .addConverterFactory(ScalarsConverterFactory.create())
+                .addConverterFactory(GsonConverterFactory.create())
+                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
+                .client(mDefaultClient)
+                .build();
+    }
+}

+ 72 - 0
app/src/main/java/com/jyc/threegames/net/SimpleRequest.java

@@ -0,0 +1,72 @@
+package com.jyc.threegames.net;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.text.TextUtils;
+import android.widget.Toast;
+
+import com.jyc.threegames.bean.ControllerMessage;
+
+import io.reactivex.Observable;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.functions.Consumer;
+import io.reactivex.schedulers.Schedulers;
+
+public class SimpleRequest<T> {
+
+    public Disposable request(Context context, Observable<? extends ControllerMessage<T>> req){
+        return request(context, req, null, null, null, null, null);
+    }
+
+    public Disposable request(Context context, Observable<? extends ControllerMessage<T>> req, Executor<T> success){
+        return request(context, req, null, null, success, null, null);
+    }
+
+    public Disposable request(Context context, Observable<? extends ControllerMessage<T>> req, Executor<T> success, Executor<Throwable> error){
+        return request(context, req, null, null, success, null, error);
+    }
+
+    public Disposable request(Context context, Observable<? extends ControllerMessage<T>> req, String errorMessage, Executor<T> success){
+        return request(context, req, errorMessage, null, success, null, null);
+    }
+
+    public Disposable request(Context context, Observable<? extends ControllerMessage<T>> req, String errorMessage, Dialog loading, Executor<T> success){
+        return request(context, req, errorMessage, loading, success, null, null);
+    }
+
+    public Disposable request(final Context context, Observable<? extends ControllerMessage<T>> req, final String errorMessage, final Dialog loading, final Executor<T> success, final Executor<ControllerMessage<T>> mustDo, final Executor<Throwable> error){
+        return req.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new Consumer<ControllerMessage<T>>() {
+                    @Override
+                    public void accept(ControllerMessage<T> message) throws Exception {
+                        if (loading != null)
+                            loading.dismiss();
+                        if (mustDo != null) {
+                            mustDo.execute(message);
+                            return;
+                        }
+                        if (message.isSuccess() && success != null){
+                            success.execute(message.getObject());
+                        }else
+                            if (!TextUtils.isEmpty(errorMessage))
+                                Toast.makeText(context, TextUtils.isEmpty(message.getMessage()) ? errorMessage : message.getMessage() , Toast.LENGTH_LONG).show();
+                    }
+                }, new Consumer<Throwable>() {
+                    @Override
+                    public void accept(Throwable throwable) throws Exception {
+                        if (loading != null)
+                            loading.dismiss();
+                        if (error != null)
+                            error.execute(throwable);
+                        else if (!TextUtils.isEmpty(errorMessage))
+                            Toast.makeText(context, errorMessage, Toast.LENGTH_LONG).show();
+
+                    }
+                });
+    }
+
+    public interface Executor<T>{
+        void execute(T obj);
+    }
+}

+ 25 - 0
app/src/main/java/com/jyc/threegames/net/TokenInterceptor.java

@@ -0,0 +1,25 @@
+package com.jyc.threegames.net;
+
+import android.text.TextUtils;
+
+import com.jyc.threegames.controller.LoginController;
+
+import java.io.IOException;
+
+import okhttp3.Interceptor;
+import okhttp3.Request;
+import okhttp3.Response;
+
+public class TokenInterceptor implements Interceptor {
+    @Override
+    public Response intercept(Chain chain) throws IOException {
+        String token = LoginController.getInstance().getToken();
+        if (TextUtils.isEmpty(token))
+            return chain.proceed(chain.request());
+        Request request = chain.request()
+                .newBuilder()
+                .addHeader("Authorization", token)
+                .build();
+        return chain.proceed(request);
+    }
+}

+ 18 - 0
app/src/main/java/com/jyc/threegames/net/api/LoginService.java

@@ -0,0 +1,18 @@
+package com.jyc.threegames.net.api;
+
+import com.jyc.threegames.bean.request.ReqLogin;
+import com.jyc.threegames.bean.result.ResLogin;
+import com.jyc.threegames.net.ResData;
+
+import io.reactivex.Observable;
+import retrofit2.http.Body;
+import retrofit2.http.Field;
+import retrofit2.http.FormUrlEncoded;
+import retrofit2.http.POST;
+
+public interface LoginService {
+
+    @FormUrlEncoded
+    @POST("login")
+    Observable<ResData<ResLogin>> login(@Field("username") String userName, @Field("password") String passWord);
+}

+ 6 - 0
app/src/main/res/drawable/border.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+    <stroke
+        android:width="1dp"
+        android:color="#999999" />
+</shape>

+ 243 - 0
app/src/main/res/layout/activity_admin.xml

@@ -0,0 +1,243 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.AdminActivity">
+
+    <androidx.appcompat.widget.Toolbar
+        android:id="@+id/toolbar"
+        android:layout_width="0dp"
+        android:fitsSystemWindows="true"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:background="@color/colorAccent"
+        android:minHeight="?attr/actionBarSize" >
+        <TextView
+            android:id="@+id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:textSize="20sp"
+            android:textStyle="bold"/>
+
+        <TextView
+            android:id="@+id/logout"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="end"
+            android:textSize="14sp"
+            android:text="退出"
+            android:layout_marginEnd="10dp"
+            android:textStyle="bold"/>
+    </androidx.appcompat.widget.Toolbar>
+
+    <ScrollView
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/toolbar"
+        app:layout_constraintBottom_toBottomOf="parent">
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="#4D856A"
+                android:layout_marginTop="10dp">
+                <TextView
+                    android:id="@+id/view_exercise_title"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="練習"
+                    android:textSize="20sp"
+                    android:layout_marginStart="10dp"
+                    android:layout_marginTop="10dp"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent"
+                    android:textColor="#fff"/>
+
+                <TextView
+                    android:id="@+id/view_exercise_title_en"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="Exercise"
+                    android:textSize="20sp"
+                    android:layout_marginTop="20dp"
+                    app:layout_constraintStart_toStartOf="@id/view_exercise_title"
+                    app:layout_constraintTop_toBottomOf="@id/view_exercise_title"
+                    android:textColor="#fff"/>
+
+                <View
+                    android:id="@+id/view_exercise_split_line"
+                    android:layout_width="0dp"
+                    android:background="#fff"
+                    android:layout_marginTop="10dp"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintTop_toBottomOf="@id/view_exercise_title_en"
+                    android:layout_height="1dp"/>
+
+                <TextView
+                    android:id="@+id/scale"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="量表"
+                    android:textSize="16sp"
+                    android:layout_marginTop="10dp"
+                    android:layout_marginBottom="10dp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintEnd_toStartOf="@+id/gameA"
+                    app:layout_constraintTop_toBottomOf="@id/view_exercise_split_line"
+                    android:textColor="#fff"/>
+
+                <TextView
+                    android:id="@+id/gameA"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="練習A"
+                    android:textSize="16sp"
+                    android:layout_marginTop="10dp"
+                    android:layout_marginBottom="10dp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintStart_toEndOf="@id/scale"
+                    app:layout_constraintEnd_toStartOf="@+id/gameB"
+                    app:layout_constraintTop_toBottomOf="@id/view_exercise_split_line"
+                    android:textColor="#fff"/>
+
+                <TextView
+                    android:id="@+id/gameB"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="練習B"
+                    android:textSize="16sp"
+                    android:layout_marginTop="10dp"
+                    android:layout_marginBottom="10dp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintStart_toEndOf="@id/gameA"
+                    app:layout_constraintEnd_toStartOf="@+id/gameC"
+                    app:layout_constraintTop_toBottomOf="@id/view_exercise_split_line"
+                    android:textColor="#fff"/>
+
+                <TextView
+                    android:id="@+id/gameC"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="練習C"
+                    android:textSize="16sp"
+                    android:layout_marginTop="10dp"
+                    android:layout_marginBottom="10dp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintStart_toEndOf="@id/gameB"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintTop_toBottomOf="@id/view_exercise_split_line"
+                    android:textColor="#fff"/>
+
+            </androidx.constraintlayout.widget.ConstraintLayout>
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="#5280BE"
+                android:layout_marginTop="10dp">
+                <TextView
+                    android:id="@+id/view_game_record_title"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="遊戲記錄"
+                    android:textSize="20sp"
+                    android:layout_marginStart="10dp"
+                    android:layout_marginTop="10dp"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent"
+                    android:textColor="#fff"/>
+
+                <TextView
+                    android:id="@+id/view_game_record_title_en"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="CPT Record"
+                    android:textSize="20sp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    android:layout_marginBottom="10dp"
+                    android:layout_marginTop="20dp"
+                    app:layout_constraintStart_toStartOf="@id/view_game_record_title"
+                    app:layout_constraintTop_toBottomOf="@id/view_game_record_title"
+                    android:textColor="#fff"/>
+            </androidx.constraintlayout.widget.ConstraintLayout>
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="#9A64B2"
+                android:layout_marginTop="10dp">
+                <TextView
+                    android:id="@+id/view_scale_record_title"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="量表記錄"
+                    android:textSize="20sp"
+                    android:layout_marginStart="10dp"
+                    android:layout_marginTop="10dp"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent"
+                    android:textColor="#fff"/>
+
+                <TextView
+                    android:id="@+id/view_scale_record_title_en"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="Scale Record"
+                    android:textSize="20sp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    android:layout_marginBottom="10dp"
+                    android:layout_marginTop="20dp"
+                    app:layout_constraintStart_toStartOf="@id/view_scale_record_title"
+                    app:layout_constraintTop_toBottomOf="@id/view_scale_record_title"
+                    android:textColor="#fff"/>
+            </androidx.constraintlayout.widget.ConstraintLayout>
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="#B67744"
+                android:layout_marginTop="10dp">
+                <TextView
+                    android:id="@+id/view_user_manage_title"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="用戶管理"
+                    android:textSize="20sp"
+                    android:layout_marginStart="10dp"
+                    android:layout_marginTop="10dp"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent"
+                    android:textColor="#fff"/>
+
+                <TextView
+                    android:id="@+id/view_user_manage_title_en"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="User Manage"
+                    android:textSize="20sp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    android:layout_marginBottom="10dp"
+                    android:layout_marginTop="20dp"
+                    app:layout_constraintStart_toStartOf="@id/view_user_manage_title"
+                    app:layout_constraintTop_toBottomOf="@id/view_user_manage_title"
+                    android:textColor="#fff"/>
+            </androidx.constraintlayout.widget.ConstraintLayout>
+        </LinearLayout>
+    </ScrollView>
+
+
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 52 - 0
app/src/main/res/layout/activity_game_one.xml

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:id="@+id/root"
+    tools:context=".activity.GameActivity">
+    <TextView
+        android:id="@+id/pre_game_hint"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:background="@drawable/border"
+        android:textSize="25sp"
+        android:textStyle="bold"
+        android:padding="10dp" />
+
+    <TextView
+        android:id="@+id/number"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="150sp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent" />
+
+    <TextView
+        android:id="@+id/game_hint"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:textSize="18sp"
+        android:textStyle="bold"
+        app:layout_constraintBottom_toBottomOf="parent"/>
+
+    <View
+        android:id="@+id/click_area"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 9 - 0
app/src/main/res/layout/activity_game_three.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.GameThreeActivity">
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 9 - 0
app/src/main/res/layout/activity_game_two.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.GameTwoActivity">
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 61 - 0
app/src/main/res/layout/activity_login.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.LoginActivity">
+
+    <androidx.appcompat.widget.Toolbar
+        android:id="@+id/toolbar"
+        android:layout_width="0dp"
+        android:fitsSystemWindows="true"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:background="@color/colorAccent"
+        android:minHeight="?attr/actionBarSize" >
+        <TextView
+            android:id="@+id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:textSize="20sp"
+            android:textStyle="bold"/>
+
+        <TextView
+            android:id="@+id/login"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="end"
+            android:textSize="14sp"
+            android:text="登录"
+            android:layout_marginEnd="10dp"
+            android:textStyle="bold"/>
+    </androidx.appcompat.widget.Toolbar>
+
+    <EditText
+        android:id="@+id/user_name"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:hint="請輸入賬號"
+        android:inputType="text"
+        android:singleLine="true"
+        android:autofillHints="賬號"
+        app:layout_constraintTop_toBottomOf="@id/toolbar"/>
+
+    <EditText
+        android:id="@+id/pass_word"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:hint="請輸入密碼"
+        android:singleLine="true"
+        android:autofillHints="密碼"
+        android:inputType="textPassword"
+        app:layout_constraintTop_toBottomOf="@+id/user_name"/>
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 11 - 0
app/src/main/res/layout/activity_main.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.NormalUserActivity">
+
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 9 - 0
app/src/main/res/layout/activity_scale.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.ScaleActivity">
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 30 - 0
app/src/main/res/layout/activity_welcome.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".activity.WelcomeActivity">
+    <ImageView
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintWidth_percent="0.2"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintVertical_bias="0.2"
+        android:src="@mipmap/ic_launcher"
+        app:layout_constraintDimensionRatio="1:1"/>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Three Games"
+        android:textSize="20sp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintVertical_bias="0.96"
+        app:layout_constraintBottom_toBottomOf="parent"/>
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 9 - 0
app/src/main/res/layout/settings_activity.xml

@@ -0,0 +1,9 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <FrameLayout
+        android:id="@+id/settings"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+</LinearLayout>

BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png


+ 12 - 0
app/src/main/res/values/arrays.xml

@@ -0,0 +1,12 @@
+<resources>
+    <!-- Reply Preference -->
+    <string-array name="reply_entries">
+        <item>Reply</item>
+        <item>Reply to all</item>
+    </string-array>
+
+    <string-array name="reply_values">
+        <item>reply</item>
+        <item>reply_all</item>
+    </string-array>
+</resources>

+ 6 - 0
app/src/main/res/values/colors.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#F8F8F8</color>
+    <color name="colorPrimaryDark">#F8F8F8</color>
+    <color name="colorAccent">#F8F8F8</color>
+</resources>

+ 19 - 0
app/src/main/res/values/strings.xml

@@ -0,0 +1,19 @@
+<resources>
+    <string name="app_name">ThreeGames</string>
+    <string name="title_activity_login">LoginActivity</string>
+
+    <!-- Preference Titles -->
+    <string name="messages_header">Messages</string>
+    <string name="sync_header">Sync</string>
+
+    <!-- Messages Preferences -->
+    <string name="signature_title">Your signature</string>
+    <string name="reply_title">Default reply action</string>
+
+    <!-- Sync Preferences -->
+    <string name="sync_title">Sync email periodically</string>
+    <string name="attachment_title">Download incoming attachments</string>
+    <string name="attachment_summary_on">Automatically download attachments for incoming emails
+    </string>
+    <string name="attachment_summary_off">Only download attachments when manually requested</string>
+</resources>

+ 10 - 0
app/src/main/res/values/styles.xml

@@ -0,0 +1,10 @@
+<resources>
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
+        <!-- Customize your theme here. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="colorAccent">@android:color/black</item>
+
+    </style>
+</resources>

+ 35 - 0
app/src/main/res/xml/root_preferences.xml

@@ -0,0 +1,35 @@
+<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <PreferenceCategory app:title="@string/messages_header">
+
+        <EditTextPreference
+            app:key="signature"
+            app:title="@string/signature_title"
+            app:useSimpleSummaryProvider="true" />
+
+        <ListPreference
+            app:defaultValue="reply"
+            app:entries="@array/reply_entries"
+            app:entryValues="@array/reply_values"
+            app:key="reply"
+            app:title="@string/reply_title"
+            app:useSimpleSummaryProvider="true" />
+
+    </PreferenceCategory>
+
+    <PreferenceCategory app:title="@string/sync_header">
+
+        <SwitchPreferenceCompat
+            app:key="sync"
+            app:title="@string/sync_title" />
+
+        <SwitchPreferenceCompat
+            app:dependency="sync"
+            app:key="attachment"
+            app:summaryOff="@string/attachment_summary_off"
+            app:summaryOn="@string/attachment_summary_on"
+            app:title="@string/attachment_title" />
+
+    </PreferenceCategory>
+
+</PreferenceScreen>

+ 17 - 0
app/src/test/java/com/jyc/threegames/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package com.jyc.threegames;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+    @Test
+    public void addition_isCorrect() {
+        assertEquals(4, 2 + 2);
+    }
+}

+ 25 - 0
build.gradle

@@ -0,0 +1,25 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+    repositories {
+        google()
+        jcenter()
+    }
+    dependencies {
+        classpath "com.android.tools.build:gradle:4.0.0"
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+        classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0'
+    }
+}
+
+allprojects {
+    repositories {
+        google()
+        jcenter()
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 19 - 0
gradle.properties

@@ -0,0 +1,19 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app"s APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Wed Jul 01 14:29:19 GMT+08:00 2020
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

+ 172 - 0
gradlew

@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"

+ 84 - 0
gradlew.bat

@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 2 - 0
settings.gradle

@@ -0,0 +1,2 @@
+include ':app'
+rootProject.name = "ThreeGames"