2016-05-19 18:31:56 +02:00
|
|
|
package com.statusim;
|
2016-03-23 16:48:26 +02:00
|
|
|
|
2016-06-08 12:43:02 +02:00
|
|
|
import android.app.AlertDialog;
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
import android.content.DialogInterface.OnCancelListener;
|
2016-07-20 12:03:05 +03:00
|
|
|
import android.content.DialogInterface.OnClickListener;
|
2016-06-16 07:23:11 +03:00
|
|
|
import android.content.Intent;
|
2016-06-21 12:03:39 +03:00
|
|
|
import android.content.res.Configuration;
|
2016-07-20 12:03:05 +03:00
|
|
|
import android.os.Bundle;
|
|
|
|
|
import com.facebook.react.ReactActivity;
|
2016-11-15 13:43:48 +02:00
|
|
|
import com.cboy.rn.splashscreen.SplashScreen;
|
2016-06-01 11:41:50 +03:00
|
|
|
|
2016-07-20 12:03:05 +03:00
|
|
|
import java.util.Properties;
|
2016-07-18 19:29:51 +03:00
|
|
|
|
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-09-07 20:35:04 +03:00
|
|
|
protected void configureStatus() {
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 12:43:02 +02:00
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
2016-11-15 13:43:48 +02:00
|
|
|
SplashScreen.show(this);
|
2016-06-08 12:43:02 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
2016-07-20 12:03:05 +03:00
|
|
|
if (!RootUtil.isDeviceRooted()) {
|
2016-09-07 20:35:04 +03:00
|
|
|
configureStatus();
|
2016-06-08 12:43:02 +02:00
|
|
|
} else {
|
2016-07-20 12:03:05 +03:00
|
|
|
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this)
|
|
|
|
|
.setMessage(getResources().getString(R.string.root_warning))
|
2016-06-08 12:43:02 +02:00
|
|
|
.setPositiveButton(getResources().getString(R.string.root_okay), new OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
dialog.dismiss();
|
2016-09-07 20:35:04 +03:00
|
|
|
configureStatus();
|
2016-06-08 12:43:02 +02:00
|
|
|
}
|
2016-07-20 12:03:05 +03:00
|
|
|
})
|
|
|
|
|
.setNegativeButton(getResources().getString(R.string.root_cancel), new OnClickListener() {
|
2016-06-08 12:43:02 +02:00
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
MainActivity.this.finishAffinity();
|
|
|
|
|
}
|
2016-07-20 12:03:05 +03:00
|
|
|
})
|
|
|
|
|
.setOnCancelListener(new OnCancelListener() {
|
2016-06-08 12:43:02 +02:00
|
|
|
@Override
|
|
|
|
|
public void onCancel(DialogInterface dialog) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
MainActivity.this.finishAffinity();
|
|
|
|
|
}
|
2016-07-20 12:03:05 +03:00
|
|
|
})
|
|
|
|
|
.create();
|
|
|
|
|
|
2016-06-08 12:43:02 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|