Implemented saving welcomeactivity settings
This commit is contained in:
parent
502f173079
commit
d9b26d0c4b
3 changed files with 51 additions and 1 deletions
|
@ -1,10 +1,21 @@
|
||||||
package com.nin0dev.vendroid
|
package com.nin0dev.vendroid
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.View.GONE
|
||||||
|
import android.view.View.VISIBLE
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import android.widget.CheckBox
|
||||||
|
import android.widget.EditText
|
||||||
|
import android.widget.RadioButton
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
import com.google.android.material.materialswitch.MaterialSwitch
|
||||||
|
|
||||||
|
|
||||||
class WelcomeActivity : AppCompatActivity() {
|
class WelcomeActivity : AppCompatActivity() {
|
||||||
|
@ -17,5 +28,39 @@ class WelcomeActivity : AppCompatActivity() {
|
||||||
window.navigationBarColor = Color.TRANSPARENT
|
window.navigationBarColor = Color.TRANSPARENT
|
||||||
|
|
||||||
setContentView(R.layout.activity_welcome)
|
setContentView(R.layout.activity_welcome)
|
||||||
|
|
||||||
|
val devbuildCheckbox = findViewById<CheckBox>(R.id.allow_custom_location)
|
||||||
|
devbuildCheckbox.setOnClickListener {
|
||||||
|
if (devbuildCheckbox.isChecked) {
|
||||||
|
MaterialAlertDialogBuilder(this)
|
||||||
|
.setTitle("Warning")
|
||||||
|
.setMessage("If you set a custom location, you will be loading and injecting Vencord from a different location. This feature is meant for developers ONLY. Never edit this setting if someone else asked you to, or if you don't know what you're doing! If you do set a custom location, you will not be able to ask for support in the Vencord support channel or in this project's issues. Are you sure you want to continue?")
|
||||||
|
.setNegativeButton(resources.getString(R.string.no)) { _, _ ->
|
||||||
|
devbuildCheckbox.isChecked = false
|
||||||
|
}
|
||||||
|
.setPositiveButton(resources.getString(R.string.yes)) { _, _ ->
|
||||||
|
findViewById<EditText>(R.id.custom_location).visibility = VISIBLE
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
findViewById<EditText>(R.id.custom_location).visibility = GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
findViewById<ExtendedFloatingActionButton>(R.id.start_vendroid).setOnClickListener {
|
||||||
|
val sPrefs = getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||||
|
val editor = sPrefs.edit()
|
||||||
|
|
||||||
|
editor.putBoolean("checkVendroidUpdates", findViewById<MaterialSwitch>(R.id.check_vendroid_updates).isChecked)
|
||||||
|
if (findViewById<RadioButton>(R.id.stable).isChecked) editor.putString("discordBranch", "stable")
|
||||||
|
if (findViewById<RadioButton>(R.id.ptb).isChecked) editor.putString("discordBranch", "ptb")
|
||||||
|
if (findViewById<RadioButton>(R.id.canary).isChecked) editor.putString("discordBranch", "canary")
|
||||||
|
if (findViewById<CheckBox>(R.id.allow_custom_location).isChecked && findViewById<EditText>(R.id.custom_location).text.isNotBlank()) editor.putString("vencordLocation", findViewById<EditText>(R.id.custom_location).text.toString())
|
||||||
|
|
||||||
|
editor.apply()
|
||||||
|
startActivity(Intent(this@WelcomeActivity, MainActivity::class.java))
|
||||||
|
finishActivity(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true">
|
android:fitsSystemWindows="true">
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/updates_title"
|
android:text="@string/updates_title"
|
||||||
|
android:textColor="@color/text"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
|
|
||||||
<com.google.android.material.materialswitch.MaterialSwitch
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
|
@ -92,7 +94,8 @@
|
||||||
android:id="@+id/custom_location"
|
android:id="@+id/custom_location"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone" />
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
|
|
@ -13,4 +13,6 @@
|
||||||
<string name="vencord_location">Vencord location</string>
|
<string name="vencord_location">Vencord location</string>
|
||||||
<string name="set_custom_location">Set custom location (Only check this if you know what you\'re doing!)</string>
|
<string name="set_custom_location">Set custom location (Only check this if you know what you\'re doing!)</string>
|
||||||
<string name="custom_location_url">Custom location URL</string>
|
<string name="custom_location_url">Custom location URL</string>
|
||||||
|
<string name="no">No</string>
|
||||||
|
<string name="yes">Yes</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue