Added handling for state with no connection

This commit is contained in:
Viktor De Pasquale 2019-10-06 12:06:09 +02:00
parent d35d1b8860
commit 5e01f785ae
4 changed files with 39 additions and 15 deletions

View File

@ -54,6 +54,7 @@ class HomeViewModel(
}
override fun refresh() = repoMagisk.fetchUpdate()
.onErrorReturn { Info.remote }
.subscribeK { updateBy(it) }
private fun updateBy(info: UpdateInfo) {
@ -64,7 +65,7 @@ class HomeViewModel(
}
stateManager.value = when {
!info.app.isUpdateChannelCorrect -> MagiskState.NOT_INSTALLED
!info.app.isUpdateChannelCorrect && isConnected.value -> MagiskState.NOT_INSTALLED
info.app.isObsolete -> MagiskState.OBSOLETE
else -> MagiskState.UP_TO_DATE
}

View File

@ -61,18 +61,38 @@
app:hideOnScroll="true"
tools:paddingBottom="48dp">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/main_navigation"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:elevation="0dp"
app:itemIconTint="@color/color_menu_tint"
app:itemTextAppearanceActive="@style/AppearanceFoundation.Tiny.Bold"
app:itemTextAppearanceInactive="@style/AppearanceFoundation.Tiny.Bold"
app:itemTextColor="@color/color_menu_tint"
app:labelVisibilityMode="unlabeled"
app:menu="@menu/menu_bottom_nav" />
android:animateLayoutChanges="true"
android:orientation="vertical">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/main_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:elevation="0dp"
app:itemIconTint="@color/color_menu_tint"
app:itemTextAppearanceActive="@style/AppearanceFoundation.Tiny.Bold"
app:itemTextAppearanceInactive="@style/AppearanceFoundation.Tiny.Bold"
app:itemTextColor="@color/color_menu_tint"
app:labelVisibilityMode="unlabeled"
app:menu="@menu/menu_bottom_nav" />
<androidx.appcompat.widget.AppCompatTextView
gone="@{viewModel.isConnected}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="@dimen/l_50"
android:text="@string/no_connection"
android:textAppearance="?appearanceTextCaptionNormal"
android:textColor="?colorError"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>

View File

@ -79,7 +79,7 @@
app:layout_constraintTop_toBottomOf="@+id/home_magisk_title" />
<FrameLayout
gone="@{viewModel.stateMagisk == MagiskState.LOADING}"
gone="@{viewModel.stateMagisk == MagiskState.LOADING || !viewModel.isConnected}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
@ -154,11 +154,12 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
android:gravity="center"
android:text="@string/manager"
android:text="@{viewModel.stateHideManagerName}"
android:textAppearance="?appearanceTextTitleNormal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_manager_icon" />
app:layout_constraintTop_toBottomOf="@+id/home_manager_icon"
tools:text="@string/manager" />
<TextSwitcher
android:id="@+id/home_manager_status"
@ -170,7 +171,7 @@
app:layout_constraintTop_toBottomOf="@+id/home_manager_title" />
<FrameLayout
gone="@{viewModel.stateManager == MagiskState.LOADING}"
gone="@{viewModel.stateManager == MagiskState.LOADING || !viewModel.isConnected}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"

View File

@ -4,6 +4,8 @@
<string name="manager">Manager</string>
<string name="magisk">Magisk</string>
<string name="no_connection">No connection available</string>
<string name="section_home">Home</string>
<string name="section_modules">@string/modules</string>
<string name="section_superuser">@string/superuser</string>