added settings and minor clean ups

* added a settings fragment
* added jsoupe for mensa/timetable parser
This commit is contained in:
Jannik 2018-10-25 18:52:33 +02:00
parent a367865971
commit b8179a5504
10 changed files with 193 additions and 25 deletions

View File

@ -29,6 +29,7 @@ dependencies {
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'org.jsoup:jsoup:1.11.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

View File

@ -23,13 +23,8 @@
package org.mosad.seil0.projectlaogai
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.Color.*
import android.os.Build
import android.os.Bundle
import android.support.annotation.RequiresApi
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
@ -75,8 +70,6 @@ class HomeFragment : Fragment() {
txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
}
@TargetApi(Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.O)
@SuppressLint("SetTextI18n")
private fun addLessons() {

View File

@ -90,13 +90,16 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Handle navigation view item clicks here.
when (item.itemId) {
R.id.nav_home -> {
// Handle the home action
val homeFragment = HomeFragment()
val fragmentTransaction: android.support.v4.app.FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, homeFragment)
fragmentTransaction.commit()
}
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()
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 -> {
@ -108,7 +111,10 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
R.id.nav_settings -> {
val settingsFragment = SettingsFragment()
val fragmentTransaction: android.support.v4.app.FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, settingsFragment)
fragmentTransaction.commit()
}
}

View File

@ -28,12 +28,6 @@ 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.
*

View File

@ -0,0 +1,46 @@
/**
* 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
/**
* The settings controller class
* contains all needed parts to display and the settings screen
*/
class SettingsFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_settings, container, false)
// Inflate the layout for this fragment
return view
}
}

View File

@ -86,12 +86,11 @@
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cardView2" android:id="@+id/scrollView_TimeTable"
>
android:background="@color/colorPrimary" android:paddingTop="6dp">
<LinearLayout
android:id="@+id/linLayout_TimeTable"

View File

@ -9,6 +9,6 @@
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="test"/>
android:text="Mensa fragment, soon!"/>
</FrameLayout>

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SettingsFragment">
<!-- TODO: Update blank fragment layout -->
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="@string/info"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_Info"
android:typeface="sans"
android:textSize="18sp" android:textStyle="bold" android:fontFamily="sans-serif"
android:layout_margin="7dp" android:textColor="@color/colorPrimary"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:padding="7dp">
<TextView
android:text="@string/sampleuser"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_User"
android:textSize="16sp" android:textStyle="bold"
android:textColor="@android:color/primary_text_light"/>
<TextView
android:text="@string/user"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_UserDesc"/>
</LinearLayout>
<View
android:id="@+id/divider2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_margin="7dp">
<TextView
android:text="@string/samplecourse"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_Course"
android:textSize="16sp" android:textColor="@android:color/primary_text_light"
android:textStyle="bold"/>
<TextView
android:text="@string/course_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_CourseDesc"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/linLayout_Settings">
<TextView
android:text="@string/settings"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_Settings"
android:typeface="sans"
android:textSize="18sp" android:textColor="@color/design_default_color_primary"
android:textStyle="bold" android:layout_margin="7dp" android:paddingTop="3dp"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_margin="7dp" android:gravity="end">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="Maincolor"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView9"
android:textSize="16sp" android:textStyle="bold"
android:textColor="@android:color/primary_text_light"/>
<TextView
android:text="The main color, default is indigo"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView8"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_margin="7dp"
android:gravity="end">
<Button
android:text="Button"
android:layout_width="40dp"
android:layout_height="40dp" android:id="@+id/button"
android:textColor="@android:color/black"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</FrameLayout>

View File

@ -4,9 +4,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@android:color/holo_blue_bright"
app:cardBackgroundColor="@android:color/background_light"
app:contentPadding="5dp" app:cardElevation="5dp"
app:cardUseCompatPadding="true" app:cardPreventCornerOverlap="false">
app:cardUseCompatPadding="true" app:cardPreventCornerOverlap="false" app:cardCornerRadius="12dp">
<LinearLayout
android:layout_width="match_parent"

View File

@ -2,7 +2,7 @@
<string name="app_name">Project Laogai</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">hso App 0.0.1</string>
<string name="nav_header_title">hso App 0.0.2</string>
<string name="nav_header_subtitle">seil0@mosad.xyz</string>
<string name="nav_header_desc">Navigation header</string>
@ -19,4 +19,10 @@
<string name="a_lesson">a lesson\na teacher\na room</string>
<string name="a_time">0.00 - 23.59</string>
<string name="info">Info</string>
<string name="sampleuser">SampleUser@stud.hs-offenburg.de</string>
<string name="user">User</string>
<string name="samplecourse">SampleCourse 3</string>
<string name="course_desc">Tap to change course</string>
</resources>