From e78258597fff25af05e8b6af7f5fa5cbb94467c2 Mon Sep 17 00:00:00 2001 From: wiecktobi Date: Sat, 2 May 2020 17:05:17 +0200 Subject: [PATCH] Converted Fragments in Activities --- android/app/src/main/AndroidManifest.xml | 6 +++++ .../java/de/hft/geotracker/MainActivity.kt | 2 +- .../src/main/java/de/hft/geotracker/home.kt | 22 --------------- .../src/main/java/de/hft/geotracker/login.kt | 27 +++++++++++-------- .../{fragment_home.xml => activity_home.xml} | 3 ++- ...{fragment_login.xml => activity_login.xml} | 1 + .../src/main/res/navigation/navigation.xml | 16 +++++------ 7 files changed, 32 insertions(+), 45 deletions(-) delete mode 100644 android/app/src/main/java/de/hft/geotracker/home.kt rename android/app/src/main/res/layout/{fragment_home.xml => activity_home.xml} (97%) rename android/app/src/main/res/layout/{fragment_login.xml => activity_login.xml} (98%) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 84ee641..b671229 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -9,6 +9,12 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> + + + + + + 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 96a2805..7546eaa 100644 --- a/android/app/src/main/java/de/hft/geotracker/MainActivity.kt +++ b/android/app/src/main/java/de/hft/geotracker/MainActivity.kt @@ -11,7 +11,7 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + 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) diff --git a/android/app/src/main/java/de/hft/geotracker/home.kt b/android/app/src/main/java/de/hft/geotracker/home.kt deleted file mode 100644 index 1a7a6a1..0000000 --- a/android/app/src/main/java/de/hft/geotracker/home.kt +++ /dev/null @@ -1,22 +0,0 @@ -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) - } - -} 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 c8e26af..ec8ce7c 100644 --- a/android/app/src/main/java/de/hft/geotracker/login.kt +++ b/android/app/src/main/java/de/hft/geotracker/login.kt @@ -1,25 +1,30 @@ 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 androidx.databinding.DataBindingUtil -import kotlinx.android.synthetic.main.fragment_login.view.* +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity /** * A simple [Fragment] subclass. */ -class login : Fragment() { +class login : AppCompatActivity() { + lateinit var login : TextView + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_login) + login = findViewById(R.id.button_login) + login.setOnClickListener { + login() + } - 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(inflater, R.layout.fragment_title, container, false) - return inflater.inflate(R.layout.fragment_login, container, false) } - + private fun login() { + val intent = Intent(this, MainActivity::class.java) + startActivity(intent) + } } diff --git a/android/app/src/main/res/layout/fragment_home.xml b/android/app/src/main/res/layout/activity_home.xml similarity index 97% rename from android/app/src/main/res/layout/fragment_home.xml rename to android/app/src/main/res/layout/activity_home.xml index fd585bc..2426aa9 100644 --- a/android/app/src/main/res/layout/fragment_home.xml +++ b/android/app/src/main/res/layout/activity_home.xml @@ -5,7 +5,8 @@ android:id="@+id/frameLayout" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".home"> + android:background="@color/background_grey" + tools:context=".MainActivity"> - - - + tools:layout="@layout/activity_login" /> + \ No newline at end of file