mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-25 12:45:12 +00:00
changed AlertDialog to materialAlertDialog and separated MainActivity core and UI
This commit is contained in:
parent
d5b07f9639
commit
d389009ad1
6 changed files with 50 additions and 29 deletions
37
app/src/main/java/com/vanced/manager/core/Main.kt
Normal file
37
app/src/main/java/com/vanced/manager/core/Main.kt
Normal file
|
@ -0,0 +1,37 @@
|
|||
package com.vanced.manager.core
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.core.ThemeActivity
|
||||
|
||||
@SuppressLint("Registered")
|
||||
open class Main: ThemeActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val prefs = getSharedPreferences("prefs", MODE_PRIVATE)
|
||||
val firstStart = prefs.getBoolean("firstStart", true)
|
||||
if (firstStart) {
|
||||
showSecurityDialog()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSecurityDialog() {
|
||||
MaterialAlertDialogBuilder(this, R.style.DialogTheme)
|
||||
.setTitle("Welcome!")
|
||||
.setMessage("Please make sure you downloaded " +
|
||||
"app from vanced.app, Vanced Discord server or GitHub")
|
||||
.setPositiveButton(
|
||||
"Close"
|
||||
) { dialog, _ -> dialog.dismiss() }
|
||||
.show()
|
||||
|
||||
val prefs = getSharedPreferences("prefs", MODE_PRIVATE)
|
||||
val editor = prefs.edit()
|
||||
editor.putBoolean("firstStart", false)
|
||||
editor.apply()
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import android.view.MenuItem
|
|||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
|
@ -13,9 +12,9 @@ import androidx.navigation.ui.setupWithNavController
|
|||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.core.ThemeActivity
|
||||
import com.vanced.manager.core.Main
|
||||
|
||||
class MainActivity : ThemeActivity() {
|
||||
class MainActivity : Main() {
|
||||
|
||||
private var isParent = true
|
||||
|
||||
|
@ -26,12 +25,6 @@ class MainActivity : ThemeActivity() {
|
|||
val toolbar: MaterialToolbar = findViewById(R.id.home_toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
val prefs = getSharedPreferences("prefs", MODE_PRIVATE)
|
||||
val firstStart = prefs.getBoolean("firstStart", true)
|
||||
if (firstStart) {
|
||||
showSecurityDialog()
|
||||
}
|
||||
|
||||
val navHost = findNavController(R.id.bottom_nav_host)
|
||||
val navBar = findViewById<BottomNavigationView>(R.id.bottom_nav)
|
||||
val appBarConfiguration = AppBarConfiguration(navHost.graph)
|
||||
|
@ -114,23 +107,4 @@ class MainActivity : ThemeActivity() {
|
|||
else -> toolbar.navigationIcon = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSecurityDialog() {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("Welcome!")
|
||||
.setMessage(
|
||||
"Before we implement a proper security system to check whether the app was modified or not," +
|
||||
" please make sure that you downloaded it from vanced.app/github"
|
||||
)
|
||||
.setPositiveButton(
|
||||
"Close"
|
||||
) { dialog, _ -> dialog.dismiss() }
|
||||
.create().show()
|
||||
|
||||
val prefs = getSharedPreferences("prefs", MODE_PRIVATE)
|
||||
val editor = prefs.edit()
|
||||
editor.putBoolean("firstStart", false)
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="Manager Devs"
|
||||
android:textSize="24sp"
|
||||
android:textColor="?attr/colorOnSurfaceVariant"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:layout_marginTop="4dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/about_license_button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:icon="@drawable/github"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp"/>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="Vanced Team"
|
||||
android:textSize="24sp"
|
||||
android:textColor="?attr/colorOnSurfaceVariant"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:layout_marginTop="4dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
@ -56,7 +57,7 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="- Laura Almeida (waman)"
|
||||
android:text="- Laura Almeida"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -19,4 +19,11 @@
|
|||
<item name="android:statusBarColor">#000000</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogTheme" parent="@style/Theme.MaterialComponents.Dialog.Alert">
|
||||
<item name="cornerFamily">rounded</item>
|
||||
<item name="cornerRadius">8dp</item>
|
||||
<item name="android:textColor">?colorOnSurfaceVariant</item>
|
||||
<item name="android:textColorPrimary">?colorOnSurfaceVariant</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue