forked from organicmaps/organicmaps
Removed promoaction code.
This commit is contained in:
parent
7a463c166b
commit
0d18941f77
5 changed files with 0 additions and 251 deletions
|
@ -29,9 +29,6 @@ import android.widget.RelativeLayout;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.facebook.Session;
|
||||
import com.facebook.SessionState;
|
||||
import com.facebook.UiLifecycleHelper;
|
||||
import com.mapswithme.country.DownloadActivity;
|
||||
import com.mapswithme.maps.Ads.AdsManager;
|
||||
import com.mapswithme.maps.Ads.MenuAd;
|
||||
|
@ -58,7 +55,6 @@ import com.mapswithme.maps.widget.MapInfoView.OnVisibilityChangedListener;
|
|||
import com.mapswithme.maps.widget.MapInfoView.State;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.Constants;
|
||||
import com.mapswithme.util.FbUtil;
|
||||
import com.mapswithme.util.LocationUtils;
|
||||
import com.mapswithme.util.ShareAction;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
@ -108,21 +104,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
private static final String IS_KML_MOVED = "KmlBeenMoved";
|
||||
private static final String IS_KITKAT_MIGRATION_COMPLETED = "KitKatMigrationCompleted";
|
||||
private static final String IS_FIRST_RUN = "FirstRun";
|
||||
|
||||
// facebook
|
||||
private static final String PENDING_PUBLISH_KEY = "mShouldReauthorize";
|
||||
private boolean mShouldReauthorize;
|
||||
private UiLifecycleHelper mFbUiHelper;
|
||||
private Session.StatusCallback mFbStatusCallback = new Session.StatusCallback()
|
||||
{
|
||||
@Override
|
||||
public void call(Session session, SessionState state, Exception exception)
|
||||
{
|
||||
if (state != null && state.isOpened() && mShouldReauthorize)
|
||||
mShouldReauthorize = FbUtil.makeFbPromoPost(MWMActivity.this);
|
||||
}
|
||||
};
|
||||
|
||||
// ads in vertical toolbar
|
||||
private BroadcastReceiver mUpdateAdsReceiver = new BroadcastReceiver()
|
||||
|
@ -727,9 +708,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
onMyPositionClicked(null);
|
||||
}
|
||||
|
||||
mFbUiHelper = new UiLifecycleHelper(this, mFbStatusCallback);
|
||||
mFbUiHelper.onCreate(savedInstanceState);
|
||||
|
||||
updateToolbarAds();
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mUpdateAdsReceiver, new IntentFilter(WorkerService.ACTION_UPDATE_MENU_ADS));
|
||||
}
|
||||
|
@ -835,8 +813,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
Framework.nativeClearBalloonListeners();
|
||||
|
||||
super.onDestroy();
|
||||
|
||||
mFbUiHelper.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1033,8 +1009,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
stopWatchingCompassStatusUpdate();
|
||||
|
||||
super.onPause();
|
||||
|
||||
mFbUiHelper.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1059,50 +1033,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
MWMApplication.get().onMwmResume(this);
|
||||
|
||||
mFbUiHelper.onResume();
|
||||
if (MWMApplication.get().isProVersion() && MWMApplication.get().nativeGetBoolean(IS_FIRST_RUN, true))
|
||||
{
|
||||
MWMApplication.get().nativeSetBoolean(IS_FIRST_RUN, false);
|
||||
|
||||
if (FbUtil.isPromoTimeNow())
|
||||
showPromoDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void showPromoDialog()
|
||||
{
|
||||
final TextView textView = (TextView) getLayoutInflater().inflate(R.layout.title_share_dialog, null);
|
||||
textView.setText(getString(R.string.maps_me_is_free_today_android));
|
||||
|
||||
new AlertDialog.Builder(MWMActivity.this)
|
||||
.setCustomTitle(textView)
|
||||
.setMessage(getString(R.string.maps_me_is_free_today_facebook_post_android))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.share, new Dialog.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
if (Session.getActiveSession() != null && Session.getActiveSession().isOpened())
|
||||
mShouldReauthorize = FbUtil.makeFbPromoPost(MWMActivity.this);
|
||||
else
|
||||
{
|
||||
mShouldReauthorize = true;
|
||||
Session.openActiveSession(getActivity(), true, mFbStatusCallback);
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.no_thanks), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private void updateExternalStorageState()
|
||||
|
@ -1419,11 +1349,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
final Point bmk = ((ParcelablePoint) data.getParcelableExtra(BookmarkActivity.PIN)).getPoint();
|
||||
onBookmarkActivated(bmk.x, bmk.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFbUiHelper.onActivityResult(requestCode, resultCode, data);
|
||||
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
|
@ -1480,19 +1405,4 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState)
|
||||
{
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(PENDING_PUBLISH_KEY, mShouldReauthorize);
|
||||
mFbUiHelper.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState)
|
||||
{
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
mShouldReauthorize = savedInstanceState.getBoolean(PENDING_PUBLISH_KEY, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.mapswithme.maps;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
@ -157,14 +156,6 @@ public class MWMApplication extends android.app.Application implements MapStorag
|
|||
if (hasBookmarks())
|
||||
BookmarkManager.getBookmarkManager(getApplicationContext());
|
||||
|
||||
final SharedPreferences prefs = getSharedPreferences(getString(R.string.pref_file_name), MODE_PRIVATE);
|
||||
if (!prefs.getBoolean(PROMO_NOTIFICATION_SHOWED, false))
|
||||
{
|
||||
Notifier.schedulePromoNotification();
|
||||
|
||||
prefs.edit().putBoolean(PROMO_NOTIFICATION_SHOWED, true).commit();
|
||||
}
|
||||
|
||||
WorkerService.startActionUpdateAds(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ public class Notifier
|
|||
private final static int ID_GUIDE_AVAIL = 0x2;
|
||||
private final static int ID_DOWNLOAD_STATUS = 0x3;
|
||||
private final static int ID_DOWNLOAD_NEW_COUNTRY = 0x4;
|
||||
private final static int ID_MWM_PRO_PROMOACTION = 0x5;
|
||||
|
||||
private Notifier() { }
|
||||
|
||||
|
@ -121,48 +120,4 @@ public class Notifier
|
|||
|
||||
Statistics.INSTANCE.trackDownloadCountryNotificationShown();
|
||||
}
|
||||
|
||||
public static void schedulePromoNotification()
|
||||
{
|
||||
final int promoYear = 2014;
|
||||
final int promoDate = 17;
|
||||
final int promoHour = 12;
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, promoYear);
|
||||
calendar.set(Calendar.MONTH, Calendar.AUGUST);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, promoDate);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, promoHour);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
|
||||
if (System.currentTimeMillis() < calendar.getTimeInMillis())
|
||||
{
|
||||
final Intent intent = new Intent(MWMApplication.get(), WorkerService.class).
|
||||
setAction(WorkerService.ACTION_PROMO_NOTIFICATION_SHOW);
|
||||
final PendingIntent pendingIntent = PendingIntent.getService(MWMApplication.get(), 0, intent, 0);
|
||||
|
||||
final AlarmManager alarm = (AlarmManager) MWMApplication.get().getSystemService(Context.ALARM_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
||||
alarm.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
|
||||
else
|
||||
alarm.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void placePromoNotification()
|
||||
{
|
||||
final Intent intent = new Intent(MWMApplication.get(), WorkerService.class).
|
||||
setAction(WorkerService.ACTION_PROMO_NOTIFICATION_CLICK);
|
||||
final PendingIntent pendingIntent = PendingIntent.getService(MWMApplication.get(), 0, intent, 0);
|
||||
|
||||
final String text = MWMApplication.get().getString(R.string.pro_version_is_free_today_android);
|
||||
final Notification notification = getBuilder()
|
||||
.setContentTitle(MWMApplication.get().getString(R.string.app_name))
|
||||
.setContentText(text)
|
||||
.setTicker(text)
|
||||
.setContentIntent(pendingIntent)
|
||||
.build();
|
||||
|
||||
getNotificationManager().notify(ID_MWM_PRO_PROMOACTION, notification);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,16 +6,13 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.Ads.AdsManager;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.LocationUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.StubLogger;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
@ -33,8 +30,6 @@ public class WorkerService extends IntentService
|
|||
public static final String ACTION_PUSH_STATISTICS = "com.mapswithme.maps.action.stat";
|
||||
public static final String ACTION_CHECK_UPDATE = "com.mapswithme.maps.action.update";
|
||||
public static final String ACTION_DOWNLOAD_COUNTRY = "com.mapswithme.maps.action.download_country";
|
||||
public static final String ACTION_PROMO_NOTIFICATION_SHOW = "com.mapswithme.maps.action.notification.show";
|
||||
public static final String ACTION_PROMO_NOTIFICATION_CLICK = "com.mapswithme.maps.action.notification.click";
|
||||
public static final String ACTION_UPDATE_MENU_ADS = "com.mapswithme.maps.action.ads.update";
|
||||
|
||||
private static final String PROMO_SHOW_EVENT_NAME = "PromoShowAndroid";
|
||||
|
@ -116,12 +111,6 @@ public class WorkerService extends IntentService
|
|||
case ACTION_DOWNLOAD_COUNTRY:
|
||||
handleActionCheckLocation();
|
||||
break;
|
||||
case ACTION_PROMO_NOTIFICATION_SHOW:
|
||||
showPromoNotification();
|
||||
break;
|
||||
case ACTION_PROMO_NOTIFICATION_CLICK:
|
||||
promoNotificationClicked();
|
||||
break;
|
||||
case ACTION_UPDATE_MENU_ADS:
|
||||
updateMenuAds();
|
||||
break;
|
||||
|
@ -219,24 +208,6 @@ public class WorkerService extends IntentService
|
|||
}
|
||||
}
|
||||
|
||||
private void showPromoNotification()
|
||||
{
|
||||
Notifier.placePromoNotification();
|
||||
Statistics.INSTANCE.trackSimpleNamedEvent(PROMO_SHOW_EVENT_NAME);
|
||||
}
|
||||
|
||||
private void promoNotificationClicked()
|
||||
{
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MWMApplication.get().getProVersionURL())).
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (!Utils.isIntentAvailable(intent))
|
||||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MWMApplication.get().getDefaultProVersionURL())).
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
startActivity(intent);
|
||||
Statistics.INSTANCE.trackSimpleNamedEvent(PROMO_CLICK_EVENT_NAME);
|
||||
}
|
||||
|
||||
private void updateMenuAds()
|
||||
{
|
||||
AdsManager.updateMenuAds();
|
||||
|
|
|
@ -1,24 +1,14 @@
|
|||
package com.mapswithme.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.facebook.AppEventsLogger;
|
||||
import com.facebook.FacebookRequestError;
|
||||
import com.facebook.HttpMethod;
|
||||
import com.facebook.Request;
|
||||
import com.facebook.RequestAsyncTask;
|
||||
import com.facebook.Response;
|
||||
import com.facebook.Session;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.SimpleLogger;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -53,73 +43,5 @@ public class FbUtil
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to get session with publish permissions and create a promo post.
|
||||
*
|
||||
* @param activity
|
||||
* @return true, if should reauthorize
|
||||
*/
|
||||
public static boolean makeFbPromoPost(Activity activity)
|
||||
{
|
||||
Session session = Session.getActiveSession();
|
||||
|
||||
if (session != null)
|
||||
{
|
||||
// check publish permissions
|
||||
List<String> permissions = session.getPermissions();
|
||||
if (!FbUtil.isSubsetOf(PUBLISH_PERMISSIONS, permissions))
|
||||
{
|
||||
Session.NewPermissionsRequest newPermissionsRequest = new Session
|
||||
.NewPermissionsRequest(activity, PUBLISH_PERMISSIONS);
|
||||
session.requestNewPublishPermissions(newPermissionsRequest);
|
||||
return true;
|
||||
}
|
||||
|
||||
final Bundle postParams = new Bundle();
|
||||
postParams.putString("message", activity.getString(R.string.maps_me_is_free_today_facebook_post_android));
|
||||
postParams.putString("link", PROMO_MARKET_URL);
|
||||
postParams.putString("picture", PROMO_IMAGE_URL);
|
||||
|
||||
Request.Callback callback = new Request.Callback()
|
||||
{
|
||||
public void onCompleted(Response response)
|
||||
{
|
||||
FacebookRequestError error = response.getError();
|
||||
if (error != null)
|
||||
Utils.toastShortcut(MWMApplication.get(), error.getErrorMessage());
|
||||
}
|
||||
};
|
||||
|
||||
Request request = new Request(session, "me/feed", postParams, HttpMethod.POST, callback);
|
||||
|
||||
RequestAsyncTask task = new RequestAsyncTask(request);
|
||||
task.execute();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPromoTimeNow()
|
||||
{
|
||||
final int promoYear = 2014;
|
||||
final int promoDateStart = 17;
|
||||
final int promoDateEnd = 18;
|
||||
final int promoHourStart = 2;
|
||||
final int promoHourEnd = 22;
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, promoYear);
|
||||
calendar.set(Calendar.MONTH, Calendar.AUGUST);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, promoDateStart);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, promoHourStart);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
final long startMillis = calendar.getTimeInMillis();
|
||||
calendar.set(Calendar.DAY_OF_MONTH, promoDateEnd);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, promoHourEnd);
|
||||
final long endMillis = calendar.getTimeInMillis();
|
||||
|
||||
return System.currentTimeMillis() > startMillis && System.currentTimeMillis() < endMillis;
|
||||
}
|
||||
|
||||
private FbUtil() {}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue