Search in sources :

Example 11 with ConfigurationManager

use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.

the class TransferManager method onPreferenceChanged.

private void onPreferenceChanged(String key) {
    // LOG.info("onPreferenceChanged(key="+key+")");
    Engine.instance().getThreadPool().execute(() -> {
        BTEngine e = BTEngine.getInstance();
        ConfigurationManager CM = ConfigurationManager.instance();
        if (key.equals(Constants.PREF_KEY_TORRENT_MAX_DOWNLOAD_SPEED)) {
            e.downloadRateLimit((int) CM.getLong(key));
        } else if (key.equals(Constants.PREF_KEY_TORRENT_MAX_UPLOAD_SPEED)) {
            e.uploadRateLimit((int) CM.getLong(key));
        } else if (key.equals(Constants.PREF_KEY_TORRENT_MAX_DOWNLOADS)) {
            e.maxActiveDownloads((int) CM.getLong(key));
        } else if (key.equals(Constants.PREF_KEY_TORRENT_MAX_UPLOADS)) {
            e.maxActiveSeeds((int) CM.getLong(key));
        } else if (key.equals(Constants.PREF_KEY_TORRENT_MAX_TOTAL_CONNECTIONS)) {
            e.maxConnections((int) CM.getLong(key));
        } else if (key.equals(Constants.PREF_KEY_TORRENT_MAX_PEERS)) {
            e.maxPeers((int) CM.getLong(key));
        }
    });
}
Also used : BTEngine(com.frostwire.bittorrent.BTEngine) ConfigurationManager(com.frostwire.android.core.ConfigurationManager)

Example 12 with ConfigurationManager

use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.

the class MainActivity method tryOnResumeInterstitial.

private void tryOnResumeInterstitial() {
    if (Offers.disabledAds()) {
        LOG.info("tryOnResumeInterstitial() aborted - ads disabled");
        delayedOnResumeInterstitialRunnable = null;
        return;
    }
    ConfigurationManager CM = ConfigurationManager.instance();
    // TEST. Uncomment below
    // CM.setLong(Constants.PREF_KEY_GUI_INSTALLATION_TIMESTAMP, (long) (System.currentTimeMillis() - 8.64e+7));
    long installationTimestamp = CM.getLong(Constants.PREF_KEY_GUI_INSTALLATION_TIMESTAMP);
    if (installationTimestamp == -1) {
        LOG.info("tryOnResumeInterstitial() aborted - wizard not finished");
        delayedOnResumeInterstitialRunnable = null;
        return;
    }
    if (!UIUtils.diceRollPassesThreshold(CM, Constants.PREF_KEY_GUI_INTERSTITIAL_ON_RESUME_THRESHOLD)) {
        LOG.info("tryOnResumeInterstitial() aborted - threshold not met");
        delayedOnResumeInterstitialRunnable = null;
        return;
    }
    long now = System.currentTimeMillis();
    long lastDisplayTimestamp = CM.getLong(Constants.PREF_KEY_GUI_INTERSTITIAL_LAST_DISPLAY);
    // if it's never been displayed, we check against the first display delayInMs setting
    if (lastDisplayTimestamp == -1) {
        int minutesSinceInstallation = (int) TimeUnit.MILLISECONDS.toMinutes(now - installationTimestamp);
        int firstDisplayDelayInMinutes = CM.getInt(Constants.PREF_KEY_GUI_INTERSTITIAL_ON_RESUME_FIRST_DISPLAY_DELAY_IN_MINUTES);
        if (minutesSinceInstallation < firstDisplayDelayInMinutes || firstDisplayDelayInMinutes == 0) {
            LOG.info("tryOnResumeInterstitial() aborted - not ready for first display yet (initialDelay=" + firstDisplayDelayInMinutes + ", minutesSinceInstallation=" + minutesSinceInstallation + ")");
            delayedOnResumeInterstitialRunnable = null;
            return;
        }
    // LOG.info("tryOnResumeInterstitial() might be ready for first display (initialDelay=" + firstDisplayDelayInMinutes + ", minutesSinceInstallation=" + minutesSinceInstallation + ")");
    } else {
        int minutesSinceSessionStarted = (int) TimeUnit.MILLISECONDS.toMinutes(now - CM.getLong(Constants.PREF_KEY_MAIN_APPLICATION_ON_CREATE_TIMESTAMP));
        int minutesSinceLastDisplay = (int) TimeUnit.MILLISECONDS.toMinutes(now - lastDisplayTimestamp);
        int onResumeOfferTimeoutInMinutes = CM.getInt(Constants.PREF_KEY_GUI_INTERSTITIAL_ON_RESUME_TIMEOUT_IN_MINUTES);
        if (minutesSinceSessionStarted < onResumeOfferTimeoutInMinutes || minutesSinceLastDisplay < onResumeOfferTimeoutInMinutes) {
            LOG.info("tryOnResumeInterstitial() aborted - too soon for next display (timeoutInMinutes=" + onResumeOfferTimeoutInMinutes + ", minutesSinceLastDisplay=" + minutesSinceLastDisplay + ", minutesSinceSessionStarted=" + minutesSinceSessionStarted + ")");
            delayedOnResumeInterstitialRunnable = null;
            return;
        }
        LOG.info("tryOnResumeInterstitial() ready for next display (timeoutInMinutes=" + onResumeOfferTimeoutInMinutes + ", minutesSinceLastDisplay=" + minutesSinceLastDisplay + ", minutesSinceSessionStarted=" + minutesSinceSessionStarted + ")");
    }
    LOG.info("tryOnResumeInterstitial() - creating new delayedOnResumeInterstitialRunnable attempt");
    delayedOnResumeInterstitialRunnable = new DelayedOnResumeInterstitialRunnable(2000, this);
    Engine.instance().getThreadPool().execute(delayedOnResumeInterstitialRunnable);
}
Also used : ConfigurationManager(com.frostwire.android.core.ConfigurationManager)

