Added Fragments and Styles

This commit is contained in:
wiecktobi 2020-04-27 20:49:29 +02:00 committed by Marcel Schwarz
parent f3237419dd
commit 8de7890c37
14 changed files with 319 additions and 16 deletions

View File

@ -1,15 +1,19 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion "29.0.3" buildToolsVersion "29.0.3"
dataBinding {
enabled = true
}
defaultConfig { defaultConfig {
applicationId "de.hft.geotracker" applicationId "de.hft.geotracker"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 29 targetSdkVersion 29
vectorDrawables.useSupportLibrary = true
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
@ -31,7 +35,13 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0' implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
testImplementation 'junit:junit:4.13' testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
implementation"android.arch.navigation:navigation-fragment-ktx:2.2.2"
implementation "android.arch.navigation:navigation-ui-ktx:2.2.2"
} }

View File

@ -2,11 +2,23 @@ package de.hft.geotracker
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import androidx.navigation.findNavController
import androidx.databinding.DataBindingUtil
import androidx.navigation.ui.NavigationUI
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
// val binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
// val navController = this.findNavController(R.id.HostFragment)
// NavigationUI.setupActionBarWithNavController(this, navController)
}
override fun onSupportNavigateUp(): Boolean {
val navController = this.findNavController(R.id.HostFragment)
return navController.navigateUp()
} }
} }

View File

@ -0,0 +1,22 @@
package de.hft.geotracker
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
/**
* A simple [Fragment] subclass.
*/
class home : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home, container, false)
}
}

View File

@ -0,0 +1,25 @@
package de.hft.geotracker
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import kotlinx.android.synthetic.main.fragment_login.view.*
/**
* A simple [Fragment] subclass.
*/
class login : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
// val binding = DataBindingUtil.inflate(inflater, R.layout.fragment_login, container, false)
// val binding = DataBindingUtil.inflate<FragmentTitleBinding>(inflater, R.layout.fragment_title, container, false)
return inflater.inflate(R.layout.fragment_login, container, false)
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/logo_blue" />
</shape>

Binary file not shown.

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/background_grey"
tools:context=".MainActivity" > tools:context=".MainActivity" >
<TextView <fragment
android:layout_width="wrap_content" android:id="@+id/HostFragment"
android:layout_height="wrap_content" android:name="androidx.navigation.fragment.NavHostFragment"
android:text="Hello World!" android:layout_width="match_parent"
app:layout_constraintBottom_toBottomOf="parent" android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent" app:navGraph="@navigation/navigation"
app:layout_constraintRight_toRightOf="parent" app:defaultNavHost="true"/>
app:layout_constraintTop_toTopOf="parent" /> </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".home">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/selected_acc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="@dimen/margin16"
android:fontFamily="@font/montserrat"
android:text="@string/timetrack_account"
android:textAppearance="@style/text_style"
android:textColor="@color/logo_white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/display_acc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16"
android:text="@string/no_account"
android:textAppearance="@style/text_style"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button_start"
style="@android:style/Widget.Material.Light.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16"
android:layout_marginBottom="@dimen/margin16"
android:background="@drawable/outlined_button"
android:text="@string/btn_start_text"
android:textAllCaps="false"
android:textAppearance="@style/text_style"
android:textColor="@color/logo_white"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button_pause" />
<Button
android:id="@+id/button_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16"
android:background="@drawable/outlined_button"
android:text="@string/pause"
android:textAppearance="@style/text_style"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/button_start"
app:layout_constraintEnd_toStartOf="@+id/button_start"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button_stop" />
<Button
android:id="@+id/button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16"
android:background="@drawable/outlined_button"
android:text="@string/stop"
android:textAppearance="@style/text_style"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/button_start"
app:layout_constraintEnd_toStartOf="@+id/button_pause"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".login">
<EditText
android:id="@+id/input_username"
style="@style/input_field"
android:layout_width="240dp"
android:layout_height="42dp"
android:layout_marginBottom="16dp"
android:colorControlNormal="@color/logo_blue"
android:ems="10"
android:hint="@string/username"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="@color/logo_white"
app:layout_constraintBottom_toTopOf="@+id/input_password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.49"
app:layout_constraintVertical_chainStyle="packed" />
<EditText
android:id="@+id/input_password"
style="@style/input_field"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="32dp"
android:ems="10"
android:hint="@string/password"
android:inputType="textPassword"
android:textAlignment="center"
app:layout_constraintBottom_toTopOf="@+id/button_login"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/input_username"
app:layout_constraintVertical_bias="0.13" />
<Button
android:id="@+id/button_login"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="16dp"
android:background="@color/logo_blue"
android:text="@string/login"
android:textAppearance="@style/text_style"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/button_signin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/input_password" />
<Button
android:id="@+id/button_signin"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:background="@drawable/outlined_button"
android:text="@string/sign_in"
android:textAppearance="@style/text_style"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_login"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/navigation"
app:startDestination="@id/login">
<fragment
android:id="@+id/login"
android:name="de.hft.geotracker.login"
android:label="fragment_login"
tools:layout="@layout/fragment_login" >
<action
android:id="@+id/action_login_to_home"
app:destination="@id/home" />
</fragment>
<fragment
android:id="@+id/home"
android:name="de.hft.geotracker.home"
android:label="fragment_home"
tools:layout="@layout/fragment_home" />
</navigation>

View File

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#6200EE</color> <color name="colorPrimary">#272727</color>
<color name="colorPrimaryDark">#3700B3</color> <color name="colorPrimaryDark">#272727</color>
<color name="colorAccent">#03DAC5</color> <color name="colorAccent">#0096ff</color>
<color name="background_grey">#131313</color>
<color name="logo_blue">#0096ff</color>
<color name="logo_white">#EBE7D9</color>
</resources> </resources>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="margin16">16dp</dimen>
<dimen name="size12">12sp</dimen>
<dimen name="size16">16sp</dimen>
</resources>

View File

@ -1,3 +1,15 @@
<resources> <resources>
<string name="app_name">Geotracker</string> <string name="app_name">Geotracker</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="timetrack_account">Selected Account:</string>
<string name="no_account">No Account Selected</string>
<string name="btn_start_text">START</string>
<string name="pause">PAUSE</string>
<string name="stop">STOP</string>
<string name="username">Your Username or E-Mail</string>
<string name="password">Password</string>
<string name="login">Login</string>
<string name="sign_in">Sign In</string>
</resources> </resources>

View File

@ -7,5 +7,18 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
</style> </style>
<style name="text_style">
<item name="android:textColor">@color/logo_white</item>
<item name="android:fontFamily">@font/montserrat</item>
<item name="android:textSize">@dimen/size16</item>
</style>
<style name="input_field">
<item name="android:textColorHint">@color/logo_blue</item>
<item name="android:textCursorDrawable">@color/colorAccent</item>
<item name="android:textColor">@color/logo_white</item>
<item name="android:fontFamily">@font/montserrat</item>
<item name="android:textSize">18sp</item>
</style>
</resources> </resources>