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: add misc stubs, fix indentation
This commit is contained in:
@@ -3,6 +3,7 @@ package android.app;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -116,6 +117,15 @@ public class Activity extends Context {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onLowMemory() {
|
||||||
|
}
|
||||||
|
|
||||||
/* --- */
|
/* --- */
|
||||||
|
|
||||||
public void setContentView(int layoutResID) throws Exception {
|
public void setContentView(int layoutResID) throws Exception {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
public class Context extends Object {
|
public class Context extends Object {
|
||||||
private final static String TAG = "Context";
|
private final static String TAG = "Context";
|
||||||
|
|
||||||
static AssetManager assets;
|
static AssetManager assets;
|
||||||
static DisplayMetrics dm;
|
static DisplayMetrics dm;
|
||||||
@@ -47,6 +47,7 @@ public class Context extends Object {
|
|||||||
File data_dir = null;
|
File data_dir = null;
|
||||||
File prefs_dir = null;
|
File prefs_dir = null;
|
||||||
File files_dir = null;
|
File files_dir = null;
|
||||||
|
File obb_dir = null;
|
||||||
File cache_dir = null;
|
File cache_dir = null;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -105,7 +106,7 @@ public class Context extends Object {
|
|||||||
return new Intent();
|
return new Intent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Looper getMainLooper() {
|
public Looper getMainLooper() {
|
||||||
System.out.println("returning the main Looper, most definitely doing just that!");
|
System.out.println("returning the main Looper, most definitely doing just that!");
|
||||||
return new Looper();
|
return new Looper();
|
||||||
}
|
}
|
||||||
@@ -130,62 +131,73 @@ public class Context extends Object {
|
|||||||
return assets;
|
return assets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private File makeFilename(File base, String name) {
|
private File makeFilename(File base, String name) {
|
||||||
if (name.indexOf(File.separatorChar) < 0) {
|
if (name.indexOf(File.separatorChar) < 0) {
|
||||||
return new File(base, name);
|
return new File(base, name);
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"File " + name + " contains a path separator");
|
"File " + name + " contains a path separator");
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getDataDirFile() {
|
private File getDataDirFile() {
|
||||||
if(data_dir == null) {
|
if(data_dir == null) {
|
||||||
data_dir = android.os.Environment.getExternalStorageDirectory();
|
data_dir = android.os.Environment.getExternalStorageDirectory();
|
||||||
}
|
}
|
||||||
return data_dir;
|
return data_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getFilesDir() {
|
public File getFilesDir() {
|
||||||
if (files_dir == null) {
|
if (files_dir == null) {
|
||||||
files_dir = new File(getDataDirFile(), "files");
|
files_dir = new File(getDataDirFile(), "files");
|
||||||
}
|
}
|
||||||
if (!files_dir.exists()) {
|
if (!files_dir.exists()) {
|
||||||
if(!files_dir.mkdirs()) {
|
if(!files_dir.mkdirs()) {
|
||||||
if (files_dir.exists()) {
|
if (files_dir.exists()) {
|
||||||
// spurious failure; probably racing with another process for this app
|
// spurious failure; probably racing with another process for this app
|
||||||
return files_dir;
|
return files_dir;
|
||||||
}
|
}
|
||||||
Log.w(TAG, "Unable to create files directory " + files_dir.getPath());
|
Log.w(TAG, "Unable to create files directory " + files_dir.getPath());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return files_dir;
|
return files_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getExternalFilesDir(String type) {
|
||||||
|
return getFilesDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getObbDir() {
|
||||||
|
if (obb_dir == null) {
|
||||||
|
obb_dir = new File(getDataDirFile(), "obb");
|
||||||
|
}
|
||||||
|
return obb_dir;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: should be something like /tmp/cache, but may need to create that directory
|
// FIXME: should be something like /tmp/cache, but may need to create that directory
|
||||||
public File getCacheDir() {
|
public File getCacheDir() {
|
||||||
if (cache_dir == null) {
|
if (cache_dir == null) {
|
||||||
cache_dir = new File("/tmp/");
|
cache_dir = new File("/tmp/");
|
||||||
}
|
}
|
||||||
return cache_dir;
|
return cache_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getPreferencesDir() {
|
private File getPreferencesDir() {
|
||||||
if (prefs_dir == null) {
|
if (prefs_dir == null) {
|
||||||
prefs_dir = new File(getDataDirFile(), "shared_prefs");
|
prefs_dir = new File(getDataDirFile(), "shared_prefs");
|
||||||
}
|
}
|
||||||
return prefs_dir;
|
return prefs_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getSharedPrefsFile(String name) {
|
public File getSharedPrefsFile(String name) {
|
||||||
return makeFilename(getPreferencesDir(), name + ".xml");
|
return makeFilename(getPreferencesDir(), name + ".xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||||
System.out.println("\n\n...> getSharedPreferences("+name+",)\n\n");
|
System.out.println("\n\n...> getSharedPreferences("+name+",)\n\n");
|
||||||
File prefsFile = getSharedPrefsFile(name);
|
File prefsFile = getSharedPrefsFile(name);
|
||||||
return new SharedPreferencesImpl(prefsFile, mode);
|
return new SharedPreferencesImpl(prefsFile, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassLoader getClassLoader() {
|
public ClassLoader getClassLoader() {
|
||||||
// not perfect, but it's what we use for now as well, and it works
|
// not perfect, but it's what we use for now as well, and it works
|
||||||
|
|||||||
Reference in New Issue
Block a user