[android] Add 'Donate' button to the main menu

Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Roman Tsisyk 2022-08-21 04:54:03 +03:00 committed by Viktor Govako
parent 45a6527e4d
commit c508dc698d
8 changed files with 98 additions and 13 deletions

View file

@ -1,15 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:pathData="M1,11h4v11h-4z"
android:fillColor="#000000"/>
<path
android:pathData="M16,3.25C16.65,2.49 17.66,2 18.7,2C20.55,2 22,3.45 22,5.3c0,2.27 -2.91,4.9 -6,7.7c-3.09,-2.81 -6,-5.44 -6,-7.7C10,3.45 11.45,2 13.3,2C14.34,2 15.35,2.49 16,3.25z"
android:fillColor="#000000"/>
<path
android:pathData="M20,17h-7l-2.09,-0.73l0.33,-0.94L13,16h2.82c0.65,0 1.18,-0.53 1.18,-1.18v0c0,-0.49 -0.31,-0.93 -0.77,-1.11L8.97,11H7v9.02L14,22l8.01,-3v0C22,17.9 21.11,17 20,17z"
android:fillColor="#000000"/>
android:fillColor="@android:color/white"
android:pathData="M9.6,15.6 L11,14.175 8.825,12 11,9.825 9.6,8.4 6,12ZM14.4,15.6 L18,12 14.4,8.4 13,9.825 15.175,12 13,14.175ZM5,21Q4.175,21 3.587,20.413Q3,19.825 3,19V5Q3,4.175 3.587,3.587Q4.175,3 5,3H19Q19.825,3 20.413,3.587Q21,4.175 21,5V19Q21,19.825 20.413,20.413Q19.825,21 19,21ZM5,19H19Q19,19 19,19Q19,19 19,19V5Q19,5 19,5Q19,5 19,5H5Q5,5 5,5Q5,5 5,5V19Q5,19 5,19Q5,19 5,19ZM5,5Q5,5 5,5Q5,5 5,5V19Q5,19 5,19Q5,19 5,19Q5,19 5,19Q5,19 5,19V5Q5,5 5,5Q5,5 5,5Z" />
</vector>

View file

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M1,11h4v11h-4z"
android:fillColor="#000000"/>
<path
android:pathData="M16,3.25C16.65,2.49 17.66,2 18.7,2C20.55,2 22,3.45 22,5.3c0,2.27 -2.91,4.9 -6,7.7c-3.09,-2.81 -6,-5.44 -6,-7.7C10,3.45 11.45,2 13.3,2C14.34,2 15.35,2.49 16,3.25z"
android:fillColor="#000000"/>
<path
android:pathData="M20,17h-7l-2.09,-0.73l0.33,-0.94L13,16h2.82c0.65,0 1.18,-0.53 1.18,-1.18v0c0,-0.49 -0.31,-0.93 -0.77,-1.11L8.97,11H7v9.02L14,22l8.01,-3v0C22,17.9 21.11,17 20,17z"
android:fillColor="#000000"/>
</vector>

View file

@ -77,6 +77,12 @@
android:text="@string/report_a_bug"
app:drawableStartCompat="@drawable/ic_report_a_bug"/>
<TextView
android:id="@+id/donate"
style="@style/MwmWidget.TextView.Item"
android:text="@string/donate"
app:drawableStartCompat="@drawable/ic_donate" />
<TextView
android:id="@+id/support_us"
style="@style/MwmWidget.TextView.Item"

View file

@ -256,6 +256,8 @@
<string name="help">Help</string>
<!-- Button in the main Help dialog -->
<string name="faq">Frequently Asked Questions</string>
<!-- Button in the main menu -->
<string name="donate">Donate</string>
<!-- Button in the main Help dialog -->
<string name="how_to_support_us">How to support us?</string>
<!-- Button in the main Help dialog -->

View file

