diff options
| -rw-r--r-- | app/build.gradle | 3 | ||||
| -rw-r--r-- | app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt | 30 | ||||
| -rw-r--r-- | app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt | 5 | ||||
| -rw-r--r-- | app/src/main/res/drawable/ic_home_black_24dp.xml | 9 | ||||
| -rw-r--r-- | app/src/main/res/layout/activity_main.xml | 32 | ||||
| -rw-r--r-- | app/src/main/res/layout/content_main.xml | 2 | ||||
| -rw-r--r-- | app/src/main/res/layout/top_manga_page.xml | 16 | ||||
| -rw-r--r-- | app/src/main/res/menu/bottom_nav_menu.xml | 19 | ||||
| -rw-r--r-- | app/src/main/res/navigation/mobile_navigation.xml | 25 | ||||
| -rw-r--r-- | app/src/main/res/values/strings.xml | 8 | 
10 files changed, 126 insertions, 23 deletions
| diff --git a/app/build.gradle b/app/build.gradle index 8a48d02..4d56e32 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,6 +30,9 @@ android {      kotlinOptions {          jvmTarget = '1.8'      } +    buildFeatures { +        viewBinding true +    }  }  dependencies { diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt index 3a50028..4a3b08b 100644 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt @@ -2,14 +2,42 @@ package xyz.adjutor.aniki.presentation.view.activity  import android.os.Bundle  import androidx.appcompat.app.AppCompatActivity +import androidx.navigation.NavController +import androidx.navigation.fragment.NavHostFragment +import androidx.navigation.ui.AppBarConfiguration +import androidx.navigation.ui.setupActionBarWithNavController +import androidx.navigation.ui.setupWithNavController +import com.google.android.material.bottomnavigation.BottomNavigationView  import xyz.adjutor.aniki.R +import xyz.adjutor.aniki.databinding.ActivityMainBinding +  class MainActivity : AppCompatActivity() { +    private lateinit var binding: ActivityMainBinding      override fun onCreate(savedInstanceState: Bundle?) {          super.onCreate(savedInstanceState) -        setContentView(R.layout.activity_main) + +        binding = ActivityMainBinding.inflate(layoutInflater) +        setContentView(binding.root) + +        val navView: BottomNavigationView = binding.navView + +        val navHostFragment = +            supportFragmentManager.findFragmentById(R.id.nav_host_fragment_activity_main) as NavHostFragment +        val navController: NavController = navHostFragment.navController +        // 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, R.id.navigation_manga, R.id.navigation_anime +            ) +        )          setSupportActionBar(findViewById(R.id.toolbar)) +        setupActionBarWithNavController(navController, appBarConfiguration) +        navView.setupWithNavController(navController) + +      }  }
\ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt index 7821e50..eb76e86 100644 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt @@ -6,7 +6,6 @@ import android.view.View  import android.view.ViewGroup  import android.widget.Button  import androidx.fragment.app.Fragment -import androidx.navigation.fragment.findNavController  import androidx.recyclerview.widget.LinearLayoutManager  import androidx.recyclerview.widget.RecyclerView  import androidx.swiperefreshlayout.widget.SwipeRefreshLayout @@ -38,10 +37,6 @@ class TopMangaFragment : Fragment() {      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {          super.onViewCreated(view, savedInstanceState) -        //button to return to the home page -        view.findViewById<Button>(R.id.button_home).setOnClickListener { -            findNavController().navigate(R.id.action_TopMangaPage_to_HomePage) -        }          view.findViewById<Button>(R.id.button_prev).setOnClickListener {              controller.onButtonPrevClick()          } diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml new file mode 100644 index 0000000..f8bb0b5 --- /dev/null +++ b/app/src/main/res/drawable/ic_home_black_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" +    android:width="24dp" +    android:height="24dp" +    android:viewportWidth="24.0" +    android:viewportHeight="24.0"> +    <path +        android:fillColor="#FF000000" +        android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" /> +</vector> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index dc71220..9c34ba0 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@  <?xml version="1.0" encoding="utf-8"?> -<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"      xmlns:app="http://schemas.android.com/apk/res-auto"      xmlns:tools="http://schemas.android.com/tools"      android:layout_width="match_parent" @@ -9,6 +9,8 @@      <com.google.android.material.appbar.AppBarLayout          android:layout_width="match_parent"          android:layout_height="wrap_content" +        app:layout_constraintEnd_toEndOf="parent" +        app:layout_constraintTop_toTopOf="parent"          android:theme="@style/Theme.Aniki.AppBarOverlay">          <androidx.appcompat.widget.Toolbar @@ -20,6 +22,30 @@      </com.google.android.material.appbar.AppBarLayout> -    <include layout="@layout/content_main" /> +    <com.google.android.material.bottomnavigation.BottomNavigationView +        android:id="@+id/nav_view" +        android:layout_width="0dp" +        android:layout_height="wrap_content" +        android:layout_marginStart="0dp" +        android:layout_marginEnd="0dp" +        android:background="?android:attr/windowBackground" +        app:layout_constraintBottom_toBottomOf="parent" +        app:layout_constraintLeft_toLeftOf="parent" +        app:layout_constraintRight_toRightOf="parent" +        app:menu="@menu/bottom_nav_menu" /> + +    <androidx.fragment.app.FragmentContainerView +        android:id="@+id/nav_host_fragment_activity_main" +        android:name="androidx.navigation.fragment.NavHostFragment" +        android:layout_width="match_parent" +        android:layout_height="match_parent" +        app:defaultNavHost="true" +        app:layout_constraintBottom_toTopOf="@id/nav_view" +        app:layout_constraintLeft_toLeftOf="parent" +        app:layout_constraintRight_toRightOf="parent" +        app:layout_constraintTop_toTopOf="parent" +        app:navGraph="@navigation/mobile_navigation" /> + +    <!--include layout="@layout/content_main" /--> -</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file +</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index c4e7db6..f4c4e46 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -5,7 +5,7 @@      android:layout_height="match_parent"      app:layout_behavior="@string/appbar_scrolling_view_behavior"> -    <fragment +    <androidx.fragment.app.FragmentContainerView          android:id="@+id/nav_host_fragment"          android:name="androidx.navigation.fragment.NavHostFragment"          android:layout_width="0dp" diff --git a/app/src/main/res/layout/top_manga_page.xml b/app/src/main/res/layout/top_manga_page.xml index b9b3182..cde56c7 100644 --- a/app/src/main/res/layout/top_manga_page.xml +++ b/app/src/main/res/layout/top_manga_page.xml @@ -8,6 +8,7 @@      tools:context=".presentation.view.fragment.TopMangaFragment">      <androidx.swiperefreshlayout.widget.SwipeRefreshLayout +        android:paddingVertical="50dp"          android:id="@+id/swiperefresh"          android:layout_width="match_parent"          android:layout_height="match_parent"> @@ -30,16 +31,8 @@          android:layout_height="wrap_content"          android:text="@string/prev"          app:layout_constraintBottom_toBottomOf="parent" -        app:layout_constraintEnd_toStartOf="@id/button_home" /> - -    <Button -        android:id="@+id/button_home" -        android:layout_width="wrap_content" -        android:layout_height="wrap_content" -        android:text="@string/home" -        app:layout_constraintBottom_toBottomOf="parent" -        app:layout_constraintEnd_toEndOf="parent" -        app:layout_constraintStart_toStartOf="parent" /> +        app:layout_constraintStart_toStartOf="parent" +        app:layout_constraintTop_toTopOf="parent" />      <Button          android:id="@+id/button_next" @@ -47,6 +40,7 @@          android:layout_height="wrap_content"          android:text="@string/next"          app:layout_constraintBottom_toBottomOf="parent" -        app:layout_constraintStart_toEndOf="@id/button_home" /> +        app:layout_constraintEnd_toEndOf="parent" +        app:layout_constraintTop_toTopOf="parent" />  </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..0ea00a0 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + +    <item +        android:id="@+id/navigation_manga" +        android:icon="@drawable/ic_home_black_24dp" +        android:title="@string/title_manga" /> + +    <item +        android:id="@+id/navigation_home" +        android:icon="@drawable/ic_home_black_24dp" +        android:title="@string/title_home" /> + +    <item +        android:id="@+id/navigation_anime" +        android:icon="@drawable/ic_home_black_24dp" +        android:title="@string/title_anime" /> + +</menu>
\ No newline at end of file diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml new file mode 100644 index 0000000..8d197c0 --- /dev/null +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<navigation xmlns:android="http://schemas.android.com/apk/res/android" +    xmlns:app="http://schemas.android.com/apk/res-auto" +    xmlns:tools="http://schemas.android.com/tools" +    android:id="@+id/mobile_navigation" +    app:startDestination="@+id/navigation_home"> + +    <fragment +        android:id="@+id/navigation_manga" +        android:name="xyz.adjutor.aniki.presentation.view.fragment.TopMangaFragment" +        android:label="@string/title_manga" +        tools:layout="@layout/top_manga_page" /> + +    <fragment +        android:id="@+id/navigation_home" +        android:name="xyz.adjutor.aniki.presentation.view.fragment.HomePage" +        android:label="@string/title_home" +        tools:layout="@layout/home_page" /> + +    <fragment +        android:id="@+id/navigation_anime" +        android:name="xyz.adjutor.aniki.presentation.view.fragment.TopAnimeFragment" +        android:label="@string/title_anime" +        tools:layout="@layout/top_anime_page" /> +</navigation>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 861a440..c998872 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,7 +42,11 @@      <string name="search_anime">Search Anime</string>      <string name="search_anime_page_label">Search Anime Page</string>      <string name="hint_query">Your query …</string> -    <string name="prev">PREV</string> -    <string name="next">NEXT</string> +    <string name="prev"><</string> +    <string name="next">></string> + +    <string name="title_home">Home</string> +    <string name="title_manga">Manga</string> +    <string name="title_anime">Anime</string>  </resources>
\ No newline at end of file | 
