add Java APIs needed for WhatsApp MainActivity and ConversationActivity

This commit is contained in:
Julian Winkler
2024-08-25 11:20:01 +02:00
parent 9d8e091799
commit c492e1f03f
74 changed files with 903 additions and 69 deletions

View File

@@ -299,9 +299,11 @@ public class LayoutInflater {
// Inflate all children.
rInflate(childParser, view, childAttrs, true);
int id = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "id", 0);
TypedArray ta = context.obtainStyledAttributes(attrs, new int[]{com.android.internal.R.attr.id});
int id = ta.getResourceId(0, 0);
if (id != 0)
view.setId(id);
ta.recycle();
group.addView(view);
}

View File

@@ -31,4 +31,6 @@ public interface Menu {
public int size();
public boolean hasVisibleItems();
public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes);
}

View File

@@ -56,4 +56,6 @@ public interface MenuItem {
public MenuItem setShowAsActionFlags(int action);
public MenuItem setAlphabeticShortcut(char alphaChar);
}

View File

@@ -1651,8 +1651,8 @@ public final class MotionEvent extends InputEvent {
throw new IllegalArgumentException("other motion event must not be null");
}
MotionEvent ev = obtain();
ev.mNativePtr = nativeCopy(ev.mNativePtr, other.mNativePtr, false /*keepHistory*/);
MotionEvent ev = obtain(other);
// ev.mNativePtr = nativeCopy(ev.mNativePtr, other.mNativePtr, false /*keepHistory*/);
return ev;
}

View File

@@ -0,0 +1,16 @@
package android.view;
import android.content.Context;
public class ScaleGestureDetector {
public interface OnScaleGestureListener {}
public ScaleGestureDetector(Context context, OnScaleGestureListener listener) {}
public void setQuickScaleEnabled(boolean enabled) {}
public boolean onTouchEvent(MotionEvent event) {
return false;
}
}

View File

@@ -4,4 +4,6 @@ public interface SubMenu extends Menu {
public MenuItem getItem();
public void clearHeader();
}

View File

@@ -30,6 +30,7 @@ import android.view.animation.Animation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
class WindowId {}
@@ -652,6 +653,8 @@ public class View implements Drawable.Callback {
*/
// void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo);
}
public interface OnDragListener {}
// --- end of interfaces
// --- subclasses
@@ -1091,7 +1094,7 @@ public class View implements Drawable.Callback {
}
public void setPadding(int left, int top, int right, int bottom) {}
public void setBackgroundResource(int resid) {
setBackgroundDrawable(getResources().getDrawable(resid));
setBackgroundDrawable(resid == 0 ? null : getResources().getDrawable(resid));
}
public void getHitRect(Rect outRect) {
@@ -1823,4 +1826,27 @@ public class View implements Drawable.Callback {
public void setNestedScrollingEnabled(boolean enabled) {}
public void setTouchDelegate(TouchDelegate touchDelegate) {}
public void setOnDragListener(OnDragListener onDragListener) {}
public void setTransitionName(String transitionName) {}
public Animation getAnimation() {return null;}
public ViewOverlay getOverlay() {
return new ViewOverlay();
}
public void cancelLongPress() {}
public int getTextAlignment() {return 0;}
public float getY() {return 0.f;}
public View findViewWithTag(Object tag) {
if (Objects.equals(tag, this.tag))
return this;
else
return null;
}
}

View File

@@ -1,5 +1,10 @@
package android.view;
import android.animation.Animator;
public class ViewAnimationUtils {
public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) {
return new Animator();
}
}

View File

@@ -7,6 +7,7 @@ import android.content.res.TypedArray;
import android.util.AttributeSet;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Objects;
public class ViewGroup extends View implements ViewParent, ViewManager {
public ArrayList<View> children;
@@ -363,6 +364,24 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
removeView(view);
}
public void setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus) {}
public void setClipChildren(boolean clipChildren) {}
public void dispatchSetPressed(boolean pressed) {}
@Override
public View findViewWithTag(Object tag) {
if (Objects.equals(tag, getTag()))
return this;
for (View child: children) {
View result = child.findViewWithTag(tag);
if (result != null)
return result;
}
return null;
}
public static class LayoutParams {
public static final int FILL_PARENT = -1;
public static final int MATCH_PARENT = -1;
@@ -442,6 +461,16 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
a.recycle();
}
public MarginLayoutParams(ViewGroup.MarginLayoutParams source) {
super();
width = source.width;
height = source.height;
leftMargin = source.leftMargin;
topMargin = source.topMargin;
rightMargin = source.rightMargin;
bottomMargin = source.bottomMargin;
}
public void setMargins(int left, int top, int right, int bottom) {
leftMargin = left;
topMargin = top;

View File

@@ -0,0 +1,8 @@
package android.view;
import android.graphics.drawable.Drawable;
public class ViewOverlay {
public void add(Drawable drawable) {}
}

View File

@@ -34,4 +34,13 @@ public class ViewStub extends View {
return view;
}
public void setLayoutResource(int layoutResource) {
this.layoutResource = layoutResource;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(0, 0);
}
}

View File

@@ -27,9 +27,11 @@ public class Window {
public View contentView;
private Window.Callback callback;
private Context context;
public Window(Window.Callback callback) {
public Window(Context context, Window.Callback callback) {
this.callback = callback;
this.context = context;
contentView = new ViewGroup(Context.this_application);
contentView.setId(android.R.id.content);
}
@@ -122,4 +124,12 @@ public class Window {
public void setBackgroundDrawableResource(int resId) {}
public int getStatusBarColor() { return 0xFFFF0000; }
public Context getContext() {
return context;
}
public boolean hasFeature(int featureId) {
return false;
}
}

View File

@@ -11,6 +11,7 @@ public interface WindowManager {
public int x;
public int y;
public int windowAnimations;
public int flags;
public LayoutParams(int w, int h, int type, int flags, int format) {
super(w, h);

View File

@@ -1,5 +1,12 @@
package android.view.animation;
public class AccelerateDecelerateInterpolator {
import android.animation.TimeInterpolator;
public class AccelerateDecelerateInterpolator implements TimeInterpolator {
@Override
public float getInterpolation(float input) {
return input;
}
}

View File

@@ -0,0 +1,8 @@
package android.view.animation;
public class AnimationSet extends Animation {
public AnimationSet(boolean shareInterpolator) {}
public void addAnimation(Animation animation) {}
}

View File

@@ -0,0 +1,6 @@
package android.view.animation;
public class OvershootInterpolator {
public OvershootInterpolator(float overshoot) {}
}

View File

@@ -0,0 +1,6 @@
package android.view.animation;
public class ScaleAnimation extends Animation {
public ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) {}
}

View File

@@ -0,0 +1,6 @@
package android.view.animation;
public class TranslateAnimation extends Animation {
public TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue) {}
}

View File

@@ -1,5 +1,8 @@
package android.view.inputmethod;
import java.util.Collections;
import java.util.List;
import android.os.IBinder;
import android.view.View;
@@ -13,4 +16,8 @@ public class InputMethodManager {
public boolean isActive(View view) {return false;}
public List/*<InputMethodInfo>*/ getEnabledInputMethodList() {
return Collections.emptyList();
}
}