|
@@ -8,7 +8,6 @@ import android.webkit.WebView;
|
|
|
import android.widget.Toast;
|
|
import android.widget.Toast;
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.core.content.ContextCompat;
|
|
|
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
|
|
|
import com.nonvioce.ijs.databinding.ActivityMainBinding;
|
|
import com.nonvioce.ijs.databinding.ActivityMainBinding;
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity {
|
|
public class MainActivity extends AppCompatActivity {
|
|
@@ -69,9 +68,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
binding.webView.addJavascriptInterface(new WebAppInterface(), "Android");
|
|
binding.webView.addJavascriptInterface(new WebAppInterface(), "Android");
|
|
|
binding.webView.loadUrl("file:///android_asset/console.html");
|
|
binding.webView.loadUrl("file:///android_asset/console.html");
|
|
|
|
|
|
|
|
- // MCP server toggle
|
|
|
|
|
- setupMcpToggle();
|
|
|
|
|
-
|
|
|
|
|
// Auto-start MCP server if enabled in settings (default: on)
|
|
// Auto-start MCP server if enabled in settings (default: on)
|
|
|
android.content.SharedPreferences prefs = getPreferences(MODE_PRIVATE);
|
|
android.content.SharedPreferences prefs = getPreferences(MODE_PRIVATE);
|
|
|
if (prefs.getBoolean("mcp_enabled", true) && !McpService.isRunning()) {
|
|
if (prefs.getBoolean("mcp_enabled", true) && !McpService.isRunning()) {
|
|
@@ -88,44 +84,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // ── MCP toggle ────────────────────────────────────────────────
|
|
|
|
|
-
|
|
|
|
|
- private void setupMcpToggle() {
|
|
|
|
|
- FloatingActionButton fab = binding.mcpToggleFab;
|
|
|
|
|
- updateMcpFabIcon(fab);
|
|
|
|
|
-
|
|
|
|
|
- fab.setOnClickListener(v -> {
|
|
|
|
|
- if (McpService.isRunning()) {
|
|
|
|
|
- stopMcpServer();
|
|
|
|
|
- } else {
|
|
|
|
|
- startMcpServer(DEFAULT_MCP_PORT);
|
|
|
|
|
- }
|
|
|
|
|
- updateMcpFabIcon(fab);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- fab.setOnLongClickListener(v -> {
|
|
|
|
|
- String msg = McpService.isRunning()
|
|
|
|
|
- ? getString(R.string.mcp_started, McpService.getPort())
|
|
|
|
|
- : getString(R.string.mcp_stopped);
|
|
|
|
|
- Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
|
|
|
|
- return true;
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void updateMcpFabIcon(FloatingActionButton fab) {
|
|
|
|
|
- if (McpService.isRunning()) {
|
|
|
|
|
- fab.setBackgroundTintList(
|
|
|
|
|
- android.content.res.ColorStateList.valueOf(
|
|
|
|
|
- getColor(R.color.mcp_fab_on)));
|
|
|
|
|
- fab.setImageResource(android.R.drawable.ic_menu_share);
|
|
|
|
|
- } else {
|
|
|
|
|
- fab.setBackgroundTintList(
|
|
|
|
|
- android.content.res.ColorStateList.valueOf(
|
|
|
|
|
- getColor(R.color.mcp_fab_off)));
|
|
|
|
|
- fab.setImageResource(android.R.drawable.ic_menu_share);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private void startMcpServer(int port) {
|
|
private void startMcpServer(int port) {
|
|
|
Intent intent = new Intent(this, McpService.class);
|
|
Intent intent = new Intent(this, McpService.class);
|
|
|
intent.setAction(McpService.ACTION_START);
|
|
intent.setAction(McpService.ACTION_START);
|
|
@@ -174,6 +132,11 @@ public class MainActivity extends AppCompatActivity {
|
|
|
return pluginManager.savePlugin(pluginJson);
|
|
return pluginManager.savePlugin(pluginJson);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @JavascriptInterface
|
|
|
|
|
+ public String restoreDefaultPlugins() {
|
|
|
|
|
+ return pluginManager.restoreDefaultPlugins();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@JavascriptInterface
|
|
@JavascriptInterface
|
|
|
public String deletePlugin(String pluginId) {
|
|
public String deletePlugin(String pluginId) {
|
|
|
return pluginManager.deletePlugin(pluginId);
|
|
return pluginManager.deletePlugin(pluginId);
|
|
@@ -482,7 +445,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
} else if (!enabled && McpService.isRunning()) {
|
|
} else if (!enabled && McpService.isRunning()) {
|
|
|
stopMcpServer();
|
|
stopMcpServer();
|
|
|
}
|
|
}
|
|
|
- updateMcpFabIcon(binding.mcpToggleFab);
|
|
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|