diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1932f68..c2af3f9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:name=".PrivateDNSApp" android:supportsRtl="true" android:theme="@style/Theme.MyApplication"> listener.onDialogPositiveClick(this, position) diff --git a/app/src/main/java/ru/karasevm/privatednstoggle/MainActivity.kt b/app/src/main/java/ru/karasevm/privatednstoggle/MainActivity.kt index 15701b0..c09f490 100644 --- a/app/src/main/java/ru/karasevm/privatednstoggle/MainActivity.kt +++ b/app/src/main/java/ru/karasevm/privatednstoggle/MainActivity.kt @@ -56,7 +56,31 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi val newFragment = DeleteServerDialogFragment(position) newFragment.show(supportFragmentManager, "delete_server") } + binding.floatingActionButton.setOnClickListener { + val newFragment = AddServerDialogFragment() + newFragment.show(supportFragmentManager, "add_server") + } binding.recyclerView.adapter = adapter + + 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")) + startActivity(browserIntent) + true + } + + R.id.enable_auto -> { + if (!item.isChecked){ + Toast.makeText(this, R.string.auto_mode_clarification, Toast.LENGTH_LONG).show() + } + sharedPrefs.edit().putBoolean("auto_enabled", !item.isChecked).apply() + item.setChecked(!item.isChecked) + true + } + else -> true + } + } } override fun onCreateOptionsMenu(menu: Menu?): Boolean { @@ -116,35 +140,6 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi Shizuku.removeRequestPermissionResultListener(this::onRequestPermissionResult) } - override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) { - R.id.add_server -> { - val newFragment = AddServerDialogFragment() - newFragment.show(supportFragmentManager, "add_server") - true - } - R.id.privacy_policy -> { - val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://karasevm.github.io/PrivateDNSAndroid/privacy_policy")) - startActivity(browserIntent) - true - } - - R.id.enable_auto -> { - if (!item.isChecked){ - Toast.makeText(this, R.string.auto_mode_clarification, Toast.LENGTH_LONG).show() - } - sharedPrefs.edit().putBoolean("auto_enabled", !item.isChecked).apply() - item.setChecked(!item.isChecked) - - true - } - - else -> { - // If we got here, the user's action was not recognized. - // Invoke the superclass to handle it. - super.onOptionsItemSelected(item) - } - } - override fun onDialogPositiveClick(dialog: DialogFragment, server: String) { if (server.isEmpty()) { Toast.makeText(this, R.string.server_length_error, Toast.LENGTH_SHORT).show() @@ -163,7 +158,6 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi adapter.notifyItemRemoved(position) sharedPrefs.edit() .putString("dns_servers", items.joinToString(separator = ",") { it }).apply() - } /** @@ -217,7 +211,5 @@ class MainActivity : AppCompatActivity(), AddServerDialogFragment.NoticeDialogLi startActivity(browserIntent) finish() } - } - } \ No newline at end of file diff --git a/app/src/main/java/ru/karasevm/privatednstoggle/PrivateDNSApp.kt b/app/src/main/java/ru/karasevm/privatednstoggle/PrivateDNSApp.kt new file mode 100644 index 0000000..fd28566 --- /dev/null +++ b/app/src/main/java/ru/karasevm/privatednstoggle/PrivateDNSApp.kt @@ -0,0 +1,11 @@ +package ru.karasevm.privatednstoggle + +import android.app.Application +import com.google.android.material.color.DynamicColors + +class PrivateDNSApp : Application() { + override fun onCreate() { + super.onCreate() + DynamicColors.applyToActivitiesIfAvailable(this) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_add_24.xml b/app/src/main/res/drawable/ic_baseline_add_24.xml index 70046c4..a904f51 100644 --- a/app/src/main/res/drawable/ic_baseline_add_24.xml +++ b/app/src/main/res/drawable/ic_baseline_add_24.xml @@ -1,4 +1,5 @@ - diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 0ff5544..2a4e3e9 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,10 +6,38 @@ android:layout_height="match_parent" tools:context=".MainActivity"> + + + + + + + android:layout_height="wrap_content" + app:layout_constraintTop_toBottomOf="@+id/topAppBarLayout" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_add.xml b/app/src/main/res/layout/dialog_add.xml index 1ec3b51..0070a35 100644 --- a/app/src/main/res/layout/dialog_add.xml +++ b/app/src/main/res/layout/dialog_add.xml @@ -4,18 +4,27 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + app:layout_constraintTop_toTopOf="parent" + android:hint="@string/add_edittext_hint"> + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 58b0127..86318a2 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -1,10 +1,6 @@ - + xmlns:android="http://schemas.android.com/apk/res/android"> - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f8c6127..6b40555 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,10 +1,15 @@ - + - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file + #498EE8 + + #6750A4 + #6750A4 + #625B71 + #7D5260 + #FFFBFE + + #D0BCFF + #CCC2DC + #EFB8C8 + #1C1B1F + diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml deleted file mode 100644 index cf31181..0000000 --- a/app/src/main/res/values/ic_launcher_background.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #498EE8 - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1765f1e..2f37be2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,7 +11,8 @@ Enable auto Automatic (opportunistic) DNS mode will now be available in the tile Cancel - Delete server? + Delete + Are you sure you want to delete server? Delete Server address cannot be empty DNS server address diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index c2f6018..7cf8d95 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,16 +1,13 @@ - - \ No newline at end of file