Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Develop #1

Merged
merged 4 commits into from
May 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Core/AndroidBinding/bin/androidbinding.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 3 additions & 2 deletions Core/AndroidBinding/src/gueei/binding/menu/AbsMenuBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ public abstract class AbsMenuBridge {

// Factory method
public static AbsMenuBridge create
(String nodeName, int id, AttributeSet attrs, Context context, Object model){
(String nodeName, int id, AttributeSet attrs, Context context,
Object model, IMenuItemChangedCallback callback){
AbsMenuBridge item;

if ("item".equals(nodeName)){
item = new MenuItemBridge(id, attrs, context, model);
item = new MenuItemBridge(id, attrs, context, model, callback);
}else if ("group".equals(nodeName)){
item = new MenuGroupBridge(id, attrs, context, model);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean onCreateOptionsMenu(Menu menu){
if (id>0){
AttributeSet attrs = Xml.asAttributeSet(parser);
AbsMenuBridge item =
AbsMenuBridge.create(nodeName, id, attrs, activity, model);
AbsMenuBridge.create(nodeName, id, attrs, activity, model, this);
if (item!=null){
items.put(id, item);
}
Expand All @@ -88,6 +88,7 @@ public boolean onCreateOptionsMenu(Menu menu){
item.onCreateOptionItem(menu);
}

menuCreated = true;
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public boolean onCreateOptionsMenu(Activity activity, Menu menu, Object model){
if (id>0){
AttributeSet attrs = Xml.asAttributeSet(parser);
AbsMenuBridge item =
AbsMenuBridge.create(nodeName, id, attrs, activity, model);
AbsMenuBridge.create(nodeName, id, attrs, activity, model, null);
if (item!=null){
items.put(id, item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.ArrayList;
import java.util.HashMap;

import android.util.Log;

/**
* A HashMap that will have fixed size,
* once the allocated size is over, the
Expand Down Expand Up @@ -34,6 +36,7 @@ public synchronized V put(K key, V value) {

for(int i=0; i<oversize; i++){
V rVal = this.get(keyList.get(i));
// Log.d("CacheHashMap:put", keyList.get(i) + ":" + rVal);
if (rVal != null && rVal.isMapped()) continue;
pendingRemove.add(i);
}
Expand Down
2 changes: 1 addition & 1 deletion Demo/MarkupDemoICS/bin/jarlist.cache
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# format is <lastModified> <length> <SHA-1> <path>
# Encoding is UTF-8
1354525842020 385685 48c94ae70fa65718b382098237806a5909bb096e C:\Users\andy\git\AndroidBindingMaster\Demo\MarkupDemoICS\libs\android-support-v4.jar
1354525842020 385685 48c94ae70fa65718b382098237806a5909bb096e C:\Users\andy\git\AndroidBindingMaster\plugin\AndroidBinding.Plugin.ABS\libs\android-support-v4.jar
1358132056998 385685 48c94ae70fa65718b382098237806a5909bb096e C:\Users\andy\git\AndroidBindingMaster\Core\AndroidBindingV30\libs\android-support-v4.jar
8 changes: 8 additions & 0 deletions Test/AndroidBindingTest/.classpath
Original file line number Diff line number Diff line change
@@ -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 exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
2 changes: 2 additions & 0 deletions Test/AndroidBindingTest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin
/gen
33 changes: 33 additions & 0 deletions Test/AndroidBindingTest/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AndroidBindingTest</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>
</projectDescription>
8 changes: 8 additions & 0 deletions Test/AndroidBindingTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="gueei.binding.test">
<uses-sdk android:minSdkVersion="4"/>
<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="gueei.binding.test"/>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="AndroidBindingUnitTestApplication">

<uses-library android:name="android.test.runner"/>
<activity android:label="TestButtonActivity" android:name=".TestButtonActivity"/></application>
</manifest>
Binary file added Test/AndroidBindingTest/android-binding.ant.jar
Binary file not shown.
60 changes: 60 additions & 0 deletions Test/AndroidBindingTest/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="android-binding" default="new-activity" basedir=".">
<property name="resource.dir" value="res"/>
<property name="classpath" value="android-binding.ant.jar"/>

<target name="new-activity" description="Use the Task">
<taskdef name="read-manifest"
classname="gueei.binding.gen.ReadFromManifestTask" classpath="${classpath}"/>
<read-manifest dir="."
setpackagename="package.name"
setsourcefoldername="package.dir"/>
<taskdef name="template" classname="gueei.binding.gen.WriteTemplateTask" classpath="${classpath}"/>
<taskdef name="register-activity" classname="gueei.binding.gen.RegisterActivityTask" classpath="${classpath}"/>
<input message="Input the new Activity's name" addproperty="activityname"/>
<!-- Create Activity File -->
<template input="BindingActivityV30.template" dir="${package.dir}" output="${activityname}.java">
<entry key="package_name" value="${package.name}"/>
<entry key="activity_name" value="${activityname}"/>
<entry key="metadata_name" value="*${activityname}_metadata"/>
</template>

<template input="activity.metadata.ics.xml.template" dir="${resource.dir}/xml-v14" output="*${activityname}_metadata.xml">
<entry key="rootview_layout" value="*${activityname}_layout"/>
<entry key="optionsmenu" value="*${activityname}_optionsmenu"/>
</template>

<template input="activity.metadata.froyo.xml.template" dir="${resource.dir}/xml" output="*${activityname}_metadata.xml">
<entry key="rootview_layout" value="*${activityname}_layout"/>
<entry key="optionsmenu" value="*${activityname}_optionsmenu"/>
</template>

<template input="activity.optionsmenu.template" dir="${resource.dir}/menu" output="*${activityname}_optionsmenu.xml">
</template>

<template input="activity.layout.template" dir="${resource.dir}/layout" output="*${activityname}_layout.xml">
</template>

<register-activity dir="." activityclassname="${activityname}"/>

<echo level="info"
message="Generation completed. Refresh your project to see the new files. "/>
</target>

<target name="create_application_class">
<taskdef name="read-manifest"
classname="gueei.binding.gen.ReadFromManifestTask" classpath="${classpath}"/>
<read-manifest dir="."
setpackagename="package.name"
setsourcefoldername="package.dir"/>
<taskdef name="register" classname="gueei.binding.gen.RegisterApplicationTask" classpath="${classpath}"/>
<taskdef name="template" classname="gueei.binding.gen.WriteTemplateTask" classpath="${classpath}"/>
<input message="Input the Application Class' name" addproperty="appname"/>
<register dir="." appclassname="${appname}"/>
<template input="application.template" dir="${package.dir}" output="${appname}.java">
<entry key="package_name" value="${package.name}"/>
<entry key="app_name" value="${appname}"/>
</template>
</target>

</project>
12 changes: 12 additions & 0 deletions Test/AndroidBindingTest/default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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.

# Project target.
target=android-4
android.library.reference.1=../AndroidBinding
40 changes: 40 additions & 0 deletions Test/AndroidBindingTest/proguard.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
15 changes: 15 additions & 0 deletions Test/AndroidBindingTest/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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 edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-15
android.library.reference.1=../../Core/AndroidBinding
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions Test/AndroidBindingTest/res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
14 changes: 14 additions & 0 deletions Test/AndroidBindingTest/res/layout/testbuttonactivity_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:binding="http://www.gueei.com/android-binding/"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button_say"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
binding:onClick="IF(IsHello, SayHello, SayGoodBye)"
android:text="Good Bye" />
</LinearLayout>
5 changes: 5 additions & 0 deletions Test/AndroidBindingTest/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World!</string>
<string name="app_name">AndroidBindingTest</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<activity xmlns:binding="http://www.gueei.com/android-binding/">
<rootView
binding:dataSource="."
binding:layoutId="@layout/testbuttonactivity_layout"/>
</activity>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gueei.binding.test;

import gueei.binding.Binder;
import android.app.Application;

public class AndroidBindingUnitTestApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
Binder.init(this);
}

}
27 changes: 27 additions & 0 deletions Test/AndroidBindingTest/src/gueei/binding/test/ConverterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gueei.binding.test;

import gueei.binding.exception.AttributeNotDefinedException;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.Button;

public class ConverterTest extends ActivityInstrumentationTestCase2<TestButtonActivity> {

public ConverterTest() {
super(TestButtonActivity.class);
}

public void test_IF_Switchable_Command() throws AttributeNotDefinedException{
final TestButtonActivity activity = getActivity();

activity.runOnUiThread(new Runnable(){
public void run() {
assertEquals(3, (int)activity.HelloWorld.get());
((Button)activity.findViewById(R.id.button_say)).performClick();
assertEquals(0, (int)activity.HelloWorld.get());
activity.IsHello.set(false);
((Button)activity.findViewById(R.id.button_say)).performClick();
assertEquals(1, (int)activity.HelloWorld.get());
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package gueei.binding.test;

import gueei.binding.ViewAttribute;
import gueei.binding.exception.AttributeNotDefinedException;
import gueei.binding.kernel.DefaultKernel;
import android.app.Application;
import android.test.AndroidTestCase;
import android.view.View;
import android.widget.TextView;

public class CustomAttributeWithFullClassNameTest extends AndroidTestCase {

public void testCustomAttributeResolution() throws AttributeNotDefinedException{
DefaultKernel kernel = new DefaultKernel();
kernel.init((Application) this.getContext().getApplicationContext());
String attributeName = CustomAttributeOfView.class.getName();
kernel.getAttributeForView(new View(mContext), attributeName);
kernel.getAttributeForView(new TextView(mContext), attributeName);
}

public static class CustomAttributeOfView<T extends View> extends ViewAttribute<T, Integer>{
public CustomAttributeOfView(T view) {
super(Integer.class, view, "Custom");
}
@Override
protected void doSetAttributeValue(Object newValue) {
}

@Override
public Integer get() {
return null;
}
}

public static class CustomAttributeOfTextView extends ViewAttribute<TextView, Integer>{
public CustomAttributeOfTextView(TextView view) {
super(Integer.class, view, "Custom");
}
@Override
protected void doSetAttributeValue(Object newValue) {
}

@Override
public Integer get() {
return null;
}
}
}
Loading