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>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-04-03T03:35:41.455486600Z" />
<timeTargetWasSelectedWithDropDown value="2024-04-07T07:35:55.802913400Z" />
</State>
</entry>
</value>

View File

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

View File

@ -136,9 +136,9 @@ class AppInputMethodService : InputMethodService(), OnKeyboardActionListener {
}
}
}
}
// 点击完成
Keyboard.KEYCODE_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.Context
import android.content.Intent
import android.content.IntentFilter
import android.graphics.Color
import android.os.Build
import android.os.Bundle
@ -11,13 +12,41 @@ import android.view.View
import android.view.inputmethod.InputMethodInfo
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity
import com.timber.soft.newkeyboard.R
import com.timber.soft.newkeyboard.databinding.ActivityApplyBinding
import com.timber.soft.newkeyboard.tools.StatusBarTools
class ApplyActivity : AppCompatActivity() {
class ApplyActivity : AppCompatActivity(), View.OnClickListener {
private lateinit var binding: ActivityApplyBinding
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?) {
super.onCreate(savedInstanceState)
@ -33,15 +62,14 @@ class ApplyActivity : AppCompatActivity() {
window.statusBarColor = Color.TRANSPARENT
}
inputManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
binding.applyBack.setOnClickListener() {
finish()
}
binding.idStep1.setOnClickListener() {
applyKeyboard()
}
binding.idStep2.setOnClickListener() {
chooseKeyboard()
}
updateUi()
listener = StepReceive()
register()
binding.idStep1.setOnClickListener(this)
binding.idStep2.setOnClickListener(this)
binding.applyBack.setOnClickListener(this)
}
override fun onResume() {
@ -49,34 +77,9 @@ class ApplyActivity : AppCompatActivity() {
updateUi()
}
private fun chooseKeyboard() {
inputManager.showInputMethodPicker()
}
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
override fun onDestroy() {
super.onDestroy()
unregisterReceiver(listener)
}
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
dataModel = intent.getSerializableExtra("KEY_EXTRA") as DataModel
previewUrl = dataModel.thumb
val cacheDir = cacheDir
val dataModelUrl = dataModel.zipUrl
zipPath = "$cacheDir/$dataModelUrl"
binding.detailsBack.setOnClickListener(View.OnClickListener {
finish()
})
@ -134,7 +132,8 @@ class DetailsActivity : AppCompatActivity(), ApplyListener {
return
}
binding.themeProgressbar.visibility = View.VISIBLE
binding.coverView.visibility = View.VISIBLE
val file = File(zipPath)
// 判断缓存中是否存在文件
if (file.exists()) {
@ -298,7 +297,7 @@ class DetailsActivity : AppCompatActivity(), ApplyListener {
* 点击设置后的回调接口
*/
override fun applyListener(isSuccess: Boolean, str: String) {
binding.themeProgressbar.visibility = View.GONE
binding.coverView.visibility = View.GONE
if (isSuccess) {
val lastIndexOf: Int = str.lastIndexOf(AppVal.res_path)
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 (default != null) {
val listDrawable = StateListDrawable().apply {
addState(intArrayOf(android.R.attr.state_pressed), press)
addState(intArrayOf(), default)
}
val listDrawable = getStatus(default,press)
functionBackgroundDraw = listDrawable
normalBackgroundDraw = 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:layout_width="33dp"
android:layout_height="33dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:padding="5dp"
android:layout_marginStart="8dp"
android:src="@drawable/svg_return"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -52,23 +52,15 @@
android:layout_width="match_parent"
android:layout_height="43dp"
android:layout_below="@id/theme_image"
android:layout_marginStart="15dp"
android:layout_marginStart="66dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="15dp"
android:layout_marginEnd="66dp"
android:background="@drawable/shape_theme_set"
android:gravity="center"
android:text="@string/download_apply"
android:textColor="@color/white"
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
android:id="@+id/theme_preloading"
@ -78,4 +70,23 @@
android:layout_alignBottom="@id/theme_image"
android:layout_centerHorizontal="true"
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>

View File

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

View File

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

View File

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

View File

@ -12,4 +12,5 @@
<string name="succ_apply">Application successful</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="loading_keyboard">Loading…</string>
</resources>