use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.
the class Offers method showInterstitialOfferIfNecessary.
public static void showInterstitialOfferIfNecessary(Activity ctx, String placement, final boolean shutdownAfterwards, final boolean dismissAfterwards, final boolean ignoreStartedTransfers) {
TransferManager TM = TransferManager.instance();
int startedTransfers = TM.incrementStartedTransfers();
ConfigurationManager CM = ConfigurationManager.instance();
final int INTERSTITIAL_OFFERS_TRANSFER_STARTS = DEBUG_MODE ? 1 : CM.getInt(Constants.PREF_KEY_GUI_INTERSTITIAL_OFFERS_TRANSFER_STARTS);
final int INTERSTITIAL_TRANSFER_OFFERS_TIMEOUT_IN_MINUTES = CM.getInt(Constants.PREF_KEY_GUI_INTERSTITIAL_TRANSFER_OFFERS_TIMEOUT_IN_MINUTES);
final long INTERSTITIAL_TRANSFER_OFFERS_TIMEOUT_IN_MS = DEBUG_MODE ? 10000 : TimeUnit.MINUTES.toMillis(INTERSTITIAL_TRANSFER_OFFERS_TIMEOUT_IN_MINUTES);
long lastInterstitialShownTimestamp = CM.getLong(Constants.PREF_KEY_GUI_INTERSTITIAL_LAST_DISPLAY);
long timeSinceLastOffer = System.currentTimeMillis() - lastInterstitialShownTimestamp;
boolean itsBeenLongEnough = timeSinceLastOffer >= INTERSTITIAL_TRANSFER_OFFERS_TIMEOUT_IN_MS;
boolean startedEnoughTransfers = startedTransfers >= INTERSTITIAL_OFFERS_TRANSFER_STARTS;
if (ignoreStartedTransfers) {
startedEnoughTransfers = true;
}
boolean shouldDisplayFirstOne = (lastInterstitialShownTimestamp == -1 && startedEnoughTransfers);
if (shouldDisplayFirstOne || (itsBeenLongEnough && startedEnoughTransfers)) {
Offers.showInterstitial(ctx, placement, shutdownAfterwards, dismissAfterwards);
TM.resetStartedTransfers();
}
}
use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.
the class Offers method getActiveAdNetworks.
/**
* Also checks the preference values under Constants.PREF_KEY_GUI_OFFERS_WATERFALL and deactivates
* the networks that have not been specified there.
* @return The Array of Active AdNetworks.
*/
private static AdNetwork[] getActiveAdNetworks() {
final ConfigurationManager CM = ConfigurationManager.instance();
final Map<String, AdNetwork> allAdNetworks = getAllAdNetworks();
final String[] waterfallShortcodes = CM.getStringArray(Constants.PREF_KEY_GUI_OFFERS_WATERFALL);
if (waterfallShortcodes == null) {
return new AdNetwork[] {};
}
final List<AdNetwork> activeAdNetworksList = new ArrayList<>(waterfallShortcodes.length);
for (String shortCode : waterfallShortcodes) {
if (allAdNetworks.containsKey(shortCode)) {
final AdNetwork adNetwork = allAdNetworks.get(shortCode);
adNetwork.enable(true);
activeAdNetworksList.add(adNetwork);
} else {
LOG.warn("unknown ad network shortcode '" + shortCode + "'");
}
}
// turn off all the networks not on activeAdNetworks if any.
for (String shortCode : allAdNetworks.keySet()) {
int shortCodeOffsetInWaterfall = getKeyOffset(shortCode, waterfallShortcodes);
boolean networkInUse = shortCodeOffsetInWaterfall != -1;
AdNetwork adNetwork = allAdNetworks.get(shortCode);
// can be null if there's a typo or it's a new network unknown to this client
if (adNetwork != null && !networkInUse) {
adNetwork.enable(false);
}
}
return activeAdNetworksList.toArray(new AdNetwork[0]);
}
use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.
the class SearchFragment method showRatingsReminder.
private void showRatingsReminder(View v) {
final RichNotification ratingReminder = findView(v, R.id.fragment_search_rating_reminder_notification);
ratingReminder.setVisibility(View.GONE);
final ConfigurationManager CM = ConfigurationManager.instance();
boolean alreadyRated = CM.getBoolean(Constants.PREF_KEY_GUI_ALREADY_RATED_US_IN_MARKET);
if (alreadyRated || ratingReminder.wasDismissed()) {
// LOG.info("SearchFragment.showRatingsReminder() aborted. alreadyRated="+alreadyRated + " wasDismissed=" + ratingReminder.wasDismissed());
return;
}
long installationTimestamp = CM.getLong(Constants.PREF_KEY_GUI_INSTALLATION_TIMESTAMP);
long daysInstalled = TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - installationTimestamp);
if (installationTimestamp == -1 || daysInstalled < 5) {
// LOG.info("SearchFragment.showRatingsReminder() aborted. Too soon to show ratings reminder. daysInstalled=" + daysInstalled);
return;
}
ClickAdapter<SearchFragment> onRateAdapter = new OnRateClickAdapter(SearchFragment.this, ratingReminder, CM);
ratingReminder.setOnClickListener(onRateAdapter);
RichNotificationActionLink rateFrostWireActionLink = new RichNotificationActionLink(ratingReminder.getContext(), getString(R.string.love_frostwire), onRateAdapter);
RichNotificationActionLink sendFeedbackActionLink = new RichNotificationActionLink(ratingReminder.getContext(), getString(R.string.send_feedback), new OnFeedbackClickAdapter(this, ratingReminder, CM));
ratingReminder.updateActionLinks(rateFrostWireActionLink, sendFeedbackActionLink);
ratingReminder.setVisibility(View.VISIBLE);
}
use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.
the class GeneralWizardPage method load.
@Override
public void load() {
ConfigurationManager CM = ConfigurationManager.instance();
textStoragePath.setText(CM.getStoragePath());
checkSeedFinishedTorrents.setChecked(CM.getBoolean(Constants.PREF_KEY_TORRENT_SEED_FINISHED_TORRENTS));
checkSeedFinishedTorrentsWifiOnly.setChecked(CM.getBoolean(Constants.PREF_KEY_TORRENT_SEED_FINISHED_TORRENTS_WIFI_ONLY));
checkSeedFinishedTorrentsWifiOnly.setEnabled(checkSeedFinishedTorrents.isChecked());
checkSeedFinishedTorrentsWifiOnly.setTextColor((checkSeedFinishedTorrents.isChecked()) ? Color.WHITE : getContext().getResources().getColor(R.color.app_text_wizard_dark));
checkUXStats.setChecked(CM.getBoolean(Constants.PREF_KEY_UXSTATS_ENABLED));
validate();
}
use of com.frostwire.android.core.ConfigurationManager in project frostwire by frostwire.
the class GeneralWizardPage method finish.
@Override
public void finish() {
ConfigurationManager CM = ConfigurationManager.instance();
CM.setBoolean(Constants.PREF_KEY_TORRENT_SEED_FINISHED_TORRENTS, checkSeedFinishedTorrents.isChecked());
CM.setBoolean(Constants.PREF_KEY_TORRENT_SEED_FINISHED_TORRENTS_WIFI_ONLY, checkSeedFinishedTorrentsWifiOnly.isChecked());
CM.setBoolean(Constants.PREF_KEY_UXSTATS_ENABLED, checkUXStats.isChecked());
}
Aggregations