add help button;

fix purchase icon;
fix toolbar title in purchases fragment;
This commit is contained in:
Skalii 2021-03-11 13:07:28 +02:00
parent 50b679dc66
commit 6e5964de40
4 changed files with 45 additions and 11 deletions

View file

@ -1064,7 +1064,7 @@
<activity android:name="net.osmand.plus.activities.PrintDialogActivity" /> <activity android:name="net.osmand.plus.activities.PrintDialogActivity" />
<activity android:name=".liveupdates.OsmLiveActivity" <activity android:name=".liveupdates.OsmLiveActivity"
android:label="@string/osm_live"/> android:label="@string/purchases"/>
<activity android:name=".wikivoyage.explore.WikivoyageExploreActivity"> <activity android:name=".wikivoyage.explore.WikivoyageExploreActivity">
<intent-filter> <intent-filter>

View file

@ -22,7 +22,22 @@
app:contentInsetEnd="0dp" app:contentInsetEnd="0dp"
app:contentInsetLeft="@dimen/settings_divider_margin_start" app:contentInsetLeft="@dimen/settings_divider_margin_start"
app:contentInsetRight="0dp" app:contentInsetRight="0dp"
app:contentInsetStart="@dimen/settings_divider_margin_start" /> app:contentInsetStart="@dimen/settings_divider_margin_start">
<ImageButton
android:id="@+id/toolbar_action"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="end"
android:layout_marginTop="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding"
android:background="@null"
android:contentDescription="@string/shared_string_help"
tools:src="@drawable/ic_action_help" />
</androidx.appcompat.widget.Toolbar>
<include layout="@layout/preference_toolbar_switch" /> <include layout="@layout/preference_toolbar_switch" />

View file

