Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05dde94e authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

Fixes on app list selection.

parent 8d17320c
Loading
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -22,21 +22,30 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.RadioButton
import android.widget.Switch
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import foundation.e.privacymodules.ipscrambler.IpScramblerModule
import foundation.e.privacymodules.ipscramblermodule.IIpScramblerModule

const val APP_1 = "org.mozilla.firefox"

class MainActivity : AppCompatActivity(), IIpScramblerModule.Listener {


    private var lblStatus: TextView? = null
    private var lblTraffic: TextView? = null
    private var mTxtOrbotLog: TextView? = null
    private var mBtnStart: Button? = null
    private var mBtnStop: Button? = null
    private var mBtnRequestStatus: Button? = null
    private var mSelectAll: RadioButton? = null
    private var mSelectApp1: RadioButton? = null

    private lateinit var ipScramblerModule: IpScramblerModule


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
@@ -45,12 +54,13 @@ class MainActivity : AppCompatActivity(), IIpScramblerModule.Listener {

        ipScramblerModule.addListener(this)


        lblStatus = findViewById(R.id.label_status)
        lblTraffic = findViewById(R.id.label_traffic)
        mTxtOrbotLog = findViewById(R.id.orbot_log)
        mBtnStart = findViewById(R.id.button_start)
        mBtnStop = findViewById(R.id.button_stop)
        mSelectAll = findViewById(R.id.select_all)
        mSelectApp1 = findViewById(R.id.select_app1)

        mBtnStart?.setOnClickListener { v: View? ->
            ipScramblerModule.prepareAndroidVpn()?.let { startActivityForResult(it, 3)}
@@ -66,6 +76,18 @@ class MainActivity : AppCompatActivity(), IIpScramblerModule.Listener {
        mBtnRequestStatus?.setOnClickListener {
            ipScramblerModule.requestStatus()
        }

        mSelectAll?.setOnClickListener {
            ipScramblerModule.appList = emptySet()
            updateAppSelection()
        }

        mSelectApp1?.setOnClickListener {
            ipScramblerModule.appList = setOf(APP_1)
            updateAppSelection()
        }

        updateAppSelection()
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@@ -82,7 +104,6 @@ class MainActivity : AppCompatActivity(), IIpScramblerModule.Listener {
        ipScramblerModule.requestStatus()
    }


    private var logHistory = ""
    override fun log(message: String) {
        logHistory = message + "\n" + logHistory
@@ -96,5 +117,10 @@ class MainActivity : AppCompatActivity(), IIpScramblerModule.Listener {
    override fun onTrafficUpdate(upload: Long, download: Long, read: Long, write: Long) {
        lblTraffic?.text = "↑ ${write/1000}kB (${upload/1000}kB/s)  ↓ ${read/1000}kB (${download/1000}kB/s)"
    }

    private fun updateAppSelection() {
        mSelectAll?.isChecked = ipScramblerModule.appList.isEmpty()
        mSelectApp1?.isChecked = ipScramblerModule.appList.contains(APP_1)
    }
}
+33 −14
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<androidx.core.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="24dp"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
@@ -61,24 +64,40 @@
        android:text="Status?"
        android:layout_marginBottom="24dp"
        />

    <RadioGroup
        android:id="@+id/selective_scrambling"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_marginBottom="24dp"
        >

        <RadioButton
            android:id="@+id/select_all"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="All"
            />
        <RadioButton
            android:id="@+id/select_app1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Firefox"
            />

    </RadioGroup>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OrbotLog: "
        />

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        >
    <TextView
        android:id="@+id/orbot_log"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="24dp"
        />
    </androidx.core.widget.NestedScrollView>


</LinearLayout>
</androidx.core.widget.NestedScrollView>
+179 B (25.4 KiB)

File changed and moved.

No diff preview for this file type.

+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
  <modelVersion>4.0.0</modelVersion>
  <groupId>foundation.e</groupId>
  <artifactId>privacymodule.tor</artifactId>
  <version>0.0.2</version>
  <version>0.0.4</version>
  <packaging>aar</packaging>
  <dependencies>
    <dependency>
+4 −4
Original line number Diff line number Diff line
@@ -3,11 +3,11 @@
  <groupId>foundation.e</groupId>
  <artifactId>privacymodule.tor</artifactId>
  <versioning>
    <latest>0.0.2</latest>
    <release>0.0.2</release>
    <latest>0.0.4</latest>
    <release>0.0.4</release>
    <versions>
      <version>0.0.2</version>
      <version>0.0.4</version>
    </versions>
    <lastUpdated>20210826064900</lastUpdated>
    <lastUpdated>20210830061036</lastUpdated>
  </versioning>
</metadata>
Loading