[android] Added validation of the first launch for Tips&Tricks

This commit is contained in:
Dmitry Donskoy 2019-05-16 15:24:16 +03:00 committed by Daria Volvenkova
parent f1abe91c5d
commit ceab008497
3 changed files with 10 additions and 4 deletions

View file

@ -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())
{

View file

@ -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

View file

@ -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;