-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from CrisisCleanup/onboarding
Onboarding
- Loading branch information
Showing
76 changed files
with
2,717 additions
and
305 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
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
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
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/crisiscleanup/ZxingQrCodeGenerator.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,36 @@ | ||
package com.crisiscleanup | ||
|
||
import android.graphics.Bitmap | ||
import android.graphics.Color | ||
import com.crisiscleanup.core.common.QrCodeGenerator | ||
import com.google.zxing.BarcodeFormat | ||
import com.google.zxing.EncodeHintType | ||
import com.google.zxing.qrcode.QRCodeWriter | ||
import javax.inject.Inject | ||
|
||
class ZxingQrCodeGenerator @Inject constructor() : QrCodeGenerator { | ||
override fun generate(payload: String, size: Int): Bitmap? { | ||
if (payload.isBlank()) { | ||
return null | ||
} | ||
|
||
val writer = QRCodeWriter() | ||
// Removing margin in image should add padding around image display | ||
val hints = mapOf( | ||
EncodeHintType.MARGIN to 0, | ||
) | ||
val bitMatrix = writer.encode(payload, BarcodeFormat.QR_CODE, size, size, hints) | ||
val width = bitMatrix.width | ||
val height = bitMatrix.height | ||
val pixels = IntArray(width * height) | ||
for (h in 0 until height) { | ||
val offset = h * width | ||
for (w in 0 until width) { | ||
pixels[offset + w] = if (bitMatrix.get(w, h)) Color.BLACK else Color.TRANSPARENT | ||
} | ||
} | ||
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) | ||
bitmap.setPixels(pixels, 0, width, 0, 0, width, height) | ||
return bitmap | ||
} | ||
} |
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
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
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
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
26 changes: 26 additions & 0 deletions
26
core/common/src/main/java/com/crisiscleanup/core/common/AppSettingsProvider.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,26 @@ | ||
package com.crisiscleanup.core.common | ||
|
||
import javax.inject.Inject | ||
|
||
interface AppSettingsProvider { | ||
val apiBaseUrl: String | ||
val baseUrl: String | ||
val mapsApiKey: String | ||
|
||
val debugEmail: String | ||
val debugPassword: String | ||
} | ||
|
||
class SecretsAppSettingsProvider @Inject constructor() : AppSettingsProvider { | ||
override val apiBaseUrl: String | ||
get() = BuildConfig.API_BASE_URL | ||
override val baseUrl: String | ||
get() = BuildConfig.BASE_URL | ||
override val mapsApiKey: String | ||
get() = BuildConfig.MAPS_API_KEY | ||
|
||
override val debugEmail: String | ||
get() = BuildConfig.DEBUG_EMAIL_ADDRESS | ||
override val debugPassword: String | ||
get() = BuildConfig.DEBUG_ACCOUNT_PASSWORD | ||
} |
7 changes: 7 additions & 0 deletions
7
core/common/src/main/java/com/crisiscleanup/core/common/QrCodeGenerator.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,7 @@ | ||
package com.crisiscleanup.core.common | ||
|
||
import android.graphics.Bitmap | ||
|
||
interface QrCodeGenerator { | ||
fun generate(payload: String, size: Int = 512): Bitmap? | ||
} |
Oops, something went wrong.