From 23c55d50fb12bfeabd8ff3d8602877123f368270 Mon Sep 17 00:00:00 2001
From: str4d <str4d@mail.i2p>
Date: Wed, 16 Jul 2014 04:20:40 +0000
Subject: [PATCH] Remove I2CP port starting, clients can use domain sockets now

---
 .../net/i2p/android/router/MainActivity.java  | 55 ++-----------------
 app/src/main/res/values/strings.xml           |  2 -
 2 files changed, 4 insertions(+), 53 deletions(-)

diff --git a/app/src/main/java/net/i2p/android/router/MainActivity.java b/app/src/main/java/net/i2p/android/router/MainActivity.java
index 7cddfa874..d14a9da4e 100644
--- a/app/src/main/java/net/i2p/android/router/MainActivity.java
+++ b/app/src/main/java/net/i2p/android/router/MainActivity.java
@@ -82,58 +82,11 @@ public class MainActivity extends I2PActivityBase implements
             return;
 
         if (action.equals("net.i2p.android.router.START_I2P")) {
-            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-            if (!prefs.getBoolean("i2cp.disableInterface", false)) {
-                // Inverted, see Util.getPropertiesFromPreferences()
-                // Ask user if we should enable I2CP
-                DialogFragment df = new DialogFragment() {
-                    @Override
-                    public Dialog onCreateDialog(Bundle savedInstanceState) {
-                        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-                        builder.setMessage(R.string.enable_i2cp)
-                        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int which) {
-                                dialog.dismiss();
-                                enableI2CP();
-                                // I2P must be restarted
-                                autoStart(true);
-                            }
-                        })
-                        .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int which) {
-                                dialog.cancel();
-                                setResult(RESULT_CANCELED);
-                                finish();
-                            }
-                        });
-                        return builder.create();
-                    }
-                };
-                df.show(getSupportFragmentManager(), "enablei2cp");
-            } else
-                autoStart(false);
+            autoStart();
         }
     }
 
-    private void enableI2CP() {
-        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-        prefs.edit().putBoolean("i2cp.disableInterface", true).commit();
-
-        // Apply new config if we are running.
-        List<RouterContext> contexts = RouterContext.listContexts();
-        if ( !((contexts == null) || (contexts.isEmpty())) ) {
-            RouterContext _context = contexts.get(0);
-            _context.router().saveConfig("i2cp.disableInterface", "false");
-        } else {
-            // Merge in new config settings, write the file.
-            Properties props = new OrderedProperties();
-            props.setProperty("i2cp.disableInterface", "false");
-            InitActivities init = new InitActivities(this);
-            init.mergeResourceToFile(R.raw.router_config, "router.config", props);
-        }
-    }
-
-    private void autoStart(boolean restartIfStarted) {
+    private void autoStart() {
         if (canStart()) {
             if (Util.isConnected(this)) {
                 mAutoStartFromIntent = true;
@@ -142,8 +95,8 @@ public class MainActivity extends I2PActivityBase implements
                 // Not connected to a network
                 // TODO: Notify user
             }
-        } else if (restartIfStarted) {
-            // TODO: Stop and start
+        } else {
+            // TODO: Notify user
         }
     }
 
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c4098c57a..fe07e4b2c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -39,8 +39,6 @@
     <string name="first_start_irc">Point your IRC client to <b>localhost:6668</b> and say hi to us on:</string>
     <string name="url_irc_i2p" translatable="false">irc://127.0.0.1:6668/i2p | irc://127.0.0.1:6668/i2p-dev</string>
 
-    <string name="enable_i2cp">Another app has requested to start I2P Android, but I2CP is disabled. I2CP is necessary for other apps to connect to I2P through I2P Android. Do you want to enable I2CP?</string>
-
     <string name="drawer_open">Open nav</string>
     <string name="drawer_close">Close nav</string>
     <string name="action_search">Search</string>
-- 
GitLab