Skip to content

Commit

Permalink
Initial support for Android 14 DP1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Mar 3, 2023
1 parent 72e23bc commit 0d2f8e2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
targetCompatibility(javaVersion)
}
kotlin.jvmToolchain(javaVersion)
compileSdk = 33
compileSdkPreview = "UpsideDownCake"
defaultConfig {
applicationId = "be.mygod.vpnhotspot"
minSdk = 28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.Toolbar
import androidx.core.os.BuildCompat
import androidx.core.os.persistableBundleOf
import androidx.core.view.isGone
import be.mygod.librootkotlinx.toByteArray
Expand All @@ -34,6 +35,7 @@ import be.mygod.vpnhotspot.databinding.DialogWifiApBinding
import be.mygod.vpnhotspot.net.monitor.TetherTimeoutMonitor
import be.mygod.vpnhotspot.util.QRCodeDialog
import be.mygod.vpnhotspot.util.RangeInput
import be.mygod.vpnhotspot.util.Services
import be.mygod.vpnhotspot.util.readableMessage
import be.mygod.vpnhotspot.util.showAllowingStateLoss
import com.google.android.material.textfield.TextInputLayout
Expand Down Expand Up @@ -512,9 +514,14 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
val canCopy = timeoutError == null && bssidValid && maxClientError == null && listsNoError &&
bridgedTimeoutError == null && vendorElementsError == null && persistentRandomizedMacValid &&
acsNoError && bandwidthError == null
(dialog as? AlertDialog)?.getButton(DialogInterface.BUTTON_POSITIVE)?.isEnabled =
ssidOk && passwordValid && bandError == null && canCopy
dialogView.toolbar.menu.findItem(android.R.id.copy).isEnabled = canCopy
val canGenerate = ssidOk && passwordValid && bandError == null && canCopy
(dialog as? AlertDialog)?.getButton(DialogInterface.BUTTON_POSITIVE)?.isEnabled = canGenerate
dialogView.toolbar.menu.apply {
findItem(R.id.invalid).isVisible = canGenerate && !arg.p2pMode && !arg.readOnly &&
BuildCompat.isAtLeastU() &&
!Services.wifi.validateSoftApConfiguration(generateConfig().toPlatform())
findItem(android.R.id.copy).isEnabled = canCopy
}
}

override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { }
Expand Down
10 changes: 9 additions & 1 deletion mobile/src/main/res/menu/toolbar_configuration.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item android:id="@+id/invalid"
android:icon="@drawable/ic_alert_warning"
android:visible="false"
android:title="@string/configuration_invalid"
app:iconTint="@color/design_default_color_error"
app:showAsAction="always"
tools:visible="true"/>
<item android:id="@android:id/copy"
android:alphabeticShortcut="c"
android:icon="?attr/actionModeCopyDrawable"
Expand Down
1 change: 1 addition & 0 deletions mobile/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<string name="permission_missing">权限不足</string>

<string name="configuration_view">设置 WLAN</string>
<string name="configuration_invalid">配置可能无效</string>
<string name="configuration_share">使用 QR 码分享</string>
<string name="configuration_rejected">Android 系统拒绝使用此配置。(详情参见日志)</string>
<string name="wifi_ssid" msgid="5519636102673067319">"网络名称"</string>
Expand Down
1 change: 1 addition & 0 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<string name="permission_missing">Permission missing</string>

<string name="configuration_view">Wi\u2011Fi configuration</string>
<string name="configuration_invalid">Possibly invalid configuration</string>
<string name="configuration_share">Share via QR code</string>
<string name="configuration_rejected">Android system refuses such configuration. (see logcat)</string>
<string name="wifi_ssid">Network name</string>
Expand Down

0 comments on commit 0d2f8e2

Please sign in to comment.