Commit ce7cb1ee authored by topjohnwu's avatar topjohnwu

Remove device section

parent d2701616
package com.topjohnwu.magisk.model.events 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.R
import com.topjohnwu.magisk.core.base.BaseActivity
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import com.topjohnwu.magisk.extensions.reboot as systemReboot import com.topjohnwu.magisk.extensions.reboot as systemReboot
object RebootEvent { object RebootEvent {
@JvmStatic private fun reboot(item: MenuItem): Boolean {
fun reboot(menuItemId: Int) = when (menuItemId) { when (item.itemId) {
R.id.action_reboot_normal -> systemReboot() R.id.action_reboot_normal -> systemReboot()
R.id.action_reboot_bootloader -> systemReboot("bootloader") R.id.action_reboot_bootloader -> systemReboot("bootloader")
R.id.action_reboot_download -> systemReboot("download") R.id.action_reboot_download -> systemReboot("download")
R.id.action_reboot_edl -> systemReboot("edl") R.id.action_reboot_edl -> systemReboot("edl")
R.id.action_reboot_recovery -> Shell.su("/system/bin/reboot recovery").submit() R.id.action_reboot_recovery -> Shell.su("/system/bin/reboot recovery").submit()
else -> Unit else -> Unit
}
return true
} }
} fun inflateMenu(activity: BaseActivity): PopupMenu {
\ No newline at end of file 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 ...@@ -4,8 +4,10 @@ import android.os.Bundle
import android.view.* import android.view.*
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding
import com.topjohnwu.magisk.model.events.RebootEvent
import com.topjohnwu.magisk.model.navigation.Navigation import com.topjohnwu.magisk.model.navigation.Navigation
import com.topjohnwu.magisk.ui.base.BaseUIFragment import com.topjohnwu.magisk.ui.base.BaseUIFragment
import com.topjohnwu.superuser.Shell
import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.androidx.viewmodel.ext.android.viewModel
class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() { class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
...@@ -27,8 +29,6 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() { ...@@ -27,8 +29,6 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
super.onCreateView(inflater, container, savedInstanceState) super.onCreateView(inflater, container, savedInstanceState)
// Set barrier reference IDs in code, since resource IDs will be stripped in release mode // 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 = binding.homeMagiskWrapper.homeMagiskTitleBarrier.referencedIds =
intArrayOf(R.id.home_magisk_action, R.id.home_magisk_title, R.id.home_magisk_icon) intArrayOf(R.id.home_magisk_action, R.id.home_magisk_title, R.id.home_magisk_icon)
binding.homeManagerWrapper.homeManagerTitleBarrier.referencedIds = binding.homeManagerWrapper.homeManagerTitleBarrier.referencedIds =
...@@ -39,10 +39,13 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() { ...@@ -39,10 +39,13 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_home_md2, menu) 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) { override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.action_settings -> Navigation.settings().dispatchOnSelf() R.id.action_settings -> Navigation.settings().dispatchOnSelf()
R.id.action_reboot -> RebootEvent.inflateMenu(activity).show()
else -> null else -> null
}?.let { true } ?: super.onOptionsItemSelected(item) }?.let { true } ?: super.onOptionsItemSelected(item)
......
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <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" /> 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> </vector>
\ No newline at end of file
...@@ -67,16 +67,6 @@ ...@@ -67,16 +67,6 @@
</com.google.android.material.card.MaterialCardView> </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 <include
android:id="@+id/home_magisk_wrapper" android:id="@+id/home_magisk_wrapper"
layout="@layout/include_home_magisk" layout="@layout/include_home_magisk"
...@@ -85,7 +75,6 @@ ...@@ -85,7 +75,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1" android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l1" android:layout_marginEnd="@dimen/l1"
android:layout_marginTop="@dimen/l1"
app:layout_constraintTop_toBottomOf="@+id/home_device_wrapper" /> app:layout_constraintTop_toBottomOf="@+id/home_device_wrapper" />
<include <include
......
This diff is collapsed.
...@@ -197,6 +197,77 @@ ...@@ -197,6 +197,77 @@
</com.google.android.material.card.MaterialCardView> </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> </LinearLayout>
</HorizontalScrollView> </HorizontalScrollView>
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> 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 <item
android:id="@+id/action_settings" android:id="@+id/action_settings"
android:icon="@drawable/ic_settings_md2" 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