Skip to content

Commit f4c12c7

Browse files
authored
Updates (#4)
- Minify Release Build - Cleanup Unused Code - Update Release Workflow - Update README.md
1 parent 4fda56c commit f4c12c7

File tree

6 files changed

+101
-71
lines changed

6 files changed

+101
-71
lines changed

.github/workflows/release.yaml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ jobs:
4444
if: ${{ !github.event.act }}
4545
continue-on-error: true
4646
run: |
47+
echo "tools_path: ${{ env.tools_path }}"
48+
4749
echo "::group::PATH"
48-
echo ${PATH}
50+
echo "${PATH}"
4951
echo "::endgroup::"
5052
5153
echo "::group::ls env.tools_path"
52-
ls -lAh ${{ env.tools_path }}/
54+
ls -lAh "${{ env.tools_path }}/"
5355
echo "::endgroup::"
5456
5557
echo "--------------------"
@@ -87,10 +89,12 @@ jobs:
8789
continue-on-error: true
8890
run: |
8991
echo "ref: ${{ github.ref }}"
90-
echo "name: ${{ github.repository_owner }}-release"
91-
echo "dir: ${{ env.path }}"
92-
echo "glob: ${{ env.path }}/*.apk"
92+
echo "path: ${{ env.path }}"
93+
echo "path/name: ${{ env.path }}/${{ env.name }}"
94+
95+
echo "::group::ls env.path"
9396
ls -lAh ${{ env.path }}
97+
echo "::endgroup::"
9498
9599
- name: "Align APK"
96100
run: |
@@ -103,16 +107,14 @@ jobs:
103107
- name: "Debug Keystore"
104108
continue-on-error: true
105109
run: |
106-
ls -lAh ${{ env.path }}
107-
108110
stat ${{ env.key_file }}
109111
keytool -list -keystore ${{ env.key_file }}
110112
111113
- name: "Sign APK"
112114
run: |
113115
apksigner sign --ks ${{ env.key_file }} \
114116
--ks-pass pass:${{ secrets.ANDROID_KEYSTORE_PASS }} \
115-
--ks-key-alias "${{ env.key_name }}" \
117+
--ks-key-alias ${{ env.key_name }} \
116118
"${{ env.path }}/${{ env.name }}"
117119
118120
- name: "Verify Signature"
@@ -136,12 +138,14 @@ jobs:
136138
file_glob: true
137139

138140
- name: "VirusTotal"
141+
if: ${{ github.event_name == 'release' }}
139142
uses: cssnr/virustotal-action@v1
140143
continue-on-error: true
141144
with:
142145
vt_api_key: ${{ secrets.VT_API_KEY }}
143146

144147
- name: "Update Release Notes Action"
148+
if: ${{ github.event_name == 'release' }}
145149
uses: smashedr/update-release-notes-action@master
146150
continue-on-error: true
147151

@@ -150,3 +154,23 @@ jobs:
150154
uses: sarisia/actions-status-discord@v1
151155
with:
152156
webhook: ${{ secrets.DISCORD_WEBHOOK }}
157+
158+
- name: "Job Summary"
159+
if: ${{ !github.event.act }}
160+
continue-on-error: true
161+
run: |
162+
echo -e "## Android Release\n\n" >> $GITHUB_STEP_SUMMARY
163+
164+
echo -e "Signed APK: \`${{ env.name }}\`\n\n" >> $GITHUB_STEP_SUMMARY
165+
166+
echo -e "<details><summary>Build Artifacts</summary>\n\n" >> $GITHUB_STEP_SUMMARY
167+
echo -e "\`\`\`text\n$(ls -lAh ${{ env.path }})\n\`\`\`\n\n" >> $GITHUB_STEP_SUMMARY
168+
echo -e "</details>\n\n" >> $GITHUB_STEP_SUMMARY
169+
170+
if [ -f "${{ env.path }}/output-metadata.json" ];then
171+
echo -e "<details><summary>File: output-metadata.json</summary>\n\n" >> $GITHUB_STEP_SUMMARY
172+
echo -e "\`\`\`json\n$(cat ${{ env.path }}/output-metadata.json)\n\`\`\`\n\n" >> $GITHUB_STEP_SUMMARY
173+
echo -e "</details>\n\n" >> $GITHUB_STEP_SUMMARY
174+
fi
175+
176+
echo -e "\n\n---" >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![GitHub Downloads](https://img.shields.io/github/downloads/django-files/android-client/total?logo=github)](https://github.com/django-files/android-client/releases/latest/download/django-files.apk)
22
[![GitHub Release Version](https://img.shields.io/github/v/release/django-files/android-client?logo=github)](https://github.com/django-files/android-client/releases/latest)
3-
[![GitHub Last Commit](https://img.shields.io/github/last-commit/django-files/android-client?logo=github&label=updated)](https://github.com/django-files/android-client/graphs/commit-activity)
43
[![GitHub Top Language](https://img.shields.io/github/languages/top/django-files/android-client?logo=htmx)](https://github.com/django-files/android-client)
4+
[![GitHub Last Commit](https://img.shields.io/github/last-commit/django-files/android-client?logo=github&label=updated)](https://github.com/django-files/android-client/graphs/commit-activity)
55
[![GitHub Repo Size](https://img.shields.io/github/repo-size/django-files/android-client?logo=bookstack&logoColor=white&label=repo%20size)](https://github.com/django-files/android-client)
66
[![GitHub Discussions](https://img.shields.io/github/discussions/django-files/android-client)](https://github.com/django-files/android-client/discussions)
77
[![GitHub Forks](https://img.shields.io/github/forks/django-files/android-client?style=flat&logo=github)](https://github.com/django-files/android-client/forks)
@@ -16,51 +16,61 @@
1616
- [Features](#Features)
1717
- [Planned](#Planned)
1818
- [Known Issues](#Known-Issues)
19-
- [Building](#Building)
19+
- [Development](#Development)
2020
- [Android Studio](#Android-Studio)
2121
- [Command Line](#Command-Line)
22-
- [Development](#Development)
2322
- [Support](#Support)
2423
- [Contributing](#Contributing)
2524

2625
Allows you to Share or Open any file with your Django Files server.
2726
The URL to the file is automatically copied to the clipboard and the preview is shown in the app.
2827

29-
| Resource | Resource&nbsp;Link |
30-
| -------- | :------------------------------------------- |
31-
| Website | https://django-files.github.io/ |
32-
| GitHub | https://github.com/django-files |
33-
| Server | https://github.com/django-files/django-files |
34-
| iOS App | https://github.com/django-files/ios-client |
28+
| Django&nbsp;Files | Link |
29+
| ----------------- | :-------------------------------------------- |
30+
| Website | https://django-files.github.io/ |
31+
| GitHub | https://github.com/django-files |
32+
| Server | https://github.com/django-files/django-files |
33+
| iOS App | https://github.com/django-files/ios-client |
34+
| Web Extension | https://github.com/django-files/web-extension |
35+
36+
> Django Files Android App is now signed starting at version 0.0.3
3537
3638
# Install
3739

38-
> Django Files is now signed starting at version 0.0.3
40+
> [!TIP]
41+
> To Install, download the latest release from GitHub and open it.
42+
>
43+
> - [Click Here to Download the Latest Release](https://github.com/django-files/android-client/releases/latest/download/django-files.apk)
3944
40-
- [Download Latest Release](https://github.com/django-files/android-client/releases/latest/download/django-files.apk)
45+
_Note: Until published on the play store, you may need to allow installation of apps from unknown sources._
4146

42-
_Until the app is published on the play store, you must allow installation of apps from unknown sources._
47+
**First try to download and install the [Latest Release](https://github.com/django-files/android-client/releases/latest/download/django-files.apk).**
48+
This should take you to the settings to allow installing the app. If not, try the steps below.
4349

4450
1. Go to your device settings.
4551
2. Search for "Install unknown apps" or similar.
4652
3. Choose the app you will install the apk file from.
4753
- Select your web browser to install directly from it.
48-
- Select your file manager to open it, locate the APK and install from there.
49-
4. [Download the Latest Release](https://github.com/django-files/android-client/releases/latest/download/django-files.apk).
50-
5. Open the download in the app you selected in step #3.
51-
6. Choose Install and Accept Play Protect notifications.
52-
7. The app is now installed, proceed to [Setup](#Setup).
54+
- Select your file manager to open it, locate the apk and install from there.
55+
4. Download the [Latest Release](https://github.com/django-files/android-client/releases/latest/download/django-files.apk).
56+
5. Open the download apk in the app you selected in step #3.
57+
6. Choose Install and Accept any Play Protect notifications.
58+
7. The app is now installed. Proceed to the [Setup](#Setup) section below.
5359

5460
## Setup
5561

56-
1. [Install](#Install) and open the app.
62+
1. [Install](#Install) and open the app on your device.
5763
2. Enter the URL to your Django Files server.
5864
3. Log in as you normally would on the website.
59-
4. Done! You can now share any file to your Django Files server...
65+
4. All Done! You can now share and open files with Django Files.
66+
67+
To use, share or open any file and choose the Django Files app.
68+
The app will then be upload the file to your Django Files server.
69+
Additionally, the URL is copied to the clipboard and the preview is show in the app.
6070

6171
# Features
6272

63-
- Share or Open any file and automatically copy the URL to the clipboard.
73+
- Share or Open any file (or multiple) and automatically copy the URL to the clipboard.
6474
- Ability to manually change servers by entering a new URL from the Server List menu.
6575
- Supports Local Login, GitHub OAuth, Google OAuth, Discord OAuth (w/o passkeys).
6676

@@ -75,9 +85,9 @@ _Until the app is published on the play store, you must allow installation of ap
7585
- Login with Google OAuth gives an error; however, if you wait ~30 seconds it will succeed.
7686
- The app gets logged out if the session expires; however, sharing continues to work.
7787

78-
# Building
88+
# Development
7989

80-
Covers Android Studio and Command Line.
90+
This section briefly covers [Android Studio](#Android-Studio) and [Command Line](#Command-Line) setup.
8191

8292
## Android Studio
8393

@@ -91,18 +101,18 @@ https://developer.android.com/studio
91101
- Import the Project
92102
- Run Gradle Sync
93103

94-
To Run. Select your device and press Play ▶️
104+
To Run: Select your device and press Play ▶️
95105

96-
To Build.
106+
To Build:
97107

98108
- Select the Build Variant (debug or release)
99109
- Build > Generate App Bundles or APK > Generate APKs
100110

101111
## Command Line
102112

103-
You will need to have [ADB](https://developer.android.com/tools/adb) installed.
113+
_Note: This section is a WIP!_
104114

105-
_Note: This section is a WIP and contains building instructions for the command line._
115+
You will need to have [ADB](https://developer.android.com/tools/adb) installed.
106116

107117
<details><summary>Click Here to Download and Install a Release</summary>
108118

@@ -169,12 +179,6 @@ _Note: you may have to uninstall before installing due to different certificate
169179

170180
For more details, see the [ADB Documentation](https://developer.android.com/tools/adb#move).
171181

172-
# Development
173-
174-
Android Studio: https://developer.android.com/studio
175-
176-
For now see [Install](#Install).
177-
178182
# Support
179183

180184
For general help or to request a feature, see:
@@ -197,3 +201,4 @@ You can also support other related projects:
197201
- [Django Files Server](https://github.com/django-files/django-files)
198202
- [Django Files iOS App](https://github.com/django-files/ios-client)
199203
- [Django Files Android App](https://github.com/django-files/android-client)
204+
- [Django Files Web Extension](https://github.com/django-files/web-extension)

app/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ android {
1919

2020
buildTypes {
2121
release {
22-
isMinifyEnabled = false
22+
isMinifyEnabled = true
23+
isShrinkResources = true
2324
proguardFiles(
2425
getDefaultProguardFile("proguard-android-optimize.txt"),
2526
"proguard-rules.pro"

app/proguard-rules.pro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
# If your project uses WebView with JS, uncomment the following
99
# and specify the fully qualified class name to the JavaScript interface
1010
# class:
11-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12-
# public *;
13-
#}
11+
-keepclassmembers class com.djangofiles.djangofiles.WebAppInterface {
12+
public *;
13+
}
1414

1515
# Uncomment this to preserve the line number information for
1616
# debugging stack traces.

app/src/main/java/com/djangofiles/djangofiles/MainActivity.kt

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.activity.enableEdgeToEdge
2424
import androidx.appcompat.app.AlertDialog
2525
import androidx.appcompat.app.AppCompatActivity
2626
import androidx.core.content.edit
27+
import androidx.core.net.toUri
2728
import androidx.core.view.ViewCompat
2829
import androidx.core.view.WindowInsetsCompat
2930
import com.djangofiles.djangofiles.databinding.ActivityMainBinding
@@ -68,7 +69,8 @@ class MainActivity : AppCompatActivity() {
6869

6970
val packageInfo = packageManager.getPackageInfo(this.packageName, 0)
7071
Log.d("MY_APP_TAG", "versionName: ${packageInfo.versionName}")
71-
val userAgent = "${webView.settings.userAgentString} DjangoFiles Android/${packageInfo.versionName}"
72+
val userAgent =
73+
"${webView.settings.userAgentString} DjangoFiles Android/${packageInfo.versionName}"
7274
Log.d("onCreate", "UA: $userAgent")
7375

7476
webView.settings.userAgentString = userAgent
@@ -108,7 +110,7 @@ class MainActivity : AppCompatActivity() {
108110
val uri = intent.data
109111
Log.d("handleIntent", "uri: $uri")
110112

111-
// String mimeType = getContentResolver().getType(uri);
113+
//String mimeType = getContentResolver().getType(uri);
112114
val mimeType = intent.type
113115
Log.d("handleIntent", "mimeType: $mimeType")
114116

@@ -176,7 +178,7 @@ class MainActivity : AppCompatActivity() {
176178
if (sharedText != null) {
177179
Log.d("handleIntent", "Received text/plain: $sharedText")
178180
if (sharedText.startsWith("content://")) {
179-
val fileUri = Uri.parse(sharedText)
181+
val fileUri = sharedText.toUri()
180182
Log.d("handleIntent", "Received URI: $fileUri")
181183
} else {
182184
Log.d("handleIntent", "Received text/plain: $sharedText")
@@ -192,7 +194,7 @@ class MainActivity : AppCompatActivity() {
192194
Toast.LENGTH_SHORT
193195
).show()
194196
} else {
195-
// val fileUri = intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
197+
//val fileUri = intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
196198
val fileUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
197199
intent.getParcelableExtra(Intent.EXTRA_STREAM, Uri::class.java)
198200
} else {
@@ -207,7 +209,7 @@ class MainActivity : AppCompatActivity() {
207209
}
208210
} else if (Intent.ACTION_SEND_MULTIPLE == action) {
209211
Log.d("handleIntent", "ACTION_SEND_MULTIPLE")
210-
// val fileUris = intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)
212+
//val fileUris = intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)
211213
val fileUris = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
212214
intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM, Uri::class.java)
213215
} else {
@@ -466,14 +468,9 @@ class MainActivity : AppCompatActivity() {
466468
private fun copyToClipboard(url: String) {
467469
webView.loadUrl(url)
468470
val clipboard = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
469-
if (clipboard != null) {
470-
val clip = ClipData.newPlainText("URL", url)
471-
clipboard.setPrimaryClip(clip)
472-
Toast.makeText(this, getString(R.string.tst_url_copied), Toast.LENGTH_SHORT).show()
473-
} else {
474-
Toast.makeText(this, getString(R.string.tst_no_clipboard), Toast.LENGTH_SHORT)
475-
.show()
476-
}
471+
val clip = ClipData.newPlainText("URL", url)
472+
clipboard.setPrimaryClip(clip)
473+
Toast.makeText(this, getString(R.string.tst_url_copied), Toast.LENGTH_SHORT).show()
477474
}
478475

479476
inner class MyWebViewClient : WebViewClient() {
@@ -498,7 +495,7 @@ class MainActivity : AppCompatActivity() {
498495
Log.d("shouldOverrideUrlLoading", "FALSE - in app")
499496
return false
500497
}
501-
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
498+
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
502499
view.context.startActivity(intent)
503500
Log.d("shouldOverrideUrlLoading", "TRUE - in browser")
504501
return true
@@ -510,13 +507,14 @@ class MainActivity : AppCompatActivity() {
510507
errorResponse: WebResourceError
511508
) {
512509
Log.d("onReceivedError", "ERROR: " + errorResponse.errorCode)
513-
Toast.makeText(
514-
view.context,
515-
"HTTP error " + errorResponse.description,
516-
Toast.LENGTH_LONG
517-
).show()
510+
// TODO: This does not seem to be helpful...
511+
//Toast.makeText(
512+
// view.context,
513+
// "HTTP error " + errorResponse.description,
514+
// Toast.LENGTH_LONG
515+
//).show()
518516
// TODO: Now that we verify the URL this should not be needed...
519-
// showSettingsDialog()
517+
//showSettingsDialog()
520518
}
521519

522520
override fun onReceivedHttpError(
@@ -525,13 +523,14 @@ class MainActivity : AppCompatActivity() {
525523
errorResponse: WebResourceResponse
526524
) {
527525
Log.d("onReceivedHttpError", "ERROR: " + errorResponse.statusCode)
528-
Toast.makeText(
529-
view.context,
530-
"HTTP error " + errorResponse.reasonPhrase,
531-
Toast.LENGTH_LONG
532-
).show()
526+
// TODO: This does not seem to be helpful...
527+
//Toast.makeText(
528+
// view.context,
529+
// "HTTP error " + errorResponse.reasonPhrase,
530+
// Toast.LENGTH_LONG
531+
//).show()
533532
// TODO: Now that we verify the URL this should not be needed...
534-
// showSettingsDialog()
533+
//showSettingsDialog()
535534
}
536535
}
537536
}

app/src/main/java/com/djangofiles/djangofiles/WebAppInterface.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.content.Context
44
import android.util.Log
55
import android.webkit.JavascriptInterface
66
import android.widget.Toast
7+
import androidx.core.content.edit
78

89
class WebAppInterface
910
internal constructor(private var context: Context) {
@@ -25,7 +26,7 @@ internal constructor(private var context: Context) {
2526
val currentToken = preferences.getString(TOKEN_KEY, null)
2627

2728
if (currentToken != authToken) {
28-
preferences.edit().putString(TOKEN_KEY, authToken).apply()
29+
preferences.edit { putString(TOKEN_KEY, authToken) }
2930
Log.d("receiveAuthToken", "Auth Token Updated.")
3031
} else {
3132
Log.d("receiveAuthToken", "Auth Token Not Changes.")

0 commit comments

Comments
 (0)