debug-1.0

This commit is contained in:
LUX-Timber 2024-04-07 16:11:07 +08:00
parent a9d33c1ec3
commit 2ddfbd9b64
12 changed files with 125 additions and 71 deletions

View File

@ -15,7 +15,7 @@
</deviceKey> </deviceKey>
</Target> </Target>
</runningDeviceTargetSelectedWithDropDown> </runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-04-03T03:35:41.455486600Z" /> <timeTargetWasSelectedWithDropDown value="2024-04-07T07:35:55.802913400Z" />
</State> </State>
</entry> </entry>
</value> </value>

View File

@ -37,9 +37,12 @@
android:resource="@xml/key_view" /> android:resource="@xml/key_view" />
</service> </service>
<activity
<activity android:name=".activity.DetailsActivity" /> android:name=".activity.DetailsActivity"
<activity android:name=".activity.ApplyActivity" /> android:exported="false" />
<activity
android:name=".activity.ApplyActivity"
android:exported="false" />
</application> </application>
</manifest> </manifest>

View File

@ -136,9 +136,9 @@ class AppInputMethodService : InputMethodService(), OnKeyboardActionListener {
} }
} }
} }
} }
// 点击完成
Keyboard.KEYCODE_DONE -> { Keyboard.KEYCODE_DONE -> {
currentInputConnection.performEditorAction(EditorInfo.IME_ACTION_DONE) currentInputConnection.performEditorAction(EditorInfo.IME_ACTION_DONE)
} }

View File

@ -3,6 +3,7 @@ package com.timber.soft.newkeyboard.activity
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter
import android.graphics.Color import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@ -11,13 +12,41 @@ import android.view.View
import android.view.inputmethod.InputMethodInfo import android.view.inputmethod.InputMethodInfo
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.timber.soft.newkeyboard.R
import com.timber.soft.newkeyboard.databinding.ActivityApplyBinding import com.timber.soft.newkeyboard.databinding.ActivityApplyBinding
import com.timber.soft.newkeyboard.tools.StatusBarTools import com.timber.soft.newkeyboard.tools.StatusBarTools
class ApplyActivity : AppCompatActivity() { class ApplyActivity : AppCompatActivity(), View.OnClickListener {
private lateinit var binding: ActivityApplyBinding private lateinit var binding: ActivityApplyBinding
private lateinit var inputManager: InputMethodManager private lateinit var inputManager: InputMethodManager
private lateinit var listener: BroadcastReceiver
private fun chooseKeyboard() {
inputManager.showInputMethodPicker()
}
private fun applyKeyboard() {
Intent(Settings.ACTION_INPUT_METHOD_SETTINGS).apply {
startActivity(this)
}
}
override fun onClick(v: View?) {
when (v) {
binding.idStep2 -> {
chooseKeyboard()
}
binding.idStep1 -> {
applyKeyboard()
}
binding.applyBack -> {
finish()
}
}
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -33,15 +62,14 @@ class ApplyActivity : AppCompatActivity() {
window.statusBarColor = Color.TRANSPARENT window.statusBarColor = Color.TRANSPARENT
} }
inputManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager inputManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
binding.applyBack.setOnClickListener() {
finish() updateUi()
} listener = StepReceive()
binding.idStep1.setOnClickListener() { register()
applyKeyboard()
} binding.idStep1.setOnClickListener(this)
binding.idStep2.setOnClickListener() { binding.idStep2.setOnClickListener(this)
chooseKeyboard() binding.applyBack.setOnClickListener(this)
}
} }
override fun onResume() { override fun onResume() {
@ -49,34 +77,9 @@ class ApplyActivity : AppCompatActivity() {
updateUi() updateUi()
} }
private fun chooseKeyboard() { override fun onDestroy() {
inputManager.showInputMethodPicker() super.onDestroy()
} unregisterReceiver(listener)
private fun applyKeyboard() {
Intent(Settings.ACTION_INPUT_METHOD_SETTINGS).apply {
startActivity(this)
}
}
private fun updateUi() {
binding.idStep1.setSelected(isEnable())
binding.idStep2.setSelected(isChoose())
}
private fun isChoose(): Boolean {
Settings.Secure.getString(contentResolver, Settings.Secure.DEFAULT_INPUT_METHOD).let { id ->
return id.startsWith(packageName)
}
}
private fun isEnable(): Boolean {
for (info: InputMethodInfo in inputManager.enabledInputMethodList) {
if (info.id.startsWith(packageName)) {
return true
}
}
return false
} }
inner class StepReceive : BroadcastReceiver() { inner class StepReceive : BroadcastReceiver() {
@ -85,4 +88,41 @@ class ApplyActivity : AppCompatActivity() {
} }
} }
private fun register() {
registerReceiver(listener, IntentFilter(Intent.ACTION_INPUT_METHOD_CHANGED))
}
private fun updateUi() {
if (isEnable()) {
binding.idStep1.setBackgroundResource(R.drawable.shape_theme_set_over)
} else {
binding.idStep1.setBackgroundResource(R.drawable.shape_theme_set)
}
if (isChoose()) {
binding.idStep2.setBackgroundResource(R.drawable.shape_theme_set_over)
} else {
binding.idStep2.setBackgroundResource(R.drawable.shape_theme_set)
}
}
/**
* 检查是否设置键盘
*/
private fun isChoose(): Boolean {
Settings.Secure.getString(contentResolver, Settings.Secure.DEFAULT_INPUT_METHOD).let { id ->
return id.startsWith(packageName)
}
}
/**
* 检查是否启用键盘
*/
private fun isEnable(): Boolean {
for (info: InputMethodInfo in inputManager.enabledInputMethodList) {
if (info.id.startsWith(packageName)) {
return true
}
}
return false
}
} }

