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
src/api-impl: fix up code style, mainly for code imported from AOSP
used the following (plus manual edits):
`clang-format --style="{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 0}`
This commit is contained in:
@@ -1,31 +1,27 @@
|
||||
package android.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.widget.TextView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerImpl;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
import android.widget.TextView;
|
||||
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
public class Activity extends Context {
|
||||
LayoutInflater layout_inflater;
|
||||
@@ -64,7 +60,7 @@ public class Activity extends Context {
|
||||
|
||||
public View root_view;
|
||||
|
||||
public final Application getApplication () {
|
||||
public final Application getApplication() {
|
||||
return (Application)getApplicationContext();
|
||||
}
|
||||
|
||||
@@ -86,10 +82,10 @@ public class Activity extends Context {
|
||||
}
|
||||
|
||||
public int getRequestedOrientation() {
|
||||
return requested_orientation;
|
||||
return requested_orientation;
|
||||
}
|
||||
|
||||
public void setRequestedOrientation (int orientation) {
|
||||
public void setRequestedOrientation(int orientation) {
|
||||
requested_orientation = orientation;
|
||||
}
|
||||
|
||||
@@ -146,7 +142,7 @@ public class Activity extends Context {
|
||||
}
|
||||
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
System.out.println("- onWindowFocusChanged - yay! (hasFocus: "+hasFocus+")");
|
||||
System.out.println("- onWindowFocusChanged - yay! (hasFocus: " + hasFocus + ")");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -162,7 +158,7 @@ public class Activity extends Context {
|
||||
|
||||
/* --- */
|
||||
|
||||
public void setContentView(int layoutResID) throws Exception {
|
||||
public void setContentView(int layoutResID) throws Exception {
|
||||
System.out.println("- setContentView - yay!");
|
||||
|
||||
XmlResourceParser xpp = Context.this_application.getResources().getLayout(layoutResID);
|
||||
@@ -183,13 +179,13 @@ public class Activity extends Context {
|
||||
w.showAll();
|
||||
|
||||
|
||||
w.connect(new Window.DeleteEvent() {
|
||||
public boolean onDeleteEvent(Widget source, Event event) {
|
||||
Gtk.mainQuit();
|
||||
return false;
|
||||
}
|
||||
});*/
|
||||
}
|
||||
w.connect(new Window.DeleteEvent() {
|
||||
public boolean onDeleteEvent(Widget source, Event event) {
|
||||
Gtk.mainQuit();
|
||||
return false;
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
|
||||
setContentView(view);
|
||||
@@ -204,7 +200,7 @@ public class Activity extends Context {
|
||||
View view = View.view_by_id.get(id);
|
||||
System.out.println("- findViewById - found this: " + view);
|
||||
|
||||
return (T) view;
|
||||
return (T)view;
|
||||
}
|
||||
|
||||
public void invalidateOptionsMenu() {
|
||||
@@ -215,14 +211,14 @@ public class Activity extends Context {
|
||||
return this.window;
|
||||
}
|
||||
|
||||
public final void runOnUiThread(Runnable action) {
|
||||
action.run(); // FIXME: running synchronously for now
|
||||
}
|
||||
public final void runOnUiThread(Runnable action) {
|
||||
action.run(); // FIXME: running synchronously for now
|
||||
}
|
||||
|
||||
protected void onActivityResult (int requestCode, int resultCode, Intent data) {}
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {}
|
||||
|
||||
public void startActivityForResult (Intent intent, int requestCode) {
|
||||
System.out.println("startActivityForResult("+intent+", "+requestCode+") called, but we don't currently support multiple activities");
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
System.out.println("startActivityForResult(" + intent + ", " + requestCode + ") called, but we don't currently support multiple activities");
|
||||
onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent()); // RESULT_CANCELED is the only pre-defined return value, so hopefully it works out for us
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,37 +6,37 @@ import android.view.View;
|
||||
|
||||
public class AlertDialog extends Dialog {
|
||||
public static class Builder {
|
||||
public Builder(Context context){
|
||||
public Builder(Context context) {
|
||||
System.out.println("making an AlertDialog$Builder as we speak, my word!");
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setPositiveButton (int textId, DialogInterface.OnClickListener listener) {
|
||||
public AlertDialog.Builder setPositiveButton(int textId, DialogInterface.OnClickListener listener) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setPositiveButton (CharSequence text, DialogInterface.OnClickListener listener) {
|
||||
public AlertDialog.Builder setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setCancelable (boolean cancelable) {
|
||||
public AlertDialog.Builder setCancelable(boolean cancelable) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setIcon (int iconId) {
|
||||
public AlertDialog.Builder setIcon(int iconId) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setTitle (CharSequence title) {
|
||||
System.out.println("AlertDialog.Builder setTitle called with: '"+title+"'");
|
||||
public AlertDialog.Builder setTitle(CharSequence title) {
|
||||
System.out.println("AlertDialog.Builder setTitle called with: '" + title + "'");
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setMessage (CharSequence message) {
|
||||
System.out.println("AlertDialog.Builder setMessage called with: '"+message+"'");
|
||||
public AlertDialog.Builder setMessage(CharSequence message) {
|
||||
System.out.println("AlertDialog.Builder setMessage called with: '" + message + "'");
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setView (View view) {
|
||||
public AlertDialog.Builder setView(View view) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@ import android.content.Context;
|
||||
|
||||
public class Dialog {
|
||||
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");
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
System.out.println("totally dismissing the Dialog "+this+" right now, which was most definitely being shown just a moment ago");
|
||||
System.out.println("totally dismissing the Dialog " + this + " right now, which was most definitely being shown just a moment ago");
|
||||
}
|
||||
|
||||
public class Builder {
|
||||
public Builder(Context context){
|
||||
public Builder(Context context) {
|
||||
System.out.println("making a Dialog$Builder as we speak, my word!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Configuration;
|
||||
//import android.graphics.PixelFormat;
|
||||
// import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
@@ -34,15 +34,13 @@ import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.view.WindowManager;
|
||||
//import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||
import com.reandroid.arsc.chunk.xml.ResXmlAttribute;
|
||||
import com.reandroid.arsc.chunk.xml.ResXmlElement;
|
||||
// import android.view.inputmethod.InputMethodManager;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Convenience for implementing an activity that will be implemented
|
||||
@@ -62,7 +60,7 @@ import com.reandroid.arsc.chunk.xml.ResXmlElement;
|
||||
* {@sample development/ndk/platforms/android-9/samples/native-activity/jni/main.c all}
|
||||
*/
|
||||
public class NativeActivity extends Activity implements SurfaceHolder.Callback,
|
||||
InputQueue.Callback, OnGlobalLayoutListener {
|
||||
InputQueue.Callback, OnGlobalLayoutListener {
|
||||
/**
|
||||
* Optional meta-that can be in the manifest for this component, specifying
|
||||
* the name of the native shared library to load. If not specified,
|
||||
@@ -81,7 +79,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
|
||||
private static final String KEY_NATIVE_SAVED_STATE = "android:native_state";
|
||||
|
||||
private NativeContentView mNativeContentView;
|
||||
// private InputMethodManager mIMM;
|
||||
// private InputMethodManager mIMM;
|
||||
|
||||
private long mNativeHandle;
|
||||
|
||||
@@ -99,8 +97,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
|
||||
private boolean mDestroyed;
|
||||
|
||||
private native long loadNativeCode(String path, String funcname, MessageQueue queue,
|
||||
String internalDataPath, String obbPath, String externalDataPath, int sdkVersion,
|
||||
AssetManager assetMgr, byte[] savedState);
|
||||
String internalDataPath, String obbPath, String externalDataPath, int sdkVersion,
|
||||
AssetManager assetMgr, byte[] savedState);
|
||||
private native void unloadNativeCode(long handle);
|
||||
|
||||
private native void onStartNative(long handle);
|
||||
@@ -113,7 +111,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
|
||||
private native void onWindowFocusChangedNative(long handle, boolean focused);
|
||||
private native void onSurfaceCreatedNative(long handle, Surface surface);
|
||||
private native void onSurfaceChangedNative(long handle, Surface surface,
|
||||
int format, int width, int height);
|
||||
int format, int width, int height);
|
||||
private native void onSurfaceRedrawNeededNative(long handle, Surface surface);
|
||||
private native void onSurfaceDestroyedNative(long handle);
|
||||
private native void onInputQueueCreatedNative(long handle, long queuePtr);
|
||||
@@ -128,7 +126,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
|
||||
}
|
||||
|
||||
public NativeContentView(Context context, AttributeSet attrs) {
|
||||
super(context/*, attrs*/);
|
||||
super(context /*, attrs*/);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,22 +167,22 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
|
||||
|
||||
// parse AndroidManifest.xml to get name and entry of native lib
|
||||
try (InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml")) {
|
||||
for (ResXmlElement activity: AndroidManifestBlock.load(inStream).listActivities()) {
|
||||
for (ResXmlElement activity : AndroidManifestBlock.load(inStream).listActivities()) {
|
||||
if (!getClass().getName().equals(activity.searchAttributeByResourceId(AndroidManifestBlock.ID_name).getValueAsString())) {
|
||||
continue;
|
||||
}
|
||||
for (ResXmlElement metaData: activity.listElements(AndroidManifestBlock.TAG_meta_data)) {
|
||||
ResXmlAttribute name = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_name);
|
||||
ResXmlAttribute value = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_value);
|
||||
if (name == null || value == null){
|
||||
continue;
|
||||
}
|
||||
if (META_DATA_LIB_NAME.equals(name.getValueAsString())){
|
||||
libname = value.getValueAsString();
|
||||
}
|
||||
if (META_DATA_FUNC_NAME.equals(name.getValueAsString())){
|
||||
funcname = value.getValueAsString();
|
||||
}
|
||||
for (ResXmlElement metaData : activity.listElements(AndroidManifestBlock.TAG_meta_data)) {
|
||||
ResXmlAttribute name = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_name);
|
||||
ResXmlAttribute value = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_value);
|
||||
if (name == null || value == null) {
|
||||
continue;
|
||||
}
|
||||
if (META_DATA_LIB_NAME.equals(name.getValueAsString())) {
|
||||
libname = value.getValueAsString();
|
||||
}
|
||||
if (META_DATA_FUNC_NAME.equals(name.getValueAsString())) {
|
||||
funcname = value.getValueAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -194,7 +192,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
|
||||
String path = null;
|
||||
|
||||
File libraryFile = new File(new File(android.os.Environment.getExternalStorageDirectory(), "lib"),
|
||||
System.mapLibraryName(libname));
|
||||
System.mapLibraryName(libname));
|
||||
if (libraryFile.exists()) {
|
||||
path = libraryFile.getPath();
|
||||
}
|
||||
@@ -204,12 +202,13 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
|
||||
}
|
||||
|
||||
byte[] nativeSavedState = savedInstanceState != null
|
||||
? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
|
||||
? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE)
|
||||
: null;
|
||||
|
||||
mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(),
|
||||
getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()),
|
||||
getAbsolutePath(getExternalFilesDir(null)),
|
||||
Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
|
||||
getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()),
|
||||
getAbsolutePath(getExternalFilesDir(null)),
|
||||
Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
|
||||
|
||||
if (mNativeHandle == 0) {
|
||||
throw new IllegalArgumentException("Unable to load native library: " + path);
|
||||
|
||||
@@ -13,9 +13,8 @@ public class PendingIntent {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void send (Context context, int code, Intent intent) {}
|
||||
public void send(Context context, int code, Intent intent) {}
|
||||
|
||||
public class CanceledException extends Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user