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

Commit

Permalink
Updater: Add a new available CDN download address
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Jan 13, 2024
1 parent b290037 commit cd68e53
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class MainViewModel : ViewModel() {
var bigversion: String? = null
var officialDownload: String? = null
var officialText: String? = null
var cdnDownload: String? = null
var changelog: String? = null
}
12 changes: 9 additions & 3 deletions app/src/main/kotlin/top/yukonga/update/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ class MainActivity : AppCompatActivity() {
officialDownload = if (recoveryRomInfo.currentRom.md5 == recoveryRomInfo.latestRom?.md5) getString(
R.string.official1_link, recoveryRomInfo.currentRom.version, recoveryRomInfo.latestRom.filename
) else getString(R.string.official2_link, recoveryRomInfo.currentRom.version, recoveryRomInfo.currentRom.filename)
officialText = if (recoveryRomInfo.currentRom.md5 == recoveryRomInfo.latestRom?.md5) getString(R.string.official, "ultimateota")
else getString(R.string.official, "bigota")
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)
changelog = log.toString().trimEnd()
}
} else {
Expand Down Expand Up @@ -454,9 +458,11 @@ class MainActivity : AppCompatActivity() {
filesizeInfo.setTextAnimation(mainViewModel.filesize)
changelogInfo.setTextAnimation(mainViewModel.changelog)
changelogInfo.setCopyClickListener(mainViewModel.changelog)
officialDownload.setDownloadClickListener(mainViewModel.filename, mainViewModel.officialDownload!!)
official.text = mainViewModel.officialText
officialDownload.setDownloadClickListener(mainViewModel.filename, mainViewModel.officialDownload!!)
officialCopy.setCopyClickListener(mainViewModel.officialDownload)
cdnDownload.setDownloadClickListener(mainViewModel.filename, mainViewModel.cdnDownload!!)
cdnCopy.setCopyClickListener(mainViewModel.cdnDownload)
} else {
secondViewArray.forEach {
if (it.isVisible) it.fadOutAnimation()
Expand Down
49 changes: 49 additions & 0 deletions app/src/main/res/layout-land/main_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,55 @@

</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/cdn"
android:elegantTextHeight="true"
android:text="@string/cdn"
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/cdn_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/cdn_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>

</com.google.android.material.card.MaterialCardView>
Expand Down
46 changes: 46 additions & 0 deletions app/src/main/res/layout/main_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,52 @@

</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/cdn"
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/cdn_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/cdn_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>

</com.google.android.material.card.MaterialCardView>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
<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="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="copy_button">Copy</string>
<string name="download_button">Download</string>
<string name="unknown_error">Failed to get security key</string>
Expand Down

0 comments on commit cd68e53

Please sign in to comment.