Skip to content

Commit

Permalink
#1822: FIxes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Corwin-Kh committed Jul 18, 2023
1 parent 48a7d0b commit 9a5315b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 36 deletions.
27 changes: 12 additions & 15 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 @@ -65,23 +67,18 @@

</LinearLayout>

<FrameLayout
<net.osmand.plus.widgets.dialogbutton.DialogButton
android:id="@+id/dismiss_button_container"
android:layout_width="match_parent"
android:layout_height="@dimen/acceptable_touch_radius"
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:paddingTop="@dimen/content_padding_small_half"
android:paddingBottom="@dimen/content_padding_small_half"
android:layout_weight="0">

<include
android:id="@+id/dismiss_button"
layout="@layout/bottom_sheet_dialog_button"
android:layout_width="match_parent"
android:layout_height="@dimen/dialog_button_height"
/>

</FrameLayout>
android:layout_marginBottom="@dimen/content_padding"
android:layout_weight="0"/>

</LinearLayout>

Expand Down
3 changes: 1 addition & 2 deletions OsmAnd/src/net/osmand/plus/backup/BackupInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ private void createFilteredFilesToDownload(@NonNull OsmandApplication app) {
private void createFilteredFilesToUpload(@NonNull OsmandApplication app) {
List<LocalFile> files = new ArrayList<>();
BackupHelper helper = app.getBackupHelper();
boolean subscribedToPromo = InAppPurchaseHelper.isSubscribedToPromo(app);
boolean proAvailable = InAppPurchaseHelper.isOsmAndProAvailable(app);
for (LocalFile localFile : filesToUpload) {
ExportSettingsType type = localFile.item != null ?
ExportSettingsType.getExportSettingsTypeForItem(localFile.item) : null;
if (type != null && helper.getBackupTypePref(type).get() && (type.isAllowedInFreeVersion() || proAvailable || subscribedToPromo)) {
if (type != null && helper.getBackupTypePref(type).get() && (type.isAllowedInFreeVersion() || proAvailable)) {
files.add(localFile);
}
}
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 showProIcon = InAppPurchaseHelper.isOsmAndProAvailable(app) || type.isAllowedInFreeVersion();
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(showProIcon ? View.GONE : View.VISIBLE);
view.setOnClickListener(view1 -> {
compoundButton.performClick();
if (listener != null) {
listener.onTypeSelected(type, compoundButton.isChecked());
}
notifyDataSetChanged();
});
AndroidUiHelper.updateVisibility(proIcon, !showProIcon);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.switch_container), showProIcon);
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 @@ -42,10 +42,9 @@ protected RemoteFilesType getRemoteFilesType() {
@Override
protected Map<ExportSettingsType, List<?>> getSelectedItems() {
Map<ExportSettingsType, List<?>> selectedItemsMap = new EnumMap<>(ExportSettingsType.class);
boolean subscribedToPromo = InAppPurchaseHelper.isSubscribedToPromo(app);
boolean proAvailable = InAppPurchaseHelper.isOsmAndProAvailable(app);
for (ExportSettingsType type : ExportSettingsType.values()) {
if (backupHelper.getBackupTypePref(type).get() && (type.isAllowedInFreeVersion() || proAvailable || subscribedToPromo)) {
if (backupHelper.getBackupTypePref(type).get() && (type.isAllowedInFreeVersion() || proAvailable)) {
selectedItemsMap.put(type, getItemsForType(type));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
searchView.setOnClickListener(v -> FavoritesSearchFragment.showInstance(getActivity(), ""));
listView.addHeaderView(searchView);
View dividerView = inflater.inflate(R.layout.list_item_divider, null, false);
boolean subscribedToPromo = InAppPurchaseHelper.isSubscribedToPromo(app);
boolean proAvailable = InAppPurchaseHelper.isOsmAndProAvailable(app);
boolean isRegistered = app.getBackupHelper().isRegistered();
if (!subscribedToPromo && !proAvailable && !isRegistered && !app.getSettings().FAVORITES_FREE_ACCOUNT_CARD_DISMISSED.get()) {
if (!proAvailable && !isRegistered && !app.getSettings().FAVORITES_FREE_ACCOUNT_CARD_DISMISSED.get()) {
freeFavoritesBackupCardDivider = inflater.inflate(R.layout.list_item_divider, listView, false);
listView.addHeaderView(freeFavoritesBackupCardDivider, null, false);
freeFavoritesBackupCard = inflater.inflate(R.layout.free_backup_card, listView, false);
Expand Down Expand Up @@ -669,7 +668,6 @@ public void shareFavoritesFinished() {

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

int buttonTextId = R.string.get_osmand_cloud;
UiUtilities.setupDialogButton(nightMode, dismissButton, SECONDARY, buttonTextId);
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 @@ -300,8 +300,6 @@ protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewH
app.getSettings().CONFIGURE_PROFILE_FREE_ACCOUNT_CARD_DISMISSED.set(true);
});
View getCloudBtnContainer = holder.findViewById(R.id.dismiss_button_container);
View getCloudBtn = holder.findViewById(R.id.dismiss_button);
UiUtilities.setupDialogButton(isNightMode(), getCloudBtn, SECONDARY, R.string.get_osmand_cloud);
getCloudBtnContainer.setOnClickListener(v -> {
FragmentActivity activity = getActivity();
if (activity != null) {
Expand Down Expand Up @@ -342,10 +340,9 @@ private void setupNavigationSettingsPref() {
}

private void setupFreeFavoritesBackupCard() {
boolean subscribedToPromo = InAppPurchaseHelper.isSubscribedToPromo(app);
boolean proAvailable = InAppPurchaseHelper.isOsmAndProAvailable(app);
boolean isRegistered = app.getBackupHelper().isRegistered();
boolean shouldShowFreeBackupCard = !subscribedToPromo && !proAvailable && !isRegistered && !app.getSettings().CONFIGURE_PROFILE_FREE_ACCOUNT_CARD_DISMISSED.get();
boolean shouldShowFreeBackupCard = !proAvailable && !isRegistered && !app.getSettings().CONFIGURE_PROFILE_FREE_ACCOUNT_CARD_DISMISSED.get();
Preference freeBackupCard = findPreference("free_favorites_backup_card");
if (freeBackupCard != null) {
freeBackupCard.setVisible(shouldShowFreeBackupCard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ public static boolean shouldShowBackupSubscription(@NonNull OsmandApplication ap
}

public static boolean shouldShowFreeAccRegistration(@NonNull OsmandApplication app) {
boolean subscribedToPromo = InAppPurchaseHelper.isSubscribedToPromo(app);
boolean proAvailable = InAppPurchaseHelper.isOsmAndProAvailable(app);
boolean isRegistered = app.getBackupHelper().isRegistered();
return !subscribedToPromo && !proAvailable && isRegistered;
return !proAvailable && isRegistered;
}

@NonNull
Expand Down

0 comments on commit 9a5315b

Please sign in to comment.