Merge pull request #69 from szkolny-eu/hotfix/message-attachments

[Messages] Fix downloading and displaying attachment on API 30+.
This commit is contained in:
Kuba Szczodrzyński 2021-09-10 23:44:26 +02:00 committed by GitHub
commit e902352a4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -37,9 +37,7 @@ class AttachmentsView @JvmOverloads constructor(
} }
private val storageDir by lazy { private val storageDir by lazy {
val storageDir = Environment.getExternalStoragePublicDirectory("Szkolny.eu") Utils.getStorageDir()
storageDir.mkdirs()
storageDir
} }
fun init(arguments: Bundle, owner: Any) { fun init(arguments: Bundle, owner: Any) {
@ -82,6 +80,7 @@ class AttachmentsView @JvmOverloads constructor(
list.adapter = adapter list.adapter = adapter
list.apply { list.apply {
setHasFixedSize(false) setHasFixedSize(false)
isNestedScrollingEnabled = false
layoutManager = LinearLayoutManager(context) layoutManager = LinearLayoutManager(context)
addItemDecoration(SimpleDividerItemDecoration(context)) addItemDecoration(SimpleDividerItemDecoration(context))
} }

View File

@ -776,7 +776,8 @@ public class Utils {
public static File getStorageDir() { public static File getStorageDir() {
if (storageDir != null) if (storageDir != null)
return storageDir; return storageDir;
storageDir = Environment.getExternalStoragePublicDirectory("Szkolny.eu"); storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
storageDir = new File(storageDir, "Szkolny.eu");
storageDir.mkdirs(); storageDir.mkdirs();
return storageDir; return storageDir;
} }

View File

@ -57,7 +57,7 @@
android:visibility="visible" android:visibility="visible"
tools:visibility="gone"/> tools:visibility="gone"/>
<ScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/content" android:id="@+id/content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
@ -306,6 +306,6 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </androidx.core.widget.NestedScrollView>
</LinearLayout> </LinearLayout>
</layout> </layout>