-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21884 from osmandapp/hmd_promo
Add HMD promo
- Loading branch information
Showing
12 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
OsmAnd/src/net/osmand/plus/chooseplan/HMDPromoFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package net.osmand.plus.chooseplan; | ||
|
||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.FRAGMENT_HMD_PROMO_ID; | ||
import static net.osmand.plus.chooseplan.OsmAndFeature.*; | ||
import static net.osmand.plus.inapp.InAppPurchaseUtils.HMD_PROMO_MONTHS; | ||
|
||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.fragment.app.FragmentManager; | ||
|
||
import net.osmand.plus.OsmandApplication; | ||
import net.osmand.plus.R; | ||
import net.osmand.plus.Version; | ||
import net.osmand.plus.inapp.InAppPurchaseUtils; | ||
import net.osmand.plus.utils.AndroidUtils; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class HMDPromoFragment extends PromoCompanyFragment { | ||
|
||
public static final String TAG = HMDPromoFragment.class.getSimpleName(); | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
settings.HMD_PROMO_SHOWED.set(true); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
protected List<OsmAndFeature> getFeatures() { | ||
return Arrays.asList(UNLIMITED_MAP_DOWNLOADS, RELIEF_3D, TERRAIN, ANDROID_AUTO, WIKIPEDIA, | ||
WIKIVOYAGE, WEATHER, MONTHLY_MAP_UPDATES, HOURLY_MAP_UPDATES, EXTERNAL_SENSORS_SUPPORT, NAUTICAL); | ||
} | ||
|
||
protected void setupContent(@NonNull View view) { | ||
super.setupContent(view); | ||
|
||
TextView title = view.findViewById(R.id.title); | ||
TextView description = view.findViewById(R.id.description); | ||
|
||
title.setText(getString(R.string.hmd_promo, String.valueOf(HMD_PROMO_MONTHS))); | ||
description.setText(getString(R.string.hmd_promo_description, String.valueOf(HMD_PROMO_MONTHS))); | ||
} | ||
|
||
public static boolean shouldShow(@NonNull OsmandApplication app) { | ||
if (Version.isHMDBuild() && app.getAppCustomization().isFeatureEnabled(FRAGMENT_HMD_PROMO_ID)) { | ||
return InAppPurchaseUtils.isHMDPromoAvailable(app) && !app.getSettings().HMD_PROMO_SHOWED.get(); | ||
} | ||
return false; | ||
} | ||
|
||
public static void showInstance(@NonNull FragmentManager manager) { | ||
if (AndroidUtils.isFragmentCanBeAdded(manager, TAG, true)) { | ||
HMDPromoFragment fragment = new HMDPromoFragment(); | ||
fragment.show(manager, TAG); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters