Search in sources :

Example 1 with SoftwareUpdaterDialog

use of com.frostwire.android.gui.dialogs.SoftwareUpdaterDialog in project frostwire by frostwire.

the class SoftwareUpdater method notifyUserAboutUpdate.

public void notifyUserAboutUpdate(final MainActivity activity) {
    try {
        if (update.a == null) {
            // make it the old behavior
            update.a = UPDATE_ACTION_OTA;
        }
        if (update.a.equals(UPDATE_ACTION_OTA)) {
            if (!ALWAYS_SHOW_UPDATE_DIALOG && !getUpdateApk().exists()) {
                LOG.info("notifyUserAboutUpdate(): " + getUpdateApk().getAbsolutePath() + " not found. Aborting.");
                return;
            }
            // Fresh runs with fast connections might send the broadcast intent before
            // MainActivity has had a chance to register the broadcast receiver (onResume)
            // therefore, the menu update icon will only show on the 2nd run only
            activity.updateNavigationMenu(true);
            SoftwareUpdaterDialog dlg = SoftwareUpdaterDialog.newInstance(update.updateMessages, update.changelog);
            dlg.show(activity.getFragmentManager());
        } else if (update.a.equals(UPDATE_ACTION_MARKET)) {
            String message = StringUtils.getLocaleString(update.marketMessages, activity.getString(R.string.update_message));
            UIUtils.showYesNoDialog(activity.getFragmentManager(), message, R.string.update_title, (dialog, which) -> {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(update.m));
                activity.startActivity(intent);
            });
        }
    } catch (Throwable e) {
        LOG.error("Failed to notify update", e);
        // try again next time MainActivity is resumed
        updateTimestamp = -1;
    }
}
Also used : ConfigurationManager(com.frostwire.android.core.ConfigurationManager) UXStats(com.frostwire.uxstats.UXStats) BufferedInputStream(java.io.BufferedInputStream) Logger(com.frostwire.util.Logger) MessageDigest(java.security.MessageDigest) Uri(android.net.Uri) Intent(android.content.Intent) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) StringUtils(com.frostwire.util.StringUtils) BuildConfig(com.frostwire.android.BuildConfig) MainActivity(com.frostwire.android.gui.activities.MainActivity) JsonUtils(com.frostwire.util.JsonUtils) Map(java.util.Map) BigInteger(java.math.BigInteger) WeakReference(java.lang.ref.WeakReference) HttpClientFactory(com.frostwire.util.HttpClientFactory) Offers(com.frostwire.android.offers.Offers) AsyncTask(android.os.AsyncTask) UXStatsConf(com.frostwire.uxstats.UXStatsConf) R(com.frostwire.android.R) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Ref(com.frostwire.util.Ref) File(java.io.File) SoftwareUpdaterDialog(com.frostwire.android.gui.dialogs.SoftwareUpdaterDialog) UIUtils(com.frostwire.android.gui.util.UIUtils) List(java.util.List) Platforms(com.frostwire.platform.Platforms) Constants(com.frostwire.android.core.Constants) InputStream(java.io.InputStream) SoftwareUpdaterDialog(com.frostwire.android.gui.dialogs.SoftwareUpdaterDialog) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)1 Uri (android.net.Uri)1 AsyncTask (android.os.AsyncTask)1 LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)1 BuildConfig (com.frostwire.android.BuildConfig)1 R (com.frostwire.android.R)1 ConfigurationManager (com.frostwire.android.core.ConfigurationManager)1 Constants (com.frostwire.android.core.Constants)1 MainActivity (com.frostwire.android.gui.activities.MainActivity)1 SoftwareUpdaterDialog (com.frostwire.android.gui.dialogs.SoftwareUpdaterDialog)1 UIUtils (com.frostwire.android.gui.util.UIUtils)1 Offers (com.frostwire.android.offers.Offers)1 Platforms (com.frostwire.platform.Platforms)1 HttpClientFactory (com.frostwire.util.HttpClientFactory)1 JsonUtils (com.frostwire.util.JsonUtils)1 Logger (com.frostwire.util.Logger)1 Ref (com.frostwire.util.Ref)1 StringUtils (com.frostwire.util.StringUtils)1 UXStats (com.frostwire.uxstats.UXStats)1 UXStatsConf (com.frostwire.uxstats.UXStatsConf)1