Skip to content

Commit f9b3746

Browse files
committed
Update
1 parent 9b662d4 commit f9b3746

8 files changed

Lines changed: 76 additions & 34 deletions

File tree

app/src/main/java/com/omarea/krscript/config/IconPathAnalysis.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ class IconPathAnalysis {
5252
return null
5353
}
5454

55+
fun loadBg(context: Context, clickableNode: ClickableNode): Drawable? {
56+
if (!clickableNode.bgPath.isEmpty()) {
57+
val inputStream = PathAnalysis(context, clickableNode.pageConfigDir).parsePath(clickableNode.bgPath)
58+
inputStream?.run {
59+
return bitmap2Drawable(BitmapFactory.decodeStream(this))
60+
}
61+
}
62+
return null
63+
}
64+
5565
fun loadtextPhoto(context: Context, row: TextNode.TextRow, pageDir: String): Drawable? {
5666
if (row.photo.isNotEmpty()) {
5767
val inputStream = PathAnalysis(context, pageDir).parsePath(row.photo)

app/src/main/java/com/omarea/krscript/config/PageConfigReader.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ class PageConfigReader {
417417
"icon", "icon-path" -> iconPath = attrValue.trim()
418418
"logo", "logo-path" -> logoPath = attrValue.trim()
419419
"photo", "photo-path" -> photoPath = attrValue.trim()
420+
"bg", "bg-path" -> bgPath = attrValue.trim()
420421
"allow-shortcut" -> allowShortcut = attrValue == "allow" || attrValue == "allow-shortcut" || attrValue == "true" || attrValue == "1"
421422
}
422423
}

app/src/main/java/com/omarea/krscript/model/ClickableNode.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ open class ClickableNode(currentPageConfigPath: String) : NodeInfoBase(currentPa
77
// 功能图标路径(桌面快捷)
88
var logoPath = ""
99
var photoPath = ""
10+
var bgPath = ""
1011

1112
// 是否允许添加快捷方式(非false,且具有key则默认允许)
1213
var allowShortcut:Boolean? = null

app/src/main/java/com/omarea/krscript/ui/ListItemClickable.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ open class ListItemClickable(context: Context,
1515
protected var shortcutIconView = layout.findViewById<View?>(R.id.kr_shortcut_icon)
1616
protected var iconView = layout.findViewById<ImageView?>(R.id.kr_icon)
1717
protected var extraIconView = layout.findViewById<ImageView?>(R.id.kr_extra_icon)
18+
protected var extraBgView = layout.findViewById<ImageView?>(R.id.kr_extra_bg)
1819

1920
fun setOnClickListener(onClickListener: OnClickListener): ListItemClickable {
2021
this.mOnClickListener = onClickListener
@@ -67,6 +68,15 @@ open class ListItemClickable(context: Context,
6768
}
6869
}
6970
}
71+
if (extraBgView != null) {
72+
extraBgView?.visibility = View.GONE
73+
if (config.bgPath.isNotEmpty()) {
74+
IconPathAnalysis().loadBg(context, config)?.run {
75+
extraBgView?.setImageDrawable(this)
76+
extraBgView?.visibility = View.VISIBLE
77+
}
78+
}
79+
}
7080
}
7181

7282
interface OnClickListener {

app/src/main/res/layout/kr_action_list_item.xml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
android:background="@drawable/krscript_item_ripple_ac"
77
android:minHeight="?android:attr/listPreferredItemHeight">
88

9+
<ImageView
10+
android:id="@+id/kr_extra_bg"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:adjustViewBounds="true"
14+
android:scaleType="fitCenter"
15+
android:visibility="gone" />
16+
917
<ImageView
1018
android:id="@id/kr_shortcut_icon"
1119
android:layout_width="10dp"
@@ -17,20 +25,19 @@
1725
app:tint="@color/kr_shortcut_color" />
1826

1927
<LinearLayout
28+
android:id="@+id/kr_layout_ac"
2029
android:layout_marginStart="10dp"
2130
android:layout_marginTop="10dp"
2231
android:layout_marginBottom="10dp"
2332
android:layout_alignParentStart="true"
24-
android:layout_centerVertical="true"
25-
android:gravity="center_vertical"
2633
android:layout_toStartOf="@id/kr_widget"
2734
android:layout_width="wrap_content"
2835
android:layout_height="wrap_content">
2936
<ImageView
3037
android:padding="0dp"
3138
android:id="@id/kr_icon"
32-
android:layout_marginStart="10dp"
33-
android:layout_gravity="center_vertical"
39+
android:layout_marginStart="5dp"
40+
android:layout_marginTop="5dp"
3441
android:layout_width="35dp"
3542
android:layout_height="35dp" />
3643

@@ -62,14 +69,6 @@
6269
style="@style/textSmall"
6370
android:visibility="gone" />
6471

65-
<ImageView
66-
android:id="@+id/kr_extra_icon"
67-
android:layout_width="match_parent"
68-
android:layout_height="wrap_content"
69-
android:layout_marginTop="4dp"
70-
android:adjustViewBounds="true"
71-
android:scaleType="fitCenter"
72-
android:visibility="gone" />
7372
</LinearLayout>
7473
</LinearLayout>
7574

@@ -85,4 +84,15 @@
8584
android:alpha="0.9"
8685
android:padding="5dp"
8786
app:tint="?android:colorAccent" />
87+
88+
<ImageView
89+
android:id="@+id/kr_extra_icon"
90+
android:layout_below="@id/kr_layout_ac"
91+
android:layout_width="match_parent"
92+
android:layout_height="wrap_content"
93+
android:padding="16dp"
94+
android:adjustViewBounds="true"
95+
android:scaleType="fitCenter"
96+
android:visibility="gone" />
97+
8898
</RelativeLayout>

app/src/main/res/layout/kr_switch_list_item.xml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
android:background="@drawable/krscript_item_ripple_ac"
77
android:minHeight="?android:attr/listPreferredItemHeight">
88

9+
<ImageView
10+
android:id="@+id/kr_extra_bg"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:adjustViewBounds="true"
14+
android:scaleType="fitCenter"
15+
android:visibility="gone" />
16+
917
<ImageView
1018
android:id="@id/kr_shortcut_icon"
1119
android:layout_width="10dp"
@@ -17,20 +25,19 @@
1725
app:tint="@color/kr_shortcut_color" />
1826

1927
<LinearLayout
28+
android:id="@+id/kr_layout_ac"
2029
android:layout_marginStart="10dp"
2130
android:layout_marginTop="10dp"
2231
android:layout_marginBottom="10dp"
2332
android:layout_alignParentStart="true"
24-
android:layout_centerVertical="true"
25-
android:gravity="center_vertical"
2633
android:layout_toStartOf="@id/kr_switch"
2734
android:layout_width="wrap_content"
2835
android:layout_height="wrap_content">
2936
<ImageView
3037
android:padding="0dp"
3138
android:id="@id/kr_icon"
32-
android:layout_marginStart="10dp"
33-
android:layout_gravity="center_vertical"
39+
android:layout_marginStart="5dp"
40+
android:layout_marginTop="5dp"
3441
android:layout_width="35dp"
3542
android:layout_height="35dp" />
3643

@@ -63,14 +70,6 @@
6370
style="@style/textSmall"
6471
android:visibility="gone" />
6572

66-
<ImageView
67-
android:id="@+id/kr_extra_icon"
68-
android:layout_width="match_parent"
69-
android:layout_height="wrap_content"
70-
android:layout_marginTop="4dp"
71-
android:adjustViewBounds="true"
72-
android:scaleType="fitCenter"
73-
android:visibility="gone" />
7473
</LinearLayout>
7574
</LinearLayout>
7675

@@ -94,4 +93,15 @@
9493
android:elevation="5dp"
9594
android:enabled="false"
9695
android:focusable="false" />
96+
97+
<ImageView
98+
android:id="@+id/kr_extra_icon"
99+
android:layout_below="@id/kr_layout_ac"
100+
android:layout_width="match_parent"
101+
android:layout_height="wrap_content"
102+
android:padding="16dp"
103+
android:adjustViewBounds="true"
104+
android:scaleType="fitCenter"
105+
android:visibility="gone" />
106+
97107
</RelativeLayout>

app/src/main/res/values-vi/strings.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ Nếu đồng ý hãy ấn vào nút xác nhận để tiếp tục."</string>
122122
<string formatted="false" name="kr_sdk_discrepancy_message">Tính năng này chỉ chạy trên hệ thống có SDK %d</string>
123123
<string name="picker_not_item">Không có tùy chọn khả dụng</string>
124124
<string name="picker_select_none">Chưa chọn mục nào</string>
125-
<string name="theme_system_default">Hệ thống (Mặc định)</string>
126-
<string name="theme_light">Chế độ Sáng</string>
127-
<string name="theme_dark">Chế độ Tối</string>
128-
<string name="theme_wallpaper_system">Hình nền (Mặc định)</string>
129-
<string name="theme_wallpaper_dark">Hình nền Tối</string>
130-
<string name="theme_wallpaper_light">Hình nền Sáng</string>
125+
<string name="theme_system_default">Hệ thống (mặc định)</string>
126+
<string name="theme_light">Chế độ sáng</string>
127+
<string name="theme_dark">Chế độ tối</string>
128+
<string name="theme_wallpaper_system">Hình nền (mặc định)</string>
129+
<string name="theme_wallpaper_dark">Hình nền tối</string>
130+
<string name="theme_wallpaper_light">Hình nền sáng</string>
131131
<string name="theme_text">Chủ đề</string>
132132
<string name="open_in_browser">Mở bằng trình duyệt</string>
133133
</resources>

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ If you agree, press the confirm button to continue."</string>
136136
<string formatted="false" name="kr_sdk_discrepancy_message">This feature only runs on systems with SDK %d</string>
137137
<string name="picker_not_item">No available options</string>
138138
<string name="picker_select_none">No item selected</string>
139-
<string name="theme_system_default">Default theme</string>
139+
<string name="theme_system_default">System Default</string>
140140
<string name="theme_light">Light Mode</string>
141141
<string name="theme_dark">Dark Mode</string>
142-
<string name="theme_wallpaper_system">Wallpaper + Default</string>
143-
<string name="theme_wallpaper_dark">Wallpaper + Dark</string>
144-
<string name="theme_wallpaper_light">Wallpaper + Light</string>
142+
<string name="theme_wallpaper_system">Wallpaper Default</string>
143+
<string name="theme_wallpaper_dark">Wallpaper Dark</string>
144+
<string name="theme_wallpaper_light">Wallpaper Light</string>
145145
<string name="theme_text">Theme</string>
146146
<string name="open_in_browser">Open with a browser</string>
147147
</resources>

0 commit comments

Comments
 (0)