Browse Source

added MenuCardView and minor clean ups

pull/20/head
Jannik 4 years ago
parent
commit
c77e535817
  1. 1
      app/src/main/java/org/mosad/seil0/projectlaogai/LessonCardView.kt
  2. 3
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
  3. 42
      app/src/main/java/org/mosad/seil0/projectlaogai/MensaFragment.kt
  4. 30
      app/src/main/java/org/mosad/seil0/projectlaogai/MenuCardView.kt
  5. 13
      app/src/main/java/org/mosad/seil0/projectlaogai/SettingsFragment.kt
  6. 1
      app/src/main/res/layout/fragment_home.xml
  7. 3
      app/src/main/res/layout/fragment_mensa.xml
  8. 2
      app/src/main/res/layout/fragment_settings.xml
  9. 42
      app/src/main/res/layout/menu_cardview.xml

1
app/src/main/java/org/mosad/seil0/projectlaogai/LessonCardView.kt

@ -24,7 +24,6 @@ package org.mosad.seil0.projectlaogai
import android.content.Context
import android.graphics.Color
import androidx.cardview.widget.CardView
import android.util.AttributeSet
import android.widget.TextView

3
app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

@ -23,7 +23,6 @@
package org.mosad.seil0.projectlaogai
import android.os.Bundle
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.navigation.NavigationView
import androidx.core.view.GravityCompat
import androidx.appcompat.app.ActionBarDrawerToggle
@ -92,7 +91,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
fragmentTransaction.commit()
}
R.id.nav_mensa -> {
val mensaFragment: MensaFragment = MensaFragment()
val mensaFragment = MensaFragment()
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, mensaFragment)
fragmentTransaction.commit()

42
app/src/main/java/org/mosad/seil0/projectlaogai/MensaFragment.kt

@ -22,11 +22,14 @@
package org.mosad.seil0.projectlaogai
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
/**
* A simple [Fragment] subclass.
@ -34,12 +37,39 @@ import android.view.ViewGroup
*/
class MensaFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_mensa, container, false)
private lateinit var linLayoutMensaFragment: LinearLayout
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_mensa, container, false)
linLayoutMensaFragment = view.findViewById(R.id.linLayout_MensaFragment)
addDay()
return view
}
fun addDay() {
val linLayoutDay = LinearLayout(context)
val txtViewDayHeading = TextView(context, null, R.string.sample_date)
val menuViewMenu1 = MenuCardView(context!!, null)
val menuViewMenu2 = MenuCardView(context!!, null)
menuViewMenu1.getTxtViewMenuHeading().text = "Essen 1"
menuViewMenu1.getTxtViewMenu().text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
menuViewMenu2.getTxtViewMenuHeading().text = "Essen 2"
menuViewMenu2.getTxtViewMenu().text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
linLayoutDay.orientation = LinearLayout.VERTICAL
linLayoutDay.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
linLayoutDay.addView(txtViewDayHeading)
linLayoutDay.addView(menuViewMenu1)
linLayoutDay.addView(menuViewMenu2)
linLayoutMensaFragment.addView(linLayoutDay)
}

30
app/src/main/java/org/mosad/seil0/projectlaogai/MenuCardView.kt

@ -0,0 +1,30 @@
package org.mosad.seil0.projectlaogai
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.widget.TextView
class MenuCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
private var txtViewMenuHeading: TextView
private var txtViewMenu: TextView
init {
inflate(context, R.layout.menu_cardview,this)
txtViewMenuHeading = findViewById(R.id.txtView_MenuHeading)
txtViewMenu = findViewById(R.id.txtView_Menu)
// workaround to prevent a white border
this.setBackgroundColor(Color.TRANSPARENT)
}
fun getTxtViewMenuHeading(): TextView {
return txtViewMenuHeading
}
fun getTxtViewMenu(): TextView {
return txtViewMenu
}
}

13
app/src/main/java/org/mosad/seil0/projectlaogai/SettingsFragment.kt

@ -31,9 +31,9 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.color.colorChooser
import com.afollestad.materialdialogs.list.listItems
import kotlinx.android.synthetic.main.fragment_settings.*
/**
* The settings controller class
* contains all needed parts to display and the settings screen
@ -50,8 +50,6 @@ class SettingsFragment : Fragment() {
val view: View = inflater.inflate(R.layout.fragment_settings, container, false)
linLayoutUser = view.findViewById(R.id.linLayout_User)
linLayoutCourse = view.findViewById(R.id.linLayout_Course)
linLayoutInfo = view.findViewById(R.id.linLayout_Info)
@ -74,6 +72,15 @@ class SettingsFragment : Fragment() {
linLayoutCourse.setOnClickListener {
// open a new dialog
val courses = listOf("AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7")
MaterialDialog(context!!)
.listItems(items = courses){ dialog, index, text ->
// TODO save selected course
// update txtView
txtView_Course.text = text
}
.show()
}
linLayoutInfo.setOnClickListener {

1
app/src/main/res/layout/fragment_home.xml

@ -82,7 +82,6 @@
android:typeface="sans"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"

3
app/src/main/res/layout/fragment_mensa.xml

@ -5,7 +5,6 @@
android:layout_height="match_parent"
tools:context=".MensaFragment">
<!-- TODO: Update blank fragment layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -13,7 +12,7 @@
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content" android:id="@+id/linLayout_MensaFragment">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"

2
app/src/main/res/layout/fragment_settings.xml

@ -5,8 +5,6 @@
android:layout_height="match_parent"
tools:context=".SettingsFragment">
<!-- TODO: Update blank fragment layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

42
app/src/main/res/layout/menu_cardview.xml

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="125dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:clickable="false"
android:maxHeight="125dp"
app:cardCornerRadius="15dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/essen_1"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_MenuHeading"
android:textStyle="bold" android:textAlignment="center" android:textSize="16sp"
android:typeface="sans" android:fontFamily="sans-serif" android:paddingBottom="5dp"/>
<TextView
android:id="@+id/txtView_Menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textAlignment="center"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close