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

Enable App Shrinking, etc. #1585

Merged
merged 5 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ 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 @@ -49,6 +44,15 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Setup Keystore
run: |
cat << EOF > keystore.properties
keyBase64=${{ secrets.SIGNING_KEY }}
storePassword=${{ secrets.KEY_STORE_PASSWORD }}
keyAlias=${{ secrets.ALIAS }}
keyPassword=${{ secrets.KEY_PASSWORD }}
EOF

- name: Build Trime
run: make release

Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ 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 @@ -48,6 +43,15 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Setup Keystore
run: |
cat << EOF > keystore.properties
keyBase64=${{ secrets.SIGNING_KEY }}
storePassword=${{ secrets.KEY_STORE_PASSWORD }}
keyAlias=${{ secrets.ALIAS }}
keyPassword=${{ secrets.KEY_PASSWORD }}
EOF

- name: Build Trime
run: make release

Expand Down
39 changes: 37 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@file:Suppress("UnstableApiUsage")

plugins {
id("com.osfans.trime.app-convention")
id("com.osfans.trime.native-app-convention")
id("com.osfans.trime.data-checksums")
id("com.osfans.trime.native-cache-hash")
Expand Down Expand Up @@ -38,8 +39,12 @@ android {

buildTypes {
release {
isMinifyEnabled = false
// proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-android.txt"
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
signingConfig =
project.signKeyFile?.let {
signingConfigs.create("release") {
Expand All @@ -57,6 +62,11 @@ android {

resValue("string", "trime_app_name", "@string/app_name_debug")
}
all {
// remove META-INF/version-control-info.textproto
@Suppress("UnstableApiUsage")
vcsInfo.include = false
}
}

buildFeatures {
Expand All @@ -83,6 +93,24 @@ android {
it.useJUnitPlatform()
}
}

dependenciesInfo {
includeInApk = false
includeInBundle = false
}

packaging {
resources {
excludes +=
setOf(
"/META-INF/*.version",
"/META-INF/*.kotlin_module", // cannot be excluded actually
"/META-INF/androidx/**",
"/DebugProbesKt.bin",
"/kotlin-tooling-metadata.json",
)
}
}
}

kotlin {
Expand Down Expand Up @@ -151,3 +179,10 @@ dependencies {
testImplementation(libs.kotest.assertions.core)
androidTestImplementation(libs.junit)
}

configurations {
all {
// remove Baseline Profile Installer or whatever it is...
exclude(group = "androidx.profileinstaller", module = "profileinstaller")
}
}
31 changes: 31 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# disable obfuscation
-dontobfuscate

# Keep JNI interface
-keep class com.osfans.trime.core.* { *; }

# remove kotlin null checks
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkNotNull(...);
static void checkExpressionValueIsNotNull(...);
static void checkNotNullExpressionValue(...);
static void checkReturnedValueIsNotNull(...);
static void checkFieldIsNotNull(...);
static void checkParameterIsNotNull(...);
static void checkNotNullParameter(...);
}

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
14 changes: 0 additions & 14 deletions app/src/main/assets/shared/tongwenfeng.trime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ style:
horizontal: true #水平模式
horizontal_gap: *hgap #键水平间距
layout:
position: fixed #候选窗口位置:left|right|left_up|right_up|fixed|bottom_left|bottom_right|top_left|top_right(left、right需要Android5.0以上)
min_length: 4 #候选窗口最小词长
max_length: 14 #超过字数则换行
sticky_lines: 1 #固顶行数
sticky_lines_land: 0 #横屏模式下的固顶行数
max_entries: 5 #候选窗口最大词条数
border: 0 #候选窗口边框宽度
max_width: 360 #最大宽度,超过则自动换行
max_height: 300 #最大高度
Expand All @@ -60,18 +54,10 @@ style:
margin_y: 5 #竖直边距
line_spacing: 0 #候选词的行间距(px)
line_spacing_multiplier: 1.2 #候选词的行间距(倍数)
real_margin: 3 #屏幕左右边缘和悬浮窗之间的距离 TODO: 在 4.0 时给 real_margin 与 spacing 换一个更适合的名字
spacing: 1 #屏幕上下边缘或预编辑上下边缘和悬浮窗之间的距离
round_corner: *round2 #候选窗口圆角
alpha: 0xff #透明度(0-255)
elevation: 0 #阴影(>=Android5.0)
background: background.png #颜色或者backgrounds目录下的图片文档名
movable: false #是否可移动窗口,或仅移动一次 true|false|once
all_phrases: false #显示所有长词
window: #悬浮窗口组件
# - {start: "", move: 'ㄓ ', end: ""}
- {start: "", composition: "%s", end: "", letter_spacing: 0.12} #letter_spacing需要Android5.0
- {start: "\n", label: "%s.", candidate: "%s", comment: "%s", end: "", sep: "☁️️"}
key_font: symbol.ttf #键盘字体
key_height: *jpgd4 #键高
key_long_text_size: 16 #长标签字号
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/assets/shared/trime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,19 @@ style:
keyboard_padding_land: 40 #横屏模式下,屏幕左右两侧与键盘的距离(避免横屏按键过度拉伸变形)
keyboard_padding_land_bottom: 0 #横屏模式下,屏幕下侧与键盘的距离
layout: #懸浮窗口設置
position: fixed #位置:left|right|left_up|right_up|fixed|bottom_left|bottom_right|top_left|top_right(left、right需要>=Android5.0)
min_length: 5 #最小詞長
max_length: 10 #超過字數則換行
sticky_lines: 0 #固頂行數
sticky_lines_land: 0 #横屏模式下的固顶行数
max_entries: 1 #最大詞條數
min_check: 3 #只要前n个候选词有长度大于等于min_length的词,就会把长度符合以及之前的词全部加到悬浮窗内。
all_phrases: false #所有滿足條件的詞語都顯示在窗口
border: 2 #邊框寬度
max_width: 230 #最大寬度,超過則自動換行
max_height: 400 #最大高度
min_width: 40 #最小寬度
min_height: 0 #最小高度
margin_x: 5 #水平邊距 NOTE: margin_{x, y, bottom} 实际为 padding
margin_y: 5 #豎直邊距
margin_bottom: 0 #底部边距 (用于适配特定背景图)
line_spacing: 0 #候选詞的行間距(px)
line_spacing_multiplier: 1.2 #候选詞的行間距(倍數)
real_margin: 3 #屏幕左右边缘和悬浮窗之间的距离 TODO: 在 4.0 时给 real_margin 与 spacing 换一个更适合的名字
spacing: 1 #屏幕上下边缘或预编辑上下边缘和悬浮窗之间的距离
round_corner: 8 #窗口圓角
alpha: 0xdd #透明度(0-255)
elevation: 5 #陰影(>=Android5.0)
movable: once #是否可移動窗口,或僅移動一次 true|false|once
window: #懸浮窗口組件
- {start: "", move: 'ㄓ ', end: ""}
- {start: "", composition: "%s", end: "", letter_spacing: 0} #letter_spacing需要>=Android5.0。TODO: 不爲0時,會導致不換行的問題
- {start: "\n", label: "%s.", candidate: "%s", comment: " %s", end: "", sep: " "}
key_font: symbol.ttf #鍵盤字型
key_height: 44 #鍵高
key_long_text_size: 14 #長標籤字號
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ class AppPrefs(
companion object {
const val UI_MODE = "other__ui_mode"
const val SHOW_APP_ICON = "other__show_app_icon"
const val SHOW_STATUS_BAR_ICON = "other__show_status_bar_icon"
}

enum class UiMode {
Expand All @@ -302,6 +301,5 @@ class AppPrefs(

val uiMode = enum(UI_MODE, UiMode.AUTO)
var showAppIcon by bool(SHOW_APP_ICON, true)
val showStatusBarIcon by bool(SHOW_STATUS_BAR_ICON, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ class LayoutStyleMapper(
style: Map<String, ConfigItem?>?,
) : Mapper(style) {
fun map(): Layout {
val position = getString("position")

val minLength = getInt("min_length")

val maxLength = getInt("max_length")

val stickyLines = getInt("sticky_lines")

val stickyLinesLand = getInt("sticky_lines_land")

val maxEntries = getInt("max_entries")

val minCheck = getInt("min_check")

val allPhrases = getBoolean("all_phrases")

val border = getInt("border")

val maxWidth = getInt("max_width")
Expand All @@ -41,47 +25,29 @@ class LayoutStyleMapper(

val marginY = getInt("margin_y")

val marginBottom = getInt("margin_bottom")

val lineSpacing = getInt("line_spacing")

val lineSpacingMultiplier = getFloat("line_spacing_multiplier")

val realMargin = getInt("real_margin")

val spacing = getInt("spacing")

val roundCorner = getFloat("round_corner")

val alpha = getInt("alpha", 204)
val elevation = getInt("elevation")
val movable = getString("movable")

return Layout(
position,
minLength,
maxLength,
stickyLines,
stickyLinesLand,
maxEntries,
minCheck,
allPhrases,
border,
maxWidth,
maxHeight,
minWidth,
minHeight,
marginX,
marginY,
marginBottom,
lineSpacing,
lineSpacingMultiplier,
realMargin,
spacing,
roundCorner,
alpha,
elevation,
movable,
)
}
}
12 changes: 0 additions & 12 deletions app/src/main/java/com/osfans/trime/data/theme/model/Layout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,16 @@
package com.osfans.trime.data.theme.model

data class Layout(
val position: String,
val minLength: Int,
val maxLength: Int,
val stickyLines: Int,
val stickyLinesLand: Int,
val maxEntries: Int,
val minCheck: Int,
val allPhrases: Boolean,
val border: Int,
val maxWidth: Int,
val maxHeight: Int,
val minWidth: Int,
val minHeight: Int,
val marginX: Int,
val marginY: Int,
val marginBottom: Int,
val lineSpacing: Int,
val lineSpacingMultiplier: Float,
val realMargin: Int,
val spacing: Int,
val roundCorner: Float,
val alpha: Int,
val elevation: Int,
val movable: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,6 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
updateRimeOption(this)
InputFeedbackManager.loadSoundEffects(this@TrimeInputMethodService)
InputFeedbackManager.resetPlayProgress()
if (prefs.other.showStatusBarIcon) {
showStatusIcon(R.drawable.ic_trime_status) // 狀態欄圖標
}
ContextCompat.getMainExecutor(this@TrimeInputMethodService).execute {
val useVirtualKeyboard =
inputDeviceManager.evaluateOnStartInputView(attribute, this@TrimeInputMethodService)
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="other_ime">其他输入法</string>
<string name="other__ui_mode_title">夜间模式</string>
<string name="others">其他</string>
<string name="other__show_status_bar_icon_title">显示通知栏图标</string>
<string name="other__destroy_on_quit_title">退出时清除缓存</string>
<string name="profile_user_data_dir">用户文件夹</string>
<string name="periodic_background_sync">后台定时同步</string>
<string name="periodic_background_sync_status">上次同步时间(状态):%1$s(%2$s)</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="other_ime">其他輸入法</string>
<string name="other__ui_mode_title">夜間模式</string>
<string name="others">其他</string>
<string name="other__show_status_bar_icon_title">顯示通知欄圖標</string>
<string name="other__destroy_on_quit_title">離開時清理記憶體</string>
<string name="profile_user_data_dir">使用者資料夾</string>
<string name="periodic_background_sync">後台定時同步</string>
<string name="periodic_background_sync_status">上次同步時間(狀態):%1$s(%2$s)</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="other_ime">Other IMEs</string>
<string name="other__ui_mode_title">Night Mode</string>
<string name="others">Others</string>
<string name="other__show_status_bar_icon_title">Show icon in notification bar</string>
<string name="other__destroy_on_quit_title">Free memory on quit</string>
<string name="profile_user_data_dir">User directory</string>
<string name="periodic_background_sync">Periodic background sync</string>
<string name="periodic_background_sync_status">Last: %1$s (%2$s)</string>
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/res/xml/other_preference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,4 @@ SPDX-License-Identifier: GPL-3.0-or-later
app:summaryOn="@string/other__show_app_icon_on_summary"
app:summaryOff="@string/other__show_app_icon_off_summary"/>

<SwitchPreferenceCompat android:key="other__show_status_bar_icon"
app:iconSpaceReserved="false"
android:title="@string/other__show_status_bar_icon_title" />

<SwitchPreferenceCompat android:key="other__destroy_on_quit"
app:iconSpaceReserved="false"
android:title="@string/other__destroy_on_quit_title" />

</PreferenceScreen>
Loading
Loading