-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 165b70b
Showing
35 changed files
with
1,208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# files for the dex VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Windows thumbnail db | ||
Thumbs.db | ||
|
||
# OSX files | ||
.DS_Store | ||
|
||
# Eclipse project files | ||
.classpath | ||
.project | ||
|
||
# Android Studio | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# Ignore gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
#NDK | ||
obj/ | ||
|
||
# Keystore files | ||
*.jks | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion "25.0.0" | ||
defaultConfig { | ||
applicationId "com.shenjing.colordoku" | ||
minSdkVersion 15 | ||
targetSdkVersion 24 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:24.0.0' | ||
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3' | ||
testCompile 'junit:junit:4.12' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in Z:\D\Program\Android\sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# 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 *; | ||
#} |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/shenjing/colordoku/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.shenjing.colordoku; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation 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() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.shenjing.colordoku", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.shenjing.colordoku"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".GameActivity"></activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.shenjing.colordoku; | ||
|
||
import android.content.Context; | ||
import android.graphics.drawable.GradientDrawable; | ||
import android.support.v4.content.ContextCompat; | ||
import android.util.AttributeSet; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.FrameLayout; | ||
|
||
/** | ||
* Created by shenjing on 2016/11/14. | ||
*/ | ||
|
||
public class Block extends FrameLayout { | ||
GradientDrawable g; | ||
public int row; | ||
public int col; | ||
// public int uncertainty = 1; | ||
public int degree = -1; | ||
public boolean changeable = false; | ||
private static final int GREY = 0; | ||
private static final int RED = 1; | ||
private static final int ORANGE = 2; | ||
private static final int YELLOW = 3; | ||
private static final int LIME = 4; | ||
private static final int GREEN = 5; | ||
private static final int TEAL = 6; | ||
private static final int BLUE = 7; | ||
private static final int PURPLE = 8; | ||
private static final int PINK = 9; | ||
private int color = GREY ; | ||
|
||
public Block(Context context) { | ||
super(context); | ||
init(); | ||
} | ||
|
||
public Block(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
init(); | ||
} | ||
|
||
private void init(){ | ||
setBackgroundResource(R.drawable.shape_block); | ||
g=(GradientDrawable) this.getBackground(); | ||
} | ||
|
||
public void setColor(int color){ | ||
this.color=color; | ||
switch (color){ | ||
case GREY : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorGrey)); | ||
break; | ||
case RED : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorRed)); | ||
break; | ||
case ORANGE : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorOrange)); | ||
break; | ||
case YELLOW : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorYellow)); | ||
break; | ||
case LIME : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorLime)); | ||
break; | ||
case GREEN : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorGreen)); | ||
break; | ||
case TEAL : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorTeal)); | ||
break; | ||
case BLUE : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorBlue)); | ||
break; | ||
case PURPLE : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorPurple)); | ||
break; | ||
case PINK : | ||
g.setColor(ContextCompat.getColor(getContext(),R.color.colorPink)); | ||
break; | ||
} | ||
} | ||
|
||
public int getColor(){ | ||
return color; | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
app/src/main/java/com/shenjing/colordoku/GameActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.shenjing.colordoku; | ||
|
||
import android.animation.AnimatorSet; | ||
import android.animation.ObjectAnimator; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
|
||
public class GameActivity extends AppCompatActivity implements View.OnClickListener { | ||
private final float scaleFrom =1.0f; | ||
private final float scaleTo =1.3f; | ||
public int currentSelected = -1; | ||
private Block[] blocks = new Block[10]; | ||
private int[] blockId = { | ||
R.id.block_grey, | ||
R.id.block_red, | ||
R.id.block_orange, | ||
R.id.block_yellow, | ||
R.id.block_lime, | ||
R.id.block_green, | ||
R.id.block_teal, | ||
R.id.block_blue, | ||
R.id.block_purple, | ||
R.id.block_pink | ||
}; | ||
private GameView gameView; | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_game); | ||
|
||
gameView = (GameView) findViewById(R.id.view_game); | ||
for (int i = 0; i < 10; i++) { | ||
blocks[i] = (Block) findViewById(blockId[i]); | ||
blocks[i].setColor(i); | ||
blocks[i].setOnClickListener(this); | ||
} | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
Log.i("GameView","Click!"); | ||
|
||
final Block b = (Block)view; | ||
int currentSelected=b.getColor(); | ||
|
||
// for (int i = 0; i < 10; i++) { | ||
// if(blockId[i] == view.getId()){ | ||
// currentSelected = i; | ||
// break; | ||
// } | ||
// } | ||
if(this.currentSelected == -1){ | ||
AnimatorSet animatorSet = new AnimatorSet(); | ||
ObjectAnimator zoomOutX = ObjectAnimator.ofFloat(b,"scaleX",1.0f,1.3f).setDuration(50); | ||
ObjectAnimator zoomOutY = ObjectAnimator.ofFloat(b,"scaleY",1.0f,1.3f).setDuration(50); | ||
animatorSet.play(zoomOutX).with(zoomOutY); | ||
animatorSet.start(); | ||
this.currentSelected = currentSelected; | ||
} else { | ||
AnimatorSet animatorSet = new AnimatorSet(); | ||
ObjectAnimator zoomInX = ObjectAnimator.ofFloat(blocks[this.currentSelected],"scaleX",1.3f,1.0f).setDuration(50); | ||
ObjectAnimator zoomInY = ObjectAnimator.ofFloat(blocks[this.currentSelected],"scaleY",1.3f,1.0f).setDuration(50); | ||
animatorSet.play(zoomInX).with(zoomInY); | ||
animatorSet.start(); | ||
if(this.currentSelected != currentSelected){ | ||
AnimatorSet animatorSetCurrent = new AnimatorSet(); | ||
ObjectAnimator zoomOutX = ObjectAnimator.ofFloat(b,"scaleX",1.0f,1.3f).setDuration(50); | ||
ObjectAnimator zoomOutY = ObjectAnimator.ofFloat(b,"scaleY",1.0f,1.3f).setDuration(50); | ||
animatorSetCurrent.play(zoomOutX).with(zoomOutY); | ||
animatorSetCurrent.start(); | ||
this.currentSelected = currentSelected; | ||
} else { | ||
this.currentSelected = -1; | ||
} | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.