From 85a0892098c4c9222fd88bfc983b40526678bad7 Mon Sep 17 00:00:00 2001 From: X1nto Date: Wed, 18 Mar 2020 22:10:54 +0400 Subject: [PATCH 001/504] UI update --- .idea/.name | 1 + .idea/render.experimental.xml | 6 + app/build.gradle | 19 +- .../java/com/vanced/manager/HomeFragment.kt | 23 +++ .../java/com/vanced/manager/MainActivity.kt | 41 ++++- .../vanced/manager/ui/home/HomeFragment.kt | 2 +- app/src/main/res/layout/activity_main.xml | 171 ++---------------- app/src/main/res/layout/fragment_home.xml | 151 +++++++++++++++- app/src/main/res/menu/bottom_nav_menu.xml | 4 + app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 3 + app/src/main/res/values/styles.xml | 2 +- 12 files changed, 241 insertions(+), 183 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/render.experimental.xml create mode 100644 app/src/main/java/com/vanced/manager/HomeFragment.kt diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000000..d9b30d8e01 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Vanced Manager \ No newline at end of file diff --git a/.idea/render.experimental.xml b/.idea/render.experimental.xml new file mode 100644 index 0000000000..d5b47c2498 --- /dev/null +++ b/.idea/render.experimental.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 827fa744ec..788823cac7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,15 +42,18 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.0.2' - implementation 'androidx.core:core-ktx:1.0.2' - implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.2.0' + implementation 'com.google.android.material:material:1.1.0' + implementation 'androidx.fragment:fragment-ktx:1.2.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.navigation:navigation-fragment:2.0.0' - implementation 'androidx.navigation:navigation-ui:2.0.0' - implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' - implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0' - implementation 'androidx.navigation:navigation-ui-ktx:2.0.0' + implementation 'androidx.browser:browser:1.2.0' + implementation 'androidx.navigation:navigation-fragment:2.2.1' + implementation 'androidx.navigation:navigation-ui:2.2.1' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1' + implementation 'androidx.navigation:navigation-ui-ktx:2.2.1' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' diff --git a/app/src/main/java/com/vanced/manager/HomeFragment.kt b/app/src/main/java/com/vanced/manager/HomeFragment.kt new file mode 100644 index 0000000000..31fffc8295 --- /dev/null +++ b/app/src/main/java/com/vanced/manager/HomeFragment.kt @@ -0,0 +1,23 @@ +package com.vanced.manager + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView + +/** + * A simple [Fragment] subclass. + */ +class HomeFragment : Fragment() { + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.fragment_home, container, false) + + } + +} diff --git a/app/src/main/java/com/vanced/manager/MainActivity.kt b/app/src/main/java/com/vanced/manager/MainActivity.kt index 3d57882b66..1564dccb14 100644 --- a/app/src/main/java/com/vanced/manager/MainActivity.kt +++ b/app/src/main/java/com/vanced/manager/MainActivity.kt @@ -3,24 +3,45 @@ package com.vanced.manager import android.os.Bundle import com.google.android.material.bottomnavigation.BottomNavigationView import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.FragmentTransaction import androidx.navigation.findNavController import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupActionBarWithNavController -import androidx.navigation.ui.setupWithNavController class MainActivity : AppCompatActivity() { + lateinit var homeFragment: HomeFragment + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - val navView: BottomNavigationView = findViewById(R.id.navigation_home) - - val navController = findNavController(R.id.mobile_navigation) - // Passing each menu ID as a set of Ids because each - // menu should be considered as top level destinations. - val appBarConfiguration = AppBarConfiguration(setOf( - R.id.navigation_home)) - setupActionBarWithNavController(navController, appBarConfiguration) - navView.setupWithNavController(navController) + + val navView : BottomNavigationView = findViewById(R.id.bottom_nav) + + homeFragment = HomeFragment() + supportFragmentManager + .beginTransaction() + .replace(R.id.frame_layout, homeFragment) + .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) + .commit() + + navView.setOnNavigationItemSelectedListener { item -> + + when (item.itemId) { + + R.id.home -> { + + homeFragment = HomeFragment() + supportFragmentManager + .beginTransaction() + .replace(R.id.frame_layout, homeFragment) + .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) + .commit() + } + + } + + true + } } } diff --git a/app/src/main/java/com/vanced/manager/ui/home/HomeFragment.kt b/app/src/main/java/com/vanced/manager/ui/home/HomeFragment.kt index aab089c66f..1dd1bee265 100644 --- a/app/src/main/java/com/vanced/manager/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/home/HomeFragment.kt @@ -22,7 +22,7 @@ class HomeFragment : Fragment() { homeViewModel = ViewModelProviders.of(this).get(HomeViewModel::class.java) val root = inflater.inflate(R.layout.fragment_home, container, false) - val textView: TextView = root.findViewById(R.id.text_home) + val textView: TextView = root.findViewById(R.id.Home) homeViewModel.text.observe(viewLifecycleOwner, Observer { textView.text = it }) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 154bc6c292..929a295ab3 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,6 @@ - + app:menu="@menu/bottom_nav_menu" + /> - + - + - - - - - - - - - - - - -