Commit 174fd429 authored by wanglei's avatar wanglei

...

parent b3146058
...@@ -19,12 +19,31 @@ ...@@ -19,12 +19,31 @@
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/logo"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/logo"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.LocalWeatherWhite" android:theme="@style/Theme.ScanQR"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".ui.start.StartActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/splash.theme"
tools:ignore="DiscouragedApi,LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.main.MainActivity"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<activity <activity
android:name=".ui.email.EmailCodeActivity" android:name=".ui.email.EmailCodeActivity"
android:exported="false" android:exported="false"
...@@ -55,17 +74,7 @@ ...@@ -55,17 +74,7 @@
android:exported="false" android:exported="false"
android:screenOrientation="portrait" android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" /> tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<activity
android:name=".ui.main.MainActivity"
android:exported="true"
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
......
...@@ -5,6 +5,15 @@ import java.util.Locale ...@@ -5,6 +5,15 @@ import java.util.Locale
object ConstObject { object ConstObject {
var ifAgreePrivacy = true
get() {
return AppPreferences.getInstance().getBoolean("ifAgreePrivacy", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("ifAgreePrivacy", value, true)
}
var isFirstLauncher = true var isFirstLauncher = true
get() { get() {
return AppPreferences.getInstance().getBoolean("isFirstLauncher", field) return AppPreferences.getInstance().getBoolean("isFirstLauncher", field)
...@@ -15,7 +24,6 @@ object ConstObject { ...@@ -15,7 +24,6 @@ object ConstObject {
} }
var appLanguageSp = Locale.getDefault().language var appLanguageSp = Locale.getDefault().language
get() { get() {
return AppPreferences.getInstance().getString("languageSp", field) return AppPreferences.getInstance().getString("languageSp", field)
......
package com.base.scanqr.ui.start
import android.content.Intent
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.base.scanqr.base.BaseActivity
import com.base.scanqr.bean.ConstObject
import com.base.scanqr.bean.ConstObject.isFirstLauncher
import com.base.scanqr.databinding.ActivityStartBinding
import com.base.scanqr.ui.main.MainActivity
import com.gyf.immersionbar.ktx.immersionBar
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import java.util.concurrent.atomic.AtomicBoolean
class StartActivity : BaseActivity<ActivityStartBinding>(ActivityStartBinding::inflate) {
private val viewModel by lazy(LazyThreadSafetyMode.NONE) {
ViewModelProvider(this)[StartViewModel::class.java]
}
override fun initView() {
super.initView()
if (ConstObject.ifAgreePrivacy) {
agreePrivacy()
}
}
private fun agreePrivacy() {
//todo 显示广告
viewModel.startJumpJob = true
viewModel.startJumpJob(lifecycleScope, ::jumpNext)
startProgressJob = true
startProgressJob()
}
private var startProgressJob: Boolean = false
private var progressJob: Job? = null
private fun startProgressJob() {
if (ConstObject.ifAgreePrivacy && startProgressJob) {
if (progressJob == null) {
progressJob = lifecycleScope.launch(Dispatchers.Main) {
while (isActive) {
binding.progressBar.progress += 1
delay(200)
}
}
}
}
}
private fun cancelProgressJob() {
progressJob?.cancel()
progressJob = null
}
private var jump: AtomicBoolean = AtomicBoolean(false)
private fun jumpNext() {
if (jump.get()) {
return
}
jump.set(true)
binding.progressBar.progress = 100
binding.root.postDelayed({
if (isFirstLauncher) {
isFirstLauncher = false
firstLauncherJump()
} else {
handleActionIdJump()
}
}, 100)
}
private fun handleActionIdJump() {
startActivity(Intent(this, MainActivity::class.java).apply {
})
}
private fun firstLauncherJump() {
startActivity(Intent(this, MainActivity::class.java).apply {
})
}
override fun initListener() {
super.initListener()
}
override fun configSystemBar() {
immersionBar {
statusBarColor("#00FFFFFF")
statusBarDarkFont(false)
// navigationBarDarkIcon(true)
// fitsSystemWindows(true)
// navigationBarColor("#FFFFFFFF")
}
}
override fun onResume() {
super.onResume()
viewModel.startJumpJob(lifecycleScope, ::jumpNext)
startProgressJob()
}
override fun onPause() {
super.onPause()
viewModel.cancelJumpJob()
cancelProgressJob()
}
}
\ No newline at end of file
package com.base.scanqr.ui.start
import androidx.lifecycle.LifecycleCoroutineScope
import androidx.lifecycle.ViewModel
import com.base.scanqr.bean.ConstObject
import com.base.scanqr.utils.LogEx
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
class StartViewModel : ViewModel() {
private val TAG = "StartViewModel"
private var jumpJob: Job? = null
private var loadingTime = 5
var startJumpJob: Boolean = false
/**
* 超时跳转
*/
fun startJumpJob(lifecycleCoroutineScope: LifecycleCoroutineScope, jumpNext: () -> Unit) {
if (ConstObject.ifAgreePrivacy && startJumpJob) {
if (jumpJob == null) {
val startTime = System.currentTimeMillis()
jumpJob = lifecycleCoroutineScope.launch {
LogEx.logDebug(TAG, "loadingTime=$loadingTime")
delay(loadingTime * 1000L)
val endTime = System.currentTimeMillis()
LogEx.logDebug(TAG, "超时跳转 time=${endTime - startTime}")
jumpNext.invoke()
}
}
}
}
/**
* 暂停超时跳转
*/
fun cancelJumpJob() {
jumpJob?.cancel()
jumpJob = null
}
}
...@@ -9,6 +9,8 @@ import android.content.IntentFilter ...@@ -9,6 +9,8 @@ import android.content.IntentFilter
import android.net.wifi.WifiConfiguration import android.net.wifi.WifiConfiguration
import android.net.wifi.WifiManager import android.net.wifi.WifiManager
import android.os.Build import android.os.Build
import android.text.Editable
import android.text.TextWatcher
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import com.base.scanqr.R import com.base.scanqr.R
...@@ -32,7 +34,7 @@ class WifiActivity : BaseActivity<ActivityWifiBinding>(ActivityWifiBinding::infl ...@@ -32,7 +34,7 @@ class WifiActivity : BaseActivity<ActivityWifiBinding>(ActivityWifiBinding::infl
private var wifiScanReceiver: WifiScanReceiver? = null private var wifiScanReceiver: WifiScanReceiver? = null
private var wifiList = arrayListOf<WifiUIBean>() private var wifiList = arrayListOf<WifiUIBean>()
private var wifiScanFinish: Boolean = false private var wifiScanFinish: Boolean = false
private var currentWifi: WifiUIBean? = null private var currentWifi: WifiUIBean = WifiUIBean()
override fun initView() { override fun initView() {
super.initView() super.initView()
...@@ -67,39 +69,66 @@ class WifiActivity : BaseActivity<ActivityWifiBinding>(ActivityWifiBinding::infl ...@@ -67,39 +69,66 @@ class WifiActivity : BaseActivity<ActivityWifiBinding>(ActivityWifiBinding::infl
binding.rg.setOnCheckedChangeListener { group, checkedId -> binding.rg.setOnCheckedChangeListener { group, checkedId ->
when (checkedId) { when (checkedId) {
R.id.radioButton1 -> { R.id.radioButton1 -> {
currentWifi?.securityId = 0 currentWifi.securityId = 0
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
currentWifi?.securityTypes = intArrayOf(WifiConfiguration.SECURITY_TYPE_PSK) currentWifi.securityTypes = intArrayOf(WifiConfiguration.SECURITY_TYPE_PSK)
} }
} }
R.id.radioButton2 -> { R.id.radioButton2 -> {
currentWifi?.securityId = 1 currentWifi.securityId = 1
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
currentWifi?.securityTypes = intArrayOf(WifiConfiguration.SECURITY_TYPE_WEP) currentWifi.securityTypes = intArrayOf(WifiConfiguration.SECURITY_TYPE_WEP)
} }
} }
R.id.radioButton3 -> { R.id.radioButton3 -> {
currentWifi?.securityId = 2 currentWifi.securityId = 2
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
currentWifi?.securityTypes = intArrayOf(WifiConfiguration.SECURITY_TYPE_OPEN) currentWifi.securityTypes = intArrayOf(WifiConfiguration.SECURITY_TYPE_OPEN)
} }
} }
} }
} }
binding.editSSID.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(s: Editable?) {
currentWifi.ssid = s.toString()
}
})
binding.editPassword.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(s: Editable?) {
currentWifi.password = s.toString()
}
})
binding.flQueren.setOnClickListener { binding.flQueren.setOnClickListener {
if (binding.editPassword.text.isEmpty()) { if (currentWifi.ssid.isEmpty()) {
toast("Enter password wifi") toast("Enter wifi ssid", true)
return@setOnClickListener
}
if (currentWifi.password.isEmpty()) {
toast("Enter password wifi", true)
return@setOnClickListener return@setOnClickListener
} }
currentWifi?.password = binding.editPassword.text.toString()
startActivity(Intent(this, WifiCodeActivity::class.java).apply { startActivity(Intent(this, WifiCodeActivity::class.java).apply {
putExtra("data", Gson().toJson(currentWifi)) putExtra("data", Gson().toJson(currentWifi))
}) })
} }
binding.switchHidden.setOnCheckedChangeListener { buttonView, isChecked -> binding.switchHidden.setOnCheckedChangeListener { buttonView, isChecked ->
currentWifi?.hidden = isChecked currentWifi.hidden = isChecked
} }
wifiManager = getSystemService(Context.WIFI_SERVICE) as WifiManager? wifiManager = getSystemService(Context.WIFI_SERVICE) as WifiManager?
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<!-- <stroke-->
<!-- android:width="1px"-->
<!-- android:color="#FF3835" />-->
<solid android:color="#FFFFFF" />
<corners android:radius="80dp" />
</shape>
</item>
<!-- android:bottom="3dp"-->
<!-- android:end="3dp"-->
<!-- android:start="3dp"-->
<!-- android:top="3dp"-->
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%">
<shape>
<corners android:radius="80dp" />
<solid android:color="#5CCBFF" />
</shape>
</scale>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/qidongyebg" />
<item
android:gravity="top|center_horizontal"
android:top="150dp">
<bitmap android:src="@mipmap/qdylogo" />
</item>
</layer-list>
\ No newline at end of file
<?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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.start.StartActivity">
<ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="150dp"
android:src="@mipmap/qdylogo"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv" />
<ProgressBar
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_marginHorizontal="36dp"
android:layout_marginBottom="20dp"
android:max="100"
android:progressDrawable="@drawable/bg_progressbar"
app:layout_constraintBottom_toTopOf="@id/tvLoading"
tools:progress="50" />
<TextView
android:id="@+id/tvLoading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="34dp"
android:text="@string/loading"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -71,16 +71,19 @@ ...@@ -71,16 +71,19 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"> android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
tools:ignore="DisableBaselineAlignment">
<LinearLayout <LinearLayout
android:id="@+id/ll_sort" android:id="@+id/ll_sort"
android:layout_width="108dp" android:layout_width="0dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginHorizontal="5dp" android:layout_marginHorizontal="6dp"
android:layout_weight="1"
android:background="@drawable/bg_eeefff_10" android:background="@drawable/bg_eeefff_10"
android:gravity="center"> android:gravity="center">
...@@ -105,9 +108,10 @@ ...@@ -105,9 +108,10 @@
<LinearLayout <LinearLayout
android:id="@+id/ll_export" android:id="@+id/ll_export"
android:layout_width="108dp" android:layout_width="0dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginHorizontal="5dp" android:layout_marginHorizontal="6dp"
android:layout_weight="1"
android:background="@drawable/bg_ecf6ee_10" android:background="@drawable/bg_ecf6ee_10"
android:gravity="center" android:gravity="center"
android:visibility="gone"> android:visibility="gone">
...@@ -133,9 +137,10 @@ ...@@ -133,9 +137,10 @@
<LinearLayout <LinearLayout
android:id="@+id/ll_remove" android:id="@+id/ll_remove"
android:layout_width="108dp" android:layout_width="0dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginHorizontal="5dp" android:layout_marginHorizontal="6dp"
android:layout_weight="1"
android:background="@drawable/bg_f8e4e6_10" android:background="@drawable/bg_f8e4e6_10"
android:gravity="center"> android:gravity="center">
......
...@@ -5,10 +5,5 @@ ...@@ -5,10 +5,5 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.main.SettingsFragment"> tools:context=".ui.main.SettingsFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout> </FrameLayout>
\ No newline at end of file
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Base.Theme.LocalWeatherWhite" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Base.Theme.ScanQR" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your dark theme here. --> <!-- Customize your dark theme here. -->
<!-- <item name="colorPrimary">@color/my_dark_primary</item> --> <!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
</style> </style>
......
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.DataRecovery" parent="Theme.ScanQR">
<!-- Transparent system bars for edge-to-edge. -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
</style>
</resources>
\ No newline at end of file
<resources> <resources>
<string name="app_name">Scan QR</string> <string name="app_name">Scan QR Code &amp; Barcode Reader</string>
<string name="facebook_app_id">12323213221414411</string> <string name="facebook_app_id">12323213221414411</string>
<string name="create">Create</string> <string name="create">Create</string>
<string name="scan">Scan</string> <string name="scan">Scan</string>
<string name="history">History</string> <string name="history">History</string>
<string name="settings">Settings</string> <string name="settings">Settings</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="wifi">Wifi</string> <string name="wifi">Wifi</string>
<string name="text">Text</string> <string name="text">Text</string>
<string name="email">Email</string> <string name="email">Email</string>
...@@ -41,11 +41,12 @@ ...@@ -41,11 +41,12 @@
<string name="to">To</string> <string name="to">To</string>
<string name="enter_address_email">Enter address email</string> <string name="enter_address_email">Enter address email</string>
<string name="subject">Subject</string> <string name="subject">Subject</string>
<string name="enter_your_message_here">Enter your message here...</string> <string name="enter_your_message_here">Enter your message here</string>
<string name="sort">Sort</string> <string name="sort">Sort</string>
<string name="export">Export</string> <string name="export">Export</string>
<string name="remove">Remove</string> <string name="remove">Remove</string>
<string name="detail">Detail</string> <string name="detail">Detail</string>
<string name="delete_qrcode">Delete QRCode</string> <string name="delete_qrcode">Delete QRCode</string>
<string name="do_you_want_delete_item">Do you want delete item?</string> <string name="do_you_want_delete_item">Do you want delete item?</string>
<string name="loading">Loading</string>
</resources> </resources>
\ No newline at end of file
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Base.Theme.LocalWeatherWhite" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Base.Theme.ScanQR" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. --> <!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> --> <!-- <item name="colorPrimary">@color/my_light_primary</item> -->
</style> </style>
<style name="Theme.LocalWeatherWhite" parent="Base.Theme.LocalWeatherWhite" /> <style name="Theme.ScanQR" parent="Base.Theme.ScanQR" />
<style name="splash.theme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowBackground">@drawable/splash_bp</item>
<item name="android:windowFullscreen">false</item>
</style>
</resources> </resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment