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
api-impl: add stubs / simple stuff for OsmAnd
without native libs present, launches and renders white square in map view; with native libs present, segfaults in bundled skia
This commit is contained in:
@@ -6,6 +6,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.net.Uri;
|
||||
@@ -451,6 +452,20 @@ public class Activity extends ContextWrapper implements Window.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public String getLocalClassName() {
|
||||
final String pkg = getPackageName();
|
||||
final String cls = this.getClass().getName();
|
||||
int packageLen = pkg.length();
|
||||
if (!cls.startsWith(pkg) || cls.length() <= packageLen || cls.charAt(packageLen) != '.') {
|
||||
return cls;
|
||||
}
|
||||
return cls.substring(packageLen+1);
|
||||
}
|
||||
|
||||
public SharedPreferences getPreferences(int mode) {
|
||||
return getSharedPreferences(getLocalClassName(), mode);
|
||||
}
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
public static native void nativeRecreateActivity(Activity activity);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
|
||||
public class Application extends ContextWrapper {
|
||||
@@ -44,13 +45,13 @@ public class Application extends ContextWrapper {
|
||||
}
|
||||
|
||||
public Application() {
|
||||
super(null);
|
||||
super(new Context());
|
||||
/* TODO: is this the right place to put this? */
|
||||
InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml");
|
||||
try {
|
||||
AndroidManifestBlock manifest = AndroidManifestBlock.load(inStream);
|
||||
int app_icon_resid = manifest.getIconResourceId();
|
||||
app_icon_path = this.getResources().getString(app_icon_resid);
|
||||
app_icon_path = r.getString(app_icon_resid);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user