Skip to content

Commit

Permalink
fix few loose ends
Browse files Browse the repository at this point in the history
Signed-off-by: androidacy-user <opensource@androidacy.com>
  • Loading branch information
androidacy-user committed Jul 6, 2023
1 parent 2df47c1 commit 04bc523
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 26 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
<activity
android:name=".CrashHandler"
android:exported="false"
android:process=":crash"
android:theme="@style/Theme.MagiskModuleManager.NoActionBar" />
<activity
android:name=".SetupActivity"
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/kotlin/com/fox2code/mmm/UpdateActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import java.io.FileOutputStream
import java.io.IOException
import java.sql.Timestamp
import java.util.Objects
import com.google.android.material.button.MaterialButton

class UpdateActivity : FoxActivity() {
private var chgWv: WebView? = null
Expand Down Expand Up @@ -266,10 +267,6 @@ class UpdateActivity : FoxActivity() {
statusTextView.setText(R.string.no_update_available)
val changelogWebView = chgWv!!
changelogWebView.loadUrl(url.replace("updates/check", "changelog"))
// execute javascript to make #rfrsh-btn just reload the page
changelogWebView.evaluateJavascript(
"(function() { document.getElementById('rfrsh-btn').onclick = function() { location.reload(); }; })();"
) { }
}
// check for update
val shouldUpdate = AppUpdateManager.appUpdateManager.checkUpdate(true)
Expand All @@ -279,11 +276,14 @@ class UpdateActivity : FoxActivity() {
// set status text to update available
statusTextView.setText(R.string.update_available)
// set button text to download
val button = findViewById<BottomNavigationItemView>(R.id.action_update)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
button.tooltipText = getString(R.string.download_update)
}
val button = findViewById<MaterialButton>(R.id.action_update)
button.text = getString(R.string.download_update)
button.icon = getDrawable(R.drawable.baseline_cloud_download_24)
button.isEnabled = true
button.visibility = View.VISIBLE
button.setOnClickListener({
downloadUpdate()
})
}
// return
}
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/kotlin/com/fox2code/mmm/module/ModuleHolder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ class ModuleHolder : Comparable<ModuleHolder?> {
if (repoModule != null || localModuleInfo?.updateZipUrl != null && localModuleInfo.updateVersionCode > localModuleInfo.versionCode) {
buttonTypeList.add(ActionButtonType.UPDATE_INSTALL)
}
if (localModuleInfo != null && localModuleInfo.updateVersionCode <= localModuleInfo.versionCode) {
val rInfo = localModuleInfo?.remoteModuleInfo
if (localModuleInfo != null && rInfo != null && rInfo.moduleInfo.versionCode <= localModuleInfo.versionCode || localModuleInfo != null && localModuleInfo.updateVersionCode != Long.MIN_VALUE && localModuleInfo.updateVersionCode <= localModuleInfo.versionCode) {
buttonTypeList.add(ActionButtonType.REMOTE)
// set updatezipurl on moduleholder

Expand All @@ -255,10 +256,10 @@ class ModuleHolder : Comparable<ModuleHolder?> {
updateZipUrl = repoModule!!.zipUrl
}
// last ditch effort, try to get remoteModuleInfo from localModuleInfo
if (localModuleInfo.remoteModuleInfo != null) {
Timber.d("remoteModuleInfo: %s", localModuleInfo.remoteModuleInfo!!.zipUrl)
updateZipUrl = localModuleInfo.remoteModuleInfo!!.zipUrl
moduleInfo?.updateZipUrl = localModuleInfo.remoteModuleInfo!!.zipUrl
if (rInfo != null) {
Timber.d("remoteModuleInfo: %s", rInfo.zipUrl)
updateZipUrl = rInfo.zipUrl
moduleInfo?.updateZipUrl = rInfo.zipUrl
}
}
val config = mainModuleConfig
Expand Down Expand Up @@ -441,4 +442,4 @@ class ModuleHolder : Comparable<ModuleHolder?> {
}
};
}
}
}
20 changes: 17 additions & 3 deletions app/src/main/res/layout/activity_update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ImageView
android:id="@+id/update_icon"
android:layout_width="101dp"
android:layout_height="93dp"
android:layout_height="101dp"
android:layout_gravity="center"
android:layout_margin="8dp"
android:contentDescription="@string/update"
Expand Down Expand Up @@ -76,7 +76,21 @@
android:text="@string/update_debug_warning"
android:textAppearance="?attr/textAppearanceBody2"
android:visibility="gone" />

<com.google.android.material.button.MaterialButton
android:id="@+id/action_update"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" android:layout_marginEnd="4dp"
android:padding="12dp"
android:text="@string/please_wait"
android:textSize="16sp"
app:icon="@drawable/ic_baseline_warning_24"
app:iconGravity="textStart"
app:iconPadding="8dp"
app:iconTintMode="src_in"
android:visibility="invisible"
app:rippleColor="@color/gray_800"
android:layout_width="match_parent"
tools:ignore="DuplicateSpeakableTextCheck" />

<!-- Changelog view -->
<LinearLayout
Expand Down Expand Up @@ -106,4 +120,4 @@
app:layout_constraintTop_toBottomOf="@id/update_container"
app:menu="@menu/update_nav" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
9 changes: 1 addition & 8 deletions app/src/main/res/menu/update_nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,4 @@
android:visible="true"
app:showAsAction="ifRoom" />

<item
android:id="@+id/action_update"
android:enabled="false"
android:icon="@drawable/ic_baseline_refresh_24"
android:title="@string/update_button"
android:visible="true"
app:showAsAction="ifRoom" />
</menu>
</menu>

0 comments on commit 04bc523

Please sign in to comment.