Compare commits
3 Commits
00e7a7f392
...
x
| Author | SHA1 | Date | |
|---|---|---|---|
| 069385fb1b | |||
| 4108ecd29f | |||
| a0f411c6ad |
@@ -25,7 +25,7 @@ task createVersionXML {
|
||||
versionFile.println( '<string name="git_version">' << version << '</string>' )
|
||||
versionFile.println( '<string name="git_hash">' << githash << '</string>' )
|
||||
versionFile.println( '<string name="build_date">' << builddate << '</string>' )
|
||||
versionFile.println( '<string name="version_code">0x00010001</string>' )
|
||||
versionFile.println( '<string name="version_code">0x00010002</string>' )
|
||||
versionFile.println( '</resources>' )
|
||||
versionFile.close()
|
||||
}
|
||||
@@ -36,10 +36,18 @@ preBuild.dependsOn createVersionXML
|
||||
// Convert SVG images from art directory into PNG files.
|
||||
//
|
||||
task generateDrawablesFromArt {
|
||||
|
||||
doLast {
|
||||
def indir = "app/src/main/art"
|
||||
def outdir = "../res"
|
||||
|
||||
String backslash= System.getProperty("file.separator")
|
||||
def buildDir = (new File(project.buildDir,'art')).toString()
|
||||
def p = ('make -C app/src/main/art RES=../res TMP='+buildDir).execute()
|
||||
p.consumeProcessOutput()
|
||||
buildDir = buildDir.replace(backslash,"/")
|
||||
def cmd = "make -C ${indir} RES=${outdir} TMP=${buildDir}"
|
||||
println cmd
|
||||
def p = cmd.execute()
|
||||
p.consumeProcessOutput(System.err,System.err)
|
||||
p.waitFor()
|
||||
if ( p.exitValue() )
|
||||
throw new GradleException("Generation of art failed.")
|
||||
@@ -60,7 +68,7 @@ android {
|
||||
buildTypes {
|
||||
release {
|
||||
runProguard true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.sokoban_release
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
# in C:\Program Files (x86)\Android\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
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.vostan.sokoban"
|
||||
android:versionCode="@string/version_code"
|
||||
android:versionCode="0x00010002"
|
||||
android:versionName="@string/git_version">
|
||||
<uses-sdk android:minSdkVersion="10"
|
||||
android:targetSdkVersion="14"/>
|
||||
|
||||
107
app/src/main/art/build.gradle
Normal file
107
app/src/main/art/build.gradle
Normal file
@@ -0,0 +1,107 @@
|
||||
//apply plugin: 'com.android.application'
|
||||
|
||||
class svg2png extends DefaultTask {
|
||||
|
||||
String input
|
||||
String output
|
||||
int width
|
||||
int hight
|
||||
def layers
|
||||
|
||||
def layerOnOff( def layer ) {
|
||||
def t = '-u "//*/svg:g[@inkscape:label=\\"'+layer.key+'\\"]/@style"'
|
||||
if ( layer.value )
|
||||
return t + ' -v display:inline'
|
||||
else
|
||||
return t + ' -v display:none'
|
||||
}
|
||||
|
||||
def configSVG( def svg, def layers ) {
|
||||
def cfg = 'xmlstarlet ed -P -N svg=http://www.w3.org/2000/svg '
|
||||
for ( layer in layers ) {
|
||||
cfg += layerOnOff( layer ) + ' '
|
||||
}
|
||||
return cfg + svg
|
||||
}
|
||||
|
||||
def configPNG( def png, def h, def w ) {
|
||||
def cfg = 'imagemagick -background none -resize '+w+'x'+h+' - ' + png
|
||||
}
|
||||
|
||||
def exportPNG( def svg, def svgLayerCfg, def png, def h, def w ) {
|
||||
def svgProc = configSVG( svg, svgLayerCfg ).execute()
|
||||
def pngProc =
|
||||
configPNG( png, h, w ).
|
||||
execute()
|
||||
svgProc.pipeTo( pngProc )
|
||||
|
||||
pngProc.consumeProcessOutput()
|
||||
pngProc.waitForOrKill(10000)
|
||||
|
||||
if ( svgProc.exitValue() )
|
||||
throw new GradleException("Failed to generate svg.")
|
||||
if ( pngProc.exitValue() )
|
||||
throw new GradleException("Failed to generate png.")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
sourceSet {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Creates version.xml
|
||||
//
|
||||
task buildIcon {
|
||||
|
||||
//from(file('srcDir'))
|
||||
//into(buildDir)
|
||||
|
||||
doLast {
|
||||
|
||||
def sizes = [ 'ldpi':[36,36],
|
||||
'mdpi':[48,48],
|
||||
'hdpi':[72,72],
|
||||
'xhdpi':[96,96] ]
|
||||
|
||||
def sizes2= [ 'ldpi':[22,36],
|
||||
'mdpi':[29,48],
|
||||
'hdpi':[43,72],
|
||||
'xhdpi':[58,96] ]
|
||||
|
||||
def sizes3= [ '':[500,500] ]
|
||||
|
||||
/*
|
||||
def files = [
|
||||
( "icon.svg", "icon.png", [ 'Debug':false ], sizes ),
|
||||
( "icon.svg", "icon_debug.png", [ 'Debug':true ], sizes ),
|
||||
|
||||
( "buttons.svg", "reset.png", [ 'Reset Smooth':true ], sizes ),
|
||||
( "buttons.svg", "undo.png", [ 'Undo Smooth':true ], sizes ),
|
||||
( "buttons.svg", "next.png", [ 'Next Smooth':true ], sizes2 ),
|
||||
( "buttons.svg", "prev.png", [ 'Prev Smooth':true ], sizes2 ),
|
||||
|
||||
( "lock.svg", "lock.png", [ 'lock':true ], sizes2 ),
|
||||
( "lock.svg", "unlock.png", [ 'unlock':true ], sizes2 ),
|
||||
( "lock.svg", "unlocking.png", [ 'locking':true ], sizes2 ),
|
||||
|
||||
( "bingo.svg", "bingo.png", [], sizes3 ),
|
||||
( "box.svg", "box.png", [], sizes3 ),
|
||||
( "floor.svg", "floor.png", [ 'Goal':false ], sizes3 ),
|
||||
( "floor.svg", "goal.png", [ 'Goal':true ], sizes3 ),
|
||||
( "wall.svg", "wall.png", [], sizes3 ),
|
||||
( "worker.svg", "worker.png", [ 'Hands':false ], sizes3 ),
|
||||
( "worker.svg", "worker_select.png", [ 'Hands':true ], sizes3 ),
|
||||
|
||||
( "splash.svg", "splash.png", [], ['':[500:800]] )
|
||||
]
|
||||
*/
|
||||
// for ( s in sizes ) {
|
||||
// exportPNG( "icon.svg",icon,s.key+"_icon.png",s.value[0],s.value[1])
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public class App extends Application
|
||||
max_level = pc.getCount();
|
||||
current_level = prefs.getInt("current_level", MIN_LEVEL);
|
||||
achieved_level = prefs.getInt("achieved_level", MIN_LEVEL+10);
|
||||
prefsEdit.apply();
|
||||
}
|
||||
//
|
||||
// This is a singleton object.
|
||||
|
||||
@@ -130,12 +130,12 @@ public class PlayActivity extends FragmentActivity
|
||||
title_view.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public boolean onReset( View v )
|
||||
public void onReset( View v )
|
||||
{
|
||||
while ( puzzle.isUndoable() )
|
||||
puzzle.restore();
|
||||
puzzle_view.invalidate();
|
||||
return true;
|
||||
//return true;
|
||||
}
|
||||
//
|
||||
// Go to previouse puzzle.
|
||||
@@ -175,16 +175,16 @@ public class PlayActivity extends FragmentActivity
|
||||
//
|
||||
// Undo last action.
|
||||
//
|
||||
public boolean onUndo( View v )
|
||||
public void onUndo( View v )
|
||||
{
|
||||
if ( puzzle.isUndoable() )
|
||||
{
|
||||
puzzle.restore();
|
||||
puzzle_view.invalidate();
|
||||
return true;
|
||||
// return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
//else
|
||||
// return false;
|
||||
}
|
||||
|
||||
private void loadCurrentPuzzle()
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:textSize="40dp"
|
||||
android:textSize="40sp"
|
||||
android:paddingLeft="5dp"
|
||||
android:textScaleX="1"
|
||||
android:textColor="#FFE680"
|
||||
|
||||
115
app/src/tests/java/org/vostan/sokoban/menu/MainActivityTest.java
Normal file
115
app/src/tests/java/org/vostan/sokoban/menu/MainActivityTest.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package org.vostan.sokoban.menu;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import org.vostan.sokoban.menu.MainActivity;
|
||||
import org.vostan.sokoban.R;
|
||||
|
||||
/**
|
||||
* This is a simple framework for a test of an Application. See
|
||||
* {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
|
||||
* how to write and extend Application tests.
|
||||
*
|
||||
* <p>To run this test, you can type:
|
||||
* adb shell am instrument -w \
|
||||
* -e class com.example.android.activityinstrumentation.MainActivityTest \
|
||||
* quux.tests/android.test.InstrumentationTestRunner
|
||||
*
|
||||
* <p>Individual tests are defined as any method beginning with 'test'.
|
||||
*
|
||||
* <p>ActivityInstrumentationTestCase2 allows these tests to run alongside a running
|
||||
* copy of the application under inspection. Calling getActivity() will return a
|
||||
* handle to this activity (launching it if needed).
|
||||
*/
|
||||
public class MainActivityTest
|
||||
extends ActivityInstrumentationTestCase2<MainActivity> {
|
||||
|
||||
MainActivity mActivity;
|
||||
|
||||
public MainActivityTest() {
|
||||
super("org.vostan.sokoban.menu.MainActivity", MainActivity.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
mActivity = getActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to make sure that spinner values are persisted across activity restarts.
|
||||
*
|
||||
* <p>Launches the main activity, sets a spinner value, closes the activity, then relaunches
|
||||
* that activity. Checks to make sure that the spinner values match what we set them to.
|
||||
*/
|
||||
// BEGIN_INCLUDE (test_name)
|
||||
public void testSpinnerValuePersistedBetweenLaunches() {
|
||||
/*
|
||||
// END_INCLUDE (test_name)
|
||||
final int TEST_SPINNER_POSITION_1 = MainActivity.WEATHER_PARTLY_CLOUDY;
|
||||
|
||||
// BEGIN_INCLUDE (launch_activity)
|
||||
// Launch the activity
|
||||
Activity activity = getActivity();
|
||||
// END_INCLUDE (launch_activity)
|
||||
|
||||
// BEGIN_INCLUDE (write_to_ui)
|
||||
// Set spinner to test position 1
|
||||
final Spinner spinner1 = (Spinner) activity.findViewById(R.id.spinner);
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Attempts to manipulate the UI must be performed on a UI thread.
|
||||
// Calling this outside runOnUiThread() will cause an exception.
|
||||
//
|
||||
// You could also use @UiThreadTest, but activity lifecycle methods
|
||||
// cannot be called if this annotation is used.
|
||||
spinner1.requestFocus();
|
||||
spinner1.setSelection(TEST_SPINNER_POSITION_1);
|
||||
}
|
||||
});
|
||||
// END_INCLUDE (write_to_ui)
|
||||
|
||||
// BEGIN_INCLUDE (relaunch_activity)
|
||||
// Close the activity
|
||||
activity.finish();
|
||||
setActivity(null); // Required to force creation of a new activity
|
||||
|
||||
// Relaunch the activity
|
||||
activity = this.getActivity();
|
||||
// END_INCLUDE (relaunch_activity)
|
||||
|
||||
// BEGIN_INCLUDE (check_results)
|
||||
// Verify that the spinner was saved at position 1
|
||||
final Spinner spinner2 = (Spinner) activity.findViewById(R.id.spinner);
|
||||
int currentPosition = spinner2.getSelectedItemPosition();
|
||||
assertEquals(TEST_SPINNER_POSITION_1, currentPosition);
|
||||
// END_INCLUDE (check_results)
|
||||
|
||||
// Since this is a stateful test, we need to make sure that the activity isn't simply
|
||||
// echoing a previously-stored value that (coincidently) matches position 1
|
||||
final int TEST_SPINNER_POSITION_2 = MainActivity.WEATHER_SNOW;
|
||||
|
||||
// Set spinner to test position 2
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
spinner2.requestFocus();
|
||||
spinner2.setSelection(TEST_SPINNER_POSITION_2);
|
||||
}
|
||||
});
|
||||
|
||||
// Close the activity
|
||||
activity.finish();
|
||||
setActivity(null);
|
||||
|
||||
// Relaunch the activity
|
||||
activity = this.getActivity();
|
||||
|
||||
// Verify that the spinner was saved at position 2
|
||||
final Spinner spinner3 = (Spinner) activity.findViewById(R.id.spinner);
|
||||
currentPosition = spinner3.getSelectedItemPosition();
|
||||
assertEquals(TEST_SPINNER_POSITION_2, currentPosition);
|
||||
*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user