Skip to content

Commit

Permalink
Merge pull request #17643 from osmandapp/1822-free_account_fix_ui
Browse files Browse the repository at this point in the history
#1822: Fixed ui for free account
  • Loading branch information
Chumva committed Jul 18, 2023
2 parents c3dbb4b + 9a5315b commit babf216
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
24 changes: 16 additions & 8 deletions OsmAnd/res/layout/free_backup_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
android:layout_marginTop="@dimen/content_padding"
android:background="?attr/bg_color"
android:orientation="horizontal"
android:paddingStart="@dimen/content_padding">
android:paddingStart="@dimen/content_padding"
>

<ImageView
android:id="@+id/icon"
Expand All @@ -20,6 +21,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/content_padding"
android:orientation="vertical">

<LinearLayout
Expand Down Expand Up @@ -50,7 +52,7 @@
android:layout_marginTop="@dimen/content_padding_small_half"
android:text="@string/free_favorites_backup_description"
android:textColor="?android:textColorSecondary"
android:textSize="16sp" />
android:textSize="@dimen/default_desc_text_size" />
</LinearLayout>

<ImageButton
Expand All @@ -59,18 +61,24 @@
android:layout_height="@dimen/acceptable_touch_radius"
android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginRight="@dimen/content_padding_small"
android:contentDescription="shared_string_close"
android:background="@null"
android:contentDescription="@string/shared_string_close"
osmand:srcCompat="@drawable/ic_action_cancel" />

</LinearLayout>

<include
android:id="@+id/dismiss_button"
layout="@layout/bottom_sheet_dialog_button"
<net.osmand.plus.widgets.dialogbutton.DialogButton
android:id="@+id/dismiss_button_container"
android:layout_width="match_parent"
android:layout_height="@dimen/dialog_button_height"
android:layout_height="wrap_content"
osmand:dialogButtonType="secondaryActive"
osmand:dialogButtonTouchableHeight="@dimen/bottom_sheet_list_item_height"
osmand:dialogButtonTopMargin="@dimen/content_padding_small"
osmand:dialogButtonHeight="@dimen/dialog_button_height"
osmand:dialogButtonTitle="@string/get_osmand_cloud"
android:layout_margin="@dimen/content_padding"
android:layout_weight="0" />
android:layout_marginBottom="@dimen/content_padding"
android:layout_weight="0"/>

</LinearLayout>

Expand Down
9 changes: 4 additions & 5 deletions OsmAnd/src/net/osmand/plus/backup/ui/BackupTypesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,18 @@ public View getChildView(int groupPosition, int childPosition, boolean isLastChi
UiUtilities.setupCompoundButton(compoundButton, nightMode, CompoundButtonType.GLOBAL);

ImageView proIcon = view.findViewById(R.id.pro_icon);
setupChildIcon(view, type.getIconRes(), selected && type.isAllowedInFreeVersion());
boolean proAvailable = InAppPurchaseHelper.isOsmAndProAvailable(app);
boolean showProIcon = !InAppPurchaseHelper.isOsmAndProAvailable(app) && !type.isAllowedInFreeVersion();
setupChildIcon(view, type.getIconRes(), selected && !showProIcon);
proIcon.setImageResource(nightMode ? R.drawable.img_button_pro_night : R.drawable.img_button_pro_day);
proIcon.setVisibility(type.isAllowedInFreeVersion() || proAvailable ? View.GONE : View.VISIBLE);
view.setOnClickListener(view1 -> {
compoundButton.performClick();
if (listener != null) {
listener.onTypeSelected(type, compoundButton.isChecked());
}
notifyDataSetChanged();
});
AndroidUiHelper.updateVisibility(proIcon, !type.isAllowedInFreeVersion());
AndroidUiHelper.updateVisibility(view.findViewById(R.id.switch_container), type.isAllowedInFreeVersion());
AndroidUiHelper.updateVisibility(proIcon, showProIcon);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.switch_container), !showProIcon);
setupSelectableBackground(view);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.divider), false);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_top_divider), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void onCategorySelected(ExportSettingsCategory category, boolean selected
@Override
public void onTypeSelected(ExportSettingsType type, boolean selected) {
boolean proAvailable = InAppPurchaseHelper.isOsmAndProAvailable(app);
if (type.isAllowedInFreeVersion() && !proAvailable) {
if (type.isAllowedInFreeVersion() || proAvailable) {
List<Object> items = getItemsForType(type);
selectedItemsMap.put(type, selected ? items : null);
if (!selected && !Algorithms.isEmpty(items)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ public void shareFavoritesFinished() {
}

private void setupGetOsmAndCloudButton(@NonNull View view) {
View dismissButton = view.findViewById(R.id.dismiss_button);
View dismissButtonContainer = view.findViewById(R.id.dismiss_button_container);
UiUtilities iconsCache = app.getUIUtilities();
ImageView closeBtn = view.findViewById(R.id.btn_close);
closeBtn.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_cancel, isNightMode()));
Expand All @@ -683,15 +683,12 @@ private void setupGetOsmAndCloudButton(@NonNull View view) {
}
});

int buttonTextId = R.string.get_osmand_cloud;
UiUtilities.setupDialogButton(nightMode, dismissButton, SECONDARY, buttonTextId);
dismissButton.setOnClickListener(v -> {
dismissButtonContainer.setOnClickListener(v -> {
FragmentActivity activity = getActivity();
if (activity != null) {
((MyPlacesActivity) getActivity()).showOsmAndCloud(this);
}
});
AndroidUiHelper.updateVisibility(dismissButton, true);
}

class FavouritesAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,8 @@ protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewH
preference.setVisible(false);
app.getSettings().CONFIGURE_PROFILE_FREE_ACCOUNT_CARD_DISMISSED.set(true);
});
View getCloudBtn = holder.findViewById(R.id.dismiss_button);
UiUtilities.setupDialogButton(isNightMode(), getCloudBtn, SECONDARY, R.string.get_osmand_cloud);
getCloudBtn.setOnClickListener(v -> {
View getCloudBtnContainer = holder.findViewById(R.id.dismiss_button_container);
getCloudBtnContainer.setOnClickListener(v -> {
FragmentActivity activity = getActivity();
if (activity != null) {
BackupAuthorizationFragment.showInstance(activity.getSupportFragmentManager());
Expand Down

0 comments on commit babf216

Please sign in to comment.