forked from organicmaps/organicmaps
[android] Added validation of the first launch for Tips&Tricks
This commit is contained in:
parent
f1abe91c5d
commit
ceab008497
3 changed files with 10 additions and 4 deletions
|
@ -545,7 +545,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private void initTips()
|
||||
{
|
||||
TipsApi api = TipsApi.requestCurrent(getClass());
|
||||
TipsApi api = TipsApi.requestCurrent(this, getClass());
|
||||
if (api == TipsApi.STUB)
|
||||
return;
|
||||
|
||||
|
@ -2318,7 +2318,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public final void onMenuItemClick()
|
||||
{
|
||||
TipsApi api = TipsApi.requestCurrent(getActivity().getClass());
|
||||
TipsApi api = TipsApi.requestCurrent(getActivity(), getActivity().getClass());
|
||||
LOGGER.d(TAG, "TipsApi = " + api);
|
||||
if (getItem() == api.getSiblingMenuItem())
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.mapswithme.maps.tips;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -10,6 +11,7 @@ import android.view.View;
|
|||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.metrics.UserActionsLogger;
|
||||
import com.mapswithme.maps.widget.menu.MainMenu;
|
||||
|
@ -164,8 +166,12 @@ public enum TipsApi
|
|||
public abstract ClickInterceptor createClickInterceptor();
|
||||
|
||||
@NonNull
|
||||
public static <T> TipsApi requestCurrent(@NonNull Class<T> requiredScreenClass)
|
||||
public static <T> TipsApi requestCurrent(@NonNull Context context,
|
||||
@NonNull Class<T> requiredScreenClass)
|
||||
{
|
||||
if (MwmApplication.from(context).isFirstLaunch())
|
||||
return STUB;
|
||||
|
||||
int index = Framework.nativeGetCurrentTipsApi();
|
||||
TipsApi value = index >= 0 ? values()[index] : STUB;
|
||||
TipsApi tipsApi = value != STUB && value.isScreenAllowed(requiredScreenClass) ? value
|
||||
|
|
|
@ -23,7 +23,7 @@ public abstract class TipsClickListener implements View.OnClickListener
|
|||
@Override
|
||||
public final void onClick(View v)
|
||||
{
|
||||
TipsApi api = TipsApi.requestCurrent(mActivity.getClass());
|
||||
TipsApi api = TipsApi.requestCurrent(mActivity, mActivity.getClass());
|
||||
if (api == mTipsApi)
|
||||
{
|
||||
MwmActivity mwmActivity = (MwmActivity) mActivity;
|
||||
|
|
Loading…
Add table
Reference in a new issue