Commit ce7cb1ee authored by topjohnwu's avatar topjohnwu

Remove device section

parent d2701616
package com.topjohnwu.magisk.model.events
import android.view.ContextThemeWrapper
import android.view.MenuItem
import android.widget.PopupMenu
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.base.BaseActivity
import com.topjohnwu.superuser.Shell
import com.topjohnwu.magisk.extensions.reboot as systemReboot
object RebootEvent {
@JvmStatic
fun reboot(menuItemId: Int) = when (menuItemId) {
R.id.action_reboot_normal -> systemReboot()
R.id.action_reboot_bootloader -> systemReboot("bootloader")
R.id.action_reboot_download -> systemReboot("download")
R.id.action_reboot_edl -> systemReboot("edl")
R.id.action_reboot_recovery -> Shell.su("/system/bin/reboot recovery").submit()
else -> Unit
private fun reboot(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_reboot_normal -> systemReboot()
R.id.action_reboot_bootloader -> systemReboot("bootloader")
R.id.action_reboot_download -> systemReboot("download")
R.id.action_reboot_edl -> systemReboot("edl")
R.id.action_reboot_recovery -> Shell.su("/system/bin/reboot recovery").submit()
else -> Unit
}
return true
}
}
\ No newline at end of file
fun inflateMenu(activity: BaseActivity): PopupMenu {
val themeWrapper = ContextThemeWrapper(activity, R.style.Foundation_PopupMenu)
val menu = PopupMenu(themeWrapper, activity.findViewById(R.id.action_reboot))
activity.menuInflater.inflate(R.menu.menu_reboot, menu.menu)
menu.setOnMenuItemClickListener(::reboot)
return menu
}
}
......@@ -4,8 +4,10 @@ import android.os.Bundle
import android.view.*
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding
import com.topjohnwu.magisk.model.events.RebootEvent
import com.topjohnwu.magisk.model.navigation.Navigation
import com.topjohnwu.magisk.ui.base.BaseUIFragment
import com.topjohnwu.superuser.Shell
import org.koin.androidx.viewmodel.ext.android.viewModel
class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
......@@ -27,8 +29,6 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
super.onCreateView(inflater, container, savedInstanceState)
// Set barrier reference IDs in code, since resource IDs will be stripped in release mode
binding.homeDeviceWrapper.homeDeviceTitleBarrier.referencedIds =
intArrayOf(R.id.home_device_action, R.id.home_device_title, R.id.home_device_icon)
binding.homeMagiskWrapper.homeMagiskTitleBarrier.referencedIds =
intArrayOf(R.id.home_magisk_action, R.id.home_magisk_title, R.id.home_magisk_icon)
binding.homeManagerWrapper.homeManagerTitleBarrier.referencedIds =
......@@ -39,10 +39,13 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_home_md2, menu)
if (!Shell.rootAccess())
menu.removeItem(R.id.action_reboot)
}
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.action_settings -> Navigation.settings().dispatchOnSelf()
R.id.action_reboot -> RebootEvent.inflateMenu(activity).show()
else -> null
}?.let { true } ?: super.onOptionsItemSelected(item)
......
......@@ -5,6 +5,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000"
android:fillColor="?colorOnSurface"
android:pathData="M12,4C14.1,4 16.1,4.8 17.6,6.3C20.7,9.4 20.7,14.5 17.6,17.6C15.8,19.5 13.3,20.2 10.9,19.9L11.4,17.9C13.1,18.1 14.9,17.5 16.2,16.2C18.5,13.9 18.5,10.1 16.2,7.7C15.1,6.6 13.5,6 12,6V10.6L7,5.6L12,0.6V4M6.3,17.6C3.7,15 3.3,11 5.1,7.9L6.6,9.4C5.5,11.6 5.9,14.4 7.8,16.2C8.3,16.7 8.9,17.1 9.6,17.4L9,19.4C8,19 7.1,18.4 6.3,17.6Z" />
</vector>
\ No newline at end of file
</vector>
......@@ -67,16 +67,6 @@
</com.google.android.material.card.MaterialCardView>
<include
android:id="@+id/home_device_wrapper"
layout="@layout/include_home_device"
viewModel="@{viewModel}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l1"
app:layout_constraintTop_toTopOf="parent" />
<include
android:id="@+id/home_magisk_wrapper"
layout="@layout/include_home_magisk"
......@@ -85,7 +75,6 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l1"
android:layout_marginTop="@dimen/l1"
app:layout_constraintTop_toBottomOf="@+id/home_device_wrapper" />
<include
......
This diff is collapsed.
......@@ -197,6 +197,77 @@
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
style="@style/W.Home.Card"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
style="@style/W.Home.Section"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:id="@+id/home_device_details_ab"
style="@style/W.Home.Item.Top"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
style="@style/W.Home.ItemContent"
android:text="A/B" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.isAB ? @string/yes : @string/no}"
tools:text="Yes" />
</LinearLayout>
<LinearLayout
android:id="@+id/home_device_details_sar"
style="@style/W.Home.Item"
app:layout_constraintStart_toStartOf="@+id/home_device_details_ab"
app:layout_constraintTop_toBottomOf="@+id/home_device_details_ab">
<TextView
style="@style/W.Home.ItemContent"
android:text="SAR" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.isSAR ? @string/yes : @string/no}"
tools:text="Yes" />
</LinearLayout>
<LinearLayout
android:id="@+id/home_device_details_recovery"
style="@style/W.Home.Item.Bottom"
app:layout_constraintStart_toStartOf="@+id/home_device_details_sar"
app:layout_constraintTop_toBottomOf="@+id/home_device_details_sar">
<TextView
style="@style/W.Home.ItemContent"
android:text="Ramdisk" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.ramdisk ? @string/yes : @string/no }"
tools:text="Yes" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</HorizontalScrollView>
......
......@@ -2,6 +2,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_reboot"
android:icon="@drawable/ic_restart"
android:title="@string/reboot"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_settings_md2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment