[android] Removed pedestrian notifications and dialogs.

This commit is contained in:
Dmitry Yunitsky 2015-09-02 18:22:36 +03:00 committed by Alex Zolotarev
parent dd241c47c5
commit ba2ff2fb90
33 changed files with 5 additions and 332 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

View file

@ -1,33 +0,0 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/margin_base_plus">
<TextView
android:id="@+id/tv__title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_walking_available"
android:textAppearance="@style/MwmTextAppearance.Title"
android:textStyle="bold"/>
<ImageView
android:id="@+id/iv__image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/margin_half_plus"
android:contentDescription="@null"
android:src="@drawable/ic_img_pedestrian_phone"/>
<TextView
android:id="@+id/tv__text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_half_plus"
android:text="@string/share_walking_routes_mastering"
android:textAppearance="@style/MwmTextAppearance.Body2"/>
</LinearLayout>

View file

@ -1348,12 +1348,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void run()
{
if (resultCode == RoutingResultCodesProcessor.NO_ERROR)
{
if (Framework.getRouter() == Framework.ROUTER_TYPE_PEDESTRIAN)
LikesManager.INSTANCE.onPedestrianBuilt();
mLayoutRouting.setState(RoutingLayout.State.ROUTE_BUILT, true);
}
else
{
mLayoutRouting.setState(RoutingLayout.State.ROUTE_BUILD_ERROR, true);

View file

@ -1,58 +0,0 @@
package com.mapswithme.maps.ads;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmDialogFragment;
import com.mapswithme.util.sharing.ShareOption;
import com.mapswithme.util.statistics.Statistics;
public abstract class BasePedestrianDialogFragment extends BaseMwmDialogFragment
{
abstract View buildView(LayoutInflater inflater);
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final LayoutInflater inflater = getActivity().getLayoutInflater();
@SuppressLint("InflateParams") final View root = buildView(inflater);
return builder.
setView(root).
setNegativeButton(R.string.dialog_routing_not_now, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
LikesManager.setRatingApplied(BasePedestrianDialogFragment.this.getClass(), true);
Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.FACEBOOK_PEDESTRIAN_CANCEL);
}
}).
setPositiveButton(R.string.share, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
LikesManager.setRatingApplied(BasePedestrianDialogFragment.this.getClass(), true);
ShareOption.PEDESTRIAN.share(getActivity());
Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.FACEBOOK_PEDESTRIAN_SHARE);
}
}).create();
}
@Override
public void onCancel(DialogInterface dialog)
{
super.onCancel(dialog);
Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.FACEBOOK_PEDESTRIAN_CANCEL);
}
}

View file

