forked from organicmaps/organicmaps
[android] Dialog to update maps for new styles.
This commit is contained in:
parent
936c48148b
commit
dbd2613594
4 changed files with 90 additions and 4 deletions
33
android/res/layout/dialog_new_style.xml
Normal file
33
android/res/layout/dialog_new_style.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<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/update_maps_alert_title"
|
||||
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_new_style_map"/>
|
||||
|
||||
<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/update_maps_alert_message"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body2"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -19,6 +19,7 @@ public enum LikesManager
|
|||
public static final String RATED_DIALOG = "RatedDialog";
|
||||
|
||||
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();
|
||||
|
||||
/*
|
||||
|
@ -31,7 +32,8 @@ 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_INVITES_OLD_USERS(FacebookInvitesDialogFragment.class, DIALOG_DELAY_DEFAULT),
|
||||
NEW_STYLE_OLD_USERS(UpdateMapsDialogFragment.class, DIALOG_DELAY_SHORT);
|
||||
|
||||
public final Class<? extends DialogFragment> clazz;
|
||||
public final int delay;
|
||||
|
@ -51,8 +53,9 @@ public enum LikesManager
|
|||
|
||||
static
|
||||
{
|
||||
sOldUsersMapping.put(1, LikeType.GPLAY_OLD_USERS);
|
||||
sOldUsersMapping.put(4, LikeType.GPLUS_OLD_USERS);
|
||||
sOldUsersMapping.put(1, LikeType.NEW_STYLE_OLD_USERS);
|
||||
sOldUsersMapping.put(4, 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);
|
||||
|
@ -76,7 +79,6 @@ public enum LikesManager
|
|||
private Runnable mLikeRunnable;
|
||||
private WeakReference<FragmentActivity> mActivityRef;
|
||||
|
||||
|
||||
public void showDialogs(FragmentActivity activity)
|
||||
{
|
||||
mActivityRef = new WeakReference<>(activity);
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.mapswithme.maps.ads;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
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.country.ActiveCountryTree;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmDialogFragment;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
public class UpdateMapsDialogFragment extends BaseMwmDialogFragment
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState)
|
||||
{
|
||||
final Activity activity = getActivity();
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
final LayoutInflater inflater = activity.getLayoutInflater();
|
||||
|
||||
@SuppressLint("InflateParams") final View root = inflater.inflate(R.layout.dialog_new_style, null);
|
||||
return builder.
|
||||
setView(root).
|
||||
setPositiveButton(R.string.update_maps_alert_button_title, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
ActiveCountryTree.updateAll();
|
||||
LikesManager.setRatingApplied(UpdateMapsDialogFragment.class, true);
|
||||
Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.NEW_STYLE_DIALOG_RATED);
|
||||
}
|
||||
}).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
super.onCancel(dialog);
|
||||
Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.NEW_STYLE_DIALOG_CANCELLED);
|
||||
}
|
||||
}
|
|
@ -71,6 +71,8 @@ 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 NEW_STYLE_DIALOG_RATED = "New style. Rated.";
|
||||
public static final String NEW_STYLE_DIALOG_CANCELLED = "New style. Cancelled.";
|
||||
}
|
||||
|
||||
public static class EventParam
|
||||
|
|
Loading…
Add table
Reference in a new issue