Misc. cleanup and formatting
|
@ -28,7 +28,7 @@ class AddServerDialogFragment : DialogFragment() {
|
|||
* implement this interface in order to receive event callbacks.
|
||||
* Each method passes the DialogFragment in case the host needs to query it. */
|
||||
interface NoticeDialogListener {
|
||||
fun onDialogPositiveClick(dialog: DialogFragment, server: String)
|
||||
fun onDialogPositiveClick(server: String)
|
||||
}
|
||||
|
||||
// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
|
||||
|
@ -62,14 +62,15 @@ class AddServerDialogFragment : DialogFragment() {
|
|||
builder.setTitle(R.string.add_server)
|
||||
.setView(view)
|
||||
// Add action buttons
|
||||
.setPositiveButton(R.string.menu_add
|
||||
.setPositiveButton(
|
||||
R.string.menu_add
|
||||
) { _, _ ->
|
||||
listener.onDialogPositiveClick(
|
||||
this,
|
||||
binding.editTextServerAddr.text.toString().trim()
|
||||
)
|
||||
}
|
||||
.setNegativeButton(R.string.cancel
|
||||
.setNegativeButton(
|
||||
R.string.cancel
|
||||
) { _, _ ->
|
||||
dialog?.cancel()
|
||||
}
|
||||
|
@ -79,7 +80,6 @@ class AddServerDialogFragment : DialogFragment() {
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
val button = ((dialog) as AlertDialog).getButton(DialogInterface.BUTTON_POSITIVE)
|
||||
binding.editTextServerAddr.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||
|
|
|
@ -7,7 +7,7 @@ import androidx.fragment.app.DialogFragment
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
|
||||
class DeleteServerDialogFragment(private val position: Int): DialogFragment() {
|
||||
class DeleteServerDialogFragment(private val position: Int) : DialogFragment() {
|
||||
// Use this instance of the interface to deliver action events
|
||||
private lateinit var listener: NoticeDialogListener
|
||||
|
||||
|
@ -15,7 +15,7 @@ class DeleteServerDialogFragment(private val position: Int): DialogFragment() {
|
|||
* implement this interface in order to receive event callbacks.
|
||||
* Each method passes the DialogFragment in case the host needs to query it. */
|
||||
interface NoticeDialogListener {
|
||||
fun onDialogPositiveClick(dialog: DialogFragment, position: Int)
|
||||
fun onDialogPositiveClick(position: Int)
|
||||
}
|
||||
|
||||
// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
|
||||
|
@ -27,21 +27,26 @@ class DeleteServerDialogFragment(private val position: Int): DialogFragment() {
|
|||
listener = context as NoticeDialogListener
|
||||
} catch (e: ClassCastException) {
|
||||
// The activity doesn't implement the interface, throw exception
|
||||
throw ClassCastException((context.toString() +
|
||||
" must implement NoticeDialogListener"))
|
||||
throw ClassCastException(
|
||||
(context.toString() +
|
||||
" must implement NoticeDialogListener")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
val builder = MaterialAlertDialogBuilder(it)
|
||||
|
||||
builder.setTitle(R.string.delete_question)
|
||||
.setMessage(R.string.delete_message)
|
||||
.setPositiveButton(R.string.delete
|
||||
.setPositiveButton(
|
||||
R.string.delete
|
||||
) { _, _ ->
|
||||
listener.onDialogPositiveClick(this, position)
|
||||
listener.onDialogPositiveClick(position)
|
||||
}
|
||||
.setNegativeButton(R.string.cancel
|
||||
.setNegativeButton(
|
||||
R.string.cancel
|
||||
) { _, _ ->
|
||||
dialog?.cancel()
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ class DnsTileService : TileService() {
|
|||
val index = items.indexOf(currentAddress)
|
||||
|
||||
if (index == -1 || currentAddress == null) {
|
||||
return items[0]
|
||||
return items[0]
|
||||
}
|
||||
if (index == items.size - 1) {
|
||||
return null
|
||||
|
|
|
@ -14,7 +14,6 @@ import android.util.Log
|
|||
import android.view.Menu
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import org.lsposed.hiddenapibypass.HiddenApiBypass
|
||||
import rikka.shizuku.Shizuku
|
||||
|
@ -67,7 +66,10 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi
|
|||
binding.topAppBar.setOnMenuItemClickListener { item ->
|
||||
when (item.itemId) {
|
||||
R.id.privacy_policy -> {
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://karasevm.github.io/PrivateDNSAndroid/privacy_policy"))
|
||||
val browserIntent = Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("https://karasevm.github.io/PrivateDNSAndroid/privacy_policy")
|
||||
)
|
||||
startActivity(browserIntent)
|
||||
true
|
||||
}
|
||||
|
@ -128,7 +130,7 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi
|
|||
Shizuku.removeRequestPermissionResultListener(this::onRequestPermissionResult)
|
||||
}
|
||||
|
||||
override fun onDialogPositiveClick(dialog: DialogFragment, server: String) {
|
||||
override fun onDialogPositiveClick(server: String) {
|
||||
if (server.isEmpty()) {
|
||||
Toast.makeText(this, R.string.server_length_error, Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
|
@ -139,7 +141,7 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi
|
|||
sharedPrefs.dns_servers = items
|
||||
}
|
||||
|
||||
override fun onDialogPositiveClick(dialog: DialogFragment,position: Int) {
|
||||
override fun onDialogPositiveClick(position: Int) {
|
||||
items.removeAt(position)
|
||||
adapter.setData(items.toMutableList())
|
||||
adapter.notifyItemRemoved(position)
|
||||
|
@ -194,7 +196,9 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi
|
|||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
override fun onRequestPermissionResult(requestCode: Int, grantResult: Int) {
|
||||
val isGranted = grantResult == PackageManager.PERMISSION_GRANTED
|
||||
|
@ -202,7 +206,10 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi
|
|||
if (isGranted) {
|
||||
grantPermissionWithShizuku()
|
||||
} else if (checkSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS) != PackageManager.PERMISSION_GRANTED) {
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://karasevm.github.io/PrivateDNSAndroid/"))
|
||||
val browserIntent = Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("https://karasevm.github.io/PrivateDNSAndroid/")
|
||||
)
|
||||
startActivity(browserIntent)
|
||||
finish()
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package ru.karasevm.privatednstoggle
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import java.util.*
|
||||
|
||||
class RecyclerAdapter(val items: MutableList<String>): RecyclerView.Adapter<RecyclerAdapter.ViewHolder>() {
|
||||
class RecyclerAdapter(private val items: MutableList<String>) :
|
||||
RecyclerView.Adapter<RecyclerAdapter.ViewHolder>() {
|
||||
|
||||
var onItemClick: ((Int) -> Unit)? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerAdapter.ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_row, parent, false)
|
||||
val view =
|
||||
LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_row, parent, false)
|
||||
val vh = ViewHolder(view)
|
||||
return vh
|
||||
}
|
||||
|
@ -30,15 +30,16 @@ class RecyclerAdapter(val items: MutableList<String>): RecyclerView.Adapter<Recy
|
|||
}
|
||||
|
||||
|
||||
|
||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val textView: TextView = itemView.findViewById(R.id.textView)
|
||||
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
onItemClick?.invoke(adapterPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setData(newItems: MutableList<String>) {
|
||||
items.run {
|
||||
clear()
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.widget.Toast
|
|||
import androidx.core.content.ContextCompat.checkSelfPermission
|
||||
import ru.karasevm.privatednstoggle.R
|
||||
|
||||
@Suppress("unused")
|
||||
object PrivateDNSUtils {
|
||||
const val DNS_MODE_OFF = "off"
|
||||
const val DNS_MODE_AUTO = "opportunistic"
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#FFFFFF">
|
||||
<group android:scaleX="0.92"
|
||||
android:scaleY="0.92"
|
||||
android:translateX="0.96"
|
||||
android:translateY="0.96">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M11.8,10.9c-2.27,-0.59 -3,-1.2 -3,-2.15 0,-1.09 1.01,-1.85 2.7,-1.85 1.78,0 2.44,0.85 2.5,2.1h2.21c-0.07,-1.72 -1.12,-3.3 -3.21,-3.81V3h-3v2.16c-1.94,0.42 -3.5,1.68 -3.5,3.61 0,2.31 1.91,3.46 4.7,4.13 2.5,0.6 3,1.48 3,2.41 0,0.69 -0.49,1.79 -2.7,1.79 -2.06,0 -2.87,-0.92 -2.98,-2.1h-2.2c0.12,2.19 1.76,3.42 3.68,3.83V21h3v-2.15c1.95,-0.37 3.5,-1.5 3.5,-3.55 0,-2.84 -2.43,-3.81 -4.7,-4.4z"/>
|
||||
</group>
|
||||
</vector>
|
Before Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 685 B |
|
@ -10,17 +10,17 @@
|
|||
android:id="@+id/topAppBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="parent">
|
||||
app:layout_constraintRight_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/topAppBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:title="@string/app_name"
|
||||
app:menu="@menu/menu_main" />
|
||||
app:menu="@menu/menu_main"
|
||||
app:title="@string/app_name" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
|
|
@ -8,21 +8,20 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:hint="@string/add_edittext_hint"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:hint="@string/add_edittext_hint">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/editTextServerAddr"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:maxLines="1"
|
||||
android:ems="10"
|
||||
android:importantForAutofill="no"
|
||||
/>
|
||||
android:inputType="textNoSuggestions"
|
||||
android:maxLines="1" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -4,8 +4,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="17dp"
|
||||
android:paddingEnd="17dp"
|
||||
android:paddingTop="10dp">
|
||||
android:paddingTop="10dp"
|
||||
android:paddingEnd="17dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/autoOptionHeader"
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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="48dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
android:focusable="true"
|
||||
android:foreground="?android:attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -7,10 +7,10 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/bottom_sheet"
|
||||
style="@style/Widget.Material3.BottomSheet"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
|
|
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 6.2 KiB |
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
</adaptive-icon>
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<color name="ic_launcher_background">#498EE8</color>
|
||||
|
||||
<color name="seed">#6750A4</color>
|
||||
<color name="seed" tools:keep="@color/seed">#6750A4</color>
|
||||
<color name="md_theme_light_primary">#6750A4</color>
|
||||
<color name="md_theme_light_secondary">#625B71</color>
|
||||
<color name="md_theme_light_tertiary">#7D5260</color>
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
<string name="add_server">Add Server</string>
|
||||
<string name="menu_add">Add</string>
|
||||
<string name="menu_privacy_policy">Privacy Policy</string>
|
||||
<string name="menu_auto_enabled">Enable auto</string>
|
||||
<string name="select_server">Select Server</string>
|
||||
<string name="auto_mode_clarification">Automatic (opportunistic) DNS mode will now be available in the tile</string>
|
||||
<string name="done">Done</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="delete_question">Delete</string>
|
||||
|
|