From 4dfa6206ad90829202123ce26adf7cd05fc5922f Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Thu, 3 Feb 2022 22:37:25 +0100 Subject: [PATCH] Experiment: Use Extended Floating Action Buttons --- .../protect/card_locker/LoyaltyCardEditActivity.java | 10 ++++++++-- .../protect/card_locker/LoyaltyCardViewActivity.java | 8 ++++---- .../main/java/protect/card_locker/MainActivity.java | 4 ++-- .../java/protect/card_locker/ManageGroupsActivity.java | 4 ++-- app/src/main/res/layout/activity_manage_group.xml | 7 ++++--- app/src/main/res/layout/loyalty_card_edit_activity.xml | 6 +++--- app/src/main/res/layout/loyalty_card_view_layout.xml | 6 +++--- app/src/main/res/layout/main_activity.xml | 6 +++--- app/src/main/res/layout/manage_groups_activity.xml | 6 +++--- app/src/main/res/values/strings.xml | 6 ++++-- .../card_locker/LoyaltyCardViewActivityTest.java | 6 +++--- 11 files changed, 39 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java index 14c6aaf1c..74d30d87a 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java @@ -37,7 +37,7 @@ import android.widget.Toast; import com.google.android.material.chip.Chip; import com.google.android.material.chip.ChipGroup; import com.google.android.material.color.MaterialColors; -import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import com.google.android.material.snackbar.Snackbar; import com.google.android.material.tabs.TabLayout; import com.jaredrummler.android.colorpicker.ColorPickerDialog; @@ -113,6 +113,8 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity { public static final String BUNDLE_BARCODETYPE = "barcodeType"; public static final String BUNDLE_ADDGROUP = "addGroup"; + ExtendedFloatingActionButton saveButton; + TabLayout tabs; ImageView thumbnail; @@ -894,7 +896,7 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity { cardImageFrontHolder.setOnClickListener(new ChooseCardImage()); cardImageBackHolder.setOnClickListener(new ChooseCardImage()); - FloatingActionButton saveButton = findViewById(R.id.fabSave); + saveButton = findViewById(R.id.fabSave); saveButton.setOnClickListener(v -> doSave()); saveButton.bringToFront(); @@ -1265,6 +1267,10 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity { return; } + // Validation done, save + saveButton.setText(R.string.saving); + saveButton.setIcon(null); + List selectedGroups = new ArrayList<>(); for (Integer chipId : groupsChips.getCheckedChipIds()) { diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index e2654a158..015af9f89 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -33,7 +33,7 @@ import android.widget.Toast; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.bottomsheet.BottomSheetBehavior; -import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import java.io.UnsupportedEncodingException; import java.math.BigDecimal; @@ -96,7 +96,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements String barcodeIdString; CatimaBarcode format; - FloatingActionButton editButton; + ExtendedFloatingActionButton editButton; Guideline centerGuideline; SeekBar barcodeScaler; @@ -578,14 +578,14 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements bottomSheetButton.setColorFilter(textColor); int complementaryColor = Utils.getComplementaryColor(darkenedColor); editButton.setBackgroundTintList(ColorStateList.valueOf(complementaryColor)); - Drawable editButtonIcon = editButton.getDrawable(); + Drawable editButtonIcon = editButton.getIcon(); editButtonIcon.mutate(); if (Utils.needsDarkForeground(complementaryColor)) { editButtonIcon.setTint(ContextCompat.getColor(this, R.color.md_theme_light_onBackground)); } else { editButtonIcon.setTint(ContextCompat.getColor(this, R.color.md_theme_dark_onBackground)); } - editButton.setImageDrawable(editButtonIcon); + editButton.setIcon(editButtonIcon); Bitmap icon = Utils.retrieveCardImage(this, loyaltyCard.id, ImageLocationType.icon); if (icon != null) { diff --git a/app/src/main/java/protect/card_locker/MainActivity.java b/app/src/main/java/protect/card_locker/MainActivity.java index 0f4906d0b..345765a2c 100644 --- a/app/src/main/java/protect/card_locker/MainActivity.java +++ b/app/src/main/java/protect/card_locker/MainActivity.java @@ -30,7 +30,7 @@ import androidx.core.splashscreen.SplashScreen; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.color.DynamicColors; -import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import com.google.android.material.tabs.TabLayout; import java.io.UnsupportedEncodingException; @@ -353,7 +353,7 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard updateLoyaltyCardList(); // End of active tab logic - FloatingActionButton addButton = findViewById(R.id.fabAdd); + ExtendedFloatingActionButton addButton = findViewById(R.id.fabAdd); addButton.setOnClickListener(v -> { Intent intent = new Intent(getApplicationContext(), ScanActivity.class); Bundle bundle = new Bundle(); diff --git a/app/src/main/java/protect/card_locker/ManageGroupsActivity.java b/app/src/main/java/protect/card_locker/ManageGroupsActivity.java index 07b92bd93..24cbe4102 100644 --- a/app/src/main/java/protect/card_locker/ManageGroupsActivity.java +++ b/app/src/main/java/protect/card_locker/ManageGroupsActivity.java @@ -13,7 +13,7 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; -import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import java.util.List; @@ -51,7 +51,7 @@ public class ManageGroupsActivity extends CatimaAppCompatActivity implements Gro protected void onResume() { super.onResume(); - FloatingActionButton addButton = findViewById(R.id.fabAdd); + ExtendedFloatingActionButton addButton = findViewById(R.id.fabAdd); addButton.setOnClickListener(v -> createGroup()); addButton.bringToFront(); diff --git a/app/src/main/res/layout/activity_manage_group.xml b/app/src/main/res/layout/activity_manage_group.xml index 4be42c39d..ffbb1980c 100644 --- a/app/src/main/res/layout/activity_manage_group.xml +++ b/app/src/main/res/layout/activity_manage_group.xml @@ -7,14 +7,15 @@ android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="protect.card_locker.ManageGroupActivity"> - + - - - - Search - Add + Add card %d selected %d selected @@ -18,8 +18,9 @@ Add to favorites Remove from favorites Cancel - Save + Save changes Edit + Edit card Delete Confirm Block Rotation @@ -268,4 +269,5 @@ Options Starred Set scale + Saving... \ No newline at end of file diff --git a/app/src/test/java/protect/card_locker/LoyaltyCardViewActivityTest.java b/app/src/test/java/protect/card_locker/LoyaltyCardViewActivityTest.java index 16829faf7..b8de91789 100644 --- a/app/src/test/java/protect/card_locker/LoyaltyCardViewActivityTest.java +++ b/app/src/test/java/protect/card_locker/LoyaltyCardViewActivityTest.java @@ -28,7 +28,7 @@ import android.widget.LinearLayout; import android.widget.SeekBar; import android.widget.TextView; -import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import com.google.android.material.tabs.TabLayout; import com.google.android.material.textfield.MaterialAutoCompleteTextView; import com.google.android.material.textfield.TextInputLayout; @@ -1218,7 +1218,7 @@ public class LoyaltyCardViewActivityTest { ImageButton maximizeButton = activity.findViewById(R.id.maximizeButton); ImageButton minimizeButton = activity.findViewById(R.id.minimizeButton); LinearLayout dotIndicator = activity.findViewById(R.id.dotIndicator); - FloatingActionButton editButton = activity.findViewById(R.id.fabEdit); + ExtendedFloatingActionButton editButton = activity.findViewById(R.id.fabEdit); SeekBar barcodeScaler = activity.findViewById(R.id.barcodeScaler); // Android should not be in fullscreen mode @@ -1322,7 +1322,7 @@ public class LoyaltyCardViewActivityTest { View bottomSheet = activity.findViewById(R.id.bottom_sheet); ImageButton maximizeButton = activity.findViewById(R.id.maximizeButton); ImageButton minimizeButton = activity.findViewById(R.id.minimizeButton); - FloatingActionButton editButton = activity.findViewById(R.id.fabEdit); + ExtendedFloatingActionButton editButton = activity.findViewById(R.id.fabEdit); SeekBar barcodeScaler = activity.findViewById(R.id.barcodeScaler); // Android should not be in fullscreen mode