Files
status-react/android/app/src/main/java/com/statusim/MainActivity.java
T

125 lines
4.5 KiB
Java
Raw Normal View History

2016-05-19 18:31:56 +02:00
package com.statusim;
2016-03-23 16:48:26 +02:00
import com.facebook.react.ReactActivity;
2016-04-01 18:05:55 +03:00
import io.realm.react.RealmReactPackage;
import com.oblador.vectoricons.VectorIconsPackage;
2016-03-23 16:48:26 +02:00
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
2016-03-23 17:02:53 +02:00
import com.rt2zz.reactnativecontacts.ReactNativeContacts;
import android.os.Bundle;
import android.os.Environment;
2016-06-08 12:43:02 +02:00
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnCancelListener;
2016-03-23 17:02:53 +02:00
import com.github.ethereum.go_ethereum.cmd.Geth;
2016-04-01 18:05:55 +03:00
import com.bitgo.randombytes.RandomBytesPackage;
2016-05-19 20:05:04 +03:00
import com.BV.LinearGradient.LinearGradientPackage;
2016-05-18 17:40:26 +03:00
import com.centaurwarchief.smslistener.SmsListener;
2016-03-23 16:48:26 +02:00
import java.util.Arrays;
import java.util.List;
2016-03-23 17:02:53 +02:00
import java.util.Properties;
import java.io.File;
2016-06-08 12:43:02 +02:00
2016-03-23 17:02:53 +02:00
import com.i18n.reactnativei18n.ReactNativeI18n;
import io.realm.react.RealmReactPackage;
2016-03-23 16:48:26 +02:00
2016-06-08 12:43:02 +02:00
2016-03-23 16:48:26 +02:00
public class MainActivity extends ReactActivity {
2016-03-23 17:02:53 +02:00
2016-06-08 12:43:02 +02:00
protected void startStatus() {
2016-03-23 17:02:53 +02:00
// Required for android-16 (???)
System.loadLibrary("gethraw");
System.loadLibrary("geth");
2016-06-08 12:43:02 +02:00
// Required because of crazy APN settings redirecting localhost (found in GB)
2016-03-23 17:02:53 +02:00
Properties properties = System.getProperties();
properties.setProperty("http.nonProxyHosts", "localhost|127.0.0.1");
properties.setProperty("https.nonProxyHosts", "localhost|127.0.0.1");
File extStore = Environment.getExternalStorageDirectory();
final String dataFolder = extStore.exists() ?
extStore.getAbsolutePath() :
getApplicationInfo().dataDir;
// Launch!
new Thread(new Runnable() {
public void run() {
2016-03-29 23:45:31 +03:00
Geth.run("--bootnodes enode://e2f28126720452aa82f7d3083e49e6b3945502cb94d9750a15e27ee310eed6991618199f878e5fbc7dfa0e20f0af9554b41f491dc8f1dbae8f0f2d37a3a613aa@139.162.13.89:30303 --shh --ipcdisable --nodiscover --rpc --rpcapi db,eth,net,web3,shh,admin --fast --datadir=" + dataFolder);
2016-03-23 17:02:53 +02:00
}
}).start();
}
2016-06-08 12:43:02 +02:00
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(!RootUtil.isDeviceRooted()) {
startStatus();
} else {
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).setMessage(getResources().getString(R.string.root_warning))
.setPositiveButton(getResources().getString(R.string.root_okay), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
startStatus();
}
}).setNegativeButton(getResources().getString(R.string.root_cancel), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
MainActivity.this.finishAffinity();
}
}).setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
MainActivity.this.finishAffinity();
}
}).create();
dialog.show();
}
}
2016-03-23 16:48:26 +02:00
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
2016-05-19 18:32:38 +02:00
return "StatusIm";
2016-03-23 16:48:26 +02:00
}
/**
* Returns whether dev mode should be enabled.
* This enables e.g. the dev menu.
*/
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
2016-04-01 18:05:55 +03:00
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
2016-03-23 16:48:26 +02:00
@Override
protected List<ReactPackage> getPackages() {
2016-03-23 17:02:53 +02:00
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
2016-04-01 18:05:55 +03:00
new RealmReactPackage(),
new VectorIconsPackage(),
2016-03-23 17:02:53 +02:00
new ReactNativeContacts(),
new ReactNativeI18n(),
2016-05-18 17:40:26 +03:00
new RandomBytesPackage(),
new LinearGradientPackage(),
2016-05-18 17:40:26 +03:00
new SmsListener(this)
2016-03-23 17:02:53 +02:00
);
2016-03-23 16:48:26 +02:00
}
}