resolved conflicts for merge of 4110368b to gingerbread-plus-aosp
Change-Id: I23f83b1272ba6aef5a4fbadf5e450c1e0b4dd82b
This commit is contained in:
17
apps/Tag/Android.mk
Normal file
17
apps/Tag/Android.mk
Normal file
@@ -0,0 +1,17 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
# Only compile source java files in this apk.
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := TagApp
|
||||
# LOCAL_PROGUARD_EABLED := disabled
|
||||
|
||||
# LOCAL_SDK_VERSION := current
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
35
apps/Tag/AndroidManifest.xml
Normal file
35
apps/Tag/AndroidManifest.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<!-- Declare the contents of this Android application. The namespace
|
||||
attribute brings in the Android platform namespace, and the package
|
||||
supplies a unique name for the application. When writing your
|
||||
own application, the package name must be changed from "com.example.*"
|
||||
to come from a domain that you own or have control over. -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.apps.tag">
|
||||
<application android:label="Tags">
|
||||
<activity android:name="Tags">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="TagSelector"></activity>
|
||||
<activity android:name="TagList"></activity>
|
||||
</application>
|
||||
</manifest>
|
||||
8
apps/Tag/res/drawable/ic_tab_artists.xml
Normal file
8
apps/Tag/res/drawable/ic_tab_artists.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- When selected, use grey -->
|
||||
<item android:drawable="@drawable/ic_tab_artists_grey"
|
||||
android:state_selected="true" />
|
||||
<!-- When not selected, use white-->
|
||||
<item android:drawable="@drawable/ic_tab_artists_white" />
|
||||
</selector>
|
||||
BIN
apps/Tag/res/drawable/ic_tab_artists_grey.png
Normal file
BIN
apps/Tag/res/drawable/ic_tab_artists_grey.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 791 B |
BIN
apps/Tag/res/drawable/ic_tab_artists_white.png
Normal file
BIN
apps/Tag/res/drawable/ic_tab_artists_white.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
25
apps/Tag/res/layout/hello_activity.xml
Normal file
25
apps/Tag/res/layout/hello_activity.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
|
||||
<EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="18sp"
|
||||
android:autoText="true"
|
||||
android:capitalize="sentences"
|
||||
android:text="@string/hello_activity_text_text" />
|
||||
|
||||
21
apps/Tag/res/layout/main.xml
Normal file
21
apps/Tag/res/layout/main.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/tabhost"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="5dp">
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="5dp" />
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
22
apps/Tag/res/menu/mailbox_menu.xml
Normal file
22
apps/Tag/res/menu/mailbox_menu.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/help_info_menu_item"
|
||||
android:icon="@android:drawable/ic_menu_help"
|
||||
android:title="@string/help_and_info" />
|
||||
</menu>
|
||||
23
apps/Tag/res/values/strings.xml
Normal file
23
apps/Tag/res/values/strings.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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="hello_activity_text_text">Hello, World!</string>
|
||||
<string name="help_and_info">help and info</string>
|
||||
<string name="saved">Saved</string>
|
||||
|
||||
</resources>
|
||||
56
apps/Tag/src/com/android/apps/tag/TagDBHelper.java
Normal file
56
apps/Tag/src/com/android/apps/tag/TagDBHelper.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.android.apps.tag;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
/**
|
||||
* @author nnk@google.com (Nick Kralevich)
|
||||
*/
|
||||
public class TagDBHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final int DATABASE_VERSION = 1;
|
||||
private static final String TABLE_CREATE = "create table Tags ("
|
||||
+ "_id INTEGER PRIMARY KEY ASC, "
|
||||
+ "description TEXT, "
|
||||
+ "date TEXT"
|
||||
+ ")";
|
||||
|
||||
private static final String FAKE_DATA =
|
||||
"INSERT INTO Tags (description) values ('hello world')";
|
||||
|
||||
private static final String FAKE_DATA2 =
|
||||
"INSERT INTO Tags (description) values ('hi world')";
|
||||
|
||||
|
||||
public TagDBHelper(Context context) {
|
||||
super(context, "Tags.db", null, DATABASE_VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(TABLE_CREATE);
|
||||
db.execSQL(FAKE_DATA);
|
||||
db.execSQL(FAKE_DATA2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
}
|
||||
}
|
||||
84
apps/Tag/src/com/android/apps/tag/TagList.java
Normal file
84
apps/Tag/src/com/android/apps/tag/TagList.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.android.apps.tag;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ListActivity;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Contacts;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
import com.trustedlogic.trustednfc.android.NfcManager;
|
||||
|
||||
/**
|
||||
* @author nnk@google.com (Nick Kralevich)
|
||||
*/
|
||||
public class TagList extends ListActivity implements DialogInterface.OnClickListener {
|
||||
|
||||
private NfcManager mManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
SQLiteDatabase db = new TagDBHelper(this.getBaseContext()).getReadableDatabase();
|
||||
Cursor c = db.query("Tags", new String[] { "_id", "description" }, null, null, null, null, null);
|
||||
SimpleCursorAdapter sca =
|
||||
new SimpleCursorAdapter(this,
|
||||
android.R.layout.two_line_list_item,
|
||||
c,
|
||||
new String[] { "description" },
|
||||
new int[] { android.R.id.text1 });
|
||||
|
||||
setListAdapter(sca);
|
||||
registerForContextMenu(getListView());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
menu.add("hello world");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id, Bundle args) {
|
||||
String[] stuff = new String[] { "a", "b" };
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle("blah")
|
||||
.setItems(stuff, this)
|
||||
.setPositiveButton("Delete", null)
|
||||
.setNegativeButton("Cancel", null)
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
showDialog(1);
|
||||
super.onListItemClick(l, v, position, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) { }
|
||||
|
||||
}
|
||||
64
apps/Tag/src/com/android/apps/tag/TagListAdapter.java
Normal file
64
apps/Tag/src/com/android/apps/tag/TagListAdapter.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.android.apps.tag;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* @author nnk@google.com (Nick Kralevich)
|
||||
*/
|
||||
public class TagListAdapter extends BaseAdapter {
|
||||
|
||||
private Context context;
|
||||
|
||||
TagListAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private static final String[] listItems = {
|
||||
"Welcome! T2000 Festival",
|
||||
"Free songs by Hula 88",
|
||||
"Welcome to FreeBucks",
|
||||
"BooBox Movie Coupons"
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return listItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItem(int position) {
|
||||
return listItems[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
TextView tv = new TextView(context);
|
||||
tv.setText(getItem(position));
|
||||
return tv;
|
||||
}
|
||||
}
|
||||
67
apps/Tag/src/com/android/apps/tag/TagSelector.java
Normal file
67
apps/Tag/src/com/android/apps/tag/TagSelector.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.android.apps.tag;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* A minimal "Hello, World!" application.
|
||||
*/
|
||||
public class TagSelector extends Activity {
|
||||
private static final int DIALOG = 1;
|
||||
private static final String[] elements = { "hello world" };
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final TextView tv = new TextView(this);
|
||||
tv.setText("hello world");
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
tv.setText("clicked!");
|
||||
showAlert();
|
||||
}
|
||||
});
|
||||
|
||||
setContentView(tv);
|
||||
|
||||
// Set the layout for this activity. You can find it
|
||||
// in res/layout/hello_activity.xml
|
||||
// setContentView(R.layout.hello_activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id, Bundle bundle) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Welcome ");
|
||||
builder.setCancelable(true);
|
||||
builder.setItems(elements, null);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
||||
private void showAlert() {
|
||||
showDialog(DIALOG);
|
||||
}
|
||||
}
|
||||
|
||||
26
apps/Tag/src/com/android/apps/tag/TagUi.java
Normal file
26
apps/Tag/src/com/android/apps/tag/TagUi.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.android.apps.tag;
|
||||
|
||||
|
||||
/**
|
||||
* @author nnk@google.com (Nick Kralevich)
|
||||
*/
|
||||
public class TagUi {
|
||||
|
||||
|
||||
}
|
||||
63
apps/Tag/src/com/android/apps/tag/Tags.java
Normal file
63
apps/Tag/src/com/android/apps/tag/Tags.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.android.apps.tag;
|
||||
|
||||
import android.app.TabActivity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TabHost;
|
||||
|
||||
/**
|
||||
* A minimal "Hello, World!" application.
|
||||
*/
|
||||
public class Tags extends TabActivity {
|
||||
/**
|
||||
* Called with the activity is first created.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
Resources res = getResources();
|
||||
TabHost tabHost = getTabHost();
|
||||
Intent i = new Intent().setClass(this, TagList.class);
|
||||
|
||||
Intent iSavedList = new Intent().setClass(this, TagList.class);
|
||||
Intent iRecentList = new Intent().setClass(this, TagList.class);
|
||||
Intent iMyTagList = new Intent().setClass(this, TagList.class);
|
||||
|
||||
|
||||
TabHost.TabSpec spec1 = tabHost.newTabSpec("1")
|
||||
.setIndicator("Saved", res.getDrawable(R.drawable.ic_tab_artists))
|
||||
.setContent(iSavedList);
|
||||
tabHost.addTab(spec1);
|
||||
|
||||
TabHost.TabSpec spec2 = tabHost.newTabSpec("2")
|
||||
.setIndicator("Recent", res.getDrawable(R.drawable.ic_tab_artists))
|
||||
.setContent(iRecentList);
|
||||
tabHost.addTab(spec2);
|
||||
|
||||
TabHost.TabSpec spec3 = tabHost.newTabSpec("3")
|
||||
.setIndicator("My Tag", res.getDrawable(R.drawable.ic_tab_artists))
|
||||
.setContent(iMyTagList);
|
||||
tabHost.addTab(spec3);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
14
apps/Tag/tests/Android.mk
Normal file
14
apps/Tag/tests/Android.mk
Normal file
@@ -0,0 +1,14 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := android.test.runner
|
||||
|
||||
LOCAL_PACKAGE_NAME := TagAppTests
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
LOCAL_INSTRUMENTATION_FOR := TagApp
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
32
apps/Tag/tests/AndroidManifest.xml
Normal file
32
apps/Tag/tests/AndroidManifest.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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.android.apps.tag">
|
||||
|
||||
<!-- We add an application tag here just so that we can indicate that
|
||||
this package needs to link against the android.test library,
|
||||
which is needed when building test cases. -->
|
||||
<application>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="android.test.InstrumentationTestRunner"
|
||||
android:targetPackage="com.example.android.helloactivity"
|
||||
android:label="HelloActivity sample tests">
|
||||
</instrumentation>
|
||||
|
||||
</manifest>
|
||||
1
apps/Tag/tests/build.properties
Normal file
1
apps/Tag/tests/build.properties
Normal file
@@ -0,0 +1 @@
|
||||
tested.project.dir=..
|
||||
40
apps/Tag/tests/src/com/android/apps/tag/TagsTest.java
Normal file
40
apps/Tag/tests/src/com/android/apps/tag/TagsTest.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.android.apps.tag;
|
||||
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
/**
|
||||
* Make sure that the main launcher activity opens up properly, which will be
|
||||
* verified by {@link #testActivityTestCaseSetUpProperly}.
|
||||
*/
|
||||
public class TagsTest extends ActivityInstrumentationTestCase2<Tags> {
|
||||
|
||||
/**
|
||||
* Creates an {@link ActivityInstrumentationTestCase2} for the {@link Tags} activity.
|
||||
*/
|
||||
public TagsTest() {
|
||||
super(Tags.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the activity under test can be launched.
|
||||
*/
|
||||
public void testActivityTestCaseSetUpProperly() {
|
||||
assertNotNull("activity should be launched successfully", getActivity());
|
||||
}
|
||||
}
|
||||
@@ -158,21 +158,20 @@ public class TouchPaint extends GraphicsActivity {
|
||||
public class MyView extends View {
|
||||
private static final int FADE_ALPHA = 0x06;
|
||||
private static final int MAX_FADE_STEPS = 256/FADE_ALPHA + 4;
|
||||
private static final int TRACKBALL_SCALE = 10;
|
||||
|
||||
private Bitmap mBitmap;
|
||||
private Canvas mCanvas;
|
||||
private final Rect mRect = new Rect();
|
||||
private final Paint mPaint;
|
||||
private final Paint mFadePaint;
|
||||
private boolean mCurDown;
|
||||
private int mCurX;
|
||||
private int mCurY;
|
||||
private float mCurPressure;
|
||||
private float mCurSize;
|
||||
private int mCurWidth;
|
||||
private float mCurX;
|
||||
private float mCurY;
|
||||
private int mFadeSteps = MAX_FADE_STEPS;
|
||||
|
||||
public MyView(Context c) {
|
||||
super(c);
|
||||
setFocusable(true);
|
||||
mPaint = new Paint();
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setARGB(255, 255, 255, 255);
|
||||
@@ -228,61 +227,59 @@ public class TouchPaint extends GraphicsActivity {
|
||||
}
|
||||
|
||||
@Override public boolean onTrackballEvent(MotionEvent event) {
|
||||
boolean oldDown = mCurDown;
|
||||
mCurDown = true;
|
||||
int N = event.getHistorySize();
|
||||
int baseX = mCurX;
|
||||
int baseY = mCurY;
|
||||
final float scaleX = event.getXPrecision();
|
||||
final float scaleY = event.getYPrecision();
|
||||
final float scaleX = event.getXPrecision() * TRACKBALL_SCALE;
|
||||
final float scaleY = event.getYPrecision() * TRACKBALL_SCALE;
|
||||
for (int i=0; i<N; i++) {
|
||||
//Log.i("TouchPaint", "Intermediate trackball #" + i
|
||||
// + ": x=" + event.getHistoricalX(i)
|
||||
// + ", y=" + event.getHistoricalY(i));
|
||||
drawPoint(baseX+event.getHistoricalX(i)*scaleX,
|
||||
baseY+event.getHistoricalY(i)*scaleY,
|
||||
event.getHistoricalPressure(i),
|
||||
event.getHistoricalSize(i));
|
||||
mCurX += event.getHistoricalX(i) * scaleX;
|
||||
mCurY += event.getHistoricalY(i) * scaleY;
|
||||
drawPoint(mCurX, mCurY, 1.0f, 16.0f);
|
||||
}
|
||||
//Log.i("TouchPaint", "Trackball: x=" + event.getX()
|
||||
// + ", y=" + event.getY());
|
||||
drawPoint(baseX+event.getX()*scaleX, baseY+event.getY()*scaleY,
|
||||
event.getPressure(), event.getSize());
|
||||
mCurDown = oldDown;
|
||||
mCurX += event.getX() * scaleX;
|
||||
mCurY += event.getY() * scaleY;
|
||||
drawPoint(mCurX, mCurY, 1.0f, 16.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean onTouchEvent(MotionEvent event) {
|
||||
int action = event.getAction();
|
||||
mCurDown = action == MotionEvent.ACTION_DOWN
|
||||
|| action == MotionEvent.ACTION_MOVE;
|
||||
int action = event.getActionMasked();
|
||||
if (action != MotionEvent.ACTION_UP && action != MotionEvent.ACTION_CANCEL) {
|
||||
int N = event.getHistorySize();
|
||||
int P = event.getPointerCount();
|
||||
for (int i = 0; i < N; i++) {
|
||||
//Log.i("TouchPaint", "Intermediate pointer #" + i);
|
||||
drawPoint(event.getHistoricalX(i), event.getHistoricalY(i),
|
||||
event.getHistoricalPressure(i),
|
||||
event.getHistoricalSize(i));
|
||||
for (int j = 0; j < P; j++) {
|
||||
mCurX = event.getHistoricalX(j, i);
|
||||
mCurY = event.getHistoricalY(j, i);
|
||||
drawPoint(mCurX, mCurY,
|
||||
event.getHistoricalPressure(j, i),
|
||||
event.getHistoricalTouchMajor(j, i));
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < P; j++) {
|
||||
mCurX = event.getX(j);
|
||||
mCurY = event.getY(j);
|
||||
drawPoint(mCurX, mCurY, event.getPressure(j), event.getTouchMajor(j));
|
||||
}
|
||||
}
|
||||
drawPoint(event.getX(), event.getY(), event.getPressure(),
|
||||
event.getSize());
|
||||
return true;
|
||||
}
|
||||
|
||||
private void drawPoint(float x, float y, float pressure, float size) {
|
||||
private void drawPoint(float x, float y, float pressure, float width) {
|
||||
//Log.i("TouchPaint", "Drawing: " + x + "x" + y + " p="
|
||||
// + pressure + " s=" + size);
|
||||
mCurX = (int)x;
|
||||
mCurY = (int)y;
|
||||
mCurPressure = pressure;
|
||||
mCurSize = size;
|
||||
mCurWidth = (int)(mCurSize*(getWidth()/3));
|
||||
if (mCurWidth < 1) mCurWidth = 1;
|
||||
if (mCurDown && mBitmap != null) {
|
||||
int pressureLevel = (int)(mCurPressure*255);
|
||||
// + pressure + " width=" + width);
|
||||
if (width < 1) width = 1;
|
||||
if (mBitmap != null) {
|
||||
float radius = width / 2;
|
||||
int pressureLevel = (int)(pressure * 255);
|
||||
mPaint.setARGB(pressureLevel, 255, 255, 255);
|
||||
mCanvas.drawCircle(mCurX, mCurY, mCurWidth, mPaint);
|
||||
mRect.set(mCurX-mCurWidth-2, mCurY-mCurWidth-2,
|
||||
mCurX+mCurWidth+2, mCurY+mCurWidth+2);
|
||||
mCanvas.drawCircle(x, y, radius, mPaint);
|
||||
mRect.set((int) (x - radius - 2), (int) (y - radius - 2),
|
||||
(int) (x + radius + 2), (int) (y + radius + 2));
|
||||
invalidate(mRect);
|
||||
}
|
||||
mFadeSteps = 0;
|
||||
|
||||
Reference in New Issue
Block a user