-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Support ldMask() for Native and Compose views. #295
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c7737c4
Fruta xml
abelonogov-ld 1c35019
Rotate user address
abelonogov-ld 4f6a6f9
XML Credit Card Editor
abelonogov-ld e7cab04
ldMask for Compose and XML views
abelonogov-ld 7b48b46
delete artifacts
abelonogov-ld 1e78c1c
Code clean up
abelonogov-ld f9008c1
Some renaming
abelonogov-ld 917929a
Small to check only ldMask flag
abelonogov-ld 89596e6
renaming file
abelonogov-ld 63d9734
missed
abelonogov-ld e162025
fix child extending beyond parent view case
abelonogov-ld 148e72c
Merge branch 'main' into andrey/xml-views-ldmask
abelonogov-ld f04c7eb
Merge branch 'main' into andrey/xml-views-ldmask
abelonogov-ld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+88 KB
e2e/android/app/src/main/assets/smoothie/images/love-you-berry-much.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+69.5 KB
e2e/android/app/src/main/assets/smoothie/images/peanut-butter-cup.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+93 KB
e2e/android/app/src/main/assets/smoothie/images/thats-berry-bananas.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions
75
e2e/android/app/src/main/java/com/example/androidobservability/CreditCardActivity.kt
This file contains hidden or 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,75 @@ | ||
| package com.example.androidobservability | ||
|
|
||
| import android.os.Bundle | ||
| import android.widget.Button | ||
| import android.widget.EditText | ||
| import android.widget.Toast | ||
| import androidx.activity.ComponentActivity | ||
|
|
||
| class CreditCardActivity : ComponentActivity() { | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_credit_card) | ||
|
|
||
| val inputCardholderName = findViewById<EditText>(R.id.input_cardholder_name) | ||
| val inputCardNumber = findViewById<EditText>(R.id.input_card_number) | ||
| val inputExpiry = findViewById<EditText>(R.id.input_expiry) | ||
| val inputCvv = findViewById<EditText>(R.id.input_cvv) | ||
| val inputZip = findViewById<EditText>(R.id.input_zip_code) | ||
| val buttonSave = findViewById<Button>(R.id.button_save_card) | ||
|
|
||
| buttonSave.setOnClickListener { | ||
| val name = inputCardholderName.text?.toString()?.trim().orEmpty() | ||
| val number = inputCardNumber.text?.toString()?.replace(" ", "")?.trim().orEmpty() | ||
| val expiry = inputExpiry.text?.toString()?.trim().orEmpty() | ||
| val cvv = inputCvv.text?.toString()?.trim().orEmpty() | ||
| val zip = inputZip.text?.toString()?.trim().orEmpty() | ||
|
|
||
| var isValid = true | ||
|
|
||
| if (name.isEmpty()) { | ||
| inputCardholderName.error = "Cardholder name is required" | ||
| isValid = false | ||
| } else { | ||
| inputCardholderName.error = null | ||
| } | ||
|
|
||
| if (number.length !in 13..19 || number.any { !it.isDigit() }) { | ||
| inputCardNumber.error = "Enter a valid card number" | ||
| isValid = false | ||
| } else { | ||
| inputCardNumber.error = null | ||
| } | ||
|
|
||
| val expiryRegex = Regex("""^(0[1-9]|1[0-2])/\d{2}$""") | ||
| if (!expiryRegex.matches(expiry)) { | ||
| inputExpiry.error = "Use MM/YY" | ||
| isValid = false | ||
| } else { | ||
| inputExpiry.error = null | ||
| } | ||
|
|
||
| if (cvv.length !in 3..4 || cvv.any { !it.isDigit() }) { | ||
| inputCvv.error = "Enter a valid CVV" | ||
| isValid = false | ||
| } else { | ||
| inputCvv.error = null | ||
| } | ||
|
|
||
| if (zip.isEmpty() || zip.length < 3 || zip.length > 10) { | ||
| inputZip.error = "Enter a valid ZIP/Postal code" | ||
| isValid = false | ||
| } else { | ||
| inputZip.error = null | ||
| } | ||
|
|
||
| if (isValid) { | ||
| Toast.makeText(this, "Card saved", Toast.LENGTH_SHORT).show() | ||
| finish() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -69,6 +69,30 @@ class MainActivity : ComponentActivity() { | |
| ) { | ||
| Text("Go to Secondary Activity") | ||
| } | ||
| Button( | ||
| onClick = { | ||
| [email protected]( | ||
| Intent( | ||
| this@MainActivity, | ||
| CreditCardActivity::class.java | ||
| ) | ||
| ) | ||
| } | ||
| ) { | ||
| Text("Open Credit Card (XML)") | ||
| } | ||
| Button( | ||
| onClick = { | ||
| [email protected]( | ||
| Intent( | ||
| this@MainActivity, | ||
| com.smoothie.SmoothieListActivity::class.java | ||
| ) | ||
| ) | ||
| } | ||
| ) { | ||
| Text("Open Fruta (XML)") | ||
| } | ||
| Button( | ||
| onClick = { | ||
| viewModel.triggerHttpRequests() | ||
|
|
||
This file contains hidden or 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
49 changes: 49 additions & 0 deletions
49
e2e/android/app/src/main/java/com/smoothie/SmoothieAdapter.kt
This file contains hidden or 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,49 @@ | ||
| package com.smoothie | ||
|
|
||
| import android.graphics.Bitmap | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import android.widget.ImageView | ||
| import android.widget.TextView | ||
| import androidx.recyclerview.widget.RecyclerView | ||
| import com.example.androidobservability.R | ||
| import com.launchdarkly.observability.api.ldMask | ||
|
|
||
| data class SmoothieItem( | ||
| val title: String, | ||
| val imageFileName: String | ||
| ) | ||
|
|
||
| class SmoothieAdapter( | ||
| private val smoothies: List<SmoothieItem>, | ||
| private val imageLoader: (String) -> Bitmap? | ||
| ) : RecyclerView.Adapter<SmoothieAdapter.ViewHolder>() { | ||
|
|
||
| class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
| val imageView: ImageView = itemView.findViewById(R.id.smoothieImage) | ||
| init { | ||
| imageView.ldMask() | ||
| } | ||
| val titleView: TextView = itemView.findViewById(R.id.smoothieTitle) | ||
| } | ||
|
|
||
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
| val view = LayoutInflater.from(parent.context).inflate(R.layout.item_smoothie, parent, false) | ||
| return ViewHolder(view) | ||
| } | ||
|
|
||
| override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
| val item = smoothies[position] | ||
| holder.titleView.text = item.title | ||
| val bitmap = imageLoader(item.imageFileName) | ||
| if (bitmap != null) { | ||
| holder.imageView.setImageBitmap(bitmap) | ||
| } else { | ||
| holder.imageView.setImageResource(R.mipmap.ic_launcher) | ||
| } | ||
| } | ||
|
|
||
| override fun getItemCount(): Int = smoothies.size | ||
| } | ||
|
|
||
48 changes: 48 additions & 0 deletions
48
e2e/android/app/src/main/java/com/smoothie/SmoothieListActivity.kt
This file contains hidden or 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,48 @@ | ||
| package com.smoothie | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| import android.graphics.BitmapFactory | ||
| import android.os.Bundle | ||
| import android.app.Activity | ||
| import androidx.recyclerview.widget.LinearLayoutManager | ||
| import androidx.recyclerview.widget.RecyclerView | ||
| import com.example.androidobservability.R | ||
|
|
||
| class SmoothieListActivity : Activity() { | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_smoothie_list) | ||
|
|
||
| val recyclerView = findViewById<RecyclerView>(R.id.recyclerView) | ||
| recyclerView.layoutManager = LinearLayoutManager(this) | ||
| recyclerView.adapter = SmoothieAdapter( | ||
| smoothies = buildSmoothies(), | ||
| imageLoader = { fileName -> | ||
| assets.open("smoothie/images/$fileName").use { input -> | ||
| BitmapFactory.decodeStream(input) | ||
| } | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| private fun buildSmoothies(): List<SmoothieItem> { | ||
| return listOf( | ||
| SmoothieItem("Berry Blue", "berry-blue.jpg"), | ||
| SmoothieItem("Carrot Chops", "carrot-chops.jpg"), | ||
| SmoothieItem("Hulking Lemonade", "hulking-lemonade.jpg"), | ||
| SmoothieItem("Kiwi Cutie", "kiwi-cutie.jpg"), | ||
| SmoothieItem("Lemonberry", "lemonberry.jpg"), | ||
| SmoothieItem("Love You Berry Much", "love-you-berry-much.jpg"), | ||
| SmoothieItem("Mango Jambo", "mango-jambo.jpg"), | ||
| SmoothieItem("One in a Melon", "one-in-a-melon.jpg"), | ||
| SmoothieItem("Papa's Papaya", "papas-papaya.jpg"), | ||
| SmoothieItem("Peanut Butter Cup", "peanut-butter-cup.jpg"), | ||
| SmoothieItem("Piña y Coco", "pina-y-coco.jpg"), | ||
| SmoothieItem("Sailor Man", "sailor-man.jpg"), | ||
| SmoothieItem("That's a S'more", "thats-a-smore.jpg"), | ||
| SmoothieItem("That's Berry Bananas", "thats-berry-bananas.jpg"), | ||
| SmoothieItem("Tropical Blue", "tropical-blue.jpg") | ||
| ) | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package should be inside
com.example.androidobservability(The whole code of the app goes there - unless you use different modules, which is not the case)