Added Settings

This commit is contained in:
wiecktobi 2020-05-04 18:51:00 +02:00
parent 57f5ba4b03
commit cdcef1fdff
14 changed files with 246 additions and 59 deletions

View File

@ -5,7 +5,7 @@ apply plugin: 'kotlin-android-extensions'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion "29.0.3" buildToolsVersion '29.0.3'
dataBinding { dataBinding {
enabled = true enabled = true
} }
@ -36,7 +36,7 @@ dependencies {
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 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0' implementation 'com.google.android.material:material:1.2.0-alpha06'
implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.preference:preference:1.1.1'
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'

View File

@ -1,24 +1,46 @@
package de.hft.geotracker package de.hft.geotracker
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.Window
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView
import android.widget.Spinner import android.widget.Spinner
import androidx.navigation.findNavController import androidx.navigation.findNavController
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.navigation.ui.NavigationUI import androidx.navigation.ui.NavigationUI
import com.google.android.material.textfield.TextInputLayout
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setSupportActionBar(findViewById(R.id.my_toolbar))
setContentView(R.layout.activity_home) setContentView(R.layout.activity_home)
// val binding = DataBindingUtil.setContentView(this, R.layout.activity_main) // val binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
// val navController = this.findNavController(R.id.HostFragment) // val navController = this.findNavController(R.id.HostFragment)
// NavigationUI.setupActionBarWithNavController(this, navController) // NavigationUI.setupActionBarWithNavController(this, navController)
// val dropdown : TextInputLayout = findViewById(R.id.filled_exposed_dropdown)
/*val editTextFilledExposedDropdown : AutoCompleteTextView = findViewById(R.id.filled_exposed_dropdown)
ArrayAdapter.createFromResource(this, R.array.accounts, R.layout.spinner_layout).also {
arrayAdapter -> arrayAdapter.setDropDownViewResource(R.layout.spinner_layout)
editTextFilledExposedDropdown.setAdapter(arrayAdapter)
}*/
/*val array = arrayOf("Test1", "Test2")
val a : ArrayAdapter<String> = ArrayAdapter(this, R.layout.spinner_layout, array)
val editTextFilledExposedDropdown : AutoCompleteTextView = findViewById(R.id.filled_exposed_dropdown)
editTextFilledExposedDropdown.setAdapter(a)*/
val spinner: Spinner = findViewById(R.id.account_spinner) val spinner: Spinner = findViewById(R.id.account_spinner)
// Create an ArrayAdapter using the string array and a default spinner layout // Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter.createFromResource(this, R.array.accounts, android.R.layout.simple_spinner_item).also { adapter -> ArrayAdapter.createFromResource(this, R.array.accounts, android.R.layout.simple_spinner_item).also { adapter ->
@ -26,15 +48,32 @@ class MainActivity : AppCompatActivity() {
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
// Apply the adapter to the spinner // Apply the adapter to the spinner
spinner.adapter = adapter spinner.adapter = adapter
}
}
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.settings -> {
// User chose the "Settings" item, show the app settings UI...
var intent = Intent(this, Settings::class.java)
startActivity(intent)
println("test")
true
}
R.id.logout -> {
// User chose the "Settings" item, show the app settings UI...
var intent = Intent(this, Login::class.java)
startActivity(intent)
true
}
else -> {
// If we got here, the user's action was not recognized.
// Invoke the superclass to handle it.
println("test")
super.onOptionsItemSelected(item)
} }
} }
override fun onBackPressed() { override fun onBackPressed() {
}
} }
override fun onSupportNavigateUp(): Boolean {
val navController = this.findNavController(R.id.HostFragment)
return navController.navigateUp()
}
}

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="@color/logo_blue" />
<corners android:radius="5dp"/>
<stroke
android:width="1dp"
android:color="@color/logo_blue" />
</shape>

View File

@ -3,7 +3,7 @@
android:shape="rectangle" > android:shape="rectangle" >
<solid android:color="@android:color/transparent" /> <solid android:color="@android:color/transparent" />
<corners android:radius="5dp"/>
<stroke <stroke
android:width="1dp" android:width="1dp"
android:color="@color/logo_blue" /> android:color="@color/logo_blue" />

View File