Example 13 with ConfigurationManager

use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.

the class MainActivity method checkLastSeenVersionBuild.

private void checkLastSeenVersionBuild() {
    final ConfigurationManager CM = ConfigurationManager.instance();
    final String lastSeenVersionBuild = CM.getString(Constants.PREF_KEY_CORE_LAST_SEEN_VERSION_BUILD);
    final String currentVersionBuild = Constants.FROSTWIRE_VERSION_STRING + "." + Constants.FROSTWIRE_BUILD;
    if (StringUtils.isNullOrEmpty(lastSeenVersionBuild)) {
        // fresh install
        // no ads on first session ever
        Offers.forceDisabledAds(this);
        CM.setString(Constants.PREF_KEY_CORE_LAST_SEEN_VERSION_BUILD, currentVersionBuild);
        UXStats.instance().log(UXAction.CONFIGURATION_WIZARD_FIRST_TIME);
    } else if (!currentVersionBuild.equals(lastSeenVersionBuild)) {
        // just updated.
        // no ads right after update
        Offers.forceDisabledAds(this);
        CM.setString(Constants.PREF_KEY_CORE_LAST_SEEN_VERSION_BUILD, currentVersionBuild);
        UXStats.instance().log(UXAction.CONFIGURATION_WIZARD_AFTER_UPDATE);
    }
}
Also used : ConfigurationManager(com.frostwire.android.core.ConfigurationManager)

Example 14 with ConfigurationManager

use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.

the class WizardActivity method nextPage.

private void nextPage() {
    View view = viewFlipper.getCurrentView();
    if (view instanceof WizardPageView) {
        WizardPageView pageView = (WizardPageView) view;
        pageView.finish();
        if (!pageView.hasNext()) {
            ConfigurationManager CM = ConfigurationManager.instance();
            CM.setBoolean(Constants.PREF_KEY_GUI_TOS_ACCEPTED, true);
            CM.setBoolean(Constants.PREF_KEY_GUI_INITIAL_SETTINGS_COMPLETE, true);
            CM.setLong(Constants.PREF_KEY_GUI_INSTALLATION_TIMESTAMP, System.currentTimeMillis());
        } else {
            viewFlipper.showNext();
            setupViewPage();
        }
    } else {
        viewFlipper.showNext();
        setupViewPage();
    }
}
Also used : WizardPageView(com.frostwire.android.gui.views.WizardPageView) WizardPageView(com.frostwire.android.gui.views.WizardPageView) View(android.view.View) ConfigurationManager(com.frostwire.android.core.ConfigurationManager)

Aggregations

ConfigurationManager (com.frostwire.android.core.ConfigurationManager)14 NetworkManager (com.frostwire.android.gui.NetworkManager)2 View (android.view.View)1 OnFeedbackClickAdapter (com.frostwire.android.gui.adapters.OnFeedbackClickAdapter)1 TransferManager (com.frostwire.android.gui.transfers.TransferManager)1 DirectionDetectorScrollListener (com.frostwire.android.gui.util.DirectionDetectorScrollListener)1 ComposedOnScrollListener (com.frostwire.android.gui.util.ScrollListeners.ComposedOnScrollListener)1 FastScrollDisabledWhenIdleOnScrollListener (com.frostwire.android.gui.util.ScrollListeners.FastScrollDisabledWhenIdleOnScrollListener)1 RichNotification (com.frostwire.android.gui.views.RichNotification)1 RichNotificationActionLink (com.frostwire.android.gui.views.RichNotificationActionLink)1 WizardPageView (com.frostwire.android.gui.views.WizardPageView)1 BTEngine (com.frostwire.bittorrent.BTEngine)1 UXStatsConf (com.frostwire.uxstats.UXStatsConf)1 ArrayList (java.util.ArrayList)1