0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-26 21:13:01 +00:00

code optimisations

This commit is contained in:
X1nto 2020-04-15 17:35:15 +04:00
parent 4c3edbd67b
commit d8bae1dfff
12 changed files with 182 additions and 149 deletions

View file

@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vanced.manager"> package="com.vanced.manager">
<uses-permission android:name="android.permission.DELETE_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<application <application
android:allowBackup="true" android:allowBackup="true"

View file

@ -5,13 +5,11 @@ import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.navigation.findNavController import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.appbar.MaterialToolbar
import com.vanced.manager.ui.fragments.HomeFragment import com.google.android.material.bottomnavigation.BottomNavigationView
import com.vanced.manager.R import com.vanced.manager.R
import com.vanced.manager.ui.fragments.SettingsFragment
import com.vanced.manager.ui.core.ThemeActivity import com.vanced.manager.ui.core.ThemeActivity
class MainActivity : ThemeActivity() { class MainActivity : ThemeActivity() {
@ -37,11 +35,11 @@ class MainActivity : ThemeActivity() {
when (item.itemId) { when (item.itemId) {
R.id.navigation_home -> { R.id.navigation_home -> {
navHost.navigate(R.id.toHomeFragment) navHost.navigate(R.id.toHomeFragment)
navBar.menu.getItem(R.id.navigation_home).isChecked = true return@setOnNavigationItemSelectedListener true
} }
R.id.navigation_settings -> { R.id.navigation_settings -> {
navHost.navigate(R.id.toSettingsFragment) navHost.navigate(R.id.toSettingsFragment)
navBar.menu.getItem(R.id.navigation_settings).isChecked = true return@setOnNavigationItemSelectedListener true
} }
} }
false false

View file

@ -1,34 +1,16 @@
package com.vanced.manager.ui.core package com.vanced.manager.ui.core
import android.app.ActivityManager
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import com.vanced.manager.R
import com.vanced.manager.ui.MainActivity import com.vanced.manager.ui.MainActivity
class SplashScreenActivity : AppCompatActivity() { class SplashScreenActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.SplashTheme)
if (android.os.Build.VERSION.SDK_INT < 28) {
setTaskBG()
}
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
startActivity(Intent(this@SplashScreenActivity, MainActivity::class.java)) startActivity(Intent(this@SplashScreenActivity, MainActivity::class.java))
finish() finish()
} }
private fun setTaskBG() {
val icon = BitmapFactory.decodeResource(resources, R.drawable.splash192)
val label = getString(R.string.app_name)
val color = ResourcesCompat.getColor(resources, R.color.Black, null)
val taskDec: ActivityManager.TaskDescription = ActivityManager.TaskDescription(label, icon, color)
setTaskDescription(taskDec)
}
} }

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Exo"></font-family>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Exo 2"></font-family>

View file

@ -1,38 +1,26 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".ui.fragments.AboutFragment">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true" android:fillViewport="true"
android:scrollbars="none" android:scrollbars="none">
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginTop="@dimen/twelvedp" android:layout_marginTop="@dimen/twelvedp"
android:layout_marginEnd="16dp"
android:background="?colorSurface" android:background="?colorSurface"
android:clipToPadding="false" android:clipToPadding="false"
android:orientation="vertical" android:orientation="vertical">
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
<include <include
android:id="@+id/about_header_wrapper" android:id="@+id/about_header_wrapper"
layout="@layout/include_about_header" layout="@layout/include_about_header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
/>
<include <include
android:id="@+id/about_vanced_devs_wrapper" android:id="@+id/about_vanced_devs_wrapper"
@ -50,13 +38,12 @@
<include <include
android:id="@+id/about_github_container_wrapper" android:id="@+id/about_github_container_wrapper"
layout="@layout/include_about_github" layout="@layout/include_about_sources"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/stdp" /> android:layout_marginTop="@dimen/stdp" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
</LinearLayout>

View file

@ -1,21 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.fragments.AboutFragment">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true" android:fillViewport="true"
android:scrollbars="none" android:scrollbars="none">
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -25,11 +13,6 @@
android:clipToPadding="false" android:clipToPadding="false"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include <include
android:id="@+id/home_vanced_wrapper" android:id="@+id/home_vanced_wrapper"
layout="@layout/include_vanced" layout="@layout/include_vanced"
@ -68,8 +51,4 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </androidx.core.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
</LinearLayout>

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content"> android:layout_height="wrap_content">
@ -44,13 +42,15 @@
android:id="@+id/button_nonroot" android:id="@+id/button_nonroot"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="18sp" android:fontFamily="@font/exo_semibold"
android:text="non-root"/> android:text="non-root"
android:textSize="18sp" />
<com.google.android.material.radiobutton.MaterialRadioButton <com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/button_root" android:id="@+id/button_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="@font/exo_semibold"
android:textSize="18sp" android:textSize="18sp"
android:text="root"/> android:text="root"/>

View file

@ -5,6 +5,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
app:cardBackgroundColor="?colorSurfaceVariant" app:cardBackgroundColor="?colorSurfaceVariant"
app:cardCornerRadius="8dp"
app:cardElevation="0dp" app:cardElevation="0dp"
app:contentPaddingLeft="8dp" app:contentPaddingLeft="8dp"
app:contentPaddingRight="8dp" app:contentPaddingRight="8dp"

