Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-10-19 23:24:50 +02:00
commit 3e7d106e28
4 changed files with 21 additions and 36 deletions

View file

@ -1877,7 +1877,9 @@ public class OsmandSettings {
public final OsmandPreference<Integer> NUMBER_OF_FREE_DOWNLOADS = new IntPreference("free_downloads_v2", 0).makeGlobal(); // public final OsmandPreference<Integer> NUMBER_OF_FREE_DOWNLOADS_V2 = new IntPreference("free_downloads_v2", 0).makeGlobal();
public final OsmandPreference<Integer> NUMBER_OF_FREE_DOWNLOADS = new IntPreference("free_downloads_v3", 0).makeGlobal();
// For DashRateUsFragment // For DashRateUsFragment
public final OsmandPreference<Long> LAST_DISPLAY_TIME = public final OsmandPreference<Long> LAST_DISPLAY_TIME =
@ -1890,13 +1892,6 @@ public class OsmandSettings {
.makeGlobal() .makeGlobal()
.cache(); .cache();
public boolean checkFreeDownloadsNumberZero(){
if(!settingsAPI.contains(globalPreferences,NUMBER_OF_FREE_DOWNLOADS.getId())){
NUMBER_OF_FREE_DOWNLOADS.set(0);
return true;
}
return false;
}
public enum DayNightMode { public enum DayNightMode {
AUTO(R.string.daynight_mode_auto), AUTO(R.string.daynight_mode_auto),

View file

@ -1,6 +1,18 @@
package net.osmand.plus.development; package net.osmand.plus.development;
import java.text.SimpleDateFormat;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.util.SunriseSunset;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
@ -14,24 +26,12 @@ import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.view.View; import android.view.View;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.util.SunriseSunset;
import java.text.SimpleDateFormat;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
//import net.osmand.plus.development.OsmandDevelopmentPlugin; //import net.osmand.plus.development.OsmandDevelopmentPlugin;
public class SettingsDevelopmentActivity extends SettingsBaseActivity { public class SettingsDevelopmentActivity extends SettingsBaseActivity {
@SuppressLint("SimpleDateFormat")
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this); ((OsmandApplication) getApplication()).applyTheme(this);
@ -143,7 +143,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
final Preference agpspref = new Preference(this); final Preference agpspref = new Preference(this);
agpspref.setTitle(R.string.agps_info); agpspref.setTitle(R.string.agps_info);
if (settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get() != 0L) { if (settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get() != 0L) {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get()))); agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
} else { } else {
@ -157,7 +156,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
if(getMyApplication().getSettings().isInternetConnectionAvailable(true)) { if(getMyApplication().getSettings().isInternetConnectionAvailable(true)) {
getMyApplication().getLocationProvider().redownloadAGPS(); getMyApplication().getLocationProvider().redownloadAGPS();
@SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get()))); agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
} }
@ -170,7 +168,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
pref = new Preference(this); pref = new Preference(this);
pref.setTitle(R.string.day_night_info); pref.setTitle(R.string.day_night_info);
if (sunriseSunset != null) { if (sunriseSunset != null) {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
pref.setSummary(getString(R.string.day_night_info_description, prt.format(sunriseSunset.getSunrise()), pref.setSummary(getString(R.string.day_night_info_description, prt.format(sunriseSunset.getSunrise()),
prt.format(sunriseSunset.getSunset()))); prt.format(sunriseSunset.getSunset())));
@ -185,9 +182,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER, cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER,
R.string.show_free_version_banner, R.string.show_free_version_banner,
R.string.show_free_version_banner_description)); R.string.show_free_version_banner_description));
cat.addPreference(createSeekBarPreference(settings.NUMBER_OF_FREE_DOWNLOADS,
R.string.free_downloads_used, R.string.free_downloads_used_description,
R.string.free_downloads_used, 5, 10));
} }
protected void availableProfileDialog() { protected void availableProfileDialog() {

View file

@ -29,7 +29,7 @@ public class BaseDownloadActivity extends ActionBarProgressActivity implements D
protected OsmandSettings settings; protected OsmandSettings settings;
private static DownloadIndexesThread downloadListIndexThread; private static DownloadIndexesThread downloadListIndexThread;
protected Set<WeakReference<Fragment>> fragSet = new HashSet<>(); protected Set<WeakReference<Fragment>> fragSet = new HashSet<>();
public static final int MAXIMUM_AVAILABLE_FREE_DOWNLOADS = 10; public static final int MAXIMUM_AVAILABLE_FREE_DOWNLOADS = 5;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {

View file

@ -256,12 +256,6 @@ public class DownloadActivity extends BaseDownloadActivity {
public void updateBannerInProgress() { public void updateBannerInProgress() {
BasicProgressAsyncTask<?, ?, ?, ?> basicProgressAsyncTask = ctx.getDownloadThread().getCurrentRunningTask(); BasicProgressAsyncTask<?, ?, ?, ?> basicProgressAsyncTask = ctx.getDownloadThread().getCurrentRunningTask();
final int countedDownloads = ctx.getDownloadThread().getCountedDownloads();
updateProgress(countedDownloads, basicProgressAsyncTask);
}
private void updateProgress(int countedDownloads,
BasicProgressAsyncTask<?, ?, ?, ?> basicProgressAsyncTask) {
final boolean isFinished = basicProgressAsyncTask == null final boolean isFinished = basicProgressAsyncTask == null
|| basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED; || basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
if (isFinished) { if (isFinished) {
@ -272,7 +266,8 @@ public class DownloadActivity extends BaseDownloadActivity {
String message = basicProgressAsyncTask.getDescription(); String message = basicProgressAsyncTask.getDescription();
int percent = basicProgressAsyncTask.getProgressPercentage(); int percent = basicProgressAsyncTask.getProgressPercentage();
setMinimizedFreeVersionBanner(true); setMinimizedFreeVersionBanner(true);
updateAvailableDownloads(countedDownloads);
updateAvailableDownloads();
downloadProgressLayout.setVisibility(View.VISIBLE); downloadProgressLayout.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(indeterminate); progressBar.setIndeterminate(indeterminate);
if (indeterminate) { if (indeterminate) {
@ -330,7 +325,8 @@ public class DownloadActivity extends BaseDownloadActivity {
buttonsLinearLayout, freeVersionBannerTitle)); buttonsLinearLayout, freeVersionBannerTitle));
} }
private void updateAvailableDownloads(int activeTasks) { private void updateAvailableDownloads() {
int activeTasks = ctx.getDownloadThread().getCountedDownloads();
OsmandSettings settings = application.getSettings(); OsmandSettings settings = application.getSettings();
final Integer mapsDownloaded = settings.NUMBER_OF_FREE_DOWNLOADS.get() + activeTasks; final Integer mapsDownloaded = settings.NUMBER_OF_FREE_DOWNLOADS.get() + activeTasks;
downloadsLeftProgressBar.setProgress(mapsDownloaded); downloadsLeftProgressBar.setProgress(mapsDownloaded);