Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK configs | setup, AGP upgrade & dependencies update #17

Merged
merged 17 commits into from
Apr 3, 2023
Merged
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.2.0'
kotlinCompilerExtensionVersion "$compose_compiler"
}
packagingOptions {
resources {
Expand All @@ -53,11 +53,11 @@ dependencies {

// other dependencies
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-alpha11'
implementation 'androidx.compose.material3:material3:1.0.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
Expand Down
41 changes: 35 additions & 6 deletions app/src/main/java/com/rocqjones/mesdk/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.rocqjones.me_design.screens.ListActivity
import com.rocqjones.me_design.screens.bottomNavAdaptive.AdaptiveNavActivity
import com.rocqjones.me_design.ui.theme.MeSDKTheme

/**
Expand All @@ -33,18 +34,29 @@ class MainActivity : ComponentActivity() {
color = MaterialTheme.colorScheme.background
) {
FirstScreen(
onMoveToListClicked = { navigateToList() }
onMoveToListClicked = { navigateToList() },
onMoveToNavClicked = { navigateToAdaptiveUI() }
)
}
}
}
}

private fun navigateToAdaptiveUI() {
try {
val b = Intent(this, AdaptiveNavActivity::class.java)
b.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(b)
} catch (e: Exception) {
e.printStackTrace()
}
}

private fun navigateToList() {
try {
val i = Intent(this, ListActivity::class.java)
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(i)
val a = Intent(this, ListActivity::class.java)
a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(a)
} catch (e: Exception) {
e.printStackTrace()
}
Expand All @@ -54,6 +66,7 @@ class MainActivity : ComponentActivity() {
@Composable
fun FirstScreen(
onMoveToListClicked: () -> Unit,
onMoveToNavClicked: () -> Unit,
modifier: Modifier = Modifier
) {
/**
Expand All @@ -64,12 +77,13 @@ fun FirstScreen(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
val padding = 24.dp
val padding = 8.dp
Text(
"Welcome to the Me SDK!",
style = MaterialTheme.typography.headlineMedium,
color =MaterialTheme.colorScheme.secondary,
)
// list
Button(
modifier = Modifier.padding(padding).fillMaxWidth(),
shape = MaterialTheme.shapes.medium,
Expand All @@ -80,6 +94,18 @@ fun FirstScreen(
style = MaterialTheme.typography.bodyLarge
)
}

// Adaptive Navigation
Button(
modifier = Modifier.padding(padding).fillMaxWidth(),
shape = MaterialTheme.shapes.medium,
onClick = onMoveToNavClicked // sets the sate to true
) {
Text(
"Adaptive Navigation",
style = MaterialTheme.typography.bodyLarge
)
}
}
}

Expand All @@ -97,6 +123,9 @@ fun FirstScreen(
@Composable
fun DefaultPreview() {
MeSDKTheme {
FirstScreen(onMoveToListClicked = {}) // empty lambda expression means "Do nothing" on click
FirstScreen(
onMoveToListClicked = {},
onMoveToNavClicked = {}
) // empty lambda expression means "Do nothing" on click
}
}
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
buildscript {
ext {
compose_version = '1.2.0'
compose_version = '1.4.0' // compose.runtime
compose_compiler = '1.4.4' // Release: https://developer.android.com/jetpack/androidx/releases/compose-kotlin
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
}
17 changes: 12 additions & 5 deletions me-design/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}

Expand All @@ -27,18 +26,23 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
compose true
}

composeOptions {
kotlinCompilerExtensionVersion '1.2.0'
// Release: https://developer.android.com/jetpack/androidx/releases/compose-kotlin
kotlinCompilerExtensionVersion "$compose_compiler"
}
packagingOptions {
resources {
Expand All @@ -51,19 +55,22 @@ dependencies {
// Me Android SDK - logic
implementation project(":me-logic")

implementation 'androidx.core:core-ktx:1.9.0'

// other dependencies
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-alpha11'
implementation 'androidx.compose.material3:material3:1.0.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
Expand Down
10 changes: 10 additions & 0 deletions me-design/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity
android:name=".screens.bottomNavAdaptive.AdaptiveNavActivity"
android:exported="false"
android:label="@string/title_activity_adaptive_nav"
android:theme="@style/Theme.MeSDK" />
<activity
android:name=".screens.ListActivity"
android:exported="false"
android:label="@string/title_activity_list"
android:theme="@style/Theme.MeSDK" />
<activity
android:name=".base.BaseActivity"
android:exported="false"
android:label="@string/title_base_activity"
android:theme="@style/Theme.MeSDK" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.rocqjones.me_design.base

import android.app.Activity
import android.os.Bundle
import androidx.activity.ComponentActivity
import com.rocqjones.me_logic.utils.ToastUtils

/**
* This will be the base class of our Design library where we'll be defining all our common behaviour used across our Activities.
* We can have a lot more abstract methods, for every bit we want specific to our subclasses.
* Example Usage: 'CustomToastUtils' demonstrates this well
*/
abstract class BaseActivity : ComponentActivity() {

private var activityContext: Activity? = null
var toastUtils: ToastUtils? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initialize()
}

private fun initialize() {
try {
activityContext = activityContext()
toastUtils = ToastUtils(activityContext!!)
} catch (e: Exception) {
e.printStackTrace()
}
}

protected abstract fun activityContext(): Activity
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ fun GenerateLazyList(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ItemCard(name: String) {
Card(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.rocqjones.me_design.screens.bottomNavAdaptive

import android.app.Activity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.rocqjones.me_design.base.BaseActivity
import com.rocqjones.me_design.ui.theme.MeSDKTheme

class AdaptiveNavActivity : BaseActivity() {

override fun activityContext(): Activity {
return this
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MeSDKTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Greeting("Check Android CI & Branch protection")
try {
// Test custom snackBar
toastUtils?.showSnackBar("This screen successfully lunched")
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}


}
}

@Composable
fun Greeting(name: String) {
Text(text = "Test $name!")
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview2() {
MeSDKTheme {
Greeting("Android")
}
}
4 changes: 3 additions & 1 deletion me-design/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<resources>
<string name="show_less">Show less</string>
<string name="show_more">Show more</string>
<string name="title_activity_list">ListActivity</string>
<string name="title_activity_list">List Activity</string>
<string name="title_activity_adaptive_nav">Adaptive Nav Activity</string>
<string name="title_base_activity">Base Activity</string>
</resources>
5 changes: 4 additions & 1 deletion me-logic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}

Expand All @@ -24,10 +23,12 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}
Expand All @@ -37,6 +38,8 @@ dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.9.0'

implementation 'com.google.android.material:material:1.8.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
Loading