Skip to content

Commit b461cc0

Browse files
authored
Updates (#70)
- Upgrade AGP to 8.12.1 - Update Dialogs - Add Login Layouts
1 parent 829812e commit b461cc0

File tree

15 files changed

+353
-297
lines changed

15 files changed

+353
-297
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
[![GitHub Downloads](https://img.shields.io/github/downloads/django-files/android-client/total?logo=android)](https://github.com/django-files/android-client/releases/latest/download/app-release.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/pulse)
34
[![Lint](https://img.shields.io/github/actions/workflow/status/django-files/android-client/lint.yaml?logo=github&logoColor=white&label=lint)](https://github.com/django-files/android-client/actions/workflows/lint.yaml)
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)
5+
[![Release](https://img.shields.io/github/actions/workflow/status/django-files/android-client/release.yaml?logo=github&logoColor=white&label=release)](https://github.com/django-files/android-client/actions/workflows/release.yaml)
6+
[![AGP Version](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fdjango-files%2Fandroid-client%2Frefs%2Fheads%2Fmaster%2Fgradle%2Flibs.versions.toml&query=%24.versions.agp&logo=gradle&label=AGP)](https://github.com/django-files/android-client/blob/master/gradle/libs.versions.toml#L2)
57
[![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)
68
[![GitHub Top Language](https://img.shields.io/github/languages/top/django-files/android-client?logo=htmx)](https://github.com/django-files/android-client)
7-
[![GitHub Discussions](https://img.shields.io/github/discussions/django-files/android-client)](https://github.com/django-files/android-client/discussions)
9+
[![GitHub Discussions](https://img.shields.io/github/discussions/django-files/android-client?logo=github)](https://github.com/django-files/android-client/discussions)
810
[![GitHub Forks](https://img.shields.io/github/forks/django-files/android-client?style=flat&logo=github)](https://github.com/django-files/android-client/forks)
911
[![GitHub Repo Stars](https://img.shields.io/github/stars/django-files/android-client?style=flat&logo=github)](https://github.com/django-files/android-client/stargazers)
1012
[![GitHub Org Stars](https://img.shields.io/github/stars/django-files?style=flat&logo=github&label=org%20stars)](https://django-files.github.io/)
1113
[![Discord](https://img.shields.io/discord/899171661457293343?logo=discord&logoColor=white&label=discord&color=7289da)](https://discord.gg/wXy6m2X8wY)
1214

1315
# Django Files Android App
1416

15-
[![GitHub Release](https://img.shields.io/github/v/release/django-files/android-client?style=for-the-badge&logo=android&label=Download%20Android%20APK&color=A4C639)](https://github.com/django-files/android-client/releases/latest/download/app-release.apk)
17+
[![GitHub Release](https://img.shields.io/github/v/release/django-files/android-client?style=for-the-badge&logo=android&label=Download%20Android%20APK&color=3ddc84)](https://github.com/django-files/android-client/releases/latest/download/app-release.apk)
1618

1719
- [Install](#Install)
1820
- [Setup](#Setup)
@@ -51,7 +53,7 @@ _If you are unsure how to install, [Obtainium](https://github.com/ImranR98/Obtai
5153
[![Get on GitHub](https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/android/get80/github.png)](https://github.com/django-files/android-client/releases/latest/download/app-release.apk)
5254
[![Get on Obtainium](https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/android/get80/obtainium.png)](https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://github.com/django-files/android-client)
5355

54-
<details><summary>📲 Click to View QR Codes 📸</summary>
56+
<details><summary>📲 Click to View QR Codes 📸 Supports Android 8 (API 26) 2017 +</summary>
5557

5658
[![QR Code GitHub](https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/django-files/android/qr-code-github.png)](https://github.com/django-files/android-client/releases/latest/download/app-release.apk)
5759

app/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ android {
6060
}
6161

6262
compileOptions {
63-
sourceCompatibility = JavaVersion.VERSION_11
64-
targetCompatibility = JavaVersion.VERSION_11
63+
sourceCompatibility = JavaVersion.VERSION_17
64+
targetCompatibility = JavaVersion.VERSION_17
6565
}
6666
//kotlinOptions {
67-
// jvmTarget = "11"
67+
// jvmTarget = "17"
6868
//}
6969
tasks.withType<KotlinJvmCompile>().configureEach {
7070
compilerOptions {
71-
jvmTarget.set(JvmTarget.JVM_11)
71+
jvmTarget.set(JvmTarget.JVM_17)
7272
}
7373
}
7474

app/src/main/java/com/djangofiles/djangofiles/ui/login/AuthorizeFragment.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class AuthorizeFragment : Fragment() {
7676
super.onViewCreated(view, savedInstanceState)
7777
Log.d("Authorize[onViewCreated]", "savedInstanceState: ${savedInstanceState?.size()}")
7878

79-
ViewCompat.setOnApplyWindowInsetsListener(binding.scrollViewLayout) { v, insets ->
79+
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
8080
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
8181
v.updatePadding(top = bars.top, bottom = bars.bottom)
8282
insets
@@ -107,6 +107,7 @@ class AuthorizeFragment : Fragment() {
107107

108108
val api = ServerApi(ctx, authUrl)
109109

110+
// TODO: Cache methodsResponse in viewModel
110111
lifecycleScope.launch {
111112
val methodsResponse = api.methods()
112113
Log.d("Authorize[onViewCreated]", "methodsResponse: $methodsResponse")
@@ -115,10 +116,10 @@ class AuthorizeFragment : Fragment() {
115116
Log.d("Authorize[onViewCreated]", "methodsData: $methodsData")
116117
if (methodsData != null) {
117118
Log.d("Authorize[onViewCreated]", "siteName: ${methodsData.siteName}")
118-
binding.siteName.text = methodsData.siteName
119-
binding.loadingLayout.visibility = View.GONE
120-
binding.gotoLoginBtn.visibility = View.VISIBLE
121-
binding.addServerBtn.visibility = View.VISIBLE
119+
_binding?.siteName?.text = methodsData.siteName
120+
_binding?.loadingLayout?.visibility = View.GONE
121+
_binding?.gotoLoginBtn?.visibility = View.VISIBLE
122+
_binding?.addServerBtn?.visibility = View.VISIBLE
122123
}
123124
}
124125
}

app/src/main/java/com/djangofiles/djangofiles/ui/login/LoginFragment.kt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,25 @@ class LoginFragment : Fragment() {
6565
super.onViewCreated(view, savedInstanceState)
6666
Log.d("Login[onViewCreated]", "savedInstanceState: ${savedInstanceState?.size()}")
6767

68-
ViewCompat.setOnApplyWindowInsetsListener(binding.scrollViewLayout) { v, insets ->
68+
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
6969
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
7070
v.updatePadding(top = bars.top, bottom = bars.bottom)
7171
insets
7272
}
7373

74-
val packageInfo =
75-
requireContext().packageManager.getPackageInfo(requireContext().packageName, 0)
76-
val versionName = packageInfo.versionName
77-
Log.d("Login[onViewCreated]", "versionName: $versionName")
74+
val ctx = requireContext()
75+
76+
//val packageInfo = ctx.packageManager.getPackageInfo(ctx.packageName, 0)
77+
//val formattedVersion = getString(
78+
// R.string.version_code_string,
79+
// packageInfo.versionName,
80+
// packageInfo.versionCode.toString()
81+
//)
82+
//Log.d("showAppInfoDialog", "formattedVersion: $formattedVersion")
83+
//binding.versionName.text = formattedVersion
84+
85+
val packageInfo = ctx.packageManager.getPackageInfo(ctx.packageName, 0)
86+
binding.versionName.text = packageInfo.versionName
7887

7988
val authUrl = arguments?.getString("authUrl")
8089
Log.d("Login[onViewCreated]", "authUrl: $authUrl")
@@ -107,7 +116,7 @@ class LoginFragment : Fragment() {
107116
//sharedPreferences?.edit { putString("saved_url", host) }
108117

109118
Log.d("loginFunction", "Processing URL: $host")
110-
val api = ServerApi(requireContext(), host)
119+
val api = ServerApi(ctx, host)
111120
lifecycleScope.launch {
112121
try {
113122
// TODO: When a session expires the server will be a duplicate...
@@ -160,7 +169,7 @@ class LoginFragment : Fragment() {
160169
e.printStackTrace()
161170
val msg = e.message ?: "Unknown Error Validating Server."
162171
Log.i("loginFunction", "msg: $msg")
163-
binding.hostnameText.error = "Validation Error"
172+
_binding?.hostnameText?.error = "Validation Error"
164173
withContext(Dispatchers.Main) {
165174
Toast.makeText(requireContext(), msg, Toast.LENGTH_LONG).show()
166175
}
@@ -176,11 +185,10 @@ class LoginFragment : Fragment() {
176185
requireActivity().finishAffinity()
177186
}
178187
}
179-
binding.websiteLink.setOnClickListener {
180-
val url = binding.websiteLink.text.toString()
181-
Log.d("websiteLink", "url: $url")
182-
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
183-
startActivity(intent)
188+
189+
binding.websiteLink.paint?.isUnderlineText = true
190+
binding.websiteLink.setOnClickListener { v ->
191+
startActivity(Intent(Intent.ACTION_VIEW, v.tag.toString().toUri()))
184192
}
185193

186194
if (authUrl != null) {

app/src/main/java/com/djangofiles/djangofiles/ui/login/LoginTwoFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class LoginTwoFragment : Fragment() {
7979
super.onViewCreated(view, savedInstanceState)
8080
Log.d("Login[onViewCreated]", "savedInstanceState: ${savedInstanceState?.size()}")
8181

82-
ViewCompat.setOnApplyWindowInsetsListener(binding.scrollViewLayout) { v, insets ->
82+
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
8383
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
8484
v.updatePadding(top = bars.top, bottom = bars.bottom)
8585
insets

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

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,22 @@ class SettingsFragment : PreferenceFragmentCompat() {
385385
.show()
386386
}
387387

388-
fun Context.showFeedbackDialog() {
388+
private fun Context.showFeedbackDialog() {
389389
val inflater = LayoutInflater.from(this)
390390
val view = inflater.inflate(R.layout.dialog_feedback, null)
391+
391392
val input = view.findViewById<EditText>(R.id.feedback_input)
393+
val websiteLink = view.findViewById<TextView>(R.id.website_link)
394+
val githubLink = view.findViewById<TextView>(R.id.github_link)
395+
396+
websiteLink.paint?.isUnderlineText = true
397+
websiteLink.setOnClickListener {
398+
startActivity(Intent(Intent.ACTION_VIEW, websiteLink.tag.toString().toUri()))
399+
}
400+
githubLink.paint?.isUnderlineText = true
401+
githubLink.setOnClickListener {
402+
startActivity(Intent(Intent.ACTION_VIEW, githubLink.tag.toString().toUri()))
403+
}
392404

393405
val dialog = MaterialAlertDialogBuilder(this)
394406
.setView(view)
@@ -417,7 +429,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
417429
putString("message", response.message())
418430
putString("code", response.code().toString())
419431
}
420-
Firebase.analytics.logEvent("send_feedback_failed", params)
432+
Firebase.analytics.logEvent("feedback_failed", params)
421433
"Error: ${response.code()}"
422434
}
423435
Log.d("showFeedbackDialog", "msg: $msg")
@@ -428,67 +440,45 @@ class SettingsFragment : PreferenceFragmentCompat() {
428440
input.error = "Feedback is Required"
429441
}
430442
}
431-
432443
input.requestFocus()
433-
434-
val link = view.findViewById<TextView>(R.id.github_link)
435-
val linkText = getString(R.string.github_link, link.tag)
436-
link.text = Html.fromHtml(linkText, Html.FROM_HTML_MODE_LEGACY)
437-
link.movementMethod = LinkMovementMethod.getInstance()
438-
439-
//val imm = this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
440-
//imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT)
441444
}
442-
443-
dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Send") { _, _ -> }
444445
dialog.show()
445446
}
446447

447-
fun Context.showAppInfoDialog() {
448+
private fun Context.showAppInfoDialog() {
448449
val inflater = LayoutInflater.from(this)
449450
val view = inflater.inflate(R.layout.dialog_app_info, null)
451+
450452
val appId = view.findViewById<TextView>(R.id.app_identifier)
451-
val appVersion = view.findViewById<TextView>(R.id.app_version)
452-
val sourceLink = view.findViewById<TextView>(R.id.source_link)
453+
val versionName = view.findViewById<TextView>(R.id.version_name)
454+
val githubLink = view.findViewById<TextView>(R.id.github_link)
453455
val websiteLink = view.findViewById<TextView>(R.id.website_link)
454-
//val appInfo = view.findViewById<TextView>(R.id.open_app_info)
455-
456-
val sourceText = getString(R.string.github_link, sourceLink.tag)
457-
Log.d("showAppInfoDialog", "sourceText: $sourceText")
458456

459-
val websiteText = getString(R.string.website_link, websiteLink.tag)
460-
Log.d("showAppInfoDialog", "websiteText: $websiteText")
457+
githubLink.paint?.isUnderlineText = true
458+
githubLink.setOnClickListener {
459+
startActivity(Intent(Intent.ACTION_VIEW, githubLink.tag.toString().toUri()))
460+
}
461+
websiteLink.paint?.isUnderlineText = true
462+
websiteLink.setOnClickListener {
463+
startActivity(Intent(Intent.ACTION_VIEW, websiteLink.tag.toString().toUri()))
464+
}
461465

462466
val packageInfo = this.packageManager.getPackageInfo(this.packageName, 0)
463-
val versionName = packageInfo.versionName
464-
Log.d("showAppInfoDialog", "versionName: $versionName")
465-
466-
val formattedVersion = getString(R.string.version_string, versionName)
467+
val formattedVersion = getString(
468+
R.string.version_code_string,
469+
packageInfo.versionName,
470+
packageInfo.versionCode.toString()
471+
)
467472
Log.d("showAppInfoDialog", "formattedVersion: $formattedVersion")
468473

469-
val dialog = MaterialAlertDialogBuilder(this)
474+
appId.text = this.packageName
475+
versionName.text = formattedVersion
476+
477+
MaterialAlertDialogBuilder(this)
470478
.setView(view)
471479
.setNegativeButton("Close", null)
472480
.create()
473-
474-
dialog.setOnShowListener {
475-
appId.text = this.packageName
476-
appVersion.text = formattedVersion
477-
478-
sourceLink.text = Html.fromHtml(sourceText, Html.FROM_HTML_MODE_LEGACY)
479-
sourceLink.movementMethod = LinkMovementMethod.getInstance()
480-
websiteLink.text = Html.fromHtml(websiteText, Html.FROM_HTML_MODE_LEGACY)
481-
websiteLink.movementMethod = LinkMovementMethod.getInstance()
482-
483-
//appInfo.setOnClickListener {
484-
// Log.d("appInfo", "setOnClickListener")
485-
// val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
486-
// data = Uri.fromParts("package", packageName, null)
487-
// }
488-
// startActivity(intent)
489-
//}
490-
}
491-
dialog.show()
481+
.show()
492482
}
493483
}
494484

app/src/main/java/com/djangofiles/djangofiles/widget/WidgetProvider.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ import com.djangofiles.djangofiles.R
1717
import com.djangofiles.djangofiles.db.ServerDao
1818
import com.djangofiles.djangofiles.db.ServerDatabase
1919
import com.djangofiles.djangofiles.work.updateStats
20-
import kotlinx.coroutines.DelicateCoroutinesApi
20+
import kotlinx.coroutines.CoroutineScope
2121
import kotlinx.coroutines.Dispatchers
22-
import kotlinx.coroutines.GlobalScope
22+
import kotlinx.coroutines.SupervisorJob
2323
import kotlinx.coroutines.launch
2424
import java.util.Date
2525

2626
class WidgetProvider : AppWidgetProvider() {
2727

28-
@OptIn(DelicateCoroutinesApi::class)
2928
override fun onReceive(context: Context, intent: Intent) {
3029
super.onReceive(context, intent)
3130
Log.i("Widget[onReceive]", "intent: $intent")
@@ -46,8 +45,8 @@ class WidgetProvider : AppWidgetProvider() {
4645
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
4746
return
4847
}
49-
Log.d("Widget[onReceive]", "GlobalScope.launch: START")
50-
GlobalScope.launch(Dispatchers.IO) {
48+
Log.d("Widget[onReceive]", "CoroutineScope.launch: START")
49+
CoroutineScope(SupervisorJob() + Dispatchers.IO).launch {
5150
context.updateStats()
5251
val appWidgetManager = AppWidgetManager.getInstance(context)
5352
onUpdate(context, appWidgetManager, intArrayOf(appWidgetId))
@@ -56,7 +55,6 @@ class WidgetProvider : AppWidgetProvider() {
5655
}
5756
}
5857

59-
@OptIn(DelicateCoroutinesApi::class)
6058
override fun onUpdate(
6159
context: Context,
6260
appWidgetManager: AppWidgetManager,
@@ -158,7 +156,7 @@ class WidgetProvider : AppWidgetProvider() {
158156
//views.setOnClickPendingIntent(R.id.file_list_button, pendingIntent3)
159157

160158
// Room Data
161-
GlobalScope.launch(Dispatchers.IO) {
159+
CoroutineScope(SupervisorJob() + Dispatchers.IO).launch {
162160
val dao: ServerDao = ServerDatabase.Companion.getInstance(context).serverDao()
163161
Log.d("Widget[onUpdate]", "dao: $dao")
164162
val server = dao.getByUrl(savedUrl)

app/src/main/res/drawable/fa_github.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
android:viewportWidth="496"
55
android:viewportHeight="512">
66
<path
7-
android:fillColor="@android:color/white"
7+
android:fillColor="?attr/colorControlNormal"
88
android:pathData="M165.9,397.4c0,2 -2.3,3.6 -5.2,3.6 -3.3,0.3 -5.6,-1.3 -5.6,-3.6 0,-2 2.3,-3.6 5.2,-3.6 3,-0.3 5.6,1.3 5.6,3.6zM134.8,392.9c-0.7,2 1.3,4.3 4.3,4.9 2.6,1 5.6,0 6.2,-2s-1.3,-4.3 -4.3,-5.2c-2.6,-0.7 -5.5,0.3 -6.2,2.3zM179,391.2c-2.9,0.7 -4.9,2.6 -4.6,4.9 0.3,2 2.9,3.3 5.9,2.6 2.9,-0.7 4.9,-2.6 4.6,-4.6 -0.3,-1.9 -3,-3.2 -5.9,-2.9zM244.8,8C106.1,8 0,113.3 0,252c0,110.9 69.8,205.8 169.5,239.2 12.8,2.3 17.3,-5.6 17.3,-12.1 0,-6.2 -0.3,-40.4 -0.3,-61.4 0,0 -70,15 -84.7,-29.8 0,0 -11.4,-29.1 -27.8,-36.6 0,0 -22.9,-15.7 1.6,-15.4 0,0 24.9,2 38.6,25.8 21.9,38.6 58.6,27.5 72.9,20.9 2.3,-16 8.8,-27.1 16,-33.7 -55.9,-6.2 -112.3,-14.3 -112.3,-110.5 0,-27.5 7.6,-41.3 23.6,-58.9 -2.6,-6.5 -11.1,-33.3 2.6,-67.9 20.9,-6.5 69,27 69,27 20,-5.6 41.5,-8.5 62.8,-8.5s42.8,2.9 62.8,8.5c0,0 48.1,-33.6 69,-27 13.7,34.7 5.2,61.4 2.6,67.9 16,17.7 25.8,31.5 25.8,58.9 0,96.5 -58.9,104.2 -114.8,110.5 9.2,7.9 17,22.9 17,46.4 0,33.7 -0.3,75.4 -0.3,83.6 0,6.5 4.6,14.4 17.3,12.1C428.2,457.8 496,362.9 496,252 496,113.3 383.5,8 244.8,8zM97.2,352.9c-1.3,1 -1,3.3 0.7,5.2 1.6,1.6 3.9,2.3 5.2,1 1.3,-1 1,-3.3 -0.7,-5.2 -1.6,-1.6 -3.9,-2.3 -5.2,-1zM86.4,344.8c-0.7,1.3 0.3,2.9 2.3,3.9 1.6,1 3.6,0.7 4.3,-0.7 0.7,-1.3 -0.3,-2.9 -2.3,-3.9 -2,-0.6 -3.6,-0.3 -4.3,0.7zM118.8,380.4c-1.6,1.3 -1,4.3 1.3,6.2 2.3,2.3 5.2,2.6 6.5,1 1.3,-1.3 0.7,-4.3 -1.3,-6.2 -2.2,-2.3 -5.2,-2.6 -6.5,-1zM107.4,365.7c-1.6,1 -1.6,3.6 0,5.9 1.6,2.3 4.3,3.3 5.6,2.3 1.6,-1.3 1.6,-3.9 0,-6.2 -1.4,-2.3 -4,-3.3 -5.6,-2z"/>
99
</vector>

0 commit comments

Comments
 (0)