@ -17,10 +17,8 @@ public enum LikesManager
public static final String LAST_RATED_SESSION = "LastRatedSession";
public static final String RATED_DIALOG = "RatedDialog";
public static final String PEDESTRIAN_COUNT = "PedestrianCount";
private static final int DIALOG_DELAY_DEFAULT = 30000;
private static final int DIALOG_DELAY_SHORT = 5000;
private static final int SESSION_NUM = MwmApplication.get().getSessionsNumber();
/*
@ -33,9 +31,7 @@ public enum LikesManager
GPLUS_NEW_USERS(GooglePlusDialogFragment.class, DIALOG_DELAY_DEFAULT),
GPLUS_OLD_USERS(GooglePlusDialogFragment.class, DIALOG_DELAY_DEFAULT),
FACEBOOK_INVITE_NEW_USERS(FacebookInvitesDialogFragment.class, DIALOG_DELAY_DEFAULT),
FACEBOOK_INVITES_OLD_USERS(FacebookInvitesDialogFragment.class, DIALOG_DELAY_DEFAULT),
FACEBOOK_PEDESTRIAN_FIRST_OLD_USERS(PedestrianFirstUseDialogFragment.class, DIALOG_DELAY_SHORT),
FACEBOOK_PEDESTRIAN_MASTER_OLD_USERS(PedestrianMasterDialogFragment.class, DIALOG_DELAY_SHORT);
FACEBOOK_INVITES_OLD_USERS(FacebookInvitesDialogFragment.class, DIALOG_DELAY_DEFAULT);
public final Class<? extends DialogFragment> clazz;
public final int delay;
@ -55,15 +51,14 @@ public enum LikesManager
static
{
sOldUsersMapping.put(1, LikeType.FACEBOOK_PEDESTRIAN_FIRST_OLD_USERS);
sOldUsersMapping.put(4, LikeType.GPLAY_OLD_USERS);
// sOldUsersMapping.put(4, LikeType.GPLUS_OLD_USERS);
sOldUsersMapping.put(1, LikeType.GPLAY_OLD_USERS);
sOldUsersMapping.put(4, LikeType.GPLUS_OLD_USERS);
sOldUsersMapping.put(6, LikeType.FACEBOOK_INVITES_OLD_USERS);
sOldUsersMapping.put(10, LikeType.GPLAY_OLD_USERS);
sOldUsersMapping.put(21, LikeType.GPLAY_OLD_USERS);
// sOldUsersMapping.put(24, LikeType.GPLUS_OLD_USERS);
sOldUsersMapping.put(24, LikeType.GPLUS_OLD_USERS);
sOldUsersMapping.put(30, LikeType.FACEBOOK_INVITES_OLD_USERS);
// sOldUsersMapping.put(44, LikeType.GPLUS_OLD_USERS);
sOldUsersMapping.put(44, LikeType.GPLUS_OLD_USERS);
sOldUsersMapping.put(50, LikeType.FACEBOOK_INVITES_OLD_USERS);
sNewUsersMapping.put(3, LikeType.GPLAY_NEW_USERS);
@ -75,12 +70,6 @@ public enum LikesManager
sNewUsersMapping.put(35, LikeType.FACEBOOK_INVITE_NEW_USERS);
sNewUsersMapping.put(50, LikeType.GPLUS_NEW_USERS);
sNewUsersMapping.put(55, LikeType.FACEBOOK_INVITE_NEW_USERS);
if (MwmApplication.get().nativeGetInt(PEDESTRIAN_COUNT, 0) >= 3 && !isRatingApplied(PedestrianMasterDialogFragment.class))
{
sOldUsersMapping.put(SESSION_NUM, LikeType.FACEBOOK_PEDESTRIAN_MASTER_OLD_USERS);
sNewUsersMapping.put(SESSION_NUM, LikeType.FACEBOOK_PEDESTRIAN_MASTER_OLD_USERS);
}
}
private final boolean mIsNewUser = MwmApplication.get().getFirstInstallVersion() == BuildConfig.VERSION_CODE;
@ -105,13 +94,6 @@ public enum LikesManager
UiThread.cancelDelayedTasks(mLikeRunnable);
}
public void onPedestrianBuilt()
{
final MwmApplication APP = MwmApplication.get();
APP.nativeSetInt(PEDESTRIAN_COUNT, APP.nativeGetInt(PEDESTRIAN_COUNT, 0) + 1);
}
private void displayLikeDialog(final Class<? extends DialogFragment> dialogFragmentClass, final int delayMillis)
{
if (isSessionRated(SESSION_NUM) || isRatingApplied(dialogFragmentClass))

View file

@ -1,27 +0,0 @@
package com.mapswithme.maps.ads;
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
public class PedestrianFirstUseDialogFragment extends BasePedestrianDialogFragment
{
protected View buildView(LayoutInflater inflater)
{
@SuppressLint("InflateParams") final View root = inflater.inflate(R.layout.fragment_pedestrian_dialog, null);
final ImageView imageView = (ImageView) root.findViewById(R.id.iv__image);
imageView.setImageResource(UiUtils.isTablet() ? R.drawable.ic_img_pedestrian_teblet : R.drawable.ic_img_pedestrian_phone);
final TextView title = (TextView) root.findViewById(R.id.tv__title);
title.setText(R.string.title_walking_available);
final TextView text = (TextView) root.findViewById(R.id.tv__text);
text.setText(R.string.share_walking_routes_first_launch);
return root;
}
}

View file

@ -1,27 +0,0 @@
package com.mapswithme.maps.ads;
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
public class PedestrianMasterDialogFragment extends BasePedestrianDialogFragment
{
protected View buildView(LayoutInflater inflater)
{
@SuppressLint("InflateParams") final View root = inflater.inflate(R.layout.fragment_pedestrian_dialog, null);
final ImageView imageView = (ImageView) root.findViewById(R.id.iv__image);
imageView.setImageResource(UiUtils.isTablet() ? R.drawable.ic_img_achive_pedestrian_tablet : R.drawable.ic_img_achive_pedestrian_phone);
final TextView title = (TextView) root.findViewById(R.id.tv__title);
title.setText(R.string.share_walking_routes_congratulations);
final TextView text = (TextView) root.findViewById(R.id.tv__text);
text.setText(R.string.share_walking_routes_mastering);
return root;
}
}

View file

@ -19,7 +19,6 @@ public final class Notifier
private final static int ID_UPDATE_AVAILABLE = 1;
private final static int ID_DOWNLOAD_FAILED = 2;
private final static int ID_DOWNLOAD_NEW_COUNTRY = 3;
private final static int ID_PEDESTRIAN = 4;
private static final MwmApplication APP = MwmApplication.get();
@ -63,17 +62,6 @@ public final class Notifier
getNotificationManager().cancel(ID_DOWNLOAD_NEW_COUNTRY);
}
public static void notifyPedestrianRouting()
{
final String title = APP.getString(R.string.title_walking_available);
final String content = APP.getString(R.string.walking_rich_notification_text);
final PendingIntent pi = PendingIntent.getActivity(APP, 0, new Intent(APP, MwmActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
placeBigNotification(title, content, pi, ID_PEDESTRIAN);
}
private static void placeNotification(String title, String content, PendingIntent pendingIntent, int notificationId)
{
final Notification notification = getBuilder(title, content, pendingIntent)

View file

@ -12,6 +12,5 @@ public class UpgradeReceiver extends BroadcastReceiver
public void onReceive(Context context, Intent intent)
{
MwmApplication.get().onUpgrade();
WorkerService.queuePedestrianNotification();
}
}

View file

@ -12,9 +12,6 @@ public class UpgradeReceiverCompat extends BroadcastReceiver
public void onReceive(Context context, Intent intent)
{
if (context.getPackageName().equals(intent.getData().getSchemeSpecificPart()))
{
MwmApplication.get().onUpgrade();
WorkerService.queuePedestrianNotification();
}
}
}

View file

@ -1,8 +1,6 @@
package com.mapswithme.maps.background;
import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -17,15 +15,10 @@ import com.mapswithme.maps.R;
import com.mapswithme.util.LocationUtils;
import com.mapswithme.util.statistics.Statistics;
import java.util.Calendar;
public class WorkerService extends IntentService
{
private static final String ACTION_CHECK_UPDATE = "com.mapswithme.maps.action.update";
private static final String ACTION_DOWNLOAD_COUNTRY = "com.mapswithme.maps.action.download_country";
private static final String ACTION_NOTIFY_PEDESTRIAN = "com.mapswithme.maps.action.notify_pedestrian";
private static final String PREF_NOTIFICATION_ALARM = "PedestrianNotificationAlarmSet";
private static final String PREF_NOTIFICATION_SHOWN = "PedestrianNotificationShown";
private static final MwmApplication APP = MwmApplication.get();
private static final SharedPreferences PREFS = MwmApplication.prefs();
@ -56,37 +49,6 @@ public class WorkerService extends IntentService
context.startService(intent);
}
/**
* Sets alarm to display notification about pedestrian routing available.
*/
public static void queuePedestrianNotification()
{
if (isPedestrianNotificationAlarmSet())
return;
Calendar time = Calendar.getInstance();
time.set(Calendar.MINUTE, 30);
final int hour = 16;
final int currentHour = time.get(Calendar.HOUR_OF_DAY);
if (currentHour > hour)
time.roll(Calendar.DAY_OF_MONTH, 1);
time.set(Calendar.HOUR_OF_DAY, hour);
final Intent intent = new Intent(APP, WorkerService.class);
intent.setAction(WorkerService.ACTION_NOTIFY_PEDESTRIAN);
final AlarmManager manager = (AlarmManager) APP.getSystemService(Context.ALARM_SERVICE);
manager.set(AlarmManager.RTC, time.getTimeInMillis(), PendingIntent.getService(APP, 0, intent, 0));
onPedestrianAlarmSet();
}
public static void checkLostPedestrianAlarm()
{
if (isPedestrianNotificationAlarmSet() && !isPedestrianNotificationShown())
queuePedestrianNotification();
}
public WorkerService()
{
super("WorkerService");
@ -102,18 +64,11 @@ public class WorkerService extends IntentService
switch (action)
{
case ACTION_CHECK_UPDATE:
checkLostPedestrianAlarm();
handleActionCheckUpdate();
break;
case ACTION_DOWNLOAD_COUNTRY:
checkLostPedestrianAlarm();
handleActionCheckLocation();
break;
case ACTION_NOTIFY_PEDESTRIAN:
if (isPedestrianNotificationShown())
return;
Notifier.notifyPedestrianRouting();
onPedestrianNotificationShown();
}
}
}
@ -191,24 +146,4 @@ public class WorkerService extends IntentService
PREFS.edit().putString(country, String.valueOf(System.currentTimeMillis())).apply();
}
}
private static boolean isPedestrianNotificationAlarmSet()
{
return PREFS.getBoolean(PREF_NOTIFICATION_ALARM, false);
}
private static void onPedestrianAlarmSet()
{
PREFS.edit().putBoolean(PREF_NOTIFICATION_ALARM, true).apply();
}
private static boolean isPedestrianNotificationShown()
{
return PREFS.getBoolean(PREF_NOTIFICATION_SHOWN, false);
}
private static void onPedestrianNotificationShown()
{
PREFS.edit().putBoolean(PREF_NOTIFICATION_SHOWN, true).apply();
}
}

