Skip to content

Commit af2fedb

Browse files
authored
Merge pull request #13 from appdevforall/ADFA-4023
Redesign markdown-preview, fix button contrast across plugins
2 parents e3cedfa + 44a7a11 commit af2fedb

20 files changed

Lines changed: 666 additions & 697 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build plugin artifacts
2+
3+
# Builds every example plugin's .cgp and exposes them as downloadable
4+
# workflow artifacts. Unlike "Update libs from CodeOnTheGo", this never
5+
# commits refreshed libs, never publishes a GitHub release, and never
6+
# deploys to the website — it only produces artifacts you can download
7+
# from the run summary.
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
codeonthego_ref:
13+
description: CodeOnTheGo branch or tag to build the libs against
14+
required: false
15+
default: stage
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 45
24+
steps:
25+
- name: Checkout plugin-examples
26+
uses: actions/checkout@v4
27+
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: temurin
32+
java-version: '17'
33+
34+
- name: Set up Gradle
35+
uses: gradle/actions/setup-gradle@v3
36+
with:
37+
cache-disabled: true
38+
add-job-summary: 'never'
39+
40+
- name: Build libs and plugins
41+
env:
42+
CODEONTHEGO_REF: ${{ github.event.inputs.codeonthego_ref }}
43+
run: ./scripts/update-libs.sh --ref "$CODEONTHEGO_REF"
44+
45+
- name: Stage .cgp files with website filenames
46+
run: |
47+
mkdir -p deploy-staging
48+
declare -A MAP=(
49+
["apk-viewer"]="apk-analyzer.cgp"
50+
["Beepy"]="beepy.cgp"
51+
["keystore-generator"]="keystore-generator.cgp"
52+
["markdown-preview"]="markdown-previewer.cgp"
53+
["ndk-installer-plugin"]="ndk-installer.cgp"
54+
["random-xkcd"]="random-xkcd.cgp"
55+
["snippets"]="snippets.cgp"
56+
)
57+
for module in "${!MAP[@]}"; do
58+
src=$(ls "${module}/build/plugin/"*.cgp 2>/dev/null | head -n1)
59+
if [ -z "$src" ]; then
60+
echo "ERROR: no .cgp found under ${module}/build/plugin/"
61+
exit 1
62+
fi
63+
cp "$src" "deploy-staging/${MAP[$module]}"
64+
echo "Staged $src -> deploy-staging/${MAP[$module]}"
65+
done
66+
ls -la deploy-staging/
67+
68+
- name: Upload .cgp artifacts
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: plugins-cgp
72+
path: deploy-staging/*.cgp
73+
retention-days: 7
74+
if-no-files-found: error

‎markdown-preview/src/main/AndroidManifest.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<application
55
android:label="Markdown Previewer"
6-
android:theme="@style/Theme.MarkdownPreviewer">
6+
android:theme="@style/PluginTheme">
77

88
<!-- Plugin metadata -->
99
<meta-data

‎markdown-preview/src/main/kotlin/com/codeonthego/markdownpreviewer/MarkdownPreviewerPlugin.kt‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.itsaky.androidide.plugins.extensions.NavigationItem
1111
import com.itsaky.androidide.plugins.extensions.ContextMenuContext
1212
import com.itsaky.androidide.plugins.services.IdeEditorTabService
1313
import com.codeonthego.markdownpreviewer.fragments.MarkdownPreviewFragment
14+
import com.codeonthego.markdownpreviewer.viewmodel.MarkdownPreviewViewModel
1415
import java.io.File
1516

1617
class MarkdownPreviewerPlugin : IPlugin, UIExtension, EditorTabExtension {
@@ -56,6 +57,9 @@ class MarkdownPreviewerPlugin : IPlugin, UIExtension, EditorTabExtension {
5657

5758
override fun dispose() {
5859
context.logger.info("MarkdownPreviewerPlugin: Disposing plugin")
60+
PreviewState.consumePendingFile()
61+
PreviewState.consumePendingUri()
62+
MarkdownPreviewViewModel.reset()
5963
}
6064

6165
// UIExtension - No main menu items (accessed via sidebar/context menu)
@@ -94,7 +98,7 @@ class MarkdownPreviewerPlugin : IPlugin, UIExtension, EditorTabExtension {
9498
NavigationItem(
9599
id = "markdown_preview_sidebar",
96100
title = "Preview",
97-
icon = android.R.drawable.ic_menu_gallery,
101+
icon = R.drawable.ic_preview,
98102
isEnabled = true,
99103
isVisible = true,
100104
group = "tools",
@@ -113,7 +117,7 @@ class MarkdownPreviewerPlugin : IPlugin, UIExtension, EditorTabExtension {
113117
EditorTabItem(
114118
id = "markdown_preview_main_tab",
115119
title = "Preview",
116-
icon = android.R.drawable.ic_menu_gallery,
120+
icon = R.drawable.ic_preview,
117121
fragmentFactory = {
118122
context.logger.debug("Creating MarkdownPreviewFragment")
119123
MarkdownPreviewFragment()
@@ -137,6 +141,11 @@ class MarkdownPreviewerPlugin : IPlugin, UIExtension, EditorTabExtension {
137141

138142
override fun onEditorTabClosed(tabId: String) {
139143
context.logger.info("Editor tab closed: $tabId")
144+
if (tabId == "markdown_preview_main_tab") {
145+
PreviewState.consumePendingFile()
146+
PreviewState.consumePendingUri()
147+
MarkdownPreviewViewModel.reset()
148+
}
140149
}
141150

142151
override fun canCloseEditorTab(tabId: String): Boolean {
@@ -182,10 +191,19 @@ class MarkdownPreviewerPlugin : IPlugin, UIExtension, EditorTabExtension {
182191
object PreviewState {
183192
@Volatile
184193
var pendingFilePath: String? = null
185-
194+
195+
@Volatile
196+
var pendingUri: android.net.Uri? = null
197+
186198
fun consumePendingFile(): String? {
187199
val path = pendingFilePath
188200
pendingFilePath = null
189201
return path
190202
}
203+
204+
fun consumePendingUri(): android.net.Uri? {
205+
val uri = pendingUri
206+
pendingUri = null
207+
return uri
208+
}
191209
}

0 commit comments

Comments
 (0)