Skip to content

Commit

Permalink
Release
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemilla committed Apr 17, 2024
1 parent fe46f80 commit 41172a9
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 197 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencyResolutionManagement {

```gradle
dependencies {
implementation 'com.github.trycourier:courier-android:3.1.6'
implementation 'com.github.trycourier:courier-android:3.1.7'
}
```

Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/courier/android/Courier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Courier private constructor(internal val context: Context) : Application.A
companion object {

var USER_AGENT = CourierAgent.NATIVE_ANDROID
internal const val VERSION = "3.1.6"
internal const val VERSION = "3.1.7"
internal const val TAG = "Courier SDK"
internal const val COURIER_PENDING_NOTIFICATION_KEY = "courier_pending_notification_key"
internal val eventBus by lazy { NotificationEventBus() }
Expand Down
54 changes: 54 additions & 0 deletions android/src/main/java/com/courier/android/ui/bar/CourierBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.courier.android.ui.bar

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import androidx.core.view.isVisible
import com.courier.android.R
import com.courier.android.models.CourierBrand
import com.courier.android.utils.launchCourierWebsite

class CourierBar @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : FrameLayout(context, attrs, defStyleAttr) {

private lateinit var courierBarButton: ImageView

init {
View.inflate(context, R.layout.courier_bar, this)
setup()
}

private fun setup() {
courierBarButton = findViewById(R.id.courierBarButton)
courierBarButton.setOnClickListener { openDialog() }
}

private fun openDialog() {

AlertDialog.Builder(context).apply {

setTitle("Learn more about Courier?")

setNegativeButton("Cancel") { _, _ ->
// Empty
}

setPositiveButton("Learn More") { _, _ ->
context.launchCourierWebsite()
}

show()

}

}

fun setBrand(brand: CourierBrand?) {
brand?.let {
isVisible = it.settings?.inapp?.showCourierFooter ?: true
}
}

}
55 changes: 13 additions & 42 deletions android/src/main/java/com/courier/android/ui/inbox/CourierInbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ import android.content.res.ColorStateList
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.LinearLayoutManager
Expand All @@ -32,12 +28,12 @@ import com.courier.android.modules.clientKey
import com.courier.android.modules.refreshInbox
import com.courier.android.modules.userId
import com.courier.android.repositories.InboxRepository
import com.courier.android.ui.CourierActionButton
import com.courier.android.ui.bar.CourierBar
import com.courier.android.ui.infoview.CourierInfoView
import com.courier.android.ui.preferences.inbox.LoadingAdapter
import com.courier.android.utils.isDarkMode
import com.courier.android.utils.launchCourierWebsite
import com.courier.android.utils.pxToDp
import com.courier.android.utils.setCourierFont
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
Expand All @@ -61,19 +57,19 @@ class CourierInbox @JvmOverloads constructor(context: Context, attrs: AttributeS
State.ERROR -> {
refreshLayout.isVisible = false
infoView.isVisible = true
detailTextView.text = field.title
infoView.setTitle(field.title)
loadingIndicator.isVisible = false
}
State.CONTENT -> {
refreshLayout.isVisible = true
infoView.isVisible = false
detailTextView.text = null
infoView.setTitle(null)
loadingIndicator.isVisible = false
}
State.EMPTY -> {
refreshLayout.isVisible = false
infoView.isVisible = true
detailTextView.text = field.title
infoView.setTitle(field.title)
loadingIndicator.isVisible = false
}
}
Expand Down Expand Up @@ -129,34 +125,18 @@ class CourierInbox @JvmOverloads constructor(context: Context, attrs: AttributeS
recyclerView.addItemDecoration(it)
}

// Empty / Error view
detailTextView.setCourierFont(
font = theme.infoViewStyle.font
)

// Button
retryButton.apply {

setStyle(
style = theme.infoViewStyle.button
)

text = "Retry"
onClick = {
state = State.LOADING
refresh()
}

infoView.setTheme(theme)
infoView.onRetry = {
state = State.LOADING
refresh()
}

// Loading
theme.getLoadingColor()?.let {
loadingIndicator.indeterminateTintList = ColorStateList.valueOf(it)
}

// Handle bar visibility
val showBar = theme.brand?.settings?.inapp?.showCourierFooter ?: true
courierBar.isVisible = showBar
// Handle bar brand
courierBar.setBrand(theme.brand)

}

Expand All @@ -166,11 +146,8 @@ class CourierInbox @JvmOverloads constructor(context: Context, attrs: AttributeS
private val layoutManager get() = recyclerView.layoutManager as? LinearLayoutManager

private lateinit var refreshLayout: SwipeRefreshLayout
private lateinit var infoView: LinearLayoutCompat
private lateinit var detailTextView: TextView
private lateinit var retryButton: CourierActionButton
private lateinit var courierBar: RelativeLayout
private lateinit var courierBarButton: ImageView
private lateinit var infoView: CourierInfoView
private lateinit var courierBar: CourierBar
private lateinit var loadingIndicator: ProgressBar

private lateinit var inboxListener: CourierInboxListener
Expand Down Expand Up @@ -239,14 +216,8 @@ class CourierInbox @JvmOverloads constructor(context: Context, attrs: AttributeS
// Loading
loadingIndicator = findViewById(R.id.loadingIndicator)

// Courier Bar Button
courierBarButton = findViewById(R.id.courierBarButton)
courierBarButton.setOnClickListener { openDialog() }

// Info View
infoView = findViewById(R.id.infoView)
detailTextView = findViewById(R.id.detailTextView)
retryButton = findViewById(R.id.retryButton)

// Courier Bar
courierBar = findViewById(R.id.courierBar)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.courier.android.ui.infoview

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
import com.courier.android.R
import com.courier.android.ui.CourierActionButton
import com.courier.android.ui.inbox.CourierInboxTheme
import com.courier.android.ui.preferences.CourierPreferencesTheme
import com.courier.android.utils.setCourierFont

class CourierInfoView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : FrameLayout(context, attrs, defStyleAttr) {

private lateinit var titleTextView: TextView
private lateinit var retryButton: CourierActionButton

internal var onRetry: (() -> Unit)? = null

init {
View.inflate(context, R.layout.courier_info_view, this)
setup()
}

private fun setup() {
titleTextView = findViewById(R.id.titleTextView)
retryButton = findViewById(R.id.retryButton)
}

fun setTitle(title: String?) {
titleTextView.text = title
}

fun setTheme(theme: CourierInboxTheme) {

titleTextView.setCourierFont(
font = theme.infoViewStyle.font
)

retryButton.apply {

setStyle(
style = theme.infoViewStyle.button
)

text = "Retry"
onClick = onRetry

}

}

fun setTheme(theme: CourierPreferencesTheme) {

titleTextView.setCourierFont(
font = theme.infoViewStyle.font
)

retryButton.apply {

setStyle(
style = theme.infoViewStyle.button
)

text = "Retry"
onClick = onRetry

}

}

}
Loading

0 comments on commit 41172a9

Please sign in to comment.