View file

@ -1,62 +0,0 @@
package com.mapswithme.util.sharing;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import com.facebook.FacebookSdk;
import com.facebook.share.model.ShareLinkContent;
import com.facebook.share.widget.ShareDialog;
import com.mapswithme.maps.R;
import java.util.Locale;
public class PedestrianShareable extends TextShareable
{
private static final String FACEBOOK_SHARE_URL = "http://maps.me/fb-pedestrian?lang=" + Locale.getDefault().getLanguage();
public PedestrianShareable(Activity context)
{
super(context);
}
@Override
public void share(SharingTarget target)
{
Activity activity = getActivity();
Intent intent = getTargetIntent(target);
String lowerCaseName = target.activityName.toLowerCase();
if (lowerCaseName.contains("facebook"))
{
shareFacebook();
return;
}
if (lowerCaseName.contains("mail"))
{
setSubject(R.string.share_walking_routes_email_subject);
intent.putExtra(Intent.EXTRA_TEXT, activity.getString(R.string.share_walking_routes_email_body));
}
else if (lowerCaseName.contains("sms") || lowerCaseName.contains("mms"))
TargetUtils.fillSmsIntent(activity, intent, activity.getString(R.string.share_walking_routes_sms));
else
setText(R.string.share_walking_routes_messenger);
super.share(target);
}
private void shareFacebook()
{
FacebookSdk.sdkInitialize(getActivity());
ShareDialog shareDialog = new ShareDialog(getActivity());
if (ShareDialog.canShow(ShareLinkContent.class))
{
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(FACEBOOK_SHARE_URL))
.build();
shareDialog.show(linkContent);
}
}
}

