Commit 729224b1 by eqy Committed by Tianqi Chen

check in (#1629)

parent 16d3c1f6
...@@ -39,11 +39,9 @@ import android.app.NotificationManager; ...@@ -39,11 +39,9 @@ import android.app.NotificationManager;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private boolean skipRelaunch = true;
// wait time before automatic restart of RPC Activity // wait time before automatic restart of RPC Activity
public static final int HANDLER_RESTART_DELAY = 5000; public static final int HANDLER_RESTART_DELAY = 5000;
private void showDialog(String title, String msg) { private void showDialog(String title, String msg) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(title); builder.setTitle(title);
...@@ -91,7 +89,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -91,7 +89,7 @@ public class MainActivity extends AppCompatActivity {
final Runnable rPCStarter = new Runnable() { final Runnable rPCStarter = new Runnable() {
public void run() { public void run() {
if (switchPersistent.isChecked()) { if (switchPersistent.isChecked()) {
System.err.println("relaunching RPC activity in 5s..."); System.err.println("relaunching RPC activity...");
Intent intent = ((MainActivity) context).updateRPCPrefs(); Intent intent = ((MainActivity) context).updateRPCPrefs();
startActivity(intent); startActivity(intent);
} }
...@@ -116,6 +114,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -116,6 +114,7 @@ public class MainActivity extends AppCompatActivity {
if (isChecked) { if (isChecked) {
System.err.println("automatic RPC restart enabled..."); System.err.println("automatic RPC restart enabled...");
updateRPCPrefs(); updateRPCPrefs();
setupRelaunch();
} else { } else {
System.err.println("automatic RPC restart disabled..."); System.err.println("automatic RPC restart disabled...");
updateRPCPrefs(); updateRPCPrefs();
...@@ -123,29 +122,14 @@ public class MainActivity extends AppCompatActivity { ...@@ -123,29 +122,14 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
Button startRPC = findViewById(R.id.button_start_rpc);
startRPC.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = ((MainActivity) context).updateRPCPrefs();
startActivity(intent);
}
});
enableInputView(true); enableInputView(true);
} }
@Override @Override
protected void onResume() { protected void onResume() {
System.err.println("MainActivity onResume..."); System.err.println("MainActivity onResume...");
System.err.println("skipRelaunch: " + skipRelaunch); enableInputView(true);
// if this is the first time onResume is called, do nothing, otherwise we setupRelaunch();
// may double launch
if (!skipRelaunch) {
enableInputView(true);
setupRelaunch();
} else {
skipRelaunch = false;
}
super.onResume(); super.onResume();
} }
......
...@@ -78,15 +78,4 @@ ...@@ -78,15 +78,4 @@
android:textOn="@string/switch_on" /> android:textOn="@string/switch_on" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_start_rpc"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/start_rpc" />
</LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -9,11 +9,10 @@ ...@@ -9,11 +9,10 @@
<string name="label_address">Address</string> <string name="label_address">Address</string>
<string name="label_port">Port</string> <string name="label_port">Port</string>
<string name="label_key">Key</string> <string name="label_key">Key</string>
<string name="label_persistent">Keep RPC Alive</string> <string name="label_persistent">Enable RPC</string>
<string name="switch_on">Enabled</string> <string name="switch_on">Enabled</string>
<string name="switch_off">Disabled</string> <string name="switch_off">Disabled</string>
<string name="start_rpc">Start RPC</string>
<string name="stop_rpc">Stop RPC</string> <string name="stop_rpc">Stop RPC</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment