Skip to content

Upload #11

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

Merged
merged 8 commits into from
May 5, 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
41 changes: 41 additions & 0 deletions .github/scripts/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# https://github.com/django-files/android-client

set -e

HLJS_VERSION="11.11.1"

which git || (echo "Missing: git" && exit 1)
which npm || (echo "Missing: npm" && exit 1)
which node || (echo "Missing: node" && exit 1)

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "SCRIPT_DIR: ${SCRIPT_DIR}"

echo "Processing highlight.js: ${HLJS_VERSION}"

SOURCE_DIR="$(realpath "${SCRIPT_DIR}/../highlightjs")"
echo "SOURCE_DIR: ${SOURCE_DIR}"
if [ -d "${SOURCE_DIR}" ];then
echo "Removing: ${SOURCE_DIR}"
rm -rf "${SOURCE_DIR}"
fi

git clone https://github.com/highlightjs/highlight.js.git "${SOURCE_DIR}"
cd "${SOURCE_DIR}"
git checkout "${HLJS_VERSION}"

npm install
node tools/build.js :common

TARGET_DIR="$(realpath "${SCRIPT_DIR}/../../app/src/main/assets/preview/dist")"
echo "TARGET_DIR: ${TARGET_DIR}"
mkdir -p "${TARGET_DIR}"

cp build/highlight.min.js "${TARGET_DIR}"
cp src/styles/stackoverflow-dark.css "${TARGET_DIR}"
cp src/styles/stackoverflow-light.css "${TARGET_DIR}"

echo "Finished: highlight.js"

echo "Everything is finished."
12 changes: 11 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
name: zipline.apk # Final APK Name
key_name: zipline-release
key_file: release.keystore
tools_path: /usr/local/lib/android/sdk/build-tools/35.0.0
tools_path: /usr/local/lib/android/sdk/build-tools/36.0.0
cmdline_tools: /usr/local/lib/android/sdk/cmdline-tools/latest/bin

jobs:
Expand Down Expand Up @@ -81,6 +81,16 @@ jobs:
cat app/build.gradle.kts
echo "::endgroup::"

- name: "Setup Node 22"
uses: actions/setup-node@v4
with:
node-version: 22

- name: "Prepare Build"
working-directory: ".github/scripts"
run: |
bash prepare.sh

- name: "Setup Java"
uses: actions/setup-java@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
.gradle/
.kotlin/
captures/
app/debug
app/release

local.properties
*.keystore
*.logcat

**/dist/
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# IDE
.idea/
.vscode/

# Build
**/dist/
**/node_modules/

# App
app/src/main/assets/preview/**
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Additionally, the URL is copied to the clipboard and the preview is show in the

### Planned

- Sharing multiple files at once.
- Improve [Django Files](https://github.com/django-files).

### Known Issues

Expand Down
18 changes: 15 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
//alias(libs.plugins.ksp)
}

android {
namespace = "org.cssnr.zipline"
compileSdk = 35
compileSdk = 36

defaultConfig {
applicationId = "org.cssnr.zipline"
minSdk = 26
targetSdk = 35
targetSdk = 36
versionCode = 1
versionName = "0.0.1"

Expand All @@ -20,13 +21,19 @@ android {
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
isDebuggable = false
}

debug {
applicationIdSuffix = ".dev"
versionNameSuffix = "-dev"
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand All @@ -52,6 +59,11 @@ dependencies {
implementation(libs.okhttp)
implementation(libs.retrofit)
implementation(libs.retrofit.gson)
implementation(libs.glide)
implementation(libs.media3.exoplayer)
implementation(libs.media3.exoplayer.dash)
implementation(libs.media3.ui)
implementation(libs.media3.ui.compose)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
Expand Down
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,20 @@

# With R8 full mode generic signatures are stripped for classes that are not kept.
-keep,allowobfuscation,allowshrinking class retrofit2.Response


# https://github.com/bumptech/glide/blob/master/library/proguard-rules.txt
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
<init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}

# Uncomment for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
android:theme="@style/Theme.Zipline"
android:enableOnBackInvokedCallback="true"
android:usesCleartextTraffic="true"
tools:targetApi="35"> <!-- TODO: Remove enableOnBackInvokedCallback ??? -->
tools:targetApi="36"> <!-- TODO: Remove enableOnBackInvokedCallback ??? -->
<activity
android:name=".MainActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize"
android:configChanges="orientation|smallestScreenSize|screenSize|screenLayout"
android:configChanges="smallestScreenSize|screenSize|screenLayout"
android:launchMode="singleTask">

<meta-data
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/assets/preview/preview.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
html,
body {
margin: 0;
padding: 0;
height: auto !important;
overflow: auto !important;
background: #1c1b1b;
color: #ccc;
}

@media (prefers-color-scheme: light) {
html,
body {
background: #f6f6f6;
color: #1c1b1b;
}
}

pre {
margin: 0;
padding: 6px;
}
16 changes: 16 additions & 0 deletions app/src/main/assets/preview/preview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Preview</title>
<link rel="stylesheet" href="preview.css">
<link rel="stylesheet" href="dist/stackoverflow-dark.css" id="code-dark">
<link rel="stylesheet" href="dist/stackoverflow-light.css" id="code-light" disabled>
</head>
<body>
<pre></pre>
<script src="dist/highlight.min.js"></script>
<script src="preview.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions app/src/main/assets/preview/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const preEl = document.querySelector('pre')
const darkStyle = document.getElementById('code-dark')
const lightStyle = document.getElementById('code-light')

document.addEventListener('DOMContentLoaded', () => {
console.log('DOMContentLoaded')
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
applyTheme(mediaQuery)
mediaQuery.addEventListener('change', applyTheme)

if (typeof Android !== 'undefined') {
console.log('Android')
Android.notifyReady()
}
})

function applyTheme(mediaQuery) {
console.log(`applyTheme: matches: ${mediaQuery.matches}`)
if (mediaQuery.matches) {
darkStyle.disabled = false
lightStyle.disabled = true
} else {
darkStyle.disabled = true
lightStyle.disabled = false
}
}

function addContent(content) {
preEl.textContent = content
hljs.highlightElement(preEl)
}
Loading
Loading