View file

@ -17,7 +17,6 @@ public abstract class ShareOption
public static final SmsShareOption SMS = new SmsShareOption();
public static final EmailShareOption EMAIL = new EmailShareOption();
public static final AnyShareOption ANY = new AnyShareOption();
public static final PedestrianShareOption PEDESTRIAN = new PedestrianShareOption();
@StringRes
protected final int mNameResId;
@ -90,17 +89,4 @@ public abstract class ShareOption
SharingHelper.shareOutside(new TextShareable(activity, body));
}
}
public static class PedestrianShareOption extends ShareOption
{
protected PedestrianShareOption()
{
super(R.string.title_walking_available, new Intent(Intent.ACTION_SEND).setType(TargetUtils.TYPE_TEXT_PLAIN));
}
public void share(final Activity activity)
{
SharingHelper.shareOutside(new PedestrianShareable(activity));
}
}
}

View file

@ -68,8 +68,6 @@ public enum Statistics
public static final String FACEBOOK_INVITE_LATER = "Facebook invites dialog cancelled.";
public static final String FACEBOOK_INVITE_INVITED = "GPlay dialog cancelled.";
public static final String RATE_DIALOG_RATED = "GPlay dialog. Rating set";
public static final String FACEBOOK_PEDESTRIAN_CANCEL = "Facebook pedestrian cancelled.";
public static final String FACEBOOK_PEDESTRIAN_SHARE = "Facebook pedestrian shared.";
}
public static class EventParam