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
add more Java APIs needed for OctoDroid
This commit is contained in:
@@ -34,6 +34,7 @@ public class Typeface {
|
||||
public static final int BOLD_ITALIC = 3;
|
||||
|
||||
public long skia_typeface = 0;
|
||||
public long native_instance = 0; // directly accessed by androidx
|
||||
|
||||
public static Typeface createFromAsset(AssetManager mgr, String path) {
|
||||
return DEFAULT;
|
||||
|
||||
@@ -22,4 +22,9 @@ public class ColorDrawable extends Drawable {
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.drawRect(getBounds(), paint);
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
paint.setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ public class Drawable {
|
||||
public abstract Drawable newDrawable(Resources res);
|
||||
|
||||
public abstract Drawable newDrawable();
|
||||
|
||||
public abstract int getChangingConfigurations();
|
||||
}
|
||||
|
||||
public void setBounds(int left, int top, int right, int bottom) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package android.graphics.drawable;
|
||||
|
||||
public class TransitionDrawable extends Drawable {
|
||||
|
||||
public TransitionDrawable(Drawable[] layers) {}
|
||||
|
||||
public void setCrossFadeEnabled(boolean enabled) {}
|
||||
|
||||
public void startTransition(int duration) {}
|
||||
}
|
||||
@@ -39,4 +39,8 @@ public class Parcel {
|
||||
public int dataPosition() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void writeParcelable(Parcelable p, int flags) {
|
||||
System.out.println("Parcel.writeParcelable(" + p + ", " + flags + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package android.text;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class Html {
|
||||
|
||||
public static interface ImageGetter {
|
||||
public Drawable getDrawable(String source);
|
||||
}
|
||||
|
||||
public static Spanned fromHtml(String source) {
|
||||
return new SpannableString(source.replace("<br/>", "\n")
|
||||
.replace("<br>", "\n")
|
||||
|
||||
@@ -330,4 +330,12 @@ public class TextUtils {
|
||||
private static Object sLock = new Object();
|
||||
|
||||
private static char[] sTemp = null;
|
||||
|
||||
public static int getTrimmedLength(CharSequence s) {
|
||||
return s.toString().trim().length();
|
||||
}
|
||||
|
||||
public static String htmlEncode(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
12
src/api-impl/android/text/format/DateUtils.java
Normal file
12
src/api-impl/android/text/format/DateUtils.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package android.text.format;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class DateUtils {
|
||||
|
||||
public static CharSequence getRelativeTimeSpanString(Context context, long millis, boolean withPreposition) {
|
||||
return new Date(millis).toString();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,18 @@ import android.content.Context;
|
||||
public class Formatter {
|
||||
|
||||
public static String formatShortFileSize(Context context, long size) {
|
||||
return String.valueOf(size);
|
||||
return formatFileSize(context, size);
|
||||
}
|
||||
|
||||
public static String formatFileSize(Context context, long size) {
|
||||
if (size > 1024 * 1024 * 1024) {
|
||||
return String.format("%.1f GiB", size / 1024.0 / 1024.0 / 1024.0);
|
||||
} else if (size > 1024 * 1024) {
|
||||
return String.format("%.1f MiB", size / 1024.0 / 1024.0);
|
||||
} else if (size > 1024) {
|
||||
return String.format("%.1f KiB", size / 1024.0);
|
||||
} else {
|
||||
return String.format("%d B", size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,17 @@ import android.graphics.drawable.Drawable;
|
||||
|
||||
public class ImageSpan extends DynamicDrawableSpan {
|
||||
|
||||
public ImageSpan(Drawable d) {}
|
||||
private Drawable drawable;
|
||||
|
||||
public ImageSpan(Drawable d) {
|
||||
drawable = d;
|
||||
}
|
||||
|
||||
public ImageSpan(Drawable d, String source) {
|
||||
drawable = d;
|
||||
}
|
||||
|
||||
public Drawable getDrawable() {
|
||||
return drawable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,11 @@ public class LayoutInflater {
|
||||
try { // FIXME ugly
|
||||
return createView(name, "android.view.", attrs);
|
||||
} catch (java.lang.ClassNotFoundException e) {
|
||||
try {
|
||||
return createView(name, "android.widget.", attrs);
|
||||
} catch (java.lang.ClassNotFoundException e1) {
|
||||
return createView(name, "android.webkit.", attrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,4 +52,8 @@ public interface MenuItem {
|
||||
|
||||
public MenuItem setIcon(Drawable icon);
|
||||
|
||||
public boolean isChecked();
|
||||
|
||||
public MenuItem setShowAsActionFlags(int action);
|
||||
|
||||
}
|
||||
9
src/api-impl/android/view/TouchDelegate.java
Normal file
9
src/api-impl/android/view/TouchDelegate.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package android.view;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
public class TouchDelegate {
|
||||
|
||||
public TouchDelegate(Rect bounds, View delegate) {
|
||||
}
|
||||
}
|
||||
@@ -1821,4 +1821,6 @@ public class View implements Drawable.Callback {
|
||||
public void setVerticalScrollbarPosition(int position) {}
|
||||
|
||||
public void setNestedScrollingEnabled(boolean enabled) {}
|
||||
|
||||
public void setTouchDelegate(TouchDelegate touchDelegate) {}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package android.webkit;
|
||||
|
||||
public class WebSettings {
|
||||
|
||||
public static enum LayoutAlgorithm {
|
||||
NORMAL,
|
||||
}
|
||||
|
||||
public String getUserAgentString() {
|
||||
return "GDPR VIOLATION";
|
||||
}
|
||||
@@ -16,4 +21,20 @@ public class WebSettings {
|
||||
public void setGeolocationEnabled(boolean enabled) {}
|
||||
|
||||
public void setCacheMode(int dummy) {}
|
||||
|
||||
public void setLayoutAlgorithm(LayoutAlgorithm layoutAlgorithm) {}
|
||||
|
||||
public void setAllowFileAccess(boolean allowFileAccess) {}
|
||||
|
||||
public void setBuiltInZoomControls(boolean builtInZoomControls) {}
|
||||
|
||||
public void setDisplayZoomControls(boolean displayZoomControls) {}
|
||||
|
||||
public void setLoadsImagesAutomatically(boolean loadsImagesAutomatically) {}
|
||||
|
||||
public void setSupportZoom(boolean supportZoom) {}
|
||||
|
||||
public void setUseWideViewPort(boolean useWideViewPort) {}
|
||||
|
||||
public void setTextZoom(int textZoom) {}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package android.webkit;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
// the only reason we need to implement this is that some app developers are such scumbags that they try to use this for tracking purposes
|
||||
@@ -9,6 +10,10 @@ public class WebView extends View {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public WebView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public WebSettings getSettings() {
|
||||
return new WebSettings();
|
||||
}
|
||||
@@ -32,4 +37,8 @@ public class WebView extends View {
|
||||
public void loadUrl(String url) {}
|
||||
|
||||
public void stopLoading() {}
|
||||
|
||||
public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl) {
|
||||
System.out.println("loadDataWithBaseURL(" + baseUrl + ", " + data + ", " + mimeType + ", " + encoding + ", " + historyUrl + ") called");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class AutoCompleteTextView extends EditText {
|
||||
@@ -16,4 +17,26 @@ public class AutoCompleteTextView extends EditText {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
public void setDropDownBackgroundDrawable(Drawable drawable) {}
|
||||
|
||||
public int getThreshold() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {}
|
||||
|
||||
public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener) {}
|
||||
|
||||
public int getDropDownAnchor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setAdapter(ListAdapter adapter) {}
|
||||
|
||||
public void setThreshold(int threshold) {}
|
||||
|
||||
public int getImeOptions() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
14
src/api-impl/android/widget/MultiAutoCompleteTextView.java
Normal file
14
src/api-impl/android/widget/MultiAutoCompleteTextView.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class MultiAutoCompleteTextView extends AutoCompleteTextView {
|
||||
|
||||
public static interface Tokenizer {}
|
||||
|
||||
public MultiAutoCompleteTextView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void setTokenizer(Tokenizer tokenizer) {}
|
||||
}
|
||||
@@ -444,8 +444,7 @@ public class PopupMenu {
|
||||
|
||||
@Override
|
||||
public Drawable getIcon() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getIcon'");
|
||||
return new Drawable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -476,6 +475,18 @@ public class PopupMenu {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'setOnActionExpandListener'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'isChecked'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem setShowAsActionFlags(int action) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'setShowAsActionFlags'");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import android.text.method.TransformationMethod;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ActionMode;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
@@ -292,4 +293,8 @@ public class TextView extends View {
|
||||
public void nullLayouts() {}
|
||||
|
||||
public void setLinkTextColor(int color) {}
|
||||
|
||||
public void setCustomSelectionActionModeCallback(ActionMode.Callback actionModeCallback) {}
|
||||
|
||||
public int getExtendedPaddingTop() {return 0;}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user