Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Updater: Add another available CDN download address
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Jan 14, 2024
1 parent 4907af9 commit 02670f1
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MainViewModel : ViewModel() {
var bigversion: String? = null
var officialDownload: String? = null
var officialText: String? = null
var cdnDownload: String? = null
var cdn1Download: String? = null
var cdn2Download: String? = null
var changelog: String? = null
}
15 changes: 10 additions & 5 deletions app/src/main/kotlin/top/yukonga/update/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ class MainActivity : AppCompatActivity() {
officialText =
if (recoveryRomInfo.currentRom.md5 == recoveryRomInfo.latestRom?.md5) getString(R.string.official, "ultimateota")
else getString(R.string.official, "bigota")
cdnDownload = if (recoveryRomInfo.currentRom.md5 == recoveryRomInfo.latestRom?.md5) getString(
R.string.cdn_link, recoveryRomInfo.currentRom.version, recoveryRomInfo.latestRom.filename
) else getString(R.string.cdn_link, recoveryRomInfo.currentRom.version, recoveryRomInfo.currentRom.filename)
cdn1Download = if (recoveryRomInfo.currentRom.md5 == recoveryRomInfo.latestRom?.md5) getString(
R.string.cdn1_link, recoveryRomInfo.currentRom.version, recoveryRomInfo.latestRom.filename
) else getString(R.string.cdn1_link, recoveryRomInfo.currentRom.version, recoveryRomInfo.currentRom.filename)
cdn2Download = if (recoveryRomInfo.currentRom.md5 == recoveryRomInfo.latestRom?.md5) getString(
R.string.cdn2_link, recoveryRomInfo.currentRom.version, recoveryRomInfo.latestRom.filename
) else getString(R.string.cdn2_link, recoveryRomInfo.currentRom.version, recoveryRomInfo.currentRom.filename)
changelog = log.toString().trimEnd()
}
} else {
Expand Down Expand Up @@ -466,8 +469,10 @@ class MainActivity : AppCompatActivity() {
official.text = mainViewModel.officialText
officialDownload.setDownloadClickListener(mainViewModel.filename, mainViewModel.officialDownload!!)
officialCopy.setCopyClickListener(mainViewModel.officialDownload)
cdnDownload.setDownloadClickListener(mainViewModel.filename, mainViewModel.cdnDownload!!)
cdnCopy.setCopyClickListener(mainViewModel.cdnDownload)
cdn1Download.setDownloadClickListener(mainViewModel.filename, mainViewModel.cdn1Download!!)
cdn1Copy.setCopyClickListener(mainViewModel.cdn1Download)
cdn2Download.setDownloadClickListener(mainViewModel.filename, mainViewModel.cdn2Download!!)
cdn2Copy.setCopyClickListener(mainViewModel.cdn2Download)
} else {
secondViewArray.forEach {
if (it.isVisible) it.fadOutAnimation()
Expand Down
57 changes: 53 additions & 4 deletions app/src/main/res/layout-land/main_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:contentDescription="@string/cdn"
android:contentDescription="@string/cdn1"
android:elegantTextHeight="true"
android:text="@string/cdn"
android:text="@string/cdn1"
android:textColor="?attr/colorOnSurfaceVariant"
android:textIsSelectable="true"
android:textSize="15sp" />
Expand All @@ -548,7 +548,7 @@
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:id="@+id/cdn_copy"
android:id="@+id/cdn1_copy"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -560,7 +560,56 @@
android:text="@string/copy_button" />

<com.google.android.material.button.MaterialButton
android:id="@+id/cdn_download"
android:id="@+id/cdn1_download"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/download_button"
android:elegantTextHeight="true"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/download_button" />

</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:contentDescription="@string/cdn2"
android:elegantTextHeight="true"
android:text="@string/cdn2"
android:textColor="?attr/colorOnSurfaceVariant"
android:textIsSelectable="true"
android:textSize="15sp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:id="@+id/cdn2_copy"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="18dp"
android:contentDescription="@string/copy_button"
android:elegantTextHeight="true"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/copy_button" />

<com.google.android.material.button.MaterialButton
android:id="@+id/cdn2_download"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
52 changes: 49 additions & 3 deletions app/src/main/res/layout/main_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:elegantTextHeight="true"
android:text="@string/cdn"
android:text="@string/cdn1"
android:textColor="?attr/colorOnSurfaceVariant"
android:textIsSelectable="true"
android:textSize="15sp" />
Expand All @@ -527,7 +527,7 @@
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:id="@+id/cdn_copy"
android:id="@+id/cdn1_copy"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -538,7 +538,53 @@
android:text="@string/copy_button" />

<com.google.android.material.button.MaterialButton
android:id="@+id/cdn_download"
android:id="@+id/cdn1_download"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elegantTextHeight="true"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/download_button" />

</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:elegantTextHeight="true"
android:text="@string/cdn2"
android:textColor="?attr/colorOnSurfaceVariant"
android:textIsSelectable="true"
android:textSize="15sp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:id="@+id/cdn2_copy"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="18dp"
android:elegantTextHeight="true"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/copy_button" />

<com.google.android.material.button.MaterialButton
android:id="@+id/cdn2_download"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="official" translatable="false">Official (%1$s)</string>
<string name="cdn" translatable="false">CDN (cdnorg)</string>
<string name="cdn1" translatable="false">CDN (cdnorg)</string>
<string name="cdn2" translatable="false">CDN (azureedge)</string>
<string name="official1_link" translatable="false">https://ultimateota.d.miui.com/%1$s/%2$s</string>
<string name="official2_link" translatable="false">https://bigota.d.miui.com/%1$s/%2$s</string>
<string name="cdn_link" translatable="false">http://cdnorg.d.miui.com/%1$s/%2$s</string>
<string name="cdn1_link" translatable="false">https://cdnorg.d.miui.com/%1$s/%2$s</string>
<string name="cdn2_link" translatable="false">https://cdn-ota.azureedge.net/%1$s/%2$s</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
<string name="security_error">Failed to get security key</string>
Expand Down

0 comments on commit 02670f1

Please sign in to comment.