Skip to content

Instantly share code, notes, and snippets.

@TheDancerCodes
TheDancerCodes / pepk command
Created May 15, 2023 19:32
Use the command below to run the tool, which will export and encrypt your private key and its public certificate.
# Ensure that you replace the arguments. Then enter your store and key passwords when prompted.
java -jar pepk.jar --keystore=foo.keystore --alias=foo --output=output.zip --encryptionkey=xxx --include-cert
@TheDancerCodes
TheDancerCodes / Fastfile.rb
Last active April 20, 2023 20:54
This is the Fastfile containing the lane that deploys to Huawei AppGallery Connect
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
desc "Deploy a new build to Huawei App Gallery"
lane :deploy_huawei_app_gallery do
huawei_appgallery_connect(
fun computeTipAndTotal() {
// 10 - Conditional check to fix java.lang.NumberFormatException: empty String crash,
// when edit text is empty.
if (billEditText.text.isEmpty()) {
// 10b) Update values of tip and total to empty & return here
tvTipAmount.text = "$INITIAL_EMPTY_VALUE"
tvTotalAmount.text = "$INITIAL_EMPTY_VALUE"
return // This ensures the logic in 7b isn't run. 👍
billEditText.addTextChangedListener(object : TextWatcher {
// Called after the user has changed some text
override fun afterTextChanged(editable: Editable?) {
// Log statement to verify the functionality of this method.
// Log the method name and the value (What the user has been typing).
Log.i(TAG, "afterTextChanged $editable")
computeTipAndTotal()
tipSeekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(p0: SeekBar?, progress: Int, p2: Boolean) {
// 2. Print out the int value of progress that is coming through.
Log.i(TAG, "onProgressChanged $progress")
// 3. Update value of the tip as we interact with the SeekBar
// Kotlin - replace this with the actual integer progress and append %
// Convert the progress value to a string and concatenate a % symbol after the value
tvTipPercent.text = "$progress%"
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/tvTotalAmount"
<TextView
android:id="@+id/tvTipAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="64dp"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
app:layout_constraintBaseline_toBaselineOf="@+id/tvTipLabel"
app:layout_constraintStart_toEndOf="@+id/tvTipLabel"
tools:text="4.50" />
<TextView
android:id="@+id/tvTipLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Tip:"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@+id/tvTotalAmount"
app:layout_constraintTop_toBottomOf="@+id/tvTotalLabel" />
<TextView
android:id="@+id/tvTotalLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/avenir_bold"
android:text="@string/total_amount"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@+id/tvTotalAmount"
<TextView
android:id="@+id/tvTotalAmount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="32dp"
android:textAppearance="@style/TextAppearance.AppCompat.Display4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"