diff options
author | Raphael <raphael@google.com> | 2010-04-01 23:39:30 -0700 |
---|---|---|
committer | Raphael <raphael@google.com> | 2010-04-02 22:05:53 -0700 |
commit | 718a35143dae79196aa46467eada542cfe49c382 (patch) | |
tree | 78eb6bfc7a4819893faaf80d6081831148c9b5e2 /samples/TicTacToeMain | |
parent | 452de9c984b7a21a2208834260a9bb6ce1b0d1a2 (diff) | |
download | android_development-718a35143dae79196aa46467eada542cfe49c382.tar.gz android_development-718a35143dae79196aa46467eada542cfe49c382.tar.bz2 android_development-718a35143dae79196aa46467eada542cfe49c382.zip |
Skeleton for tic-tac-toe sample.
Change-Id: I41e7013d469cb2eba9f475aa0a94c4630cacbb64
Diffstat (limited to 'samples/TicTacToeMain')
-rwxr-xr-x | samples/TicTacToeMain/.classpath | 8 | ||||
-rw-r--r-- | samples/TicTacToeMain/.gitignore | 4 | ||||
-rwxr-xr-x | samples/TicTacToeMain/.project | 40 | ||||
-rwxr-xr-x | samples/TicTacToeMain/AndroidManifest.xml | 39 | ||||
-rwxr-xr-x | samples/TicTacToeMain/default.properties | 28 | ||||
-rwxr-xr-x | samples/TicTacToeMain/res/drawable/icon.png | bin | 0 -> 1468 bytes | |||
-rwxr-xr-x | samples/TicTacToeMain/res/layout/main.xml | 69 | ||||
-rwxr-xr-x | samples/TicTacToeMain/res/values/strings.xml | 26 | ||||
-rwxr-xr-x | samples/TicTacToeMain/src/com/example/tictactoe/MainActivity.java | 53 |
9 files changed, 267 insertions, 0 deletions
diff --git a/samples/TicTacToeMain/.classpath b/samples/TicTacToeMain/.classpath new file mode 100755 index 000000000..2db729987 --- /dev/null +++ b/samples/TicTacToeMain/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="src" path="TicTacToeLib"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/samples/TicTacToeMain/.gitignore b/samples/TicTacToeMain/.gitignore new file mode 100644 index 000000000..93624e73d --- /dev/null +++ b/samples/TicTacToeMain/.gitignore @@ -0,0 +1,4 @@ +.svn +bin +gen + diff --git a/samples/TicTacToeMain/.project b/samples/TicTacToeMain/.project new file mode 100755 index 000000000..9d7485aa5 --- /dev/null +++ b/samples/TicTacToeMain/.project @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TicTacToeMain</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>TicTacToeLib</name>
+ <type>2</type>
+ <locationURI>_android_TicTacToeLib/src</locationURI>
+ </link>
+ </linkedResources>
+</projectDescription>
diff --git a/samples/TicTacToeMain/AndroidManifest.xml b/samples/TicTacToeMain/AndroidManifest.xml new file mode 100755 index 000000000..4881b359b --- /dev/null +++ b/samples/TicTacToeMain/AndroidManifest.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.example.tictactoe" + android:versionCode="1" + android:versionName="1.0"> + <application android:icon="@drawable/icon" android:label="@string/app_name"> + <activity android:name=".MainActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <!-- This is defined in TicTacToeLib. Right now we need to manually + copy it here. Eventually it should get merged automatically. --> + <activity android:name=".library.GameActivity" /> + + + </application> + <uses-sdk android:minSdkVersion="Froyo" /> + +</manifest> diff --git a/samples/TicTacToeMain/default.properties b/samples/TicTacToeMain/default.properties new file mode 100755 index 000000000..d2fdd807a --- /dev/null +++ b/samples/TicTacToeMain/default.properties @@ -0,0 +1,28 @@ +# +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +android.library.reference.1=../TicTacToeLib/ +# Project target. +target=android-Froyo diff --git a/samples/TicTacToeMain/res/drawable/icon.png b/samples/TicTacToeMain/res/drawable/icon.png Binary files differnew file mode 100755 index 000000000..b8665ff7b --- /dev/null +++ b/samples/TicTacToeMain/res/drawable/icon.png diff --git a/samples/TicTacToeMain/res/layout/main.xml b/samples/TicTacToeMain/res/layout/main.xml new file mode 100755 index 000000000..1e75004b6 --- /dev/null +++ b/samples/TicTacToeMain/res/layout/main.xml @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:gravity="center_horizontal" + > + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:layout_marginTop="20dip" + android:layout_marginBottom="5dip" + android:text="@string/welcome" + /> + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:layout_marginBottom="5dip" + android:text="@string/explain2" + /> + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:layout_marginBottom="20dip" + android:text="@string/explain1" + /> + + <Button + android:id="@+id/start_player" + android:text="@string/start_player" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + /> + <Button + android:id="@+id/start_comp" + android:text="@string/start_comp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="10dip" + /> + + <ImageView + android:id="@+id/ImageView01" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/icon" + /> + +</LinearLayout> diff --git a/samples/TicTacToeMain/res/values/strings.xml b/samples/TicTacToeMain/res/values/strings.xml new file mode 100755 index 000000000..00522f703 --- /dev/null +++ b/samples/TicTacToeMain/res/values/strings.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> + +<resources> + <string name="start_comp">Start -- Computer goes first</string> + <string name="start_player">Start -- Player goes first</string> + <string name="welcome"><b>Welcome to the Tic-Tac-Toe Sample!</b></string>
+ <string name="explain1">This sample code demonstrates how to split an application in multiple projects by using the \'project library\' available in the Froyo SDK Tools.</string> + <string name="explain2">This activity is defined in one project. The second activity, launched by one of the buttons below, is located in another project which is a \"library\" to the main one and merged in the same APK.</string> + <string name="hello">Hello World, MainActivity!</string> + <string name="app_name">Tic-Tac-Toe Sample</string> +</resources> diff --git a/samples/TicTacToeMain/src/com/example/tictactoe/MainActivity.java b/samples/TicTacToeMain/src/com/example/tictactoe/MainActivity.java new file mode 100755 index 000000000..a66b54b53 --- /dev/null +++ b/samples/TicTacToeMain/src/com/example/tictactoe/MainActivity.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.tictactoe; + +import com.example.tictactoe.library.GameActivity; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.view.View.OnClickListener; + +public class MainActivity extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + findViewById(R.id.start_player).setOnClickListener( + new OnClickListener() { + public void onClick(View v) { + startGame(true); + } + }); + + findViewById(R.id.start_comp).setOnClickListener( + new OnClickListener() { + public void onClick(View v) { + startGame(false); + } + }); + } + + private void startGame(boolean startWithHuman) { + Intent i = new Intent(this, GameActivity.class); + i.putExtra(GameActivity.EXTRA_START_WITH_HUMAN, startWithHuman); + startActivity(i); + } +}
\ No newline at end of file |