View file

@ -7,14 +7,14 @@
app:cardCornerRadius="@dimen/eightdp" app:cardCornerRadius="@dimen/eightdp"
app:cardBackgroundColor="?colorSurfaceVariant" app:cardBackgroundColor="?colorSurfaceVariant"
app:cardElevation="0dp" app:cardElevation="0dp"
app:contentPaddingLeft="12dp" app:contentPaddingBottom="4dp"
app:contentPaddingRight="12dp" app:contentPaddingLeft="8dp"
app:contentPaddingBottom="12dp" app:contentPaddingRight="8dp"
app:cardPreventCornerOverlap="true"> app:cardPreventCornerOverlap="true">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent">
<TextView <TextView
android:id="@+id/useful_links_title" android:id="@+id/useful_links_title"
@ -58,7 +58,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/support_us" android:text="@string/support_us"
android:layout_marginTop="4dp" android:layout_marginTop="5dp"
android:textAllCaps="false" android:textAllCaps="false"
android:textColor="#ffffff" android:textColor="#ffffff"
app:backgroundTint="?colorPrimary" app:backgroundTint="?colorPrimary"

View file

@ -10,26 +10,98 @@
android:id="@+id/home_fragment" android:id="@+id/home_fragment"
android:name="com.vanced.manager.ui.fragments.HomeFragment" android:name="com.vanced.manager.ui.fragments.HomeFragment"
android:label="@string/title_home" android:label="@string/title_home"
tools:layout="@layout/fragment_home" /> tools:layout="@layout/fragment_home">
<action
android:id="@+id/toAboutFragment"
app:destination="@id/about_fragment"
app:enterAnim="@anim/fragment_fade_enter"
app:exitAnim="@anim/fragment_fade_exit"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<action
android:id="@+id/toInstallThemeFragment"
app:destination="@id/install_theme_fragment"
app:enterAnim="@anim/fragment_fade_enter"
app:exitAnim="@animator/fragment_exit"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
</fragment>
<fragment <fragment
android:id="@+id/settings_fragment" android:id="@+id/settings_fragment"
android:name="com.vanced.manager.ui.fragments.SettingsFragment" android:name="com.vanced.manager.ui.fragments.SettingsFragment"
android:label="@string/title_settings" /> android:label="@string/title_settings">
<action
android:id="@+id/toAboutFragment"
app:destination="@id/about_fragment"
app:enterAnim="@anim/fragment_fade_enter"
app:exitAnim="@anim/fragment_fade_exit"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
</fragment>
<fragment
android:id="@+id/about_fragment"
android:name="com.vanced.manager.ui.fragments.AboutFragment"
android:label="@string/about"
tools:layout="@layout/fragment_about" />
<fragment
android:id="@+id/install_theme_fragment"
android:name="com.vanced.manager.ui.fragments.VancedThemeSelectionFragment"
android:label="@string/about"
tools:layout="@layout/fragment_vanced_theme_selection">
<action
android:id="@+id/toInstallVariantFragment"
app:destination="@id/install_variant_fragment"
app:enterAnim="@animator/fragment_enter"
app:exitAnim="@animator/fragment_exit"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
</fragment>
<fragment
android:id="@+id/install_variant_fragment"
android:name="com.vanced.manager.ui.fragments.VancedVariantSelectionFragment"
android:label="@string/about"
tools:layout="@layout/fragment_vanced_variant_selection">
<action
android:id="@+id/toInstallLanguageFragment"
app:destination="@id/install_language_fragment"
app:enterAnim="@animator/fragment_enter"
app:exitAnim="@animator/fragment_exit"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
</fragment>
<fragment
android:id="@+id/install_language_fragment"
android:name="com.vanced.manager.ui.fragments.VancedLanguageSelectionFragment"
android:label="@string/about"
tools:layout="@layout/fragment_vanced_language_selection" />
<action <action
android:id="@+id/toSettingsFragment" android:id="@+id/toSettingsFragment"
app:destination="@id/settings_fragment" app:destination="@id/settings_fragment"
app:enterAnim="@anim/nav_default_enter_anim" app:enterAnim="@anim/fragment_fade_enter"
app:exitAnim="@anim/nav_default_exit_anim" app:exitAnim="@anim/fragment_fade_exit"
app:popEnterAnim="@anim/nav_default_pop_enter_anim" app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" /> app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<action <action
android:id="@+id/toHomeFragment" android:id="@+id/toHomeFragment"
app:destination="@id/home_fragment" app:destination="@id/home_fragment"
app:enterAnim="@anim/nav_default_enter_anim" app:enterAnim="@anim/fragment_fade_enter"
app:exitAnim="@anim/nav_default_exit_anim" app:exitAnim="@anim/fragment_fade_exit"
app:popEnterAnim="@anim/nav_default_pop_enter_anim" app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" /> app:popExitAnim="@anim/nav_default_pop_exit_anim" />

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<array name="preloaded_fonts" translatable="false"> <array name="preloaded_fonts" translatable="false">
<item>@font/exo</item>
<item>@font/exo_2</item>
<item>@font/exo_semibold</item> <item>@font/exo_semibold</item>
</array> </array>
</resources> </resources>