forked from pascua28/Shizuku
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pascua28:master' into master
- Loading branch information
Showing
6 changed files
with
257 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
manager/src/main/java/moe/shizuku/manager/home/StartSystemViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package moe.shizuku.manager.home | ||
|
||
import android.content.Intent | ||
import android.text.method.LinkMovementMethod | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.appcompat.app.AlertDialog | ||
import moe.shizuku.manager.R | ||
import moe.shizuku.manager.databinding.HomeItemContainerBinding | ||
import moe.shizuku.manager.databinding.HomeStartSystemBinding | ||
import moe.shizuku.manager.ktx.toHtml | ||
import moe.shizuku.manager.starter.StarterActivity | ||
import rikka.html.text.HtmlCompat | ||
import rikka.recyclerview.BaseViewHolder | ||
import rikka.recyclerview.BaseViewHolder.Creator | ||
|
||
class StartSystemViewHolder(private val binding: HomeStartSystemBinding, system: View) : | ||
BaseViewHolder<Boolean>(system) { | ||
|
||
companion object { | ||
val CREATOR = Creator<Boolean> { inflater: LayoutInflater, parent: ViewGroup? -> | ||
val outer = HomeItemContainerBinding.inflate(inflater, parent, false) | ||
val inner = HomeStartSystemBinding.inflate(inflater, outer.root, true) | ||
StartSystemViewHolder(inner, outer.root) | ||
} | ||
} | ||
|
||
private inline val start get() = binding.button1 | ||
|
||
private var alertDialog: AlertDialog? = null | ||
|
||
init { | ||
val listener = View.OnClickListener { v: View -> onStartClicked(v) } | ||
start.setOnClickListener(listener) | ||
binding.text1.movementMethod = LinkMovementMethod.getInstance() | ||
} | ||
|
||
private fun onStartClicked(v: View) { | ||
val context = v.context | ||
val intent = Intent(context, StarterActivity::class.java).apply { | ||
putExtra(StarterActivity.EXTRA_IS_ROOT, false) | ||
putExtra(StarterActivity.EXTRA_IS_SYSTEM, true) | ||
} | ||
context.startActivity(intent) | ||
} | ||
|
||
override fun onBind() { | ||
start.isEnabled = true | ||
if (data!!) { | ||
start.visibility = View.GONE | ||
} else { | ||
start.visibility = View.VISIBLE | ||
} | ||
|
||
val sb = StringBuilder() | ||
.append( | ||
context.getString( | ||
R.string.home_system_description | ||
) | ||
) | ||
|
||
binding.text1.text = sb.toHtml(HtmlCompat.FROM_HTML_OPTION_TRIM_WHITESPACE) | ||
} | ||
|
||
override fun onRecycle() { | ||
super.onRecycle() | ||
alertDialog = null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
style="?homeCardStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center_vertical" | ||
android:orientation="horizontal"> | ||
|
||
<ImageView | ||
android:id="@android:id/icon" | ||
style="@style/CardIcon" | ||
android:duplicateParentState="true" | ||
android:importantForAccessibility="no" | ||
android:src="@drawable/ic_root_24dp" /> | ||
|
||
<TextView | ||
android:id="@android:id/title" | ||
style="@style/CardTitle" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="@dimen/home_icon_padding" | ||
android:layout_weight="1" | ||
android:text="@string/home_system_title" /> | ||
|
||
</LinearLayout> | ||
|
||
<TextView | ||
android:id="@android:id/text1" | ||
style="@style/CardContent" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="24dp" | ||
android:layout_marginBottom="24dp" | ||
tools:text="@string/home_system_description" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@android:id/button1" | ||
style="@style/CardButton" | ||
android:enabled="false" | ||
android:text="@string/home_root_button_start" | ||
app:icon="@drawable/ic_server_start_24dp" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@android:id/button2" | ||
style="@style/CardButton" | ||
android:enabled="false" | ||
android:text="@string/home_root_button_restart" | ||
android:visibility="gone" | ||
app:icon="@drawable/ic_server_restart" | ||
tools:visibility="visible" /> | ||
|
||
</LinearLayout> |
Oops, something went wrong.