Skip to content

Commit

Permalink
Robust: Revamp application layouts (danascape#4)
Browse files Browse the repository at this point in the history
* Fixed issue (danascape#3) - findViewById used instead of binding in MainActivity. Also did some code sanitization and cleanup
  • Loading branch information
rajitdeb authored Oct 14, 2023
1 parent e3d7e4a commit 944ecfc
Show file tree
Hide file tree
Showing 23 changed files with 799 additions and 644 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -39,6 +43,7 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}

}

dependencies {
Expand All @@ -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"
}
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.dsi.robust">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand All @@ -9,9 +8,11 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Robust">

<activity
android:name=".MainActivity"
android:exported="false" />

<activity
android:name=".SplashActivity"
android:exported="true">
Expand All @@ -21,6 +22,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>
20 changes: 12 additions & 8 deletions app/src/main/java/dev/dsi/robust/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
package dev.dsi.robust

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.navigation.findNavController
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
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<View>(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)

}
}
34 changes: 16 additions & 18 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity">

<FrameLayout
android:id="@+id/frameLayout"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/navHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottomNav">

<fragment
android:id="@+id/navHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_graph" />

</FrameLayout>
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" />

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNav"
style="@style/Widget.App.BottomNavigationView"
style="@style/Widget.Design.BottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:backgroundTint="@color/white"
app:itemIconTint="@color/black"
app:itemRippleColor="@color/material_blue"
app:itemTextColor="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_nav_menu" />

</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 944ecfc

Please sign in to comment.