@ -86,6 +86,7 @@ import com.mapswithme.maps.widget.placepage.PlacePageController;
import com.mapswithme.maps.widget.placepage.PlacePageData;
import com.mapswithme.maps.widget.placepage.PlacePageFactory;
import com.mapswithme.maps.widget.placepage.RoutingModeListener;
import com.mapswithme.util.Config;
import com.mapswithme.util.Counters;
import com.mapswithme.util.InputUtils;
import com.mapswithme.util.PermissionsUtils;
@ -201,6 +202,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
@NonNull
private PlacePageController mPlacePageController;
private String mDonatesUrl;
public interface LeftAnimationTrackListener
{
void onTrackStarted(boolean collapsed);
@ -447,6 +450,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
getDownloadMapsCounter(),
this::onDownloadMapsOptionSelected
));
mDonatesUrl = Config.getDonateUrl();
if (!TextUtils.isEmpty(mDonatesUrl))
items.add(new MenuBottomSheetItem(R.string.donate, R.drawable.ic_donate, this::onDonateOptionSelected));
items.add(new MenuBottomSheetItem(R.string.settings, R.drawable.ic_settings, this::onSettingsOptionSelected));
items.add(new MenuBottomSheetItem(R.string.share_my_location, R.drawable.ic_share, this::onShareLocationOptionSelected));
return items;
@ -2004,6 +2010,11 @@ public class MwmActivity extends BaseMwmFragmentActivity
showDownloader(false);
}
public void onDonateOptionSelected()
{
Utils.openUrl(this, mDonatesUrl);
}
public void onSettingsOptionSelected()
{
Intent intent = new Intent(getActivity(), SettingsActivity.class);

View file

@ -1,6 +1,7 @@
package com.mapswithme.maps.help;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -14,6 +15,7 @@ import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmFragment;
import com.mapswithme.util.Config;
import com.mapswithme.util.Constants;
import com.mapswithme.util.Graphics;
import com.mapswithme.util.Utils;
@ -22,6 +24,8 @@ import java.text.SimpleDateFormat;
public class HelpFragment extends BaseMwmFragment implements View.OnClickListener
{
private String mDonateUrl;
private void setupItem(@IdRes int id, boolean tint, @NonNull View frame)
{
TextView view = frame.findViewById(id);
@ -47,6 +51,7 @@ public class HelpFragment extends BaseMwmFragment implements View.OnClickListene
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
mDonateUrl = Config.getDonateUrl();
View root = inflater.inflate(R.layout.about, container, false);
((TextView) root.findViewById(R.id.version))
@ -67,13 +72,16 @@ public class HelpFragment extends BaseMwmFragment implements View.OnClickListene
setupItem(R.id.openstreetmap, true, root);
setupItem(R.id.faq, true, root);
setupItem(R.id.report, true, root);
if ("google".equalsIgnoreCase(BuildConfig.FLAVOR))
if (TextUtils.isEmpty(mDonateUrl))
{
TextView view = root.findViewById(R.id.support_us);
view.setVisibility(View.GONE);
TextView donateView = root.findViewById(R.id.donate);
donateView.setVisibility(View.GONE);
TextView supportUsView = root.findViewById(R.id.support_us);
supportUsView.setVisibility(View.GONE);
}
else
{
setupItem(R.id.donate, true, root);
setupItem(R.id.support_us, true, root);
}
setupItem(R.id.rate, true, root);
@ -131,6 +139,8 @@ public class HelpFragment extends BaseMwmFragment implements View.OnClickListene
Utils.sendBugReport(getActivity(), "");
else if (id == R.id.support_us)
openLink(Constants.Url.SUPPORT_US);
else if (id == R.id.donate)
openLink(mDonateUrl);
else if (id == R.id.rate)
Utils.openAppInMarket(getActivity(), BuildConfig.REVIEW_URL);
else if (id == R.id.copyright)

View file

@ -41,6 +41,7 @@ public final class Config
private static final String KEY_MISC_ENABLE_SCREEN_SLEEP = "EnableScreenSleep";
private static final String KEY_MISC_SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen";
private static final String KEY_MISC_AGPS_TIMESTAMP = "AGPSTimestamp";
private static final String KEY_DONATE_URL = "DonateUrl";
private Config() {}
@ -64,11 +65,13 @@ public final class Config
return nativeGetLong(key, def);
}
@NonNull
private static String getString(String key)
{
return getString(key, "");
}
@NonNull
private static String getString(String key, String def)
{
return nativeGetString(key, def);
@ -335,6 +338,11 @@ public final class Config
nativeSetTransliteration(value);
}
@NonNull
public static String getDonateUrl()
{
return getString(KEY_DONATE_URL);
}
private static native boolean nativeGetBoolean(String name, boolean defaultValue);
private static native void nativeSetBoolean(String name, boolean value);

View file

@ -5138,6 +5138,45 @@
zh-Hans = 问题和解答
zh-Hant = 問題和解答
[donate]
comment = Button in the main menu
tags = android
en = Donate
ar = ﻉﺮﺒﺘﻳ
be = Ахвяраваць
bg = Дарете
cs = Darovat
da = Doner
de = Spenden
el = Προσφέρω
es = Donar
eu = Dohaintza eman
fa = ﺪﯿﻨﮐ ﺍﺪﻫﺍ
fi = Lahjoittaa
fr = Faire un don
he = םוֹרתְלִ
hu = Adományoz
id = Menyumbangkan
it = Donare
ja = 寄付
ko = 기부
nb = Donere
nl = Doneren
pl = Podarować
pt = Doar
pt-BR = Doar
ro = Donează
ru = Поддержать рублём
sk = Darovať
sv = Donera
sw = Changia
th = บริจาค
tr = Bağış yapmak
uk = Пожертвувати
vi = Quyên tặng
zh-Hans = 捐
zh-Hant = 捐
[how_to_support_us]
comment = Button in the main Help dialog
tags = android,ios