From 752893ccd94bc78b2c9f131ccbbdcd1c50e26f61 Mon Sep 17 00:00:00 2001 From: Rajit Deb Date: Sat, 14 Oct 2023 10:35:42 +0530 Subject: [PATCH 1/8] Fixed issue (#3) - findViewById used instead of binding in MainActivity. Also did some code sanitization and cleanup --- .idea/compiler.xml | 2 +- .idea/deploymentTargetDropDown.xml | 10 + .idea/gradle.xml | 5 +- .idea/kotlinc.xml | 6 + .idea/migrations.xml | 10 + .idea/misc.xml | 2 +- .idea/vcs.xml | 6 + app/build.gradle | 14 +- app/src/main/AndroidManifest.xml | 6 +- .../main/java/dev/dsi/robust/MainActivity.kt | 16 +- app/src/main/res/layout/activity_main.xml | 34 +- app/src/main/res/layout/fragment_about.xml | 715 +++++++++--------- app/src/main/res/layout/fragment_add_item.xml | 26 +- app/src/main/res/layout/fragment_fridge.xml | 27 +- app/src/main/res/layout/fragment_tips.xml | 182 +++-- .../main/res/layout/recycler_view_item.xml | 35 +- app/src/main/res/menu/bottom_nav_menu.xml | 18 +- app/src/main/res/navigation/nav_graph.xml | 12 +- app/src/main/res/values/strings.xml | 45 ++ build.gradle | 6 +- gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 59536 bytes gradle/wrapper/gradle-wrapper.properties | 5 +- gradlew | 257 ++++--- 23 files changed, 798 insertions(+), 641 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/migrations.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8..b589d56 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..0c0c338 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 526b4c2..0897082 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,16 +4,15 @@ diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..7e340a7 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 2a4d5b5..55c0ec2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index cd77b67..7282516 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,12 +5,14 @@ plugins { } android { - compileSdk 31 + + compileSdk 33 + namespace 'dev.dsi.robust' defaultConfig { applicationId "dev.dsi.robust" minSdk 26 - targetSdk 31 + targetSdk 33 versionCode 1 versionName "1.0" @@ -23,10 +25,12 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + buildFeatures { viewBinding true dataBinding true } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -39,6 +43,7 @@ android { kotlinOptions { jvmTarget = '1.8' } + } dependencies { @@ -59,18 +64,23 @@ dependencies { //coroutines implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0' + //lifecycle implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1" + //recyclerview implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation "androidx.recyclerview:recyclerview-selection:1.2.0-alpha01" + //room def room_version = "2.4.2" implementation "androidx.room:room-runtime:$room_version" kapt "androidx.room:room-compiler:$room_version" + // optional - Kotlin Extensions and Coroutines support for Room implementation "androidx.room:room-ktx:$room_version" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + //lottie implementation "com.airbnb.android:lottie:4.2.2" } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d180b52..759f870 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + + + @@ -21,6 +22,7 @@ + \ No newline at end of file diff --git a/app/src/main/java/dev/dsi/robust/MainActivity.kt b/app/src/main/java/dev/dsi/robust/MainActivity.kt index 37d8f87..a4f1767 100644 --- a/app/src/main/java/dev/dsi/robust/MainActivity.kt +++ b/app/src/main/java/dev/dsi/robust/MainActivity.kt @@ -3,21 +3,27 @@ package dev.dsi.robust import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View +import androidx.navigation.NavController import androidx.navigation.findNavController +import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.setupWithNavController import dev.dsi.robust.databinding.ActivityMainBinding class MainActivity : AppCompatActivity() { + private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - binding = ActivityMainBinding.inflate(layoutInflater) - val view = binding.root - setContentView(view) - val navHost = findViewById(R.id.navHostFragment) - binding.bottomNav.setupWithNavController(navHost.findNavController()) + setContentView(binding.root) + + val navHost = supportFragmentManager + .findFragmentById(binding.navHostFragment.id) as NavHostFragment + + val navController: NavController = navHost.navController + + binding.bottomNav.setupWithNavController(navController) } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 516d924..8e3c967 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,37 +1,35 @@ - - - - - - + android:layout_height="0dp" + app:defaultNavHost="true" + app:layout_constraintBottom_toTopOf="@+id/bottomNav" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:navGraph="@navigation/nav_graph" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 4476441..9fe7365 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -1,466 +1,465 @@ - - - - - - - - - - - - - //Madhur - - - + android:layout_height="wrap_content"> - + + + + + + + + + - - - - - + android:layout_marginStart="16dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="16dp"> + + + android:layout_marginStart="16dp" + android:orientation="vertical"> + + -