summaryrefslogtreecommitdiff
path: root/app/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/java/src')
-rw-r--r--app/java/src/DNSService.java33
-rw-r--r--app/java/src/MainActivity.java68
2 files changed, 101 insertions, 0 deletions
diff --git a/app/java/src/DNSService.java b/app/java/src/DNSService.java
new file mode 100644
index 0000000..4f760a5
--- /dev/null
+++ b/app/java/src/DNSService.java
@@ -0,0 +1,33 @@
+package org.pihole.dnsproxy;
+
+import android.app.AlertDialog;
+import android.app.Service;
+
+import android.content.Intent;
+
+import android.net.VpnService;
+
+public class DNSService extends VpnService {
+
+ private static boolean isRunning = false;
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ //VpnService.prepare();
+
+ DNSService.isRunning = true;
+
+ return Service.START_STICKY;
+ }
+
+ @Override
+ public void onDestroy() {
+ DNSService.isRunning = false;
+ super.onDestroy();
+ }
+
+ public static boolean isRunning()
+ {
+ return DNSService.isRunning;
+ }
+}
diff --git a/app/java/src/MainActivity.java b/app/java/src/MainActivity.java
new file mode 100644
index 0000000..9fd99f6
--- /dev/null
+++ b/app/java/src/MainActivity.java
@@ -0,0 +1,68 @@
+package org.pihole.dnsproxy;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+
+import android.content.Intent;
+
+import android.net.VpnService;
+
+import android.os.Bundle;
+
+import android.view.TextureView;
+import android.view.View;
+
+import android.widget.Button;
+import android.widget.Toast;
+
+public class MainActivity extends Activity {
+
+ private Button buttonStart;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ this.buttonStart = (Button) findViewById(R.id.button_start);
+ this.buttonStart.setText(DNSService.isRunning() ? "Stop" : "Start");
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ this.buttonStart.setText("on RESSSSUME");
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {}
+
+ public void onStartClick(View view) {
+ Intent intent = VpnService.prepare(this);
+ if (intent != null) {
+ startActivityForResult(intent, 0);
+ }
+ //Intent intent = new Intent(this, DNSService.class);
+
+ if (!DNSService.isRunning()) {
+ startService(intent);
+
+ new AlertDialog.Builder(this)
+ .setTitle("PROXY START")
+ .setMessage("BRRR")
+ .show();
+ Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show();
+ this.buttonStart.setText("Stop");
+ }
+ else {
+ stopService(intent);
+
+ new AlertDialog.Builder(this)
+ .setTitle("PROXY STOP")
+ .setMessage("RRRB")
+ .show();
+ Toast.makeText(this, "service stopping", Toast.LENGTH_SHORT).show();
+ this.buttonStart.setText("Start");
+ }
+ }
+}