fixed splash screen and fragments
This commit is contained in:
parent
b591394794
commit
db47736be9
|
@ -16,16 +16,20 @@ import com.vanced.manager.ui.core.ThemeActivity
|
|||
|
||||
class MainActivity : ThemeActivity() {
|
||||
|
||||
val homeFragment: HomeFragment = HomeFragment()
|
||||
val settingsFragment: SettingsFragment = SettingsFragment()
|
||||
private val homeFragment: HomeFragment = HomeFragment()
|
||||
private val settingsFragment: SettingsFragment = SettingsFragment()
|
||||
|
||||
var currentFragment: Fragment? = null
|
||||
var activeFragment: Int = R.id.navigation_home
|
||||
private var currentFragment: Fragment? = null
|
||||
private var activeFragment: Int = R.id.navigation_home
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
savedInstanceState?.let {
|
||||
activeFragment = it.getInt(CURRENT_FRAGMENT, R.id.navigation_home)
|
||||
}
|
||||
|
||||
val toolbar: MaterialToolbar = findViewById(R.id.home_toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
|
@ -35,16 +39,22 @@ class MainActivity : ThemeActivity() {
|
|||
showSecurityDialog()
|
||||
}
|
||||
|
||||
supportFragmentManager.beginTransaction().add(R.id.frame_layout, SettingsFragment()).hide(SettingsFragment()).commit()
|
||||
supportFragmentManager.beginTransaction().add(R.id.frame_layout, HomeFragment()).commit()
|
||||
|
||||
val navView: BottomNavigationView = findViewById(R.id.bottom_nav)
|
||||
|
||||
when (activeFragment) {
|
||||
R.id.navigation_home -> currentFragment = homeFragment
|
||||
R.id.navigation_settings -> currentFragment = settingsFragment
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.add(R.id.frame_layout, settingsFragment).hide(settingsFragment)
|
||||
.add(R.id.frame_layout, homeFragment).hide(homeFragment)
|
||||
.show(currentFragment!!)
|
||||
.commit()
|
||||
}
|
||||
|
||||
val navView: BottomNavigationView = findViewById(R.id.bottom_nav)
|
||||
|
||||
navView.setOnNavigationItemSelectedListener{
|
||||
setFragments(it.itemId)
|
||||
}
|
||||
|
@ -91,11 +101,10 @@ class MainActivity : ThemeActivity() {
|
|||
.beginTransaction()
|
||||
.hide(currentFragment!!)
|
||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
.show(HomeFragment())
|
||||
.show(homeFragment)
|
||||
.commit()
|
||||
|
||||
currentFragment = homeFragment
|
||||
|
||||
}
|
||||
R.id.navigation_settings -> {
|
||||
if (currentFragment is SettingsFragment) {
|
||||
|
@ -105,14 +114,17 @@ class MainActivity : ThemeActivity() {
|
|||
.beginTransaction()
|
||||
.hide(currentFragment!!)
|
||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
.show(SettingsFragment())
|
||||
.show(settingsFragment)
|
||||
.commit()
|
||||
|
||||
currentFragment = settingsFragment
|
||||
}
|
||||
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
companion object{
|
||||
const val CURRENT_FRAGMENT = "current_fragment"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@ class SplashScreenActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(R.style.SplashTheme)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 28) {
|
||||
setTaskBG()
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
startActivity(Intent(this@SplashScreenActivity, MainActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/vanced_install_appbar"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="8dp"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -9,6 +9,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
android:scrollbars="none"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:contentPadding="6dp"
|
||||
|
@ -26,10 +27,12 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.core.widget.ContentLoadingProgressBar
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:id="@+id/update_center_progressbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/update_center_text"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/update_center_text"
|
||||
android:progress="10"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
app:cardPreventCornerOverlap="true"
|
||||
app:contentPaddingLeft="8dp"
|
||||
app:contentPaddingRight="8dp"
|
||||
app:contentPaddingTop="5dp">
|
||||
app:contentPaddingTop="5dp"
|
||||
app:contentPaddingBottom="5dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -121,7 +122,6 @@
|
|||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="117dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:text="@string/uninstall"
|
||||
app:iconPadding="0dp"
|
||||
|
@ -129,8 +129,7 @@
|
|||
app:backgroundTint="?attr/colorError"
|
||||
app:icon="@drawable/ic_delete_black_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/microg_installbtn" />
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
app:cardPreventCornerOverlap="true"
|
||||
app:contentPaddingRight="8dp"
|
||||
app:contentPaddingLeft="8dp"
|
||||
app:contentPaddingTop="5dp">
|
||||
app:contentPaddingTop="5dp"
|
||||
app:contentPaddingBottom="5dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -104,16 +105,14 @@
|
|||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="117dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:text="@string/uninstall"
|
||||
app:iconPadding="0dp"
|
||||
android:textAllCaps="false"
|
||||
app:backgroundTint="?attr/colorError"
|
||||
app:icon="@drawable/ic_delete_black_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vanced_installbtn" />
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Preference
|
||||
android:key="update_check"
|
||||
|
@ -8,7 +8,8 @@
|
|||
android:icon="@drawable/ic_cloud_upload_black_24dp"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="Interface">
|
||||
android:title="Interface"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_brush_black_24dp"
|
||||
|
@ -37,7 +38,8 @@
|
|||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="Manager">
|
||||
android:title="Manager"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
<SwitchPreference
|
||||
android:title="Push Notifications"
|
||||
|
|
Loading…
Reference in New Issue