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

130 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-06-27 18:35:25 +03:00
import com.statusim.geth.module.GethPackage;
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;
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-06-16 07:23:11 +03:00
import android.content.Intent;
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-06-21 12:03:39 +03:00
import com.github.yamill.orientation.OrientationPackage;
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-09 12:49:02 +03:00
import com.statusim.Jail.JailPackage;
2016-03-23 17:02:53 +02:00
2016-06-01 11:41:50 +03:00
import com.lwansbrough.RCTCamera.*;
2016-03-23 17:02:53 +02:00
import com.i18n.reactnativei18n.ReactNativeI18n;
2016-06-21 12:03:39 +03:00
import android.content.res.Configuration;
2016-06-01 11:41:50 +03:00
2016-07-18 19:29:51 +03:00
import com.rnfs.RNFSPackage;
2016-03-23 16:48:26 +02:00
public class MainActivity extends ReactActivity {
2016-06-16 07:27:58 +03:00
private static final String TAG = "MainActivity";
2016-06-08 12:43:02 +02:00
protected void startStatus() {
// 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");
}
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 17:02:53 +02:00
}
2016-06-16 07:23:11 +03:00
@Override
protected void onDestroy() {
super.onDestroy();
}
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-06-08 15:15:23 +03:00
new JailPackage(),
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-06-01 11:41:50 +03:00
new RCTCameraPackage(),
2016-06-21 12:03:39 +03:00
new SmsListener(this),
2016-06-27 18:35:25 +03:00
new OrientationPackage(this),
2016-07-18 19:29:51 +03:00
new RNFSPackage(),
2016-06-27 18:35:25 +03:00
new GethPackage()
2016-03-23 17:02:53 +02:00
);
2016-03-23 16:48:26 +02:00
}
2016-06-21 12:03:39 +03:00
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Intent intent = new Intent("onConfigurationChanged");
intent.putExtra("newConfig", newConfig);
this.sendBroadcast(intent);
}
2016-03-23 16:48:26 +02:00
}