Skip to content

Commit e25aa84

Browse files
authored
Fix Add Server Logic (#9)
1 parent d7c947b commit e25aa84

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
- name: "Verify Build"
9797
run: |
9898
apkanalyzer -h apk summary "${{ env.path }}/${{ env.output }}"
99-
99+
100100
echo "::group::ls env.path"
101101
ls -lAh ${{ env.path }}
102102
echo "::endgroup::"

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
Allows you to Share or Open any file with your Django Files server.
2828
The URL to the file is automatically copied to the clipboard and the preview is shown in the app.
2929

30+
- Supports Android 8 (API 26) 2017 or Newer.
31+
3032
| Django Files | Link |
3133
| ----------------- | :-------------------------------------------- |
3234
| Website | https://django-files.github.io/ |
@@ -35,8 +37,6 @@ The URL to the file is automatically copied to the clipboard and the preview is
3537
| iOS App | https://github.com/django-files/ios-client |
3638
| Web Extension | https://github.com/django-files/web-extension |
3739

38-
> Django Files Android App is now signed starting at version 0.0.3
39-
4040
## Install
4141

4242
> [!TIP]
@@ -63,16 +63,16 @@ should take you to the settings area to allow installation if not already enable
6363

6464
</details>
6565

66+
> [!NOTE]
67+
> Swipe from the left to access the Android menu.
68+
6669
### Setup
6770

6871
1. [Install](#Install) and open the app on your device.
6972
2. Enter the URL to your Django Files server.
7073
3. Log in as you normally would on the website.
7174
4. All Done! You can now share and open files with Django Files.
7275

73-
> [!TIP]
74-
> Swipe from the left to access the Android menu.
75-
7676
To use, share or open any file and choose the Django Files app.
7777
The app will then be upload the file to your Django Files server.
7878
Additionally, the URL is copied to the clipboard and the preview is show in the app.
@@ -83,20 +83,22 @@ Additionally, the URL is copied to the clipboard and the preview is show in the
8383
## Features
8484

8585
- Share or Open any file (or multiple) and automatically copy the URL to the clipboard.
86-
- Ability to manually change servers by entering a new URL from the Server List menu.
86+
- Ability to add multiple servers and switch on the fly from the Server List menu.
8787
- Supports Local Login, GitHub OAuth, Google OAuth, Discord OAuth (w/o passkeys).
88+
- Native Android Navigation Drawer from Server List or Swipe from Left.
8889

8990
### Planned
9091

91-
- Ability to save multiple servers and switch between them automatically in the Server List menu.
9292
- Ability for the app to log you in if your session is expired or when switching servers.
9393

9494
### Known Issues
9595

9696
- Login with Discord OAuth passkeys does not work.
97-
- Login with Google OAuth gives an error; however, if you wait ~30 seconds it will succeed.
97+
- Login with Google OAuth gives an error; however, may succeed if you wait ~30 seconds.
9898
- The app gets logged out if the session expires; however, sharing continues to work.
9999
- Upon logging back in, you may need to leave the app open (in the background) for ~30 seconds to allow the cookie to be saved.
100+
- Deleting the active server does not deactivate it and it remains active until selecting another server.
101+
- Uploading from the website (Uppy) in the app does not work due to a permissions issue.
100102

101103
# Development
102104

@@ -123,7 +125,7 @@ To Build:
123125

124126
## Command Line
125127

126-
_Note: This section is a WIP!_
128+
_Note: This section is a WIP! For more details see the [release.yaml](.github/workflows/release.yaml)._
127129

128130
You will need to have [ADB](https://developer.android.com/tools/adb) installed.
129131

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,14 @@ class MainActivity : AppCompatActivity() {
402402
// TODO: Change this to HEAD or use response data...
403403
val request = Request.Builder().header("User-Agent", "DF").url(authUrl).get().build()
404404
return try {
405-
val response = client.newCall(request).execute()
406-
Log.d("checkUrl", "Success: Remote OK.")
407405
val dao: ServerDao = ServerDatabase.getInstance(this).serverDao()
408-
dao.add(Server(url = url))
406+
val response = client.newCall(request).execute()
407+
if (response.isSuccessful) {
408+
Log.d("checkUrl", "Success: Remote OK.")
409+
dao.add(Server(url = url))
410+
} else {
411+
Log.d("checkUrl", "Error: Remote code: ${response.code}")
412+
}
409413
response.isSuccessful
410414
} catch (e: Exception) {
411415
Log.d("checkUrl", "Error: Remote Failed!")

app/src/main/java/com/djangofiles/djangofiles/settings/SettingsFragment.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
139139
val request = Request.Builder().header("User-Agent", "DF").url(authUrl).get().build()
140140
return try {
141141
val response = client.newCall(request).execute()
142-
Log.d("checkUrl", "Success: Remote OK.")
143-
dao.add(Server(url = url))
142+
if (response.isSuccessful) {
143+
Log.d("checkUrl", "Success: Remote OK.")
144+
dao.add(Server(url = url))
145+
} else {
146+
Log.d("checkUrl", "Error: Remote code: ${response.code}")
147+
}
144148
response.isSuccessful
145149
} catch (e: Exception) {
146150
Log.d("checkUrl", "Error: Remote Failed!")
@@ -395,7 +399,8 @@ abstract class ServerDatabase : RoomDatabase() {
395399
abstract fun serverDao(): ServerDao
396400

397401
companion object {
398-
@Volatile private var instance: ServerDatabase? = null
402+
@Volatile
403+
private var instance: ServerDatabase? = null
399404

400405
fun getInstance(context: Context): ServerDatabase =
401406
instance ?: synchronized(this) {

0 commit comments

Comments
 (0)