mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-05-09 12:07:45 +03:00
some fixes to make NewPipe not crash when layouting
This commit is contained in:
parent
1474d8d3e1
commit
28cd0006bc
13 changed files with 171 additions and 29 deletions
|
@ -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)
|
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")));
|
GtkWidget *widget = GTK_WIDGET(_PTR(_GET_LONG_FIELD(this, "widget")));
|
||||||
|
if (!on_click_listener)
|
||||||
|
return;
|
||||||
|
|
||||||
JavaVM *jvm;
|
JavaVM *jvm;
|
||||||
(*env)->GetJavaVM(env, &jvm);
|
(*env)->GetJavaVM(env, &jvm);
|
||||||
|
|
|
@ -18,6 +18,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
|
||||||
private native void nativeShow(long ptr);
|
private native void nativeShow(long ptr);
|
||||||
|
|
||||||
public AlertDialog(Context context) {
|
public AlertDialog(Context context) {
|
||||||
|
super(context, 0);
|
||||||
nativePtr = nativeInit();
|
nativePtr = nativeInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +26,6 @@ public class AlertDialog extends Dialog implements DialogInterface {
|
||||||
nativeSetTitle(nativePtr, String.valueOf(title));
|
nativeSetTitle(nativePtr, String.valueOf(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnCancelListener(OnCancelListener onCancelListener) {}
|
|
||||||
|
|
||||||
public void setCancelable(boolean cancelable) {}
|
|
||||||
|
|
||||||
public void setMessage(CharSequence message) {
|
public void setMessage(CharSequence message) {
|
||||||
System.out.println("AlertDialog setMessage called with: '" + message + "'");
|
System.out.println("AlertDialog setMessage called with: '" + message + "'");
|
||||||
nativeSetMessage(nativePtr, String.valueOf(message));
|
nativeSetMessage(nativePtr, String.valueOf(message));
|
||||||
|
@ -54,17 +51,15 @@ public class AlertDialog extends Dialog implements DialogInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private Context context;
|
|
||||||
private AlertDialog dialog;
|
private AlertDialog dialog;
|
||||||
|
|
||||||
public Builder(Context context) {
|
public Builder(Context context) {
|
||||||
System.out.println("making an AlertDialog$Builder as we speak, my word!");
|
System.out.println("making an AlertDialog$Builder as we speak, my word!");
|
||||||
this.context = context;
|
|
||||||
dialog = new AlertDialog(context);
|
dialog = new AlertDialog(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlertDialog.Builder setPositiveButton(int textId, DialogInterface.OnClickListener listener) {
|
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) {
|
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) {
|
public AlertDialog.Builder setTitle(int title) {
|
||||||
return setTitle(context.getResources().getText(title));
|
return setTitle(dialog.getContext().getText(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlertDialog.Builder setMessage(CharSequence message) {
|
public AlertDialog.Builder setMessage(CharSequence message) {
|
||||||
|
|
|
@ -1,8 +1,36 @@
|
||||||
package android.app;
|
package android.app;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface.OnCancelListener;
|
||||||
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
public class Dialog {
|
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() {
|
public void show() {
|
||||||
System.out.println("totally showing the Dialog " + this + " right now, most definitely doing that");
|
System.out.println("totally showing the Dialog " + this + " right now, most definitely doing that");
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,9 +323,22 @@ public final class AssetManager {
|
||||||
break;
|
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)
|
if (valueItem == null)
|
||||||
return false;
|
return false;
|
||||||
outValue.resourceId = 0;
|
outValue.resourceId = ident;
|
||||||
outValue.type = valueItem.getType();
|
outValue.type = valueItem.getType();
|
||||||
outValue.data = valueItem.getData();
|
outValue.data = valueItem.getData();
|
||||||
outValue.assetCookie = -1;
|
outValue.assetCookie = -1;
|
||||||
|
@ -925,31 +938,20 @@ public final class AssetManager {
|
||||||
if (valueItem.getValueType() == ValueType.REFERENCE) {
|
if (valueItem.getValueType() == ValueType.REFERENCE) {
|
||||||
while (valueItem.getValueType() == ValueType.REFERENCE) {
|
while (valueItem.getValueType() == ValueType.REFERENCE) {
|
||||||
resId = valueItem.getData();
|
resId = valueItem.getData();
|
||||||
valueItem = null;
|
|
||||||
if (resId == 0)
|
if (resId == 0)
|
||||||
break;
|
break;
|
||||||
valueItem = tableBlockSearch(resId).pickOne().getResValue();
|
entry = tableBlockSearch(resId).pickOne();
|
||||||
if (valueItem == null)
|
if (entry == null || entry.getResValue() == null)
|
||||||
break;
|
break;
|
||||||
|
valueItem = entry.getResValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
outValues[d + AssetManager.STYLE_RESOURCE_ID] = resId;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,8 @@ public class TypedArray {
|
||||||
return defValue;
|
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 (getValueAt(index * AssetManager.STYLE_NUM_ENTRIES, value)) {
|
||||||
if (value.type == -1)
|
if (value.type == -1)
|
||||||
return null;
|
return null;
|
||||||
|
if (value.type == TypedValue.TYPE_REFERENCE && value.data == 0)
|
||||||
|
return null;
|
||||||
return mResources.loadColorStateList(value, value.resourceId);
|
return mResources.loadColorStateList(value, value.resourceId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
31
src/api-impl/android/database/DatabaseErrorHandler.java
Normal file
31
src/api-impl/android/database/DatabaseErrorHandler.java
Normal file
|
@ -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);
|
||||||
|
}
|
14
src/api-impl/android/view/GestureDetector.java
Normal file
14
src/api-impl/android/view/GestureDetector.java
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package android.view;
|
||||||
|
|
||||||
|
public class GestureDetector {
|
||||||
|
|
||||||
|
public interface OnGestureListener {
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnDoubleTapListener {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SimpleOnGestureListener implements OnGestureListener {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1201,4 +1201,31 @@ public class View extends Object {
|
||||||
|
|
||||||
protected boolean awakenScrollBars() {return false;}
|
protected boolean awakenScrollBars() {return false;}
|
||||||
public Matrix getMatrix() {return new Matrix();}
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,4 +35,12 @@ public class ViewConfiguration {
|
||||||
public boolean hasPermanentMenuKey() {
|
public boolean hasPermanentMenuKey() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getDoubleTapTimeout() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getScaledDoubleTapSlop() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||||
addView(child, new LayoutParams(width, height));
|
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)
|
if (child.parent == this)
|
||||||
return;
|
return;
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
|
@ -67,6 +67,15 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||||
native_addView(widget, child.widget, index, params);
|
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) {
|
public void removeView(View child) {
|
||||||
if (child.parent != this)
|
if (child.parent != this)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
import android.animation.TimeInterpolator;
|
import android.animation.TimeInterpolator;
|
||||||
|
|
||||||
public class ViewPropertyAnimator {
|
public class ViewPropertyAnimator {
|
||||||
|
@ -9,4 +10,22 @@ public class ViewPropertyAnimator {
|
||||||
public ViewPropertyAnimator setInterpolator(TimeInterpolator interpolator) {
|
public ViewPropertyAnimator setInterpolator(TimeInterpolator interpolator) {
|
||||||
return this;
|
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() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,6 @@ public class OverScroller extends ViewGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void abortAnimation () {}
|
public void abortAnimation () {}
|
||||||
|
|
||||||
|
public void startScroll(int startX, int startY, int dx, int dy, int duration) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@ hax_jar = jar('hax', [
|
||||||
'android/content/SharedPreferences.java',
|
'android/content/SharedPreferences.java',
|
||||||
'android/database/Cursor.java',
|
'android/database/Cursor.java',
|
||||||
'android/database/ContentObserver.java',
|
'android/database/ContentObserver.java',
|
||||||
|
'android/database/DatabaseErrorHandler.java',
|
||||||
'android/database/DataSetObservable.java',
|
'android/database/DataSetObservable.java',
|
||||||
'android/database/DataSetObserver.java',
|
'android/database/DataSetObserver.java',
|
||||||
'android/database/Observable.java',
|
'android/database/Observable.java',
|
||||||
|
@ -248,6 +249,7 @@ hax_jar = jar('hax', [
|
||||||
'android/view/ContextThemeWrapper.java',
|
'android/view/ContextThemeWrapper.java',
|
||||||
'android/view/Choreographer.java',
|
'android/view/Choreographer.java',
|
||||||
'android/view/Display.java',
|
'android/view/Display.java',
|
||||||
|
'android/view/GestureDetector.java',
|
||||||
'android/view/Gravity.java',
|
'android/view/Gravity.java',
|
||||||
'android/view/InflateException.java',
|
'android/view/InflateException.java',
|
||||||
'android/view/InputDevice.java',
|
'android/view/InputDevice.java',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue