diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6d57e315698180fdf395c0d9e957a7e06bd8548f..d3ce10872b0e13e6a83530f247ce2f43b1943068 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,7 +17,6 @@ android:name=".MainActivity" android:exported="true" android:label="@string/app_name" - android:configChanges="orientation|screenSize" > <intent-filter> <action android:name="android.intent.action.MAIN" /> diff --git a/app/src/main/java/pbd/tubes/exe_android/MainActivity.kt b/app/src/main/java/pbd/tubes/exe_android/MainActivity.kt index 4476919771b383717fd111d49aeb205ac52393e9..cd2a2a584ed9b0e198e28c8b2bd4ac69033acb4e 100644 --- a/app/src/main/java/pbd/tubes/exe_android/MainActivity.kt +++ b/app/src/main/java/pbd/tubes/exe_android/MainActivity.kt @@ -1,13 +1,18 @@ package pbd.tubes.exe_android +import android.content.res.Configuration import android.os.Bundle import android.util.Log import androidx.appcompat.app.AppCompatActivity +import androidx.navigation.NavController import androidx.navigation.findNavController import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupActionBarWithNavController import androidx.navigation.ui.setupWithNavController import com.google.android.material.bottomnavigation.BottomNavigationView +import com.google.android.material.navigation.NavigationBarView +import com.google.android.material.navigation.NavigationView +import com.google.android.material.navigationrail.NavigationRailView import pbd.tubes.exe_android.databinding.ActivityMainBinding class MainActivity : AppCompatActivity() { @@ -18,27 +23,43 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) - actionBar?.let { - binding.container.setPadding(0, it.height, 0, 0) - Log.d("MyApp", "Padded action bar set") - } setContentView(binding.root) - val navView: BottomNavigationView? = binding.navView + val navController = findNavController(R.id.nav_host_fragment_activity_main) + + when (resources.configuration.orientation){ + Configuration.ORIENTATION_LANDSCAPE -> { + binding.navViewRail?.let { + setUpNavBar(it) + } + Log.d("MyApp", "Orientation is LANDSCAPE") + } + Configuration.ORIENTATION_PORTRAIT -> { + binding.navView?.let { + setUpNavBar(it) + } + Log.d("MyApp", "Orientation is PORTRAIT") + } + else -> { + Log.d("MyApp", "What other config?") + } + } + binding.addFab.setOnClickListener { + navController.navigate(R.id.navigation_add_transaction) + } + } + private fun setUpNavBar( + navigationBarView: NavigationBarView + ){ val navController = findNavController(R.id.nav_host_fragment_activity_main) - // Passing each menu ID as a set of Ids because each - // menu should be considered as top level destinations. val appBarConfiguration = AppBarConfiguration( setOf( R.id.navigation_transactions, R.id.navigation_scan, R.id.navigation_chart, R.id.navigation_settings - ) + ), +// fallbackOnNavigateUpListener = {navController.navigateUp()} //TODO(navigate back) ) setupActionBarWithNavController(navController, appBarConfiguration) - navView!!.setupWithNavController(navController) - - binding.addFab.setOnClickListener { - navController.navigate(R.id.navigation_add_transaction) - } + navigationBarView.setupWithNavController(navController) } // private fun fabShow(){ // binding.addFab.show() diff --git a/app/src/main/res/layout/fragment_add_transaction.xml b/app/src/main/res/layout/fragment_add_transaction.xml index 98d4971e35bbb8b42d85ec5b6473a7869e2953b1..f7b8a418e836dc5e76dac32923bc34b713487009 100644 --- a/app/src/main/res/layout/fragment_add_transaction.xml +++ b/app/src/main/res/layout/fragment_add_transaction.xml @@ -1,54 +1,61 @@ <?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" +<ScrollView + 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_height="match_parent" tools:context=".ui.transactions.AddTransactionFragment" - tools:ignore="HardcodedText" - > + tools:ignore="HardcodedText"> - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/transactionNameInputLayout" - android:layout_width="wrap_content" + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="64dp" - android:minWidth="300dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> + android:orientation="vertical" + android:layout_gravity="center_horizontal" + > - <com.google.android.material.textfield.TextInputEditText - android:layout_width="match_parent" + <com.google.android.material.textfield.TextInputLayout + android:id="@+id/transactionNameInputLayout" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:hint="@string/transaction_name_text" - android:singleLine="true" - android:textColorHint="@android:color/transparent" /> - </com.google.android.material.textfield.TextInputLayout> + android:layout_marginTop="8dp" + android:minWidth="300dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/transactionNominalInputLayout" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="32dp" - android:minWidth="300dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/transactionNameInputLayout" - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> + <com.google.android.material.textfield.TextInputEditText + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/transaction_name_text" + android:singleLine="true" + android:textColorHint="@android:color/transparent" /> + </com.google.android.material.textfield.TextInputLayout> - <com.google.android.material.textfield.TextInputEditText - android:layout_width="match_parent" + <com.google.android.material.textfield.TextInputLayout + android:id="@+id/transactionNominalInputLayout" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:hint="@string/transaction_nominal_text" - android:inputType="number" - android:singleLine="true" - android:textColorHint="@android:color/transparent" - android:value="" /> - </com.google.android.material.textfield.TextInputLayout> + android:layout_marginTop="32dp" + android:minWidth="300dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/transactionNameInputLayout" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> + + <com.google.android.material.textfield.TextInputEditText + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/transaction_nominal_text" + android:inputType="number" + android:singleLine="true" + android:textColorHint="@android:color/transparent" + android:value="" /> + </com.google.android.material.textfield.TextInputLayout> <TextView android:id="@+id/transaction_category" @@ -57,10 +64,10 @@ android:layout_marginTop="32dp" android:text="@string/transaction_category" app:layout_constraintBottom_toTopOf="@+id/categoryRadioGroup" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.15" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/transactionNominalInputLayout"/> + app:layout_constraintEnd_toEndOf="@+id/categoryRadioGroup" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="@+id/categoryRadioGroup" + app:layout_constraintTop_toBottomOf="@+id/transactionNominalInputLayout" /> <RadioGroup android:id="@+id/categoryRadioGroup" @@ -87,34 +94,34 @@ android:text="Pemasukan" /> </RadioGroup> - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/transactionLocationInputLayout" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="32dp" - android:minWidth="300dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/categoryRadioGroup" - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> - - <com.google.android.material.textfield.TextInputEditText - android:layout_width="match_parent" + <com.google.android.material.textfield.TextInputLayout + android:id="@+id/transactionLocationInputLayout" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:hint="@string/transaction_location" - android:singleLine="true" - android:textColorHint="@android:color/transparent" /> + android:layout_marginTop="32dp" + android:minWidth="300dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/categoryRadioGroup" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> - </com.google.android.material.textfield.TextInputLayout> + <com.google.android.material.textfield.TextInputEditText + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/transaction_location" + android:singleLine="true" + android:textColorHint="@android:color/transparent" /> - <Button - android:id="@+id/submit_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="64dp" - android:text="Submit" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" /> + </com.google.android.material.textfield.TextInputLayout> -</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file + <Button + android:id="@+id/submit_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:text="Submit" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/transactionLocationInputLayout" /> + </androidx.constraintlayout.widget.ConstraintLayout> +</ScrollView> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_edit_transaction.xml b/app/src/main/res/layout/fragment_edit_transaction.xml index 315851ab3e70018dc23135b860dcc45742dbc120..84371848763e2f0357372c8440303bf72ada6637 100644 --- a/app/src/main/res/layout/fragment_edit_transaction.xml +++ b/app/src/main/res/layout/fragment_edit_transaction.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" +<ScrollView 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" @@ -7,29 +7,20 @@ tools:ignore="HardcodedText" tools:context=".ui.transactions.EditTransactionFragment" > - - <TextView - android:id="@+id/FragmentTitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="32dp" - android:text="Edit Transaction" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.15" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> <com.google.android.material.textfield.TextInputLayout android:id="@+id/transactionEditNameInputLayout" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="64dp" + android:layout_marginTop="16dp" android:minWidth="300dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> + app:layout_constraintTop_toTopOf="parent"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" @@ -68,10 +59,10 @@ android:layout_marginTop="32dp" android:text="@string/transaction_category" app:layout_constraintBottom_toTopOf="@+id/categoryRadioGroup" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.15" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/transactionEditDateInputLayout"/> + app:layout_constraintEnd_toEndOf="@+id/categoryRadioGroup" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="@+id/categoryRadioGroup" + app:layout_constraintTop_toBottomOf="@+id/transactionEditDateInputLayout" /> <RadioGroup android:id="@+id/categoryRadioGroup" @@ -151,15 +142,14 @@ </com.google.android.material.textfield.TextInputLayout> - <Button android:id="@+id/submit_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="64dp" + android:layout_marginTop="16dp" android:text="Submit" - app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" /> - -</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/categoryRadioGroup" /> + </androidx.constraintlayout.widget.ConstraintLayout> +</ScrollView> \ No newline at end of file