-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
231 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
android/src/main/java/com/courier/android/ui/bar/CourierBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
android/src/main/java/com/courier/android/ui/infoview/CourierInfoView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.