diff --git a/src/api-impl-jni/views/android_view_View.c b/src/api-impl-jni/views/android_view_View.c index 31c947fc..3e5ae5eb 100644 --- a/src/api-impl-jni/views/android_view_View.c +++ b/src/api-impl-jni/views/android_view_View.c @@ -70,6 +70,8 @@ JNIEXPORT void JNICALL Java_android_view_View_setOnTouchListener(JNIEnv *env, jo JNIEXPORT void JNICALL Java_android_view_View_setOnClickListener(JNIEnv *env, jobject this, jobject on_click_listener) { GtkWidget *widget = GTK_WIDGET(_PTR(_GET_LONG_FIELD(this, "widget"))); + if (!on_click_listener) + return; JavaVM *jvm; (*env)->GetJavaVM(env, &jvm); diff --git a/src/api-impl/android/app/AlertDialog.java b/src/api-impl/android/app/AlertDialog.java index 95d8d790..1aaf33e8 100644 --- a/src/api-impl/android/app/AlertDialog.java +++ b/src/api-impl/android/app/AlertDialog.java @@ -18,6 +18,7 @@ public class AlertDialog extends Dialog implements DialogInterface { private native void nativeShow(long ptr); public AlertDialog(Context context) { + super(context, 0); nativePtr = nativeInit(); } @@ -25,10 +26,6 @@ public class AlertDialog extends Dialog implements DialogInterface { nativeSetTitle(nativePtr, String.valueOf(title)); } - public void setOnCancelListener(OnCancelListener onCancelListener) {} - - public void setCancelable(boolean cancelable) {} - public void setMessage(CharSequence message) { System.out.println("AlertDialog setMessage called with: '" + message + "'"); nativeSetMessage(nativePtr, String.valueOf(message)); @@ -54,17 +51,15 @@ public class AlertDialog extends Dialog implements DialogInterface { } public static class Builder { - private Context context; private AlertDialog dialog; public Builder(Context context) { System.out.println("making an AlertDialog$Builder as we speak, my word!"); - this.context = context; dialog = new AlertDialog(context); } public AlertDialog.Builder setPositiveButton(int textId, DialogInterface.OnClickListener listener) { - return setPositiveButton(context.getResources().getText(textId), listener); + return setPositiveButton(dialog.getContext().getText(textId), listener); } public AlertDialog.Builder setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener) { @@ -88,7 +83,7 @@ public class AlertDialog extends Dialog implements DialogInterface { } public AlertDialog.Builder setTitle(int title) { - return setTitle(context.getResources().getText(title)); + return setTitle(dialog.getContext().getText(title)); } public AlertDialog.Builder setMessage(CharSequence message) { diff --git a/src/api-impl/android/app/Dialog.java b/src/api-impl/android/app/Dialog.java index aa51a65f..11a54967 100644 --- a/src/api-impl/android/app/Dialog.java +++ b/src/api-impl/android/app/Dialog.java @@ -1,8 +1,36 @@ package android.app; import android.content.Context; +import android.content.DialogInterface.OnCancelListener; +import android.content.DialogInterface.OnDismissListener; +import android.view.View; public class Dialog { + + private Context context; + + public Dialog(Context context, int themeResId) { + this.context = context; + } + + public final boolean requestWindowFeature(int featureId) { + return false; + } + + public Context getContext() { + return context; + } + + public void setContentView(View view) {} + + public void setOwnerActivity(Activity activity) {} + + public void setCancelable(boolean cancelable) {} + + public void setOnCancelListener(OnCancelListener onCancelListener) {} + + public void setOnDismissListener(OnDismissListener onDismissListener) {} + public void show() { System.out.println("totally showing the Dialog " + this + " right now, most definitely doing that"); } diff --git a/src/api-impl/android/content/res/AssetManager.java b/src/api-impl/android/content/res/AssetManager.java index 465d9754..a6253be8 100644 --- a/src/api-impl/android/content/res/AssetManager.java +++ b/src/api-impl/android/content/res/AssetManager.java @@ -323,9 +323,22 @@ public final class AssetManager { break; } } + + ident = 0; + if (valueItem != null && valueItem.getValueType() == ValueType.REFERENCE) { + while (valueItem.getValueType() == ValueType.REFERENCE) { + ident = valueItem.getData(); + valueItem = null; + if (ident == 0) + break; + valueItem = tableBlockSearch(ident).pickOne().getResValue(); + if (valueItem == null) + break; + } + } if (valueItem == null) return false; - outValue.resourceId = 0; + outValue.resourceId = ident; outValue.type = valueItem.getType(); outValue.data = valueItem.getData(); outValue.assetCookie = -1; @@ -925,31 +938,20 @@ public final class AssetManager { if (valueItem.getValueType() == ValueType.REFERENCE) { while (valueItem.getValueType() == ValueType.REFERENCE) { resId = valueItem.getData(); - valueItem = null; if (resId == 0) break; - valueItem = tableBlockSearch(resId).pickOne().getResValue(); - if (valueItem == null) + entry = tableBlockSearch(resId).pickOne(); + if (entry == null || entry.getResValue() == null) break; + valueItem = entry.getResValue(); } outValues[d + AssetManager.STYLE_RESOURCE_ID] = resId; - if (valueItem != null) { - outValues[d + AssetManager.STYLE_TYPE] = valueItem.getType(); - outValues[d + AssetManager.STYLE_DATA] = valueItem.getData(); - outValues[d + AssetManager.STYLE_ASSET_COOKIE] = getCookie(valueItem); - outIndices[++outIndices[0]] = i; - } else { - outValues[d + AssetManager.STYLE_TYPE] = -1; - outValues[d + AssetManager.STYLE_ASSET_COOKIE] = -1; - } - } else { - outValues[d+AssetManager.STYLE_RESOURCE_ID] = 0; - outValues[d+AssetManager.STYLE_TYPE] = valueItem.getType(); - outValues[d+AssetManager.STYLE_DATA] = valueItem.getData(); - outValues[d+AssetManager.STYLE_ASSET_COOKIE] = getCookie(valueItem); - outIndices[++outIndices[0]] = i; } + outValues[d + AssetManager.STYLE_TYPE] = valueItem.getType(); + outValues[d + AssetManager.STYLE_DATA] = valueItem.getData(); + outValues[d + AssetManager.STYLE_ASSET_COOKIE] = getCookie(valueItem); + outIndices[++outIndices[0]] = i; } return true; } diff --git a/src/api-impl/android/content/res/TypedArray.java b/src/api-impl/android/content/res/TypedArray.java index fb74a40e..8e66e58d 100644 --- a/src/api-impl/android/content/res/TypedArray.java +++ b/src/api-impl/android/content/res/TypedArray.java @@ -314,7 +314,8 @@ public class TypedArray { return defValue; } - throw new UnsupportedOperationException("Can't convert to color: type=0x" + Integer.toHexString(type)); + Log.e(Resources.TAG, "Can't convert to color: type=0x" + Integer.toHexString(type)); + return defValue; } /** @@ -331,6 +332,8 @@ public class TypedArray { if (getValueAt(index * AssetManager.STYLE_NUM_ENTRIES, value)) { if (value.type == -1) return null; + if (value.type == TypedValue.TYPE_REFERENCE && value.data == 0) + return null; return mResources.loadColorStateList(value, value.resourceId); } return null; diff --git a/src/api-impl/android/database/DatabaseErrorHandler.java b/src/api-impl/android/database/DatabaseErrorHandler.java new file mode 100644 index 00000000..0a819546 --- /dev/null +++ b/src/api-impl/android/database/DatabaseErrorHandler.java @@ -0,0 +1,31 @@ +/* + * 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 android.database; + +import android.database.sqlite.SQLiteDatabase; + +/** + * An interface to let apps define an action to take when database corruption is detected. + */ +public interface DatabaseErrorHandler { + /** + * The method invoked when database corruption is detected. + * @param dbObj the {@link SQLiteDatabase} object representing the database on which corruption + * is detected. + */ + void onCorruption(SQLiteDatabase dbObj); +} diff --git a/src/api-impl/android/view/GestureDetector.java b/src/api-impl/android/view/GestureDetector.java new file mode 100644 index 00000000..83544ee5 --- /dev/null +++ b/src/api-impl/android/view/GestureDetector.java @@ -0,0 +1,14 @@ +package android.view; + +public class GestureDetector { + + public interface OnGestureListener { + } + + public interface OnDoubleTapListener { + } + + public static class SimpleOnGestureListener implements OnGestureListener { + + } +} diff --git a/src/api-impl/android/view/View.java b/src/api-impl/android/view/View.java index 70be3e6c..1847ba62 100644 --- a/src/api-impl/android/view/View.java +++ b/src/api-impl/android/view/View.java @@ -1201,4 +1201,31 @@ public class View extends Object { protected boolean awakenScrollBars() {return false;} public Matrix getMatrix() {return new Matrix();} + + protected static final int[] EMPTY_STATE_SET = new int[0]; + + /** + * Utility to return a default size. Uses the supplied size if the + * MeasureSpec imposed no constraints. Will get larger if allowed + * by the MeasureSpec. + * + * @param size Default size for this view + * @param measureSpec Constraints imposed by the parent + * @return The size this view should be. + */ + public static int getDefaultSize(int size, int measureSpec) { + int result = size; + int specMode = MeasureSpec.getMode(measureSpec); + int specSize = MeasureSpec.getSize(measureSpec); + switch (specMode) { + case MeasureSpec.UNSPECIFIED: + result = size; + break; + case MeasureSpec.AT_MOST: + case MeasureSpec.EXACTLY: + result = specSize; + break; + } + return result; + } } diff --git a/src/api-impl/android/view/ViewConfiguration.java b/src/api-impl/android/view/ViewConfiguration.java index 5cfacb7f..f6394ee9 100644 --- a/src/api-impl/android/view/ViewConfiguration.java +++ b/src/api-impl/android/view/ViewConfiguration.java @@ -35,4 +35,12 @@ public class ViewConfiguration { public boolean hasPermanentMenuKey() { return false; } + + public static int getDoubleTapTimeout() { + return 0; + } + + public int getScaledDoubleTapSlop() { + return 0; + } } diff --git a/src/api-impl/android/view/ViewGroup.java b/src/api-impl/android/view/ViewGroup.java index 2cf4955c..d54a9a1c 100644 --- a/src/api-impl/android/view/ViewGroup.java +++ b/src/api-impl/android/view/ViewGroup.java @@ -56,7 +56,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager { addView(child, new LayoutParams(width, height)); } - public void addView(View child, int index, LayoutParams params) { + private void addViewInternal(View child, int index, LayoutParams params) { if (child.parent == this) return; if (params != null) { @@ -67,6 +67,15 @@ public class ViewGroup extends View implements ViewParent, ViewManager { native_addView(widget, child.widget, index, params); } + public void addView(View child, int index, LayoutParams params) { + addViewInternal(child, index, params); + } + + protected boolean addViewInLayout(View child, int index, LayoutParams params) { + addViewInternal(child, index, params); + return true; + } + public void removeView(View child) { if (child.parent != this) return; diff --git a/src/api-impl/android/view/ViewPropertyAnimator.java b/src/api-impl/android/view/ViewPropertyAnimator.java index 5426b98b..b920d2e0 100644 --- a/src/api-impl/android/view/ViewPropertyAnimator.java +++ b/src/api-impl/android/view/ViewPropertyAnimator.java @@ -1,5 +1,6 @@ package android.view; +import android.animation.Animator; import android.animation.TimeInterpolator; public class ViewPropertyAnimator { @@ -9,4 +10,22 @@ public class ViewPropertyAnimator { public ViewPropertyAnimator setInterpolator(TimeInterpolator interpolator) { return this; } + + public ViewPropertyAnimator setListener(Animator.AnimatorListener listener) { + return this; + } + + public ViewPropertyAnimator alpha(float alpha) { + return this; + } + + public ViewPropertyAnimator setDuration(long duration) { + return this; + } + + public ViewPropertyAnimator setStartDelay(long duration) { + return this; + } + + public void start() {} } diff --git a/src/api-impl/android/widget/OverScroller.java b/src/api-impl/android/widget/OverScroller.java index a4c17d0f..97a31ed0 100644 --- a/src/api-impl/android/widget/OverScroller.java +++ b/src/api-impl/android/widget/OverScroller.java @@ -11,4 +11,6 @@ public class OverScroller extends ViewGroup { } public void abortAnimation () {} + + public void startScroll(int startX, int startY, int dx, int dy, int duration) {} } diff --git a/src/api-impl/meson.build b/src/api-impl/meson.build index 7ad2529c..3c141194 100644 --- a/src/api-impl/meson.build +++ b/src/api-impl/meson.build @@ -87,6 +87,7 @@ hax_jar = jar('hax', [ 'android/content/SharedPreferences.java', 'android/database/Cursor.java', 'android/database/ContentObserver.java', + 'android/database/DatabaseErrorHandler.java', 'android/database/DataSetObservable.java', 'android/database/DataSetObserver.java', 'android/database/Observable.java', @@ -248,6 +249,7 @@ hax_jar = jar('hax', [ 'android/view/ContextThemeWrapper.java', 'android/view/Choreographer.java', 'android/view/Display.java', + 'android/view/GestureDetector.java', 'android/view/Gravity.java', 'android/view/InflateException.java', 'android/view/InputDevice.java',