@ -1,5 +1,6 @@
<?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" <androidx.constraintlayout.widget.ConstraintLayout
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:id="@+id/frameLayout" android:id="@+id/frameLayout"
@ -9,12 +10,29 @@
tools:context=".MainActivity"> tools:context=".MainActivity">
<!-- TODO: Update blank fragment layout --> <!-- TODO: Update blank fragment layout -->
<androidx.appcompat.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:contextClickable="false"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/menu"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleTextAppearance="@style/text_style" />
<TextView <TextView
android:id="@+id/selected_acc" android:id="@+id/selected_acc"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="@dimen/margin16" android:layout_marginTop="16dp"
android:fontFamily="@font/montserrat" android:fontFamily="@font/montserrat"
android:text="@string/timetrack_account" android:text="@string/timetrack_account"
android:textAppearance="@style/text_style" android:textAppearance="@style/text_style"
@ -23,7 +41,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toBottomOf="@+id/my_toolbar"
app:layout_constraintVertical_bias="0.0" /> app:layout_constraintVertical_bias="0.0" />
<TextView <TextView
@ -37,64 +55,37 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<Button <ToggleButton
android:id="@+id/button_start" android:id="@+id/button_start_stop"
style="@android:style/Widget.Material.Light.Button" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin16" android:layout_marginStart="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16" android:layout_marginEnd="@dimen/margin16"
android:layout_marginBottom="@dimen/margin16" android:layout_marginBottom="@dimen/margin16"
android:background="@drawable/outlined_button" android:background="@drawable/outlined_button_filled"
android:text="@string/btn_start_text" android:checked="true"
android:textAllCaps="false"
android:textAppearance="@style/text_style" android:textAppearance="@style/text_style"
android:textColor="@color/logo_white" android:textOff="@string/stop"
android:textOn="@string/btn_start_text"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="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" /> app:layout_constraintStart_toStartOf="parent" />
<Spinner <Spinner
android:id="@+id/account_spinner" android:id="@+id/account_spinner"
android:layout_width="180dp" android:layout_width="180dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16" android:layout_marginEnd="@dimen/margin16"
android:background="@color/logo_white" android:background="@color/logo_white"
android:textAlignment="textEnd" android:textAlignment="textEnd"
app:layout_constraintBottom_toTopOf="@+id/display_acc"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@+id/my_toolbar" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -8,7 +8,7 @@
tools:context=".Login"> tools:context=".Login">
<EditText <EditText
android:id="@+id/input_username" android:id="@+id/setting_input_username"
style="@style/input_field" style="@style/input_field"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="42dp" android:layout_height="42dp"
@ -42,16 +42,18 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/input_username" app:layout_constraintTop_toBottomOf="@+id/setting_input_username"
app:layout_constraintVertical_bias="0.13" /> app:layout_constraintVertical_bias="0.13" />
<Button <Button
android:id="@+id/button_create_account" android:id="@+id/button_create_account"
style="@style/Widget.AppCompat.Button"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:background="@color/logo_blue" android:background="@drawable/outlined_button_filled"
android:backgroundTint="@color/colorAccent"
android:text="@string/login" android:text="@string/login"
android:textAppearance="@style/text_style" android:textAppearance="@style/text_style"
android:textStyle="bold" android:textStyle="bold"

View File

@ -76,7 +76,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin16" android:layout_marginTop="@dimen/margin16"
android:layout_marginBottom="175dp" android:layout_marginBottom="175dp"
android:background="@color/logo_blue" android:background="@drawable/outlined_button_filled"
android:text="@string/create_account" android:text="@string/create_account"
android:textAppearance="@style/text_style" android:textAppearance="@style/text_style"
android:textStyle="bold" android:textStyle="bold"

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Test"
xmlns:android="http://schemas.android.com/apk/res/android">
<AutoCompleteTextView
android:id="@+id/filled_exposed_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>

View File

@ -1,9 +1,117 @@
<LinearLayout 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: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:background="@color/background_grey">
<FrameLayout <FrameLayout
android:id="@+id/settings" android:id="@+id/settings"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" >
<ScrollView
android:id="@+id/settings_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:orientation="vertical">
<TextView
android:id="@+id/settings_change_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Change Username"
android:textAppearance="@style/text_style" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="@color/colorAccent" />
<EditText
android:id="@+id/setting_input_username"
style="@style/input_field"
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="@dimen/margin16"
android:layout_marginEnd="16dp"
android:layout_marginBottom="@dimen/margin16"
android:background="@drawable/outlined_button"
android:ems="10"
android:hint="@string/username"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="@color/logo_white" />
<TextView
android:id="@+id/setting_change_pasword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin16"
android:layout_marginTop="@dimen/margin16"
android:layout_marginBottom="8dp"
android:text="Change Username"
android:textAppearance="@style/text_style" />
<View
android:id="@+id/divider3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorAccent"
app:layout_constraintHorizontal_bias="1.0" />
<EditText
android:id="@+id/setting_input_password"
style="@style/input_field"
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_marginStart="@dimen/margin16"
android:layout_marginTop="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16"
android:layout_marginBottom="@dimen/margin16"
android:background="@drawable/outlined_button"
android:ems="10"
android:hint="@string/password"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="@color/logo_white" />
<EditText
android:id="@+id/setting_input_password2"
style="@style/input_field"
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_marginStart="@dimen/margin16"
android:layout_marginTop="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16"
android:layout_marginBottom="@dimen/margin16"
android:background="@drawable/outlined_button"
android:ems="10"
android:hint="@string/confirm_password"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="@color/logo_white" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin16"
android:layout_marginTop="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16"
android:layout_marginBottom="@dimen/margin16"
android:background="@drawable/outlined_button_filled"
android:text="@string/submit" />
</LinearLayout>
</ScrollView>
</FrameLayout>
</LinearLayout> </LinearLayout>

View File

@ -7,4 +7,7 @@
android:textSize="16sp" android:textSize="16sp"
android:textColor="@color/logo_white" android:textColor="@color/logo_white"
android:fontFamily="@font/montserrat" android:fontFamily="@font/montserrat"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="?attr/textAppearanceSubtitle1"
/> />

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_favorite"
android:icon="@drawable/ic_logo_gt"
android:title="test"
app:showAsAction="ifRoom" />
<item
android:id="@+id/setting"
android:icon="@android:drawable/btn_star"
android:title="@string/title_activity_settings"
app:showAsAction="collapseActionView" />
<item
android:id="@+id/logout"
android:title="@string/logout" />
</menu>

View File

@ -33,4 +33,6 @@
<string name="confirm_password">Confirm Password</string> <string name="confirm_password">Confirm Password</string>
<string name="register">Register</string> <string name="register">Register</string>
<string name="create_account">Create Account</string> <string name="create_account">Create Account</string>
<string name="submit">Submit</string>
<string name="logout">Logout</string>
</resources> </resources>

View File

@ -1,7 +1,7 @@
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>