added MenuCardView and minor clean ups
This commit is contained in:
		| @ -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 | ||||
|  | ||||
|  | ||||
| @ -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() | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -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 | ||||
|     } | ||||
| } | ||||
| @ -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 { | ||||
|  | ||||
| @ -82,7 +82,6 @@ | ||||
|                         android:typeface="sans"/> | ||||
|             </LinearLayout> | ||||
|         </androidx.cardview.widget.CardView> | ||||
|  | ||||
|         <ScrollView | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="0dp" | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
| @ -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
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								app/src/main/res/layout/menu_cardview.xml
									
									
									
									
									
										Normal file
									
								
							| @ -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> | ||||
		Reference in New Issue
	
	Block a user