From d6aa0e576c98656084cccb194868ad16cea85265 Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Mon, 12 Sep 2022 17:58:03 +0200 Subject: [PATCH] Fix create account dialog on RTL locale & remove update cache --- .../cloudstream3/utils/InAppUpdater.kt | 13 +- app/src/main/res/layout/add_account_input.xml | 227 +++++++++--------- 2 files changed, 125 insertions(+), 115 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt index 42d200d0..54492e6d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt @@ -200,16 +200,23 @@ class InAppUpdater { private suspend fun Activity.downloadUpdate(url: String): Boolean { try { Log.d(LOG_TAG, "Downloading update: $url") + val appUpdateName = "CloudStream" + val appUpdateSuffix = "apk" - val localContext = this + // Delete all old updates + this.cacheDir.listFiles()?.filter { + it.name.startsWith(appUpdateName) && it.extension == appUpdateSuffix + }?.forEach { + it.deleteOnExit() + } - val downloadedFile = File.createTempFile("CloudStream", ".apk") + val downloadedFile = File.createTempFile(appUpdateName, ".$appUpdateSuffix") val sink: BufferedSink = downloadedFile.sink().buffer() updateLock.withLock { sink.writeAll(app.get(url).body.source()) sink.close() - openApk(localContext, Uri.fromFile(downloadedFile)) + openApk(this, Uri.fromFile(downloadedFile)) } return true } catch (e: Exception) { diff --git a/app/src/main/res/layout/add_account_input.xml b/app/src/main/res/layout/add_account_input.xml index 1471af9c..ea48a80f 100644 --- a/app/src/main/res/layout/add_account_input.xml +++ b/app/src/main/res/layout/add_account_input.xml @@ -1,131 +1,134 @@ - - - - - - - + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dp" + android:layout_marginBottom="10dp" + android:orientation="horizontal"> - + + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:textColor="?attr/textColor" + android:textSize="20sp" + android:textStyle="bold" + tools:text="Test" /> - - - + + + + android:layout_height="wrap_content" + android:autofillHints="username" + android:hint="@string/example_username" + android:inputType="text" + android:nextFocusLeft="@id/apply_btt" + android:nextFocusRight="@id/cancel_btt" + android:nextFocusDown="@id/login_email_input" + android:requiresFadingEdge="vertical" + android:textColorHint="?attr/grayTextColor" + tools:ignore="LabelFor" /> + + + + + + + + + + + android:id="@+id/apply_btt" + style="@style/WhiteButton" + android:layout_width="wrap_content" + android:layout_gravity="center_vertical|end" + android:text="@string/login" /> + android:id="@+id/cancel_btt" + style="@style/BlackButton" + android:layout_width="wrap_content" + android:layout_gravity="center_vertical|end" + android:text="@string/sort_cancel" /> \ No newline at end of file