You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
some fixes to make NewPipe not crash when layouting
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
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;}
|
||||
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() {
|
||||
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));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -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() {}
|
||||
}
|
||||
|
||||
@@ -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) {}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user