View File

@ -63,14 +63,12 @@ class DetailsActivity : AppCompatActivity(), ApplyListener {
inputManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager inputManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
dataModel = intent.getSerializableExtra("KEY_EXTRA") as DataModel dataModel = intent.getSerializableExtra("KEY_EXTRA") as DataModel
previewUrl = dataModel.thumb previewUrl = dataModel.thumb
val cacheDir = cacheDir val cacheDir = cacheDir
val dataModelUrl = dataModel.zipUrl val dataModelUrl = dataModel.zipUrl
zipPath = "$cacheDir/$dataModelUrl" zipPath = "$cacheDir/$dataModelUrl"
binding.detailsBack.setOnClickListener(View.OnClickListener { binding.detailsBack.setOnClickListener(View.OnClickListener {
finish() finish()
}) })
@ -134,7 +132,8 @@ class DetailsActivity : AppCompatActivity(), ApplyListener {
return return
} }
binding.themeProgressbar.visibility = View.VISIBLE binding.coverView.visibility = View.VISIBLE
val file = File(zipPath) val file = File(zipPath)
// 判断缓存中是否存在文件 // 判断缓存中是否存在文件
if (file.exists()) { if (file.exists()) {
@ -298,7 +297,7 @@ class DetailsActivity : AppCompatActivity(), ApplyListener {
* 点击设置后的回调接口 * 点击设置后的回调接口
*/ */
override fun applyListener(isSuccess: Boolean, str: String) { override fun applyListener(isSuccess: Boolean, str: String) {
binding.themeProgressbar.visibility = View.GONE binding.coverView.visibility = View.GONE
if (isSuccess) { if (isSuccess) {
val lastIndexOf: Int = str.lastIndexOf(AppVal.res_path) val lastIndexOf: Int = str.lastIndexOf(AppVal.res_path)
val substring = str.subSequence(0, lastIndexOf + AppVal.res_path.length).toString() val substring = str.subSequence(0, lastIndexOf + AppVal.res_path.length).toString()

View File

@ -101,10 +101,7 @@ class MyKeyboardView @JvmOverloads constructor(
) )
if (press != null) { if (press != null) {
if (default != null) { if (default != null) {
val listDrawable = StateListDrawable().apply { val listDrawable = getStatus(default,press)
addState(intArrayOf(android.R.attr.state_pressed), press)
addState(intArrayOf(), default)
}
functionBackgroundDraw = listDrawable functionBackgroundDraw = listDrawable
normalBackgroundDraw = listDrawable normalBackgroundDraw = listDrawable
spBackgroundDraw = listDrawable spBackgroundDraw = listDrawable

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#7E7E7E"/>
<corners android:radius="10dp"/>
</shape>

View File

@ -18,9 +18,9 @@
android:id="@+id/details_back" android:id="@+id/details_back"
android:layout_width="33dp" android:layout_width="33dp"
android:layout_height="33dp" android:layout_height="33dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:padding="5dp" android:padding="5dp"
android:layout_marginStart="8dp"
android:src="@drawable/svg_return" android:src="@drawable/svg_return"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -52,23 +52,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="43dp" android:layout_height="43dp"
android:layout_below="@id/theme_image" android:layout_below="@id/theme_image"
android:layout_marginStart="15dp" android:layout_marginStart="66dp"
android:layout_marginTop="64dp" android:layout_marginTop="64dp"
android:layout_marginEnd="15dp" android:layout_marginEnd="66dp"
android:background="@drawable/shape_theme_set" android:background="@drawable/shape_theme_set"
android:gravity="center" android:gravity="center"
android:text="@string/download_apply" android:text="@string/download_apply"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="15sp" /> android:textSize="15sp" />
<ProgressBar
android:id="@+id/theme_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/theme_set"
android:layout_centerHorizontal="true"
android:indeterminateTint="@color/white"
android:visibility="gone" />
<ProgressBar <ProgressBar
android:id="@+id/theme_preloading" android:id="@+id/theme_preloading"
@ -78,4 +70,23 @@
android:layout_alignBottom="@id/theme_image" android:layout_alignBottom="@id/theme_image"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:indeterminateTint="@color/theme_color" /> android:indeterminateTint="@color/theme_color" />
<RelativeLayout
android:id="@+id/cover_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BF000000"
android:visibility="gone">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/loading_keyboard"
android:textColor="@color/white"
android:textSize="24dp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -45,8 +45,8 @@
<com.google.android.material.tabs.TabLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout" android:id="@+id/tabLayout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="36dp" android:layout_height="38dp"
android:layout_marginTop="8dp" android:layout_marginTop="4dp"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title" app:layout_constraintTop_toBottomOf="@id/tv_title"
app:tabIndicatorColor="@color/theme_color" app:tabIndicatorColor="@color/theme_color"

View File

@ -10,16 +10,15 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center"
android:padding="10dp" android:padding="18dp"
android:text="text_TAB" android:text="text_TAB"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="14sp" /> android:textSize="14sp" />
<View <View
android:id="@+id/line_index" android:id="@+id/line_index"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="2dp"
android:background="@color/theme_color" /> android:background="@color/theme_color" />
</LinearLayout> </LinearLayout>

View File

@ -2,9 +2,6 @@
<resources> <resources>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="theme_color">#FFBB86FC</color> <color name="theme_color">#FFBB86FC</color>
<color name="gray">#FF888888</color>
</resources> </resources>

View File

@ -12,4 +12,5 @@
<string name="succ_apply">Application successful</string> <string name="succ_apply">Application successful</string>
<string name="fail_apply">Application failed, please try again</string> <string name="fail_apply">Application failed, please try again</string>
<string name="text_promote">For normal use, please enter the setting to complete the setting steps.</string> <string name="text_promote">For normal use, please enter the setting to complete the setting steps.</string>
<string name="loading_keyboard">Loading…</string>
</resources> </resources>