Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and fix 20241211 #1530

Merged
merged 9 commits into from
Dec 13, 2024
15 changes: 5 additions & 10 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
build:
if: ${{ github.repository == 'osfans/trime' && github.ref == 'refs/heads/develop' }}
runs-on: ubuntu-24.04
env:
SIGN_KEY_BASE64: ${{ secrets.SIGNING_KEY }}
SIGN_KEY_STORE_PWD: ${{ secrets.KEY_STORE_PASSWORD }}
SIGN_KEY_ALIAS: ${{ secrets.ALIAS }}
SIGN_KEY_PWD: ${{ secrets.KEY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -44,16 +49,6 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Setup keystore
run: |
echo ${{ secrets.SIGNING_KEY }} | base64 --decode | cat >> $(pwd)/signingkey.jks
cat << EOF > keystore.properties
storeFile=$(pwd)/signingkey.jks
storePassword=${{ secrets.KEY_STORE_PASSWORD }}
keyAlias=${{ secrets.ALIAS }}
keyPassword=${{ secrets.KEY_PASSWORD }}
EOF

- name: Build Trime
run: make release

Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ env:
jobs:
build:
runs-on: ubuntu-24.04
env:
SIGN_KEY_BASE64: ${{ secrets.SIGNING_KEY }}
SIGN_KEY_STORE_PWD: ${{ secrets.KEY_STORE_PASSWORD }}
SIGN_KEY_ALIAS: ${{ secrets.ALIAS }}
SIGN_KEY_PWD: ${{ secrets.KEY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -43,16 +48,6 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Setup keystore
run: |
echo ${{ secrets.SIGNING_KEY }} | base64 --decode | cat >> $(pwd)/signingkey.jks
cat << EOF > keystore.properties
storeFile=$(pwd)/signingkey.jks
storePassword=${{ secrets.KEY_STORE_PASSWORD }}
keyAlias=${{ secrets.ALIAS }}
keyPassword=${{ secrets.KEY_PASSWORD }}
EOF

- name: Build Trime
run: make release

Expand Down
16 changes: 6 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ android {
isMinifyEnabled = false
// proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-android.txt"
signingConfig =
with(ApkRelease) {
if (project.buildApkRelease) {
signingConfigs.create("release") {
storeFile = file(project.storeFile!!)
storePassword = project.storePassword
keyAlias = project.keyAlias
keyPassword = project.keyPassword
}
} else {
null
project.signKeyFile?.let {
signingConfigs.create("release") {
storeFile = it
storePassword = project.signKeyStorePwd
keyAlias = project.signKeyAlias
keyPassword = project.signKeyPwd
}
}

Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/osfans/trime/core/Rime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,6 @@ class Rime :
@JvmStatic
external fun forgetRimeCandidate(index: Int): Boolean

@JvmStatic
external fun getLibrimeVersion(): String

// module
@JvmStatic
external fun runRimeTask(taskName: String?): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ object OpenCCDictManager {
configFileName: String,
): String

@JvmStatic
external fun getOpenCCVersion(): String

const val MODE_BIN_TO_TXT = true // OCD(2) to TXT
const val MODE_TXT_TO_BIN = false // TXT to OCD2
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class GeneralStyleMapper(

val textFont = getStringList("text_font")

val textSize = getInt("text_size")
val textSize = getFloat("text_size")

val verticalCorrection = getInt("vertical_correction")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LayoutStyleMapper(

val roundCorner = getFloat("round_corner")

val alpha = getInt("alpha")
val alpha = getFloat("alpha", 0.8f)
val elevation = getInt("elevation")
val movable = getString("movable")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ data class GeneralStyle(
val symbolFont: List<String>,
val symbolTextSize: Float,
val textFont: List<String>,
val textSize: Int,
val textSize: Float,
val verticalCorrection: Int,
val verticalGap: Int,
val longTextFont: List<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data class Layout(
val realMargin: Int,
val spacing: Int,
val roundCorner: Float,
val alpha: Int,
val alpha: Float,
val elevation: Int,
val movable: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class ComposingPopupWindow(
theme.generalStyle.layout.border,
"border_color",
theme.generalStyle.layout.roundCorner,
theme.generalStyle.layout.alpha,
theme.generalStyle.layout.alpha
.toInt(),
),
)
width = WindowManager.LayoutParams.WRAP_CONTENT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@
package com.osfans.trime.ime.composition

import android.content.Context
import android.graphics.Outline
import android.graphics.Rect
import android.view.Gravity
import android.view.View
import android.view.ViewOutlineProvider
import android.view.WindowManager
import android.widget.PopupWindow
import com.osfans.trime.core.RimeProto
import com.osfans.trime.daemon.RimeSession
import com.osfans.trime.daemon.launchOnReady
import com.osfans.trime.data.theme.ColorManager
import com.osfans.trime.data.theme.Theme
import com.osfans.trime.ime.bar.QuickBar
import com.osfans.trime.ime.broadcast.InputBroadcastReceiver
import com.osfans.trime.ime.dependency.InputScope
import me.tatarka.inject.annotations.Inject
import splitties.views.backgroundColor

@InputScope
@Inject
Expand All @@ -26,8 +32,29 @@ class PreeditModule(
rime: RimeSession,
private val bar: QuickBar,
) : InputBroadcastReceiver {
private val textBackColor = ColorManager.getColor("text_back_color")

private val topLeftCornerRadiusOutlineProvider =
object : ViewOutlineProvider() {
override fun getOutline(
view: View,
outline: Outline,
) {
val radius = theme.generalStyle.layout.roundCorner
val width = view.width
val height = view.height
val rect = Rect(-radius.toInt(), 0, width, (height + radius).toInt())
outline.setRoundRect(rect, radius)
}
}

val ui =
PreeditUi(context, theme).apply {
PreeditUi(context, theme, setupPreeditView = {
textBackColor?.let { backgroundColor = it }
}).apply {
root.alpha = theme.generalStyle.layout.alpha
root.outlineProvider = topLeftCornerRadiusOutlineProvider
root.clipToOutline = true
preedit.setOnCursorMoveListener { position ->
rime.launchOnReady { it.moveCursorPos(position) }
}
Expand All @@ -42,13 +69,17 @@ class PreeditModule(
override fun onInputContextUpdate(ctx: RimeProto.Context) {
ui.update(ctx.composition)
if (ctx.composition.length > 0) {
window.showAtLocation(bar.view, Gravity.START or Gravity.TOP, 0, 0)
val (x, y) = intArrayOf(0, 0).also { bar.view.getLocationInWindow(it) }
window.showAtLocation(bar.view, Gravity.START or Gravity.TOP, x, y)
ui.root.post {
window.update(x, y - ui.root.height, -1, -1)
}
} else {
window.dismiss()
}
}

fun onDetached() {
window.dismiss()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.text.style.BackgroundColorSpan
import android.text.style.ForegroundColorSpan
import android.view.MotionEvent
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.text.buildSpannedString
import com.osfans.trime.core.RimeProto
import com.osfans.trime.data.theme.ColorManager
Expand All @@ -25,6 +26,7 @@ import splitties.views.setPaddingDp
open class PreeditUi(
final override val ctx: Context,
private val theme: Theme,
private val setupPreeditView: (TextView.() -> Unit)? = null,
) : Ui {
private val textColor = ColorManager.getColor("text_color")
private val highlightTextColor = ColorManager.getColor("hilited_text_color")
Expand All @@ -34,8 +36,9 @@ open class PreeditUi(
view(::PreeditTextView) {
setPaddingDp(3, 1, 3, 1)
textColor?.let { setTextColor(it) }
textSize = theme.generalStyle.textSize.toFloat()
textSize = theme.generalStyle.textSize
typeface = FontManager.getTypeface("text_font")
setupPreeditView?.invoke(this)
}

override val root =
Expand Down
32 changes: 1 addition & 31 deletions app/src/main/java/com/osfans/trime/ime/core/InputView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
package com.osfans.trime.ime.core

import android.annotation.SuppressLint
import android.app.Dialog
import android.graphics.Color
import android.os.Build
import android.view.View
import android.view.View.OnClickListener
import android.view.WindowManager
import android.view.inputmethod.EditorInfo
import android.widget.ImageView
import androidx.constraintlayout.widget.ConstraintLayout
Expand All @@ -37,7 +35,6 @@ import com.osfans.trime.ime.keyboard.KeyboardWindow
import com.osfans.trime.ime.preview.KeyPreviewChoreographer
import com.osfans.trime.ime.symbol.LiquidKeyboard
import com.osfans.trime.util.ColorUtils
import com.osfans.trime.util.styledFloat
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import splitties.dimensions.dp
Expand Down Expand Up @@ -372,40 +369,13 @@ class InputView(
broadcaster.onSelectionUpdate(start, end)
}

private var showingDialog: Dialog? = null

fun showDialog(dialog: Dialog) {
showingDialog?.dismiss()
val windowToken = windowToken
check(windowToken != null) { "InputView Token is null." }
val window = dialog.window!!
window.attributes.apply {
token = windowToken
type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG
}
window.addFlags(
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM or
WindowManager.LayoutParams.FLAG_DIM_BEHIND,
)
window.setDimAmount(themedContext.styledFloat(android.R.attr.backgroundDimAmount))
showingDialog =
dialog.apply {
setOnDismissListener { [email protected] = null }
show()
}
}

fun finishInput() {
showingDialog?.dismiss()
}

override fun onDetachedFromWindow() {
ViewCompat.setOnApplyWindowInsetsListener(this, null)
showingDialog?.dismiss()
// cancel the notification job and clear all broadcast receivers,
// implies that InputView should not be attached again after detached.
baseCallbackHandler.cancelJob()
updateWindowViewHeightJob.cancel()
preedit.onDetached()
preview.root.removeAllViews()
broadcaster.clear()
super.onDetachedFromWindow()
Expand Down
Loading
Loading