forked from organicmaps/organicmaps
Listen for buyPro callbacks in base activities. Fixes downloader problem with routing in Lite.
This commit is contained in:
parent
1511bfa963
commit
d5242b603d
5 changed files with 64 additions and 56 deletions
|
@ -243,4 +243,11 @@ public class DownloadActivity extends MapsWithMeBaseListActivity implements View
|
|||
{
|
||||
updateActionBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBuyPro()
|
||||
{
|
||||
super.onBuyPro();
|
||||
getDownloadAdapter().notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import com.mapswithme.country.ActiveCountryTree;
|
|||
import com.mapswithme.country.DownloadActivity;
|
||||
import com.mapswithme.maps.Ads.AdsManager;
|
||||
import com.mapswithme.maps.Ads.MenuAd;
|
||||
import com.mapswithme.maps.Framework.BuyProListener;
|
||||
import com.mapswithme.maps.Framework.OnBalloonListener;
|
||||
import com.mapswithme.maps.Framework.RoutingListener;
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
|
@ -83,7 +82,7 @@ import java.util.Stack;
|
|||
|
||||
public class MWMActivity extends NvEventQueueActivity
|
||||
implements LocationService.LocationListener, OnBalloonListener, OnVisibilityChangedListener,
|
||||
OnClickListener, RoutingListener, BuyProListener
|
||||
OnClickListener, RoutingListener
|
||||
{
|
||||
public static final String EXTRA_TASK = "map_task";
|
||||
private final static String TAG = "MWMActivity";
|
||||
|
@ -306,7 +305,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
public void onBookmarksClicked(View v)
|
||||
{
|
||||
if (!MWMApplication.get().hasBookmarks())
|
||||
showProVersionBanner(getString(R.string.bookmarks_in_pro_version));
|
||||
UiUtils.showBuyProDialog(this, getString(R.string.bookmarks_in_pro_version));
|
||||
else
|
||||
startActivity(new Intent(this, BookmarkCategoriesActivity.class));
|
||||
}
|
||||
|
@ -536,18 +535,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void showProVersionBanner(final String message)
|
||||
{
|
||||
runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
UiUtils.showBuyProDialog(MWMActivity.this, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkBuyProDialog()
|
||||
{
|
||||
if (!BuildConfig.IS_PRO &&
|
||||
|
@ -577,9 +564,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
public void onSearchClicked(View v)
|
||||
{
|
||||
if (!BuildConfig.IS_PRO)
|
||||
{
|
||||
showProVersionBanner(getString(R.string.search_available_in_pro_version));
|
||||
}
|
||||
UiUtils.showBuyProDialog(this, getString(R.string.search_available_in_pro_version));
|
||||
else if (!MapStorage.INSTANCE.updateMaps(R.string.search_update_maps, this, new MapStorage.UpdateFunctor()
|
||||
{
|
||||
@Override
|
||||
|
@ -742,7 +727,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
setUpRoutingBox();
|
||||
|
||||
Framework.nativeSetRoutingListener(this);
|
||||
Framework.nativeSetBuyProListener(this);
|
||||
Framework.nativeConnectBalloonListeners(this);
|
||||
|
||||
final Intent intent = getIntent();
|
||||
|
@ -1451,7 +1435,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
{
|
||||
if (!BuildConfig.IS_PRO)
|
||||
{
|
||||
showProVersionBanner(getString(R.string.routing_failed_buy_pro));
|
||||
UiUtils.showBuyProDialog(this, getString(R.string.routing_failed_buy_pro));
|
||||
return;
|
||||
}
|
||||
if (!MWMApplication.get().nativeGetBoolean(IS_ROUTING_DISCLAIMER_APPROVED, false))
|
||||
|
@ -1619,11 +1603,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
});
|
||||
}
|
||||
|
||||
public void onBuyPro()
|
||||
{
|
||||
showProVersionBanner(getString(R.string.routing_failed_buy_pro));
|
||||
}
|
||||
|
||||
public interface MapTask extends Serializable
|
||||
{
|
||||
public boolean run(MWMActivity target);
|
||||
|
|
|
@ -8,14 +8,18 @@ import android.support.v4.app.FragmentActivity;
|
|||
import android.view.MenuItem;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
public class MapsWithMeBaseFragmentActivity extends FragmentActivity
|
||||
public class MapsWithMeBaseFragmentActivity extends FragmentActivity implements Framework.BuyProListener
|
||||
{
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
Framework.nativeSetBuyProListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,4 +64,8 @@ public class MapsWithMeBaseFragmentActivity extends FragmentActivity
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void onBuyPro()
|
||||
{
|
||||
UiUtils.showBuyProDialog(MapsWithMeBaseFragmentActivity.this, getString(R.string.routing_failed_buy_pro));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,15 +9,24 @@ import android.support.v4.app.ListFragment;
|
|||
import android.view.MenuItem;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
/**
|
||||
* TODO use simple activity and {@link ListFragment} instead.
|
||||
*/
|
||||
public class MapsWithMeBaseListActivity extends ListActivity
|
||||
public class MapsWithMeBaseListActivity extends ListActivity implements Framework.BuyProListener
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
Framework.nativeSetBuyProListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
|
@ -46,11 +55,6 @@ public class MapsWithMeBaseListActivity extends ListActivity
|
|||
}
|
||||
}
|
||||
|
||||
public MWMApplication getMwmApplication()
|
||||
{
|
||||
return (MWMApplication) getApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
|
@ -66,4 +70,8 @@ public class MapsWithMeBaseListActivity extends ListActivity
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void onBuyPro()
|
||||
{
|
||||
UiUtils.showBuyProDialog(MapsWithMeBaseListActivity.this, getString(R.string.routing_failed_buy_pro));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,30 +272,36 @@ public final class UiUtils
|
|||
showIf(!TextUtils.isEmpty(text), tv);
|
||||
}
|
||||
|
||||
public static void showBuyProDialog(final Activity activity, String message)
|
||||
public static void showBuyProDialog(final Activity activity, final String message)
|
||||
{
|
||||
new AlertDialog.Builder(activity)
|
||||
.setMessage(message)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(activity.getString(R.string.get_it_now), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
openAppInMarket(activity, BuildConfig.PRO_URL);
|
||||
}
|
||||
}).
|
||||
setNegativeButton(activity.getString(R.string.cancel), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
new AlertDialog.Builder(activity)
|
||||
.setMessage(message)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(activity.getString(R.string.get_it_now), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
openAppInMarket(activity, BuildConfig.PRO_URL);
|
||||
}
|
||||
}).
|
||||
setNegativeButton(activity.getString(R.string.cancel), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void openAppInMarket(Activity activity, String marketUrl)
|
||||
|
|
Loading…
Add table
Reference in a new issue