From 881d01535d83ccb7114fff7d313d66cef9968d49 Mon Sep 17 00:00:00 2001 From: wiecktobi Date: Mon, 4 May 2020 20:26:29 +0200 Subject: [PATCH] Change app theme * Toolbar with logout on home screen * Add a Toolbar to login and register view * Embed Settings view --- .../hft/geotracker/activities/MainActivity.kt | 41 ++++++------- .../de/hft/geotracker/activities/Settings.kt | 17 ++---- .../de/hft/geotracker/retrofit/ValuesUser.kt | 2 +- android/app/src/main/res/drawable/ic_logo.xml | 61 +++++++++++++++++++ .../app/src/main/res/layout/activity_home.xml | 50 ++++++++------- .../src/main/res/layout/activity_login.xml | 15 +++++ .../src/main/res/layout/activity_register.xml | 16 +++++ .../app/src/main/res/layout/dropdown_menu.xml | 12 ++-- .../src/main/res/layout/settings_activity.xml | 49 +++++++++++---- android/app/src/main/res/menu/menu.xml | 15 ++--- android/app/src/main/res/values/styles.xml | 2 +- 11 files changed, 194 insertions(+), 86 deletions(-) create mode 100644 android/app/src/main/res/drawable/ic_logo.xml diff --git a/android/app/src/main/java/de/hft/geotracker/activities/MainActivity.kt b/android/app/src/main/java/de/hft/geotracker/activities/MainActivity.kt index d634e7d..b3c8a83 100644 --- a/android/app/src/main/java/de/hft/geotracker/activities/MainActivity.kt +++ b/android/app/src/main/java/de/hft/geotracker/activities/MainActivity.kt @@ -45,7 +45,6 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setSupportActionBar(findViewById(R.id.my_toolbar)) setContentView(R.layout.activity_home) this.getSharedPreferences("LOCATION", Context.MODE_PRIVATE) @@ -123,6 +122,24 @@ class MainActivity : AppCompatActivity() { actionButton.setOnClickListener { callStartStop() } + my_toolbar.setNavigationOnClickListener { + altitude.text = "Pressed" + } + my_toolbar.setOnMenuItemClickListener { menuItem -> + when (menuItem.itemId) { + R.id.settings -> { + var intent = Intent(this, Settings::class.java) + startActivity(intent) + println("Settings pressed") + true + } + R.id.logout -> { + println("Logout pressed") + true + } + else -> false + } + } } private fun callStartStop() { @@ -164,28 +181,6 @@ class MainActivity : AppCompatActivity() { PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } - 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() { } diff --git a/android/app/src/main/java/de/hft/geotracker/activities/Settings.kt b/android/app/src/main/java/de/hft/geotracker/activities/Settings.kt index c9951bf..13301df 100644 --- a/android/app/src/main/java/de/hft/geotracker/activities/Settings.kt +++ b/android/app/src/main/java/de/hft/geotracker/activities/Settings.kt @@ -4,25 +4,16 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.preference.PreferenceFragmentCompat import de.hft.geotracker.R +import kotlinx.android.synthetic.main.activity_home.* class Settings : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.settings_activity) - supportFragmentManager - .beginTransaction() - .replace( - R.id.settings, - SettingsFragment() - ) - .commit() - supportActionBar?.setDisplayHomeAsUpEnabled(true) - } - - class SettingsFragment : PreferenceFragmentCompat() { - override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - setPreferencesFromResource(R.xml.root_preferences, rootKey) + my_toolbar.setNavigationOnClickListener { + onBackPressed() } } + } \ No newline at end of file diff --git a/android/app/src/main/java/de/hft/geotracker/retrofit/ValuesUser.kt b/android/app/src/main/java/de/hft/geotracker/retrofit/ValuesUser.kt index 25b9cc2..df869f2 100644 --- a/android/app/src/main/java/de/hft/geotracker/retrofit/ValuesUser.kt +++ b/android/app/src/main/java/de/hft/geotracker/retrofit/ValuesUser.kt @@ -8,7 +8,7 @@ class ValuesUser ( lastname : String, username : String, location : String, - id : Integer) { + id : kotlin.Int) { @SerializedName("role") var role = role diff --git a/android/app/src/main/res/drawable/ic_logo.xml b/android/app/src/main/res/drawable/ic_logo.xml new file mode 100644 index 0000000..dc623bf --- /dev/null +++ b/android/app/src/main/res/drawable/ic_logo.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/layout/activity_home.xml b/android/app/src/main/res/layout/activity_home.xml index fcfd7e6..12a8837 100644 --- a/android/app/src/main/res/layout/activity_home.xml +++ b/android/app/src/main/res/layout/activity_home.xml @@ -1,6 +1,5 @@ - - - + app:layout_constraintTop_toTopOf="parent"> + + + + + diff --git a/android/app/src/main/res/layout/activity_login.xml b/android/app/src/main/res/layout/activity_login.xml index 16bac8f..52cfba4 100644 --- a/android/app/src/main/res/layout/activity_login.xml +++ b/android/app/src/main/res/layout/activity_login.xml @@ -6,6 +6,21 @@ android:layout_height="match_parent" android:background="@color/background_grey" tools:context=".activities.Login"> + + + + + + + - + android:layout_height="59dp" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" /> \ No newline at end of file diff --git a/android/app/src/main/res/layout/settings_activity.xml b/android/app/src/main/res/layout/settings_activity.xml index 15fc665..4f4c508 100644 --- a/android/app/src/main/res/layout/settings_activity.xml +++ b/android/app/src/main/res/layout/settings_activity.xml @@ -3,17 +3,49 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/background_grey"> + android:background="@color/background_grey" + android:orientation="vertical"> + + + + + + + android:layout_height="match_parent"> + +