MainActivity: Move search FAB to fragment_apps_games layout
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -130,7 +130,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
attachNavigation()
|
attachNavigation()
|
||||||
attachDrawer()
|
attachDrawer()
|
||||||
attachSearch()
|
|
||||||
|
|
||||||
/*Check only if download to external storage is enabled*/
|
/*Check only if download to external storage is enabled*/
|
||||||
if (Preferences.getBoolean(this, Preferences.PREFERENCE_DOWNLOAD_EXTERNAL)) {
|
if (Preferences.getBoolean(this, Preferences.PREFERENCE_DOWNLOAD_EXTERNAL)) {
|
||||||
@@ -183,7 +182,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (navDestination !is FloatingWindow) {
|
if (navDestination !is FloatingWindow) {
|
||||||
when (navDestination.id) {
|
when (navDestination.id) {
|
||||||
in topLevelFrags -> {
|
in topLevelFrags -> {
|
||||||
B.searchFab.visibility = View.VISIBLE
|
|
||||||
B.navView.visibility = View.VISIBLE
|
B.navView.visibility = View.VISIBLE
|
||||||
B.toolbar.visibility = View.VISIBLE
|
B.toolbar.visibility = View.VISIBLE
|
||||||
B.drawerLayout.setDrawerLockMode(LOCK_MODE_UNLOCKED)
|
B.drawerLayout.setDrawerLockMode(LOCK_MODE_UNLOCKED)
|
||||||
@@ -223,18 +221,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun hideTopLevelOnlyViews() {
|
private fun hideTopLevelOnlyViews() {
|
||||||
B.searchFab.visibility = View.GONE
|
|
||||||
B.navView.visibility = View.GONE
|
B.navView.visibility = View.GONE
|
||||||
B.toolbar.visibility = View.GONE
|
B.toolbar.visibility = View.GONE
|
||||||
B.drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED)
|
B.drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun attachSearch() {
|
|
||||||
B.searchFab.setOnClickListener {
|
|
||||||
navController.navigate(R.id.searchSuggestionFragment)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun attachNavigation() {
|
private fun attachNavigation() {
|
||||||
val bottomNavigationView: BottomNavigationView = B.navView
|
val bottomNavigationView: BottomNavigationView = B.navView
|
||||||
bottomNavigationView.setupWithNavController(navController)
|
bottomNavigationView.setupWithNavController(navController)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.view.View
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.providers.AuthProvider
|
import com.aurora.store.data.providers.AuthProvider
|
||||||
@@ -85,6 +86,10 @@ class AppsContainerFragment : Fragment(R.layout.fragment_apps_games) {
|
|||||||
) { tab: TabLayout.Tab, position: Int ->
|
) { tab: TabLayout.Tab, position: Int ->
|
||||||
tab.text = tabTitles[position]
|
tab.text = tabTitles[position]
|
||||||
}.attach()
|
}.attach()
|
||||||
|
|
||||||
|
binding.searchFab.setOnClickListener {
|
||||||
|
findNavController().navigate(R.id.searchSuggestionFragment)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.view.View
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.providers.AuthProvider
|
import com.aurora.store.data.providers.AuthProvider
|
||||||
@@ -84,6 +85,10 @@ class GamesContainerFragment : Fragment(R.layout.fragment_apps_games) {
|
|||||||
) { tab: TabLayout.Tab, position: Int ->
|
) { tab: TabLayout.Tab, position: Int ->
|
||||||
tab.text = tabTitles[position]
|
tab.text = tabTitles[position]
|
||||||
}.attach()
|
}.attach()
|
||||||
|
|
||||||
|
binding.searchFab.setOnClickListener {
|
||||||
|
findNavController().navigate(R.id.searchSuggestionFragment)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
|
android:id="@+id/drawer_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@@ -58,21 +57,6 @@
|
|||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
app:menu="@menu/menu_bottom_nav" />
|
app:menu="@menu/menu_bottom_nav" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/search_fab"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:layout_marginStart="@dimen/margin_normal"
|
|
||||||
android:layout_marginTop="@dimen/height_bottom_adj"
|
|
||||||
android:layout_marginEnd="@dimen/margin_normal"
|
|
||||||
android:layout_marginBottom="@dimen/height_bottom_adj"
|
|
||||||
android:contentDescription="@string/action_search"
|
|
||||||
app:backgroundTint="?colorAccent"
|
|
||||||
app:srcCompat="@drawable/ic_round_search"
|
|
||||||
app:tint="@color/colorWhite"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
<com.google.android.material.navigation.NavigationView
|
<com.google.android.material.navigation.NavigationView
|
||||||
|
|||||||
@@ -44,4 +44,16 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/tab_layout" />
|
android:layout_below="@id/tab_layout" />
|
||||||
</RelativeLayout>
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/search_fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_margin="@dimen/margin_large"
|
||||||
|
android:contentDescription="@string/action_search"
|
||||||
|
app:backgroundTint="?colorAccent"
|
||||||
|
app:srcCompat="@drawable/ic_round_search"
|
||||||
|
app:tint="@color/colorWhite" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user