Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create menu #74

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ dependencies {
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
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'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Expand Down
22 changes: 16 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<uses-feature android:name="android.hardware.camera"
android:required="true" />
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />

<application
android:hardwareAccelerated="true"
android:allowBackup="true"
Expand All @@ -17,8 +18,12 @@
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".FoodAdditionActivity"
android:label="@string/foodAdditionHeader">
android:label="@string/foodAdditionHeader">
</activity>
<activity
android:name=".MenuActivity"
android:label="@string/title_activity_menu"
android:theme="@style/NoActionBar"></activity>
<activity android:name=".SettingActivity" />
<activity android:name=".HowToLookShelterActivity" />
<activity android:name=".HowToNotificationSettingsActivity" />
Expand All @@ -32,14 +37,19 @@
<activity android:name=".FirstDescriptionActivity" />
<activity android:name=".InitialNumberSettingActivity" />
<activity android:name=".InitialNotificationSettingActivity" />
<activity android:name=".PreservedFoodListActivity" />
<activity
android:name=".ShoppingListActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".PreservedFoodListActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ShoppingListActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
</application>
</manifest>
</manifest>
53 changes: 53 additions & 0 deletions app/src/main/java/com/example/kanazawaapp_2019/MenuActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.example.kanazawaapp_2019

import android.os.Bundle
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import androidx.drawerlayout.widget.DrawerLayout
import com.google.android.material.navigation.NavigationView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import android.view.Menu

class MenuActivity : AppCompatActivity() {

private lateinit var appBarConfiguration: AppBarConfiguration

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_menu)
// val toolbar: Toolbar = findViewById(R.id.toolbar)
// setSupportActionBar(toolbar)

val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navView: NavigationView = findViewById(R.id.nav_view)
// val navController = findNavController(R.id.nav_host_fragment)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
appBarConfiguration = AppBarConfiguration(
setOf(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow,
R.id.nav_tools
), drawerLayout
)
// setupActionBarWithNavController(navController, appBarConfiguration)
// navView.setupWithNavController(navController)
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.menu, menu)
return true
}

override fun onSupportNavigateUp(): Boolean {
val navController = findNavController(R.id.nav_host_fragment)
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package com.example.kanazawaapp_2019
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.ToggleButton
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.tabs.TabLayout
import kotlinx.android.synthetic.main.activity_menu.*
import kotlinx.android.synthetic.main.activity_preserved_foods_list.*

class PreservedFoodListActivity : AppCompatActivity() {
Expand All @@ -18,6 +21,12 @@ class PreservedFoodListActivity : AppCompatActivity() {
it.setDisplayHomeAsUpEnabled(true)
it.setHomeButtonEnabled(true)
}?:IllegalAccessError("toolbar cannot be,null")

val actionBarDrawerToggle = ActionBarDrawerToggle(this, drawer_layout,toolBar,R.string.app_name, R.string.app_name)
drawer_layout.addDrawerListener(actionBarDrawerToggle)
actionBarDrawerToggle.syncState()


// set adapter
val fragmentAdapter = PagerAdapterFoodList(supportFragmentManager)
viewPager.adapter = fragmentAdapter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.kanazawaapp_2019.ui.gallery

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.example.kanazawaapp_2019.R

class GalleryFragment : Fragment() {

private lateinit var galleryViewModel: GalleryViewModel

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
galleryViewModel =
ViewModelProviders.of(this).get(GalleryViewModel::class.java)
val root = inflater.inflate(R.layout.fragment_gallery, container, false)
val textView: TextView = root.findViewById(R.id.text_gallery)
galleryViewModel.text.observe(this, Observer {
textView.text = it
})
return root
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.kanazawaapp_2019.ui.gallery

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class GalleryViewModel : ViewModel() {

private val _text = MutableLiveData<String>().apply {
value = "This is gallery Fragment"
}
val text: LiveData<String> = _text
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.kanazawaapp_2019.ui.home

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.example.kanazawaapp_2019.R

class HomeFragment : Fragment() {

private lateinit var homeViewModel: HomeViewModel

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
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)
homeViewModel.text.observe(this, Observer {
textView.text = it
})
return root
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.kanazawaapp_2019.ui.home

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class HomeViewModel : ViewModel() {

private val _text = MutableLiveData<String>().apply {
value = "This is home Fragment"
}
val text: LiveData<String> = _text
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.kanazawaapp_2019.ui.send

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.example.kanazawaapp_2019.R

class SendFragment : Fragment() {

private lateinit var sendViewModel: SendViewModel

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
sendViewModel =
ViewModelProviders.of(this).get(SendViewModel::class.java)
val root = inflater.inflate(R.layout.fragment_send, container, false)
val textView: TextView = root.findViewById(R.id.text_send)
sendViewModel.text.observe(this, Observer {
textView.text = it
})
return root
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.kanazawaapp_2019.ui.send

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class SendViewModel : ViewModel() {

private val _text = MutableLiveData<String>().apply {
value = "This is send Fragment"
}
val text: LiveData<String> = _text
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.kanazawaapp_2019.ui.share

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.example.kanazawaapp_2019.R

class ShareFragment : Fragment() {

private lateinit var shareViewModel: ShareViewModel

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
shareViewModel =
ViewModelProviders.of(this).get(ShareViewModel::class.java)
val root = inflater.inflate(R.layout.fragment_share, container, false)
val textView: TextView = root.findViewById(R.id.text_share)
shareViewModel.text.observe(this, Observer {
textView.text = it
})
return root
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.kanazawaapp_2019.ui.share

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class ShareViewModel : ViewModel() {

private val _text = MutableLiveData<String>().apply {
value = "This is share Fragment"
}
val text: LiveData<String> = _text
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.kanazawaapp_2019.ui.slideshow

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.example.kanazawaapp_2019.R

class SlideshowFragment : Fragment() {

private lateinit var slideshowViewModel: SlideshowViewModel

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
slideshowViewModel =
ViewModelProviders.of(this).get(SlideshowViewModel::class.java)
val root = inflater.inflate(R.layout.fragment_slideshow, container, false)
val textView: TextView = root.findViewById(R.id.text_slideshow)
slideshowViewModel.text.observe(this, Observer {
textView.text = it
})
return root
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.kanazawaapp_2019.ui.slideshow

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class SlideshowViewModel : ViewModel() {

private val _text = MutableLiveData<String>().apply {
value = "This is slideshow Fragment"
}
val text: LiveData<String> = _text
}
Loading