From cdcef1fdffbc1c5d23752043c7189b7210e659b6 Mon Sep 17 00:00:00 2001 From: wiecktobi Date: Mon, 4 May 2020 18:51:00 +0200 Subject: [PATCH] Added Settings --- android/app/build.gradle | 4 +- .../java/de/hft/geotracker/MainActivity.kt | 49 +++++++- .../drawable-v24/outlined_button_filled.xml | 11 ++ .../res/drawable/ic_search_black_24dp.xml | 0 .../src/main/res/drawable/outlined_button.xml | 2 +- .../app/src/main/res/layout/activity_home.xml | 79 ++++++------ .../src/main/res/layout/activity_login.xml | 8 +- .../src/main/res/layout/activity_register.xml | 2 +- .../app/src/main/res/layout/dropdown_menu.xml | 13 ++ .../src/main/res/layout/settings_activity.xml | 112 +++++++++++++++++- .../src/main/res/layout/spinner_layout.xml | 3 + android/app/src/main/res/menu/menu.xml | 18 +++ android/app/src/main/res/values/strings.xml | 2 + android/app/src/main/res/values/styles.xml | 2 +- 14 files changed, 246 insertions(+), 59 deletions(-) create mode 100644 android/app/src/main/res/drawable-v24/outlined_button_filled.xml create mode 100644 android/app/src/main/res/drawable/ic_search_black_24dp.xml create mode 100644 android/app/src/main/res/layout/dropdown_menu.xml create mode 100644 android/app/src/main/res/menu/menu.xml diff --git a/android/app/build.gradle b/android/app/build.gradle index d508896..0eab8f5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 29 - buildToolsVersion "29.0.3" + buildToolsVersion '29.0.3' dataBinding { enabled = true } @@ -36,7 +36,7 @@ dependencies { implementation 'androidx.core:core-ktx:1.2.0' 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' + implementation 'com.google.android.material:material:1.2.0-alpha06' implementation 'androidx.preference:preference:1.1.1' testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test.ext:junit:1.1.1' diff --git a/android/app/src/main/java/de/hft/geotracker/MainActivity.kt b/android/app/src/main/java/de/hft/geotracker/MainActivity.kt index aeea9a6..67651f1 100644 --- a/android/app/src/main/java/de/hft/geotracker/MainActivity.kt +++ b/android/app/src/main/java/de/hft/geotracker/MainActivity.kt @@ -1,24 +1,46 @@ package de.hft.geotracker import android.annotation.SuppressLint +import android.content.Intent import androidx.appcompat.app.AppCompatActivity 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.AutoCompleteTextView import android.widget.Spinner import androidx.navigation.findNavController import androidx.databinding.DataBindingUtil import androidx.navigation.ui.NavigationUI +import com.google.android.material.textfield.TextInputLayout class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + setSupportActionBar(findViewById(R.id.my_toolbar)) setContentView(R.layout.activity_home) + // val binding = DataBindingUtil.setContentView(this, R.layout.activity_main) // val navController = this.findNavController(R.id.HostFragment) // 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 = 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) // 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 -> @@ -26,15 +48,32 @@ class MainActivity : AppCompatActivity() { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) // Apply the adapter to the spinner 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 onSupportNavigateUp(): Boolean { - val navController = this.findNavController(R.id.HostFragment) - return navController.navigateUp() - } } diff --git a/android/app/src/main/res/drawable-v24/outlined_button_filled.xml b/android/app/src/main/res/drawable-v24/outlined_button_filled.xml new file mode 100644 index 0000000..b4d018c --- /dev/null +++ b/android/app/src/main/res/drawable-v24/outlined_button_filled.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/ic_search_black_24dp.xml b/android/app/src/main/res/drawable/ic_search_black_24dp.xml new file mode 100644 index 0000000..e69de29 diff --git a/android/app/src/main/res/drawable/outlined_button.xml b/android/app/src/main/res/drawable/outlined_button.xml index 88ffb77..7b98209 100644 --- a/android/app/src/main/res/drawable/outlined_button.xml +++ b/android/app/src/main/res/drawable/outlined_button.xml @@ -3,7 +3,7 @@ android:shape="rectangle" > - + diff --git a/android/app/src/main/res/layout/activity_home.xml b/android/app/src/main/res/layout/activity_home.xml index bf47fdc..f74b28f 100644 --- a/android/app/src/main/res/layout/activity_home.xml +++ b/android/app/src/main/res/layout/activity_home.xml @@ -1,5 +1,6 @@ - + + + -