mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-05-13 19:16:47 -04:00
Make bottom sheet button tapable and add group info
This commit is contained in:
@@ -32,6 +32,8 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import protect.card_locker.preferences.Settings;
|
||||
|
||||
public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
@@ -40,7 +42,9 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
|
||||
TextView cardIdFieldView;
|
||||
View bottomSheet;
|
||||
ImageView bottomSheetButton;
|
||||
TextView noteView;
|
||||
TextView groupsView;
|
||||
TextView storeName;
|
||||
ImageView barcodeImage;
|
||||
View collapsingToolbarLayout;
|
||||
@@ -106,7 +110,9 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
|
||||
cardIdFieldView = findViewById(R.id.cardIdView);
|
||||
bottomSheet = findViewById(R.id.bottom_sheet);
|
||||
bottomSheetButton = findViewById(R.id.bottomSheetButton);
|
||||
noteView = findViewById(R.id.noteView);
|
||||
groupsView = findViewById(R.id.groupsView);
|
||||
storeName = findViewById(R.id.storeName);
|
||||
barcodeImage = findViewById(R.id.barcode);
|
||||
collapsingToolbarLayout = findViewById(R.id.collapsingToolbarLayout);
|
||||
@@ -142,20 +148,39 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
}
|
||||
});
|
||||
|
||||
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
|
||||
final BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
|
||||
behavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
||||
if (newState == BottomSheetBehavior.STATE_COLLAPSED || newState == BottomSheetBehavior.STATE_HIDDEN) {
|
||||
editButton.show();
|
||||
} else {
|
||||
editButton.hide();
|
||||
switch (newState) {
|
||||
case BottomSheetBehavior.STATE_COLLAPSED:
|
||||
bottomSheetButton.setImageResource(R.drawable.ic_baseline_arrow_drop_up_24);
|
||||
editButton.show();
|
||||
break;
|
||||
case BottomSheetBehavior.STATE_EXPANDED:
|
||||
bottomSheetButton.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24);
|
||||
editButton.hide();
|
||||
break;
|
||||
case BottomSheetBehavior.STATE_HIDDEN:
|
||||
editButton.show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide(@NonNull View bottomSheet, float slideOffset) { }
|
||||
});
|
||||
|
||||
bottomSheetButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (behavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
} else {
|
||||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,11 +239,33 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
|
||||
if(loyaltyCard.note.length() > 0)
|
||||
{
|
||||
bottomSheet.setVisibility(View.VISIBLE);
|
||||
noteView.setVisibility(View.VISIBLE);
|
||||
noteView.setText(loyaltyCard.note);
|
||||
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(noteView,
|
||||
getResources().getInteger(R.integer.settings_card_note_min_font_size_sp)-1,
|
||||
settings.getCardNoteFontSize(), 1, TypedValue.COMPLEX_UNIT_SP);
|
||||
}
|
||||
else
|
||||
{
|
||||
noteView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
List<Group> loyaltyCardGroups = db.getLoyaltyCardGroups(loyaltyCardId);
|
||||
|
||||
if(loyaltyCardGroups.size() > 0) {
|
||||
StringBuilder groupsString = new StringBuilder();
|
||||
for (Group group : loyaltyCardGroups) {
|
||||
groupsString.append(group._id);
|
||||
groupsString.append(" ");
|
||||
}
|
||||
|
||||
groupsView.setVisibility(View.VISIBLE);
|
||||
groupsView.setText(getString(R.string.groupsList, groupsString.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
groupsView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (noteView.getVisibility() == View.VISIBLE || groupsView.getVisibility() == View.VISIBLE) {
|
||||
bottomSheet.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -81,11 +81,6 @@ public class Settings
|
||||
return getInt(R.string.settings_key_card_id_font_size, R.integer.settings_card_id_font_size_sp);
|
||||
}
|
||||
|
||||
public int getCardNoteFontSize()
|
||||
{
|
||||
return getInt(R.string.settings_key_card_note_font_size, R.integer.settings_card_note_font_size_sp);
|
||||
}
|
||||
|
||||
public boolean useMaxBrightnessDisplayingBarcode()
|
||||
{
|
||||
return getBoolean(R.string.settings_key_display_barcode_max_brightness, true);
|
||||
|
||||
@@ -87,19 +87,31 @@
|
||||
app:behavior_peekHeight="80dp"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
<TextView
|
||||
<ImageButton
|
||||
android:id="@+id/bottomSheetButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:background="@color/colorPrimary"
|
||||
android:gravity="center"
|
||||
android:text="@string/pullUpForMoreInfo"
|
||||
android:textColor="@android:color/white" />
|
||||
android:src="@drawable/ic_baseline_arrow_drop_up_24"
|
||||
android:tint="@android:color/white" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noteView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:padding="20dp"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:autoSizeMinTextSize="@dimen/singleCardNoteTextSizeMin"
|
||||
app:autoSizeMaxTextSize="@dimen/singleCardNoteTextSizeMax" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/groupsView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:padding="20dp"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:autoSizeMinTextSize="@dimen/singleCardNoteTextSizeMin"
|
||||
app:autoSizeMaxTextSize="@dimen/singleCardNoteTextSizeMax" />
|
||||
|
||||
@@ -106,5 +106,4 @@
|
||||
<item quantity="one"><xliff:g xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">%d</xliff:g> carte</item>
|
||||
<item quantity="other"><xliff:g xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">%d</xliff:g> cartes</item>
|
||||
</plurals>
|
||||
<string name="pullUpForMoreInfo">Tirez pour plus d\'informations</string>
|
||||
</resources>
|
||||
@@ -28,7 +28,6 @@
|
||||
<integer name="settings_card_note_list_font_size_sp">14</integer>
|
||||
<integer name="settings_card_title_font_size_sp">40</integer>
|
||||
<integer name="settings_card_id_font_size_sp">50</integer>
|
||||
<integer name="settings_card_note_font_size_sp">50</integer>
|
||||
|
||||
<!-- Constraints -->
|
||||
<integer name="settings_card_title_list_max_font_size_sp">40</integer>
|
||||
@@ -39,6 +38,4 @@
|
||||
<integer name="settings_card_title_min_font_size_sp">16</integer>
|
||||
<integer name="settings_card_id_max_font_size_sp">50</integer>
|
||||
<integer name="settings_card_id_min_font_size_sp">16</integer>
|
||||
<integer name="settings_card_note_max_font_size_sp">50</integer>
|
||||
<integer name="settings_card_note_min_font_size_sp">26</integer>
|
||||
</resources>
|
||||
@@ -138,5 +138,5 @@
|
||||
<string name="leaveWithoutSaveConfirmation">Are you sure you want to leave this screen? Changed made will not be saved.</string>
|
||||
<string name="addWithCamera">Scan the barcode with your camera</string>
|
||||
<string name="addManually">Manually enter card ID</string>
|
||||
<string name="pullUpForMoreInfo">Pull up for more info</string>
|
||||
<string name="groupsList">Groups: <xliff:g>%s</xliff:g></string>
|
||||
</resources>
|
||||
|
||||
@@ -41,13 +41,6 @@
|
||||
app:vnt_maxValue="@integer/settings_card_id_max_font_size_sp"
|
||||
app:vnt_minValue="@integer/settings_card_id_min_font_size_sp" />
|
||||
|
||||
<com.vanniktech.vntnumberpickerpreference.VNTNumberPickerPreference
|
||||
android:key="@string/settings_key_card_note_font_size"
|
||||
android:title="@string/settings_card_note_font_size"
|
||||
android:defaultValue="@integer/settings_card_note_font_size_sp"
|
||||
app:vnt_maxValue="@integer/settings_card_note_max_font_size_sp"
|
||||
app:vnt_minValue="@integer/settings_card_note_min_font_size_sp" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/settings_key_display_barcode_max_brightness"
|
||||
|
||||
Reference in New Issue
Block a user