@ -1033,7 +1033,7 @@ public class MapActivityActions implements DialogProvider {
if (Version.isGooglePlayEnabled() || Version.isHuawei() || Version.isDeveloperVersion(app)) { if (Version.isGooglePlayEnabled() || Version.isHuawei() || Version.isDeveloperVersion(app)) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.purchases, mapActivity) optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.purchases, mapActivity)
.setId(DRAWER_OSMAND_LIVE_ID) .setId(DRAWER_OSMAND_LIVE_ID)
.setIcon(R.drawable.ic_action_osm_live) .setIcon(R.drawable.ic_action_purchases)
.setListener(new ItemClickListener() { .setListener(new ItemClickListener() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {

View file

@ -4,9 +4,11 @@ import android.app.AlarmManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -16,6 +18,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -37,6 +40,7 @@ import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.CompoundButtonType;
import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.base.BaseOsmAndDialogFragment;
@ -66,8 +70,6 @@ import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL;
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.formatShortDateTime; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.formatShortDateTime;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getNameToDisplay; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getNameToDisplay;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
@ -88,6 +90,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
public static final String URL = "https://osmand.net/api/osmlive_status"; public static final String URL = "https://osmand.net/api/osmlive_status";
public static final String TAG = LiveUpdatesFragmentNew.class.getSimpleName(); public static final String TAG = LiveUpdatesFragmentNew.class.getSimpleName();
private final static Log LOG = PlatformUtil.getLog(LiveUpdatesFragmentNew.class); private final static Log LOG = PlatformUtil.getLog(LiveUpdatesFragmentNew.class);
private static final String SUBSCRIPTION_URL = "https://osmand.net/features/subscription";
private OsmandApplication app; private OsmandApplication app;
private OsmandSettings settings; private OsmandSettings settings;
@ -135,6 +138,18 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
dismiss(); dismiss();
} }
}); });
ImageButton iconHelp = toolbar.findViewById(R.id.toolbar_action);
Drawable helpDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_help, iconColorResId);
iconHelp.setImageDrawable(helpDrawable);
iconHelp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(SUBSCRIPTION_URL));
if (AndroidUtils.isIntentSafe(app, intent)) {
startActivity(intent);
}
}
});
listView = (ExpandableListView) view.findViewById(android.R.id.list); listView = (ExpandableListView) view.findViewById(android.R.id.list);
adapter = new LiveMapsAdapter(); adapter = new LiveMapsAdapter();
@ -149,7 +164,8 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app) && settings.IS_LIVE_UPDATES_ON.get()) { if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app) && settings.IS_LIVE_UPDATES_ON.get()) {
if (getFragmentManager() != null) { if (getFragmentManager() != null) {
LiveUpdatesSettingsDialogFragmentNew LiveUpdatesSettingsDialogFragmentNew
.showInstance(getFragmentManager(), LiveUpdatesFragmentNew.this, adapter.getChild(groupPosition, childPosition).getFileName()); .showInstance(getFragmentManager(), LiveUpdatesFragmentNew.this,
adapter.getChild(groupPosition, childPosition).getFileName());
} }
return true; return true;
} else { } else {
@ -250,12 +266,13 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
} }
private void updateToolbarSwitch(final boolean isChecked) { private void updateToolbarSwitch(final boolean isChecked) {
int switchColor = ContextCompat.getColor(app, isChecked ? getActiveTextColorId(nightMode) : getSecondaryTextColorId(nightMode)); int switchColor = ContextCompat.getColor(app,
isChecked ? getActiveTextColorId(nightMode) : getSecondaryTextColorId(nightMode));
AndroidUtils.setBackground(toolbarSwitchContainer, new ColorDrawable(switchColor)); AndroidUtils.setBackground(toolbarSwitchContainer, new ColorDrawable(switchColor));
SwitchCompat switchView = toolbarSwitchContainer.findViewById(R.id.switchWidget); SwitchCompat switchView = toolbarSwitchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(isChecked); switchView.setChecked(isChecked);
UiUtilities.setupCompoundButton(switchView, nightMode, TOOLBAR); UiUtilities.setupCompoundButton(switchView, nightMode, CompoundButtonType.TOOLBAR);
toolbarSwitchContainer.setOnClickListener(new View.OnClickListener() { toolbarSwitchContainer.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -503,7 +520,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
boolean liveUpdateOn = settings.IS_LIVE_UPDATES_ON.get(); boolean liveUpdateOn = settings.IS_LIVE_UPDATES_ON.get();
CommonPreference<Boolean> localUpdateOn = preferenceForLocalIndex(item, settings); CommonPreference<Boolean> localUpdateOn = preferenceForLocalIndex(item, settings);
// IncrementalChangesManager changesManager = app.getResourceManager().getChangesManager(); // IncrementalChangesManager changesManager = app.getResourceManager().getChangesManager();
UiUtilities.setupCompoundButton(option, nightMode, GLOBAL); UiUtilities.setupCompoundButton(option, nightMode, CompoundButtonType.GLOBAL);
option.setChecked(localUpdateOn.get()); option.setChecked(localUpdateOn.get());
title.setText(getNameToDisplay(item, app)); title.setText(getNameToDisplay(item, app));
@ -525,7 +542,8 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
} }
Drawable statusDrawable = ContextCompat.getDrawable(app, R.drawable.ic_map); Drawable statusDrawable = ContextCompat.getDrawable(app, R.drawable.ic_map);
int resColorId = !localUpdateOn.get() ? getSecondaryIconColorId(nightMode) : !liveUpdateOn ? getDefaultIconColorId(nightMode) : getOsmandIconColorId(nightMode); int resColorId = !localUpdateOn.get() ? getSecondaryIconColorId(nightMode) :
!liveUpdateOn ? getDefaultIconColorId(nightMode) : getOsmandIconColorId(nightMode);
int statusColor = ContextCompat.getColor(app, resColorId); int statusColor = ContextCompat.getColor(app, resColorId);
if (statusDrawable != null) { if (statusDrawable != null) {
DrawableCompat.setTint(statusDrawable, statusColor); DrawableCompat.setTint(statusDrawable, statusColor);
@ -561,7 +579,8 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
@Override @Override
protected String doInBackground(Void... params) { protected String doInBackground(Void... params) {
try { try {
return AndroidNetworkUtils.sendRequest(app, URL, null, "Requesting map updates info...", false, false); return AndroidNetworkUtils.sendRequest(app, URL, null,
"Requesting map updates info...", false, false);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error: " + "Requesting map updates info error", e); LOG.error("Error: " + "Requesting map updates info error", e);
return null; return null;