From 67379787b33b52c93aac7abb7f546401412a8f04 Mon Sep 17 00:00:00 2001 From: wiecktobi Date: Sun, 3 May 2020 19:52:58 +0200 Subject: [PATCH] Regiser Activity --- android/app/build.gradle | 3 +- android/app/src/main/AndroidManifest.xml | 7 +- .../src/main/java/de/hft/geotracker/Login.kt | 19 +++-- .../java/de/hft/geotracker/MainActivity.kt | 13 ++++ .../main/java/de/hft/geotracker/Register.kt | 15 +++- .../app/src/main/res/layout/activity_home.xml | 15 +++- .../src/main/res/layout/activity_login.xml | 18 ++--- .../src/main/res/layout/activity_register.xml | 78 +++++++++++++++++++ .../src/main/res/layout/spinner_layout.xml | 12 ++- .../src/main/res/navigation/navigation.xml | 2 +- android/app/src/main/res/values/arrays.xml | 3 +- android/app/src/main/res/values/strings.xml | 23 +++++- .../app/src/main/res/xml/root_preferences.xml | 35 +++++++++ 13 files changed, 216 insertions(+), 27 deletions(-) create mode 100644 android/app/src/main/res/xml/root_preferences.xml diff --git a/android/app/build.gradle b/android/app/build.gradle index f2741d6..013d879 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -37,11 +37,12 @@ dependencies { 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 'androidx.preference:preference:1.1.0-rc01' testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test.ext:junit:1.1.1' 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-fragment-ktx:2.2.2" implementation "android.arch.navigation:navigation-ui-ktx:2.2.2" } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b671229..cb1b834 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -9,9 +9,14 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + + + + diff --git a/android/app/src/main/java/de/hft/geotracker/Login.kt b/android/app/src/main/java/de/hft/geotracker/Login.kt index ec8ce7c..8fa2428 100644 --- a/android/app/src/main/java/de/hft/geotracker/Login.kt +++ b/android/app/src/main/java/de/hft/geotracker/Login.kt @@ -3,26 +3,33 @@ package de.hft.geotracker import android.content.Intent import android.os.Bundle import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup import android.widget.TextView import androidx.appcompat.app.AppCompatActivity /** * A simple [Fragment] subclass. */ -class login : AppCompatActivity() { +class Login : AppCompatActivity() { lateinit var login : TextView + lateinit var reg : TextView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_login) - login = findViewById(R.id.button_login) + login = findViewById(R.id.button_create_account) login.setOnClickListener { login() } - + reg = findViewById(R.id.button_register) + reg.setOnClickListener { + register() + } } + + private fun register() { + val intent = Intent(this, Register::class.java) + startActivity(intent) + } + private fun login() { val intent = Intent(this, MainActivity::class.java) startActivity(intent) 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 57925f7..aeea9a6 100644 --- a/android/app/src/main/java/de/hft/geotracker/MainActivity.kt +++ b/android/app/src/main/java/de/hft/geotracker/MainActivity.kt @@ -1,7 +1,10 @@ package de.hft.geotracker +import android.annotation.SuppressLint import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import android.widget.ArrayAdapter +import android.widget.Spinner import androidx.navigation.findNavController import androidx.databinding.DataBindingUtil import androidx.navigation.ui.NavigationUI @@ -15,6 +18,16 @@ class MainActivity : AppCompatActivity() { // val binding = DataBindingUtil.setContentView(this, R.layout.activity_main) // val navController = this.findNavController(R.id.HostFragment) // NavigationUI.setupActionBarWithNavController(this, navController) + + 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 -> + // Specify the layout to use when the list of choices appears + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) + // Apply the adapter to the spinner + spinner.adapter = adapter + + } } override fun onBackPressed() { diff --git a/android/app/src/main/java/de/hft/geotracker/Register.kt b/android/app/src/main/java/de/hft/geotracker/Register.kt index 99e3864..96762fa 100644 --- a/android/app/src/main/java/de/hft/geotracker/Register.kt +++ b/android/app/src/main/java/de/hft/geotracker/Register.kt @@ -1,12 +1,25 @@ package de.hft.geotracker +import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import android.widget.TextView class Register : AppCompatActivity() { - + lateinit var reg : TextView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_register) + reg = findViewById(R.id.button_create_account) + reg.setOnClickListener { + createAccount() + } } + + private fun createAccount() { + var intent = Intent(this, MainActivity::class.java) + startActivity(intent) + } + + } diff --git a/android/app/src/main/res/layout/activity_home.xml b/android/app/src/main/res/layout/activity_home.xml index 2426aa9..bf47fdc 100644 --- a/android/app/src/main/res/layout/activity_home.xml +++ b/android/app/src/main/res/layout/activity_home.xml @@ -30,8 +30,8 @@ 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:layout_marginTop="140dp" + android:layout_marginEnd="28dp" android:text="@string/no_account" android:textAppearance="@style/text_style" app:layout_constraintEnd_toEndOf="parent" @@ -86,4 +86,15 @@ app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" /> + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/activity_login.xml b/android/app/src/main/res/layout/activity_login.xml index a356f4c..ed4a0f5 100644 --- a/android/app/src/main/res/layout/activity_login.xml +++ b/android/app/src/main/res/layout/activity_login.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background_grey" - tools:context=".login"> + tools:context=".Login">