Commit 5602d6b3 authored by fipaddict's avatar fipaddict Committed by augier

Create navigation menu

parent 854ed3ba
Pipeline #2051 failed with stage
package fr.chenry.android.freshrss.activities
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.Navigation
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import fr.chenry.android.freshrss.FreshRSSApplication
import fr.chenry.android.freshrss.MainNavDirections
import fr.chenry.android.freshrss.R
import fr.chenry.android.freshrss.components.subscriptions.SubscriptionSection
import fr.chenry.android.freshrss.store.Store
......@@ -29,6 +31,12 @@ class MainActivity : AppCompatActivity() {
FreshRSSApplication.application.refresherService.value.whenNotNull { it.refresh() }
}
fun onMenuItemClick(item: MenuItem) {
when (item.getItemId()) {
R.id.activity_main_drawer_settings -> MainNavDirections.actionGlobalSettingsFragment()
}
}
override fun onResume() {
restoreState()
super.onResume()
......
package fr.chenry.android.freshrss.components.settings
import android.content.Context
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import fr.chenry.android.freshrss.R
/**
* A simple [Fragment] subclass.
* Activities that contain this fragment must implement the
* [SettingsFragment.OnFragmentInteractionListener] interface
* to handle interaction events.
* Use the [SettingsFragment.newInstance] factory method to
* create an instance of this fragment.
*
*/
class SettingsFragment : Fragment() {
private var listener: OnFragmentInteractionListener? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_settings, container, false)
}
// TODO: Rename method, update argument and hook method into UI event
fun onButtonPressed(uri: Uri) {
listener?.onFragmentInteraction(uri)
}
override fun onAttach(context: Context) {
super.onAttach(context)
if (context is OnFragmentInteractionListener) {
listener = context
} else {
throw RuntimeException(context.toString() + " must implement OnFragmentInteractionListener")
}
}
override fun onDetach() {
super.onDetach()
listener = null
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
*
*
* See the Android Training lesson [Communicating with Other Fragments]
* (http://developer.android.com/training/basics/fragments/communicating.html)
* for more information.
*/
interface OnFragmentInteractionListener {
fun onFragmentInteraction(uri: Uri)
}
companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @return A new instance of fragment SettingsFragment.
*/
@JvmStatic
fun newInstance() = SettingsFragment().apply {
}
}
}
<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="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z"/>
</vector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M19.1,12.9a2.8,2.8 0,0 0,0.1 -0.9,2.8 2.8,0 0,0 -0.1,-0.9l2.1,-1.6a0.7,0.7 0,0 0,0.1 -0.6L19.4,5.5a0.7,0.7 0,0 0,-0.6 -0.2l-2.4,1a6.5,6.5 0,0 0,-1.6 -0.9l-0.4,-2.6a0.5,0.5 0,0 0,-0.5 -0.4H10.1a0.5,0.5 0,0 0,-0.5 0.4L9.3,5.4a5.6,5.6 0,0 0,-1.7 0.9l-2.4,-1a0.4,0.4 0,0 0,-0.5 0.2l-2,3.4c-0.1,0.2 0,0.4 0.2,0.6l2,1.6a2.8,2.8 0,0 0,-0.1 0.9,2.8 2.8,0 0,0 0.1,0.9L2.8,14.5a0.7,0.7 0,0 0,-0.1 0.6l1.9,3.4a0.7,0.7 0,0 0,0.6 0.2l2.4,-1a6.5,6.5 0,0 0,1.6 0.9l0.4,2.6a0.5,0.5 0,0 0,0.5 0.4h3.8a0.5,0.5 0,0 0,0.5 -0.4l0.3,-2.6a5.6,5.6 0,0 0,1.7 -0.9l2.4,1a0.4,0.4 0,0 0,0.5 -0.2l2,-3.4c0.1,-0.2 0,-0.4 -0.2,-0.6ZM12,15.6A3.6,3.6 0,1 1,15.6 12,3.6 3.6,0 0,1 12,15.6Z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<androidx.drawerlayout.widget.DrawerLayout
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"
......@@ -15,4 +15,12 @@
android:name="androidx.navigation.fragment.NavHostFragment"
app:navGraph="@navigation/nav_graph"
app:defaultNavHost="true" />
</LinearLayout>
\ No newline at end of file
<com.google.android.material.navigation.NavigationView
android:id="@+id/activity_main_navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/navigation_drawer_header"
app:menu="@menu/activity_main_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context=".components.settings.SettingsFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/settings_fragment"/>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher_round"
android:contentDescription="@string/nav_header_desc"
android:id="@+id/imageView"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/nav_header_title"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nav_header_subtitle"
android:id="@+id/textView"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="@string/title_settings" android:id="@+id/activity_main_drawer_settings"
android:icon="@drawable/ic_settings_black_24dp" android:onClick="onMenuItemClick"/>
</menu>
\ No newline at end of file
......@@ -64,4 +64,8 @@
app:exitAnim="@anim/nav_default_pop_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<fragment android:id="@+id/settingsFragment"
android:name="fr.chenry.android.freshrss.components.settings.SettingsFragment"
android:label="fragment_settings" tools:layout="@layout/fragment_settings"/>
<action android:id="@+id/action_global_settingsFragment" app:destination="@id/settingsFragment"/>
</navigation>
\ No newline at end of file
......@@ -53,9 +53,12 @@
<string name="notification_channel_refresh_title">Événements de raffraîchissement</string>
<string name="notification_channel_refresh_description">Événements lors de la récupération de contenus de votre serveur FreshRSS</string>
<string name="notification_channel_errors_title">Erreurs</string>
<string name="notification_channel_errors_description">FreshRSS a rencontre une erreur dont vous devriez être
<string name="notification_channel_errors_description">FreshRSS a rencontré une erreur dont vous devriez être
informé
</string>
<string name="no_internet_connection_avaible">There is no internet connection avaible for now, please retry later
</string>
<string name="no_internet_connection_avaible">Aucune connexion internet disponible, veuillez réessayer plus tard.</string>
<string name="menu_home">Accueil</string>
<string name="nav_header_title">FreshRSS</string>
<string name="nav_header_subtitle">Menu</string>
<string name="title_settings">Configuration</string>
</resources>
\ No newline at end of file
......@@ -63,8 +63,12 @@
<string name="share_article">Share article of %s</string>
<string name="this_feed">this feed</string>
<string name="instance_url_malformed">This URL is malformed</string>
<string name="no_internet_connection_avaible">There is no internet connection avaible for now, please retry later
</string>
<string name="no_internet_connection_avaible">There is no internet connection avaible for now, please retry later</string>
<!-- Other messages -->
<string name="nav_header_title">FreshRSS</string>
<string name="nav_header_subtitle">Navigation</string>
<string name="nav_header_desc">Navigation header</string>
<string name="menu_home">Home</string>
<string name="settings_fragment">Hello settings fragment</string>
<string name="title_settings">Settings</string>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment