ui updates
This commit is contained in:
parent
671f192f5b
commit
934224d8e8
|
@ -10,10 +10,10 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.databinding.ViewPreferenceBinding
|
||||
|
||||
class EmptyPreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyle, defStyleRes) {
|
||||
|
||||
private var _binding: ViewPreferenceBinding? = null
|
||||
|
|
|
@ -8,9 +8,9 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.databinding.ViewPreferenceCategoryBinding
|
||||
|
||||
class PreferenceCategory @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
) : LinearLayout(context, attrs, defStyle) {
|
||||
|
||||
private var _binding: ViewPreferenceCategoryBinding? = null
|
||||
|
|
|
@ -11,10 +11,10 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.databinding.ViewPreferenceSwitchBinding
|
||||
|
||||
class PreferenceSwitch @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyle, defStyleRes) {
|
||||
|
||||
interface OnCheckedListener {
|
||||
|
@ -43,8 +43,9 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
val title = getText(R.styleable.PreferenceSwitch_switch_title)
|
||||
val summary = getText(R.styleable.PreferenceSwitch_switch_summary)
|
||||
val key = getText(R.styleable.PreferenceSwitch_switch_key)
|
||||
setDefaultValue(getBoolean(R.styleable.PreferenceSwitch_switch_def_value, false))
|
||||
val defValue = getBoolean(R.styleable.PreferenceSwitch_switch_def_value, false)
|
||||
setKey(key)
|
||||
setDefaultValue(defValue)
|
||||
setTitle(title)
|
||||
setSummary(summary)
|
||||
recycle()
|
||||
|
@ -64,7 +65,7 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
fun setOnCheckedListener(method: (buttonView: CompoundButton, isChecked: Boolean) -> Unit) {
|
||||
mListener = object : OnCheckedListener{
|
||||
mListener = object : OnCheckedListener {
|
||||
override fun onChecked(buttonView: CompoundButton, isChecked: Boolean) {
|
||||
method(buttonView, isChecked)
|
||||
}
|
||||
|
@ -85,11 +86,11 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
|
||||
fun setKey(key: CharSequence?) {
|
||||
prefKey = key.toString()
|
||||
binding.preferenceSwitch.isChecked = prefs.getBoolean(prefKey, defValue)
|
||||
binding.preferenceSwitch.isChecked = prefs.getBoolean(key.toString(), defValue)
|
||||
}
|
||||
|
||||
fun setDefaultValue(newVal: Boolean) {
|
||||
defValue = newVal
|
||||
binding.preferenceSwitch.isChecked = prefs.getBoolean(prefKey, defValue)
|
||||
binding.preferenceSwitch.isChecked = prefs.getBoolean(prefKey, newVal)
|
||||
}
|
||||
}
|
|
@ -4,98 +4,112 @@ import android.content.Intent
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.net.toUri
|
||||
import androidx.preference.*
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.crowdin.platform.Crowdin
|
||||
import com.vanced.manager.BuildConfig.ENABLE_CROWDIN_AUTH
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.BuildConfig
|
||||
import com.vanced.manager.core.ui.base.BindingFragment
|
||||
import com.vanced.manager.databinding.FragmentDevSettingsBinding
|
||||
import com.vanced.manager.ui.WelcomeActivity
|
||||
import com.vanced.manager.ui.dialogs.ManagerUpdateDialog
|
||||
import com.vanced.manager.ui.dialogs.URLChangeDialog
|
||||
import com.vanced.manager.utils.LanguageHelper.authCrowdin
|
||||
|
||||
class DevSettingsFragment: PreferenceFragmentCompat() {
|
||||
class DevSettingsFragment : BindingFragment<FragmentDevSettingsBinding>() {
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.dev_settings, rootKey)
|
||||
private val prefs by lazy { getDefaultSharedPreferences(requireActivity()) }
|
||||
|
||||
val ftSwitch: Preference? = findPreference("firstlaunch_switch")
|
||||
override fun binding(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
) = FragmentDevSettingsBinding.inflate(inflater, container, false)
|
||||
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
ftSwitch?.setOnPreferenceClickListener {
|
||||
override fun otherSetups() {
|
||||
setHasOptionsMenu(true)
|
||||
bindData()
|
||||
}
|
||||
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setTitle("FirstLaunch activated")
|
||||
.setMessage("boolean will be activated on next app start")
|
||||
.setPositiveButton("Restart") { _, _ ->
|
||||
run {
|
||||
startActivity(Intent(requireContext(), WelcomeActivity::class.java))
|
||||
activity?.finish()
|
||||
}
|
||||
}
|
||||
.create()
|
||||
.show()
|
||||
private fun bindData() {
|
||||
with(binding) {
|
||||
bindWelcomeLauncher()
|
||||
bindForceUpdate()
|
||||
bindChannelURL()
|
||||
bindCrowdin()
|
||||
bindKernelArch()
|
||||
bindAndroidVersion()
|
||||
}
|
||||
}
|
||||
|
||||
private fun FragmentDevSettingsBinding.bindWelcomeLauncher() {
|
||||
welcomeScreenLauncher.setOnClickListener {
|
||||
prefs.edit {
|
||||
putBoolean("firstLaunch", true)
|
||||
putBoolean("show_changelog_tooltip", true)
|
||||
}
|
||||
true
|
||||
|
||||
startActivity(Intent(requireContext(), WelcomeActivity::class.java))
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
|
||||
if (ENABLE_CROWDIN_AUTH) {
|
||||
findPreference<PreferenceCategory>("crowdin_pref_category")?.isVisible = true
|
||||
private fun FragmentDevSettingsBinding.bindForceUpdate() {
|
||||
forceManagerUpdate.setOnClickListener {
|
||||
ManagerUpdateDialog.newInstance(true).show(
|
||||
requireActivity().supportFragmentManager,
|
||||
"update_manager"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<Preference>("crowdin_auth")?.isVisible = !Crowdin.isAuthorized()
|
||||
findPreference<SwitchPreferenceCompat>("crowdin_upload_screenshot")?.isVisible = Crowdin.isAuthorized()
|
||||
findPreference<SwitchPreferenceCompat>("crowdin_real_time")?.isVisible = Crowdin.isAuthorized()
|
||||
private fun FragmentDevSettingsBinding.bindChannelURL() {
|
||||
channelUrl.setOnClickListener {
|
||||
URLChangeDialog().show(childFragmentManager.beginTransaction(), null)
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<Preference>("crowdin_auth")?.setOnPreferenceClickListener {
|
||||
private fun FragmentDevSettingsBinding.bindCrowdin() {
|
||||
if (BuildConfig.ENABLE_CROWDIN_AUTH) {
|
||||
val isAuthorized = Crowdin.isAuthorized()
|
||||
crowdinCategory.isVisible = true
|
||||
|
||||
crowdinAuth.isVisible = !isAuthorized
|
||||
screenshotUploading.isVisible = isAuthorized
|
||||
realTimeUpdates.isVisible = isAuthorized
|
||||
|
||||
crowdinAuth.setOnClickListener {
|
||||
requireActivity().authCrowdin()
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
if (!Settings.canDrawOverlays(requireActivity())) {
|
||||
val intent = Intent(
|
||||
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
("package:" + requireActivity().packageName).toUri()
|
||||
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
("package:" + requireActivity().packageName).toUri()
|
||||
)
|
||||
startActivityForResult(intent, 69)
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
|
||||
Crowdin.authorize(requireActivity())
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<Preference>("install_url")?.setOnPreferenceClickListener {
|
||||
URLChangeDialog().show(childFragmentManager.beginTransaction(), "Install URL")
|
||||
true
|
||||
}
|
||||
|
||||
private fun FragmentDevSettingsBinding.bindKernelArch() {
|
||||
val supportedAbis: Array<String> = Build.SUPPORTED_ABIS
|
||||
|
||||
findPreference<Preference>("device_arch")?.summary =
|
||||
kernelArch.setSummary(
|
||||
if (supportedAbis.contains("arm64-v8a") || supportedAbis.contains("x86_64")) {
|
||||
"64bit"
|
||||
} else {
|
||||
"32bit"
|
||||
}
|
||||
|
||||
findPreference<Preference>("device_os")?.summary = "${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})"
|
||||
|
||||
val forceUpdate: Preference? = findPreference("force_update")
|
||||
forceUpdate?.setOnPreferenceClickListener {
|
||||
ManagerUpdateDialog.newInstance(true).show(
|
||||
requireActivity().supportFragmentManager,
|
||||
"update_manager"
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
private fun FragmentDevSettingsBinding.bindAndroidVersion() {
|
||||
androidVersion.setSummary("${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})")
|
||||
}
|
||||
}
|
|
@ -3,10 +3,10 @@
|
|||
android:shape="rectangle">
|
||||
|
||||
<corners
|
||||
android:topRightRadius="8dp"
|
||||
android:topLeftRadius="8dp"
|
||||
android:bottomRightRadius="8dp"
|
||||
android:bottomLeftRadius="8dp" />
|
||||
android:topRightRadius="12dp"
|
||||
android:topLeftRadius="12dp"
|
||||
android:bottomRightRadius="12dp"
|
||||
android:bottomLeftRadius="12dp" />
|
||||
|
||||
<solid
|
||||
android:color="?colorLinkBG" />
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/serviced_header"
|
||||
tools:text="@string/script_sleep_timer"
|
||||
android:text="@string/script_sleep_timer"
|
||||
style="@style/DialogCardTitle" />
|
||||
|
||||
<com.vanced.manager.ui.core.ThemedMaterialSlider
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="8dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<com.vanced.manager.ui.core.PreferenceCategory
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/category_background"
|
||||
app:category_title="General">
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/welcome_screen_launcher"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="Welcome screen launcher"
|
||||
app:preference_summary="Title says it all" />
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/force_manager_update"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="Force Manager Update"
|
||||
app:preference_summary="Update manager without comparing versionCode"/>
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/channel_url"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="@string/update_url" />
|
||||
|
||||
</com.vanced.manager.ui.core.PreferenceCategory>
|
||||
|
||||
<com.vanced.manager.ui.core.PreferenceCategory
|
||||
android:id="@+id/crowdin_category"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/category_background"
|
||||
app:category_title="Crowdin"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/crowdin_auth"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="Authorize" />
|
||||
|
||||
<com.vanced.manager.ui.core.PreferenceSwitch
|
||||
android:id="@+id/screenshot_uploading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="Screenshot Uploading (ADMIN ONLY)"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.vanced.manager.ui.core.PreferenceSwitch
|
||||
android:id="@+id/real_time_updates"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="Real-time Updates"
|
||||
android:visibility="gone" />
|
||||
|
||||
</com.vanced.manager.ui.core.PreferenceCategory>
|
||||
|
||||
<com.vanced.manager.ui.core.PreferenceCategory
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/category_background"
|
||||
app:category_title="Device Info">
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/kernel_arch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="Kernel Architecture"/>
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/android_version"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="Android Version"/>
|
||||
|
||||
</com.vanced.manager.ui.core.PreferenceCategory>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
|
@ -22,15 +22,14 @@
|
|||
android:id="@+id/recycler_app_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/view_app" />
|
||||
|
||||
<com.vanced.manager.ui.core.ThemedTextView
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:text="@string/support_us"
|
||||
style="@style/CardTextHeader" />
|
||||
|
||||
|
@ -38,15 +37,13 @@
|
|||
android:id="@+id/recycler_sponsors"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
tools:itemCount="2"
|
||||
tools:listitem="@layout/view_sponsor" />
|
||||
|
||||
<com.vanced.manager.ui.core.ThemedTextView
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:text="@string/social_media"
|
||||
style="@style/CardTextHeader" />
|
||||
|
||||
|
@ -59,6 +56,7 @@
|
|||
android:paddingBottom="8dp"
|
||||
tools:itemCount="6"
|
||||
tools:listitem="@layout/view_social_link" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
app:cardBackgroundColor="?colorLinkBG"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="0dp"
|
||||
app:contentPaddingBottom="4dp"
|
||||
app:contentPaddingLeft="16dp"
|
||||
app:contentPaddingRight="16dp"
|
||||
app:contentPaddingLeft="12dp"
|
||||
app:contentPaddingRight="12dp"
|
||||
app:contentPaddingTop="8dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
@ -31,7 +31,6 @@
|
|||
<com.vanced.manager.ui.core.ThemedOutlinedMaterialButton
|
||||
android:id="@+id/app_install_button"
|
||||
style="@style/OutlinedButtonStyle"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textColor="?colorPrimary"
|
||||
app:layout_constraintBottom_toTopOf="@id/app_uninstall"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
android:layout_width="165dp"
|
||||
android:layout_height="97dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
app:cardBackgroundColor="?colorLinkBG"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="0dp">
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<string name="theme">Theme</string>
|
||||
<string name="theme_dark">Dark Theme</string>
|
||||
<string name="theme_light">Light Theme</string>
|
||||
<string name="update_url">Update Channel URL</string>
|
||||
<string name="update_url">Channel URL</string>
|
||||
<string name="push_notifications">%1$s Push Notifications</string>
|
||||
<string name="push_notifications_summary">Receive push notifications when an update for %1$s is released</string>
|
||||
<string name="update_center">Manager Update Center</string>
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Preference
|
||||
android:key="firstlaunch_switch"
|
||||
android:title="First start switcher"
|
||||
android:summary="No reason to touch this, seriously"/>
|
||||
|
||||
<Preference
|
||||
android:key="force_update"
|
||||
android:title="Force Manager Update"
|
||||
android:summary="Update manager without comparing versionCode"/>
|
||||
|
||||
<Preference
|
||||
android:title="@string/update_url"
|
||||
android:key="install_url" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="Crowdin"
|
||||
android:key="crowdin_pref_category"
|
||||
app:isPreferenceVisible="false">
|
||||
|
||||
<Preference
|
||||
android:title="Authorize"
|
||||
android:key="crowdin_auth" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:title="Screenshot Uploading (ADMIN ONLY)"
|
||||
android:key="crowdin_upload_screenshot"
|
||||
app:isPreferenceVisible="false"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:title="Real-time updates"
|
||||
android:key="crowdin_real_time"
|
||||
app:isPreferenceVisible="false"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="Device info">
|
||||
|
||||
<Preference
|
||||
android:key="device_arch"
|
||||
android:title="Kernel Architecture" />
|
||||
|
||||
<Preference
|
||||
android:key="device_os"
|
||||
android:title="Android Version" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue