initial commit 2

This commit is contained in:
2018-10-24 18:22:05 +02:00
parent 0623c41b3c
commit 8741652638
55 changed files with 1358 additions and 1 deletions

View File

@ -0,0 +1,104 @@
/**
* ProjectLaogai
*
* Copyright 2018 <seil0@mosad.xyz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package org.mosad.seil0.projectlaogai
import android.annotation.SuppressLint
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.CardView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
/**
* The "home" controller class
* contains all needed parts to display the apps home screen
*/
class HomeFragment : Fragment() {
private lateinit var txtViewMenu1: TextView
private lateinit var txtViewMenu2: TextView
private lateinit var scrollViewTimeTable: ScrollView
private lateinit var linLayoutTimeTable: LinearLayout
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_home, container, false)
// init UI elements
txtViewMenu1 = view.findViewById(R.id.txtView_Menu1)
txtViewMenu2 = view.findViewById(R.id.txtView_Menu2)
scrollViewTimeTable = view.findViewById(R.id.scrollView_TimeTable)
linLayoutTimeTable = view.findViewById(R.id.linLayout_TimeTable)
setText()
addLessons()
// Inflate the layout for this fragment
return view
}
@SuppressLint("SetTextI18n")
private fun setText() {
txtViewMenu1.text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
}
@SuppressLint("SetTextI18n")
private fun addLessons() {
// for each lesson to display on homescreen create a cardview
val cardView = CardView(context!!)
val linLayout = LinearLayout(context)
val tv = TextView(context)
cardView.radius = 20F
cardView.cardElevation = 10F
cardView.setContentPadding(10,10,10,10)
cardView.preventCornerOverlap = true
cardView.useCompatPadding = true
linLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 160)
linLayout.orientation = LinearLayout.HORIZONTAL
tv.text = "test\nRaum abc"
linLayout.addView(tv)
cardView.addView(linLayout)
// TODO make lesson card an seperate oject
//var lessonCardView = LessonCardView(context!!, null)
linLayoutTimeTable.addView(cardView)
}
}

View File

@ -0,0 +1,17 @@
package org.mosad.seil0.projectlaogai
import android.content.Context
import android.support.v7.widget.CardView
import android.util.AttributeSet
import android.view.LayoutInflater
import kotlinx.android.synthetic.main.lesson_cardview.view.*
class LessonCardView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : CardView(context, attrs){
init {
LayoutInflater.from(context).inflate(R.layout.lesson_cardview,this, false)
}
}

View File

@ -0,0 +1,118 @@
/**
* ProjectLaogai
*
* Copyright 2018 <seil0@mosad.xyz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package org.mosad.seil0.projectlaogai
import android.os.Bundle
import android.support.design.widget.Snackbar
import android.support.design.widget.NavigationView
import android.support.v4.view.GravityCompat
import android.support.v7.app.ActionBarDrawerToggle
import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
//TODO make toolbar and navbar global
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
//init home fragment TODO make a abstract fragment class
val homeFragment = HomeFragment()
val fragmentTransaction: android.support.v4.app.FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, homeFragment)
fragmentTransaction.commit()
fab.setOnClickListener { view ->
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}
val toggle = ActionBarDrawerToggle(
this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
)
drawer_layout.addDrawerListener(toggle)
toggle.syncState()
nav_view.setNavigationItemSelectedListener(this)
}
override fun onBackPressed() {
if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
drawer_layout.closeDrawer(GravityCompat.START)
} else {
super.onBackPressed()
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.main, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
return when (item.itemId) {
R.id.action_settings -> true
else -> super.onOptionsItemSelected(item)
}
}
override fun onNavigationItemSelected(item: MenuItem): Boolean {
// Handle navigation view item clicks here.
when (item.itemId) {
R.id.nav_home -> {
// Handle the home action
}
R.id.nav_mensa -> {
//val mensaFragment: MensaFragment = MensaFragment()
//val fragmentTransaction: android.support.v4.app.FragmentTransaction = supportFragmentManager.beginTransaction()
//fragmentTransaction.replace(R.id.fragment_container, mensaFragment)
//fragmentTransaction.commit()
}
R.id.nav_timetable -> {
}
R.id.nav_moodle -> {
}
R.id.nav_email -> {
}
R.id.nav_settings -> {
}
}
drawer_layout.closeDrawer(GravityCompat.START)
return true
}
}

View File

@ -0,0 +1,52 @@
/**
* ProjectLaogai
*
* Copyright 2018 <seil0@mosad.xyz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package org.mosad.seil0.projectlaogai
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"
/**
* A simple [Fragment] subclass.
*
*/
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)
}
}