diff --git a/OsmAnd/res/layout/fragment_reports.xml b/OsmAnd/res/layout/fragment_reports.xml index 68e58e9ba2..1ca53cbd87 100644 --- a/OsmAnd/res/layout/fragment_reports.xml +++ b/OsmAnd/res/layout/fragment_reports.xml @@ -1,6 +1,6 @@ - + app:columnCount="2"> @@ -72,29 +72,29 @@ tools:text="Worldwide"/> - + - + app:columnCount="2"> + app:layout_columnSpan="2"/> @@ -132,7 +132,7 @@ @@ -168,7 +168,7 @@ @@ -204,7 +204,7 @@ @@ -238,7 +238,7 @@ android:textColor="?android:textColorPrimary"/> - + @@ -266,8 +266,8 @@ android:layout_height="wrap_content" android:gravity="left|center_vertical" android:textSize="@dimen/default_desc_text_size" - osmand:textAllCapsCompat="false" - osmand:typeface="@string/font_roboto_medium" + app:textAllCapsCompat="false" + app:typeface="@string/font_roboto_medium" tools:text="http://osmand.net/osm_live"/> diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 165a57ae03..a1a4e4b97e 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -528,19 +528,19 @@ public class AppInitializer implements IProgress { }); AlarmManager alarmMgr = (AlarmManager) app.getSystemService(Context.ALARM_SERVICE); for (LocalIndexInfo fm : fullMaps) { - String fullMap = fm.getFileName(); - if (!preferenceLiveUpdatesOn(fullMap, settings).get()) { + String fileName = fm.getFileName(); + if (!preferenceLiveUpdatesOn(fileName, settings).get()) { continue; } - int updateFrequencyOrd = preferenceUpdateFrequency(fullMap, settings).get(); + int updateFrequencyOrd = preferenceUpdateFrequency(fileName, settings).get(); LiveUpdatesHelper.UpdateFrequency updateFrequency = LiveUpdatesHelper.UpdateFrequency.values()[updateFrequencyOrd]; - long lastCheck = preferenceLastCheck(fullMap, settings).get(); + long lastCheck = preferenceLastCheck(fileName, settings).get(); if (System.currentTimeMillis() - lastCheck > updateFrequency.getTime() * 2) { - runLiveUpdate(app, fullMap, false); - PendingIntent alarmIntent = getPendingIntent(app, fullMap); - int timeOfDayOrd = preferenceTimeOfDayToUpdate(fullMap, settings).get(); + runLiveUpdate(app, fileName, false); + PendingIntent alarmIntent = getPendingIntent(app, fileName); + int timeOfDayOrd = preferenceTimeOfDayToUpdate(fileName, settings).get(); LiveUpdatesHelper.TimeOfDay timeOfDayToUpdate = LiveUpdatesHelper.TimeOfDay.values()[timeOfDayOrd]; setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesAlarmReceiver.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesAlarmReceiver.java index d54baa5bf4..859ca50692 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesAlarmReceiver.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesAlarmReceiver.java @@ -8,7 +8,6 @@ import android.net.wifi.WifiManager; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; -import net.osmand.plus.activities.LocalIndexInfo; import org.apache.commons.logging.Log; @@ -20,17 +19,17 @@ public class LiveUpdatesAlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String fileName = intent.getAction(); - String localIndexInfo = + String localIndexInfoFile = intent.getStringExtra(LiveUpdatesHelper.LOCAL_INDEX_INFO); WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); final OsmandApplication application = (OsmandApplication) context.getApplicationContext(); final OsmandSettings settings = application.getSettings(); - if (!preferenceDownloadViaWiFi(localIndexInfo, settings).get() || wifi.isWifiEnabled()) { - new PerformLiveUpdateAsyncTask(context, localIndexInfo, false).execute(fileName); + if (!preferenceDownloadViaWiFi(localIndexInfoFile, settings).get() || wifi.isWifiEnabled()) { + new PerformLiveUpdateAsyncTask(context, localIndexInfoFile, false).execute(fileName); } else { - PerformLiveUpdateAsyncTask.tryRescheduleDownload(context, settings, localIndexInfo); + PerformLiveUpdateAsyncTask.tryRescheduleDownload(context, settings, localIndexInfoFile); } } } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index f86b984747..0154994c3a 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -11,6 +11,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.DrawableRes; +import android.support.annotation.NonNull; import android.support.v4.app.FragmentManager; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBar; @@ -270,8 +271,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList } public void add(LocalIndexInfo info) { - OsmandSettings.CommonPreference preference = preferenceLiveUpdatesOn(info.getFileName(), - getSettings()); + OsmandSettings.CommonPreference preference = preferenceLiveUpdatesOn( + info.getFileName(), getSettings()); if (preference.get()) { dataShouldUpdate.add(info); } else { @@ -338,7 +339,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList } else { viewHolder = (LocalFullMapsViewHolder) convertView.getTag(); } - viewHolder.bindLocalIndexInfo(getChild(groupPosition, childPosition), isLastChild); + viewHolder.bindLocalIndexInfo(getChild(groupPosition, childPosition).getFileName(), isLastChild); return convertView; } @@ -392,14 +393,14 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList AlarmManager alarmMgr = (AlarmManager) getActivity() .getSystemService(Context.ALARM_SERVICE); for (LocalIndexInfo li : dataShouldUpdate) { - String localIndexInfo = li.getFileName(); + String fileName = li.getFileName(); PendingIntent alarmIntent = getPendingIntent(getActivity(), - localIndexInfo); + fileName); if (enable) { final OsmandSettings.CommonPreference updateFrequencyPreference = - preferenceUpdateFrequency(localIndexInfo, getSettings()); + preferenceUpdateFrequency(fileName, getSettings()); final OsmandSettings.CommonPreference timeOfDayPreference = - preferenceTimeOfDayToUpdate(localIndexInfo, getSettings()); + preferenceTimeOfDayToUpdate(fileName, getSettings()); UpdateFrequency updateFrequency = UpdateFrequency.values()[updateFrequencyPreference.get()]; TimeOfDay timeOfDayToUpdate = TimeOfDay.values()[timeOfDayPreference.get()]; setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate); @@ -489,9 +490,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList divider = view.findViewById(R.id.divider); } - @SuppressWarnings("deprecation") - public void bindLocalIndexInfo(final LocalIndexInfo it, boolean isLastChild) { - final String item = it.getFileName(); + public void bindLocalIndexInfo(@NonNull final String item, boolean isLastChild) { OsmandApplication context = fragment.getMyActivity().getMyApplication(); final OsmandSettings.CommonPreference shouldUpdatePreference = preferenceLiveUpdatesOn(item, fragment.getSettings()); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java index d2861427a6..a5f1f49894 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java @@ -8,7 +8,6 @@ import android.support.annotation.NonNull; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.OsmandActionBarActivity; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.util.Algorithms; @@ -32,45 +31,45 @@ public class LiveUpdatesHelper { public static final int DEFAULT_LAST_CHECK = -1; public static OsmandSettings.CommonPreference preferenceForLocalIndex( - String item, OsmandSettings settings) { - final String settingId = item + LIVE_UPDATES_ON_POSTFIX; + String fileName, OsmandSettings settings) { + final String settingId = fileName + LIVE_UPDATES_ON_POSTFIX; return settings.registerBooleanPreference(settingId, false); } public static OsmandSettings.CommonPreference preferenceLiveUpdatesOn( - String item, OsmandSettings settings) { - final String settingId = item + LIVE_UPDATES_ON_POSTFIX; + String fileName, OsmandSettings settings) { + final String settingId = fileName + LIVE_UPDATES_ON_POSTFIX; return settings.registerBooleanPreference(settingId, false); } public static OsmandSettings.CommonPreference preferenceDownloadViaWiFi( - String item, OsmandSettings settings) { - final String settingId = item + DOWNLOAD_VIA_WIFI_POSTFIX; + String fileName, OsmandSettings settings) { + final String settingId = fileName + DOWNLOAD_VIA_WIFI_POSTFIX; return settings.registerBooleanPreference(settingId, false); } public static OsmandSettings.CommonPreference preferenceUpdateFrequency( - String item, OsmandSettings settings) { - final String settingId = item + UPDATE_TIMES_POSTFIX; + String fileName, OsmandSettings settings) { + final String settingId = fileName + UPDATE_TIMES_POSTFIX; return settings.registerIntPreference(settingId, UpdateFrequency.HOURLY.ordinal()); } public static OsmandSettings.CommonPreference preferenceTimeOfDayToUpdate( - String item, OsmandSettings settings) { - final String settingId = item + TIME_OF_DAY_TO_UPDATE_POSTFIX; + String fileName, OsmandSettings settings) { + final String settingId = fileName + TIME_OF_DAY_TO_UPDATE_POSTFIX; return settings.registerIntPreference(settingId, TimeOfDay.NIGHT.ordinal()); } public static OsmandSettings.CommonPreference preferenceLastCheck( - String item, OsmandSettings settings) { - final String settingId = item + LAST_UPDATE_ATTEMPT_ON_POSTFIX; + String fileName, OsmandSettings settings) { + final String settingId = fileName + LAST_UPDATE_ATTEMPT_ON_POSTFIX; return settings.registerLongPreference(settingId, DEFAULT_LAST_CHECK); } - public static String getNameToDisplay(String child, OsmandActionBarActivity activity) { + public static String getNameToDisplay(String fileName, OsmandActionBarActivity activity) { return FileNameTranslationHelper.getFileName(activity, activity.getMyApplication().getResourceManager().getOsmandRegions(), - child); + fileName); } public static String formatDateTime(Context ctx, long dateTime) { @@ -80,12 +79,12 @@ public class LiveUpdatesHelper { } public static PendingIntent getPendingIntent(@NonNull Context context, - @NonNull String localIndexInfo) { + @NonNull String fileName) { Intent intent = new Intent(context, LiveUpdatesAlarmReceiver.class); - final File file = new File(localIndexInfo); - final String fileName = Algorithms.getFileNameWithoutExtension(file); - intent.putExtra(LOCAL_INDEX_INFO, localIndexInfo); - intent.setAction(fileName); + final File file = new File(fileName); + final String fileNameNoExt = Algorithms.getFileNameWithoutExtension(file); + intent.putExtra(LOCAL_INDEX_INFO, fileName); + intent.setAction(fileNameNoExt); return PendingIntent.getBroadcast(context, 0, intent, 0); } @@ -159,8 +158,8 @@ public class LiveUpdatesHelper { } } - public static void runLiveUpdate(Context context, final String info, boolean forceUpdate) { - final String fnExt = Algorithms.getFileNameWithoutExtension(new File(info)); - new PerformLiveUpdateAsyncTask(context, info, forceUpdate).execute(fnExt); + public static void runLiveUpdate(Context context, final String fileName, boolean forceUpdate) { + final String fnExt = Algorithms.getFileNameWithoutExtension(new File(fileName)); + new PerformLiveUpdateAsyncTask(context, fileName, forceUpdate).execute(fnExt); } } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java index 2cf6587ca2..518569080d 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java @@ -47,14 +47,15 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.runLiveUpdate; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.setAlarmForPendingIntent; public class LiveUpdatesSettingsDialogFragment extends DialogFragment { - private static final Log LOG = PlatformUtil.getLog(LiveUpdatesAlarmReceiver.class); - private static final String LOCAL_INDEX = "local_index"; + private static final Log LOG = PlatformUtil.getLog(LiveUpdatesSettingsDialogFragment.class); + private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name"; @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - final String localIndexInfo = getArguments().getString(LOCAL_INDEX); + final String fileName = getArguments().getString(LOCAL_INDEX_FILE_NAME); + assert fileName != null; View view = LayoutInflater.from(getActivity()) .inflate(R.layout.dialog_live_updates_item_settings, null); @@ -68,19 +69,19 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { final View updateTimesOfDayLayout = view.findViewById(R.id.updateTimesOfDayLayout); final TextView sizeTextView = (TextView) view.findViewById(R.id.sizeTextView); - regionNameTextView.setText(getNameToDisplay(localIndexInfo, getMyActivity())); + regionNameTextView.setText(getNameToDisplay(fileName, getMyActivity())); final String fileNameWithoutExtension = - Algorithms.getFileNameWithoutExtension(new File(localIndexInfo)); + Algorithms.getFileNameWithoutExtension(new File(fileName)); final IncrementalChangesManager changesManager = getMyApplication().getResourceManager().getChangesManager(); final long timestamp = changesManager.getTimestamp(fileNameWithoutExtension); String lastUpdateDate = formatDateTime(getActivity(), timestamp); - final long lastCheck = preferenceLastCheck(localIndexInfo, getSettings()).get(); + final long lastCheck = preferenceLastCheck(fileName, getSettings()).get(); String lastCheckString = formatDateTime(getActivity(), lastCheck != DEFAULT_LAST_CHECK ? lastCheck : timestamp); lastMapChangeTextView.setText(getString(R.string.last_map_change, lastUpdateDate)); - OsmandSettings.CommonPreference preference = preferenceLiveUpdatesOn(localIndexInfo, + OsmandSettings.CommonPreference preference = preferenceLiveUpdatesOn(fileName, getSettings()); if (preference.get()) { lastUpdateTextView.setText(getString(R.string.last_update, lastCheckString)); @@ -89,13 +90,13 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { } final OsmandSettings.CommonPreference liveUpdatePreference = - preferenceForLocalIndex(localIndexInfo, getSettings()); + preferenceForLocalIndex(fileName, getSettings()); final OsmandSettings.CommonPreference downloadViaWiFiPreference = - preferenceDownloadViaWiFi(localIndexInfo, getSettings()); + preferenceDownloadViaWiFi(fileName, getSettings()); final OsmandSettings.CommonPreference updateFrequencyPreference = - preferenceUpdateFrequency(localIndexInfo, getSettings()); + preferenceUpdateFrequency(fileName, getSettings()); final OsmandSettings.CommonPreference timeOfDayPreference = - preferenceTimeOfDayToUpdate(localIndexInfo, getSettings()); + preferenceTimeOfDayToUpdate(fileName, getSettings()); downloadOverWiFiCheckBox.setChecked(!liveUpdatePreference.get() || downloadViaWiFiPreference.get()); @@ -116,7 +117,6 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { updateFrequenciesStrings[i] = getString(updateFrequencies[i].getLocalizedId()); } - refreshTimeOfDayLayout(UpdateFrequency.values()[updateFrequencyPreference.get()], updateTimesOfDayLayout); updateFrequencySpinner.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.action_spinner_item, updateFrequenciesStrings)); updateFrequencySpinner.setSelection(updateFrequencyPreference.get()); @@ -141,7 +141,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { if (!liveUpdatesSwitch.isChecked()) { long updatesSize = changesManager.getUpdatesSize(fileNameWithoutExtension); if (updatesSize != 0) { - ClearUpdatesDialogFragment.createInstance(localIndexInfo) + ClearUpdatesDialogFragment.createInstance(fileName) .show(getParentFragment().getChildFragmentManager(), null); } } @@ -153,13 +153,13 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { AlarmManager alarmMgr = (AlarmManager) getActivity() .getSystemService(Context.ALARM_SERVICE); - PendingIntent alarmIntent = getPendingIntent(getActivity(), localIndexInfo); + PendingIntent alarmIntent = getPendingIntent(getActivity(), fileName); final int timeOfDayInt = updateTimesOfDaySpinner.getSelectedItemPosition(); timeOfDayPreference.set(timeOfDayInt); if (liveUpdatesSwitch.isChecked() && getSettings().IS_LIVE_UPDATES_ON.get()) { - runLiveUpdate(getActivity(), localIndexInfo, false); + runLiveUpdate(getActivity(), fileName, false); UpdateFrequency updateFrequency = UpdateFrequency.values()[updateFrequencyInt]; TimeOfDay timeOfDayToUpdate = TimeOfDay.values()[timeOfDayInt]; setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate); @@ -173,7 +173,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { .setNeutralButton(R.string.update_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - runLiveUpdate(getActivity(), localIndexInfo, true); + runLiveUpdate(getActivity(), fileName, true); sizeTextView.setText(getUpdatesSize(fileNameWithoutExtension, changesManager)); } }); @@ -221,10 +221,10 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { return (AbstractDownloadActivity) this.getActivity(); } - public static LiveUpdatesSettingsDialogFragment createInstance(String localIndexInfo) { + public static LiveUpdatesSettingsDialogFragment createInstance(String fileName) { LiveUpdatesSettingsDialogFragment fragment = new LiveUpdatesSettingsDialogFragment(); Bundle args = new Bundle(); - args.putString(LOCAL_INDEX, localIndexInfo); + args.putString(LOCAL_INDEX_FILE_NAME, fileName); fragment.setArguments(args); return fragment; } @@ -233,7 +233,9 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - final String localIndexInfo = getArguments().getString(LOCAL_INDEX); + final String localIndexInfo = getArguments().getString(LOCAL_INDEX_FILE_NAME); + assert localIndexInfo != null; + final IncrementalChangesManager changesManager = getMyApplication().getResourceManager().getChangesManager(); final String fileNameWithoutExtension = @@ -256,10 +258,10 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { return (OsmandApplication) getActivity().getApplication(); } - public static ClearUpdatesDialogFragment createInstance(String localIndexInfo) { + public static ClearUpdatesDialogFragment createInstance(String fileName) { ClearUpdatesDialogFragment fragment = new ClearUpdatesDialogFragment(); Bundle args = new Bundle(); - args.putString(LOCAL_INDEX, localIndexInfo); + args.putString(LOCAL_INDEX_FILE_NAME, fileName); fragment.setArguments(args); return fragment; } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java index f7264b11c6..db0a0b8efd 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java @@ -3,24 +3,20 @@ package net.osmand.plus.liveupdates; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; -import android.content.Intent; import android.os.AsyncTask; import android.support.annotation.NonNull; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; -import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.download.AbstractDownloadActivity; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.IndexItem; import net.osmand.plus.resources.IncrementalChangesManager; -import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; -import java.io.File; import java.util.ArrayList; import java.util.List; @@ -33,14 +29,14 @@ public class PerformLiveUpdateAsyncTask @NonNull private final Context context; @NonNull - private final String localIndexInfo; + private final String localIndexFileName; private final boolean forceUpdate; public PerformLiveUpdateAsyncTask(@NonNull Context context, - @NonNull String localIndexInfo, + @NonNull String localIndexFileName, boolean forceUpdate) { this.context = context; - this.localIndexInfo = localIndexInfo; + this.localIndexFileName = localIndexFileName; this.forceUpdate = forceUpdate; } @@ -53,7 +49,7 @@ public class PerformLiveUpdateAsyncTask } final OsmandApplication myApplication = getMyApplication(); OsmandSettings.CommonPreference lastCheckPreference = - LiveUpdatesHelper.preferenceLastCheck(localIndexInfo, myApplication.getSettings()); + LiveUpdatesHelper.preferenceLastCheck(localIndexFileName, myApplication.getSettings()); lastCheckPreference.set(System.currentTimeMillis()); } @@ -80,7 +76,7 @@ public class PerformLiveUpdateAsyncTask final OsmandSettings settings = application.getSettings(); if (result.errorMessage != null) { LOG.info(result.errorMessage); - tryRescheduleDownload(context, settings, localIndexInfo); + tryRescheduleDownload(context, settings, localIndexFileName); } else { settings.LIVE_UPDATES_RETRIES.resetToDefault(); List ll = result.getItemsForUpdate(); @@ -97,7 +93,7 @@ public class PerformLiveUpdateAsyncTask downloadThread.setUiActivity((DownloadIndexesThread.DownloadEvents) context); } boolean downloadViaWiFi = - LiveUpdatesHelper.preferenceDownloadViaWiFi(localIndexInfo, settings).get(); + LiveUpdatesHelper.preferenceDownloadViaWiFi(localIndexFileName, settings).get(); if (getMyApplication().getSettings().isInternetConnectionAvailable()) { if (forceUpdate || settings.isWifiConnected() || !downloadViaWiFi) { long szLong = 0; @@ -133,9 +129,9 @@ public class PerformLiveUpdateAsyncTask public static void tryRescheduleDownload(@NonNull Context context, @NonNull OsmandSettings settings, - @NonNull String localIndexInfo) { + @NonNull String localIndexFileName) { final OsmandSettings.CommonPreference updateFrequencyPreference = - preferenceUpdateFrequency(localIndexInfo, settings); + preferenceUpdateFrequency(localIndexFileName, settings); final Integer frequencyOrdinal = updateFrequencyPreference.get(); if (LiveUpdatesHelper.UpdateFrequency.values()[frequencyOrdinal] == LiveUpdatesHelper.UpdateFrequency.HOURLY) { @@ -143,12 +139,7 @@ public class PerformLiveUpdateAsyncTask } final Integer retriesLeft = settings.LIVE_UPDATES_RETRIES.get(); if (retriesLeft > 0) { - Intent intent = new Intent(context, LiveUpdatesAlarmReceiver.class); - final File file = new File(localIndexInfo); - final String fileName = Algorithms.getFileNameWithoutExtension(file); - intent.putExtra(LiveUpdatesHelper.LOCAL_INDEX_INFO, localIndexInfo); - intent.setAction(fileName); - PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); + PendingIntent alarmIntent = LiveUpdatesHelper.getPendingIntent(context, localIndexFileName); long timeToRetry = System.currentTimeMillis() + AlarmManager.INTERVAL_HOUR; diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java index e6a76a00b4..0eac451a67 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java @@ -86,25 +86,9 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_reports, container, false); monthReportsSpinner = (Spinner) view.findViewById(R.id.monthReportsSpinner); - final View monthButton = view.findViewById(R.id.monthButton); - monthReportsSpinner.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - event.offsetLocation(AndroidUtils.dpToPx(getActivity(), 48f), 0); - monthButton.onTouchEvent(event); - return true; - } - }); monthsForReportsAdapter = new MonthsForReportsAdapter(getActivity()); monthReportsSpinner.setAdapter(monthsForReportsAdapter); - monthButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - monthReportsSpinner.performClick(); - } - }); - view.findViewById(R.id.show_all).setOnClickListener(new OnClickListener() { @Override @@ -148,9 +132,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect countryNameTextView.setText(selectedCountryItem.getLocalName()); setThemedDrawable(view, R.id.calendarImageView, R.drawable.ic_action_data); - setThemedDrawable(view, R.id.monthDropDownIcon, R.drawable.ic_action_arrow_drop_down); setThemedDrawable(view, R.id.regionIconImageView, R.drawable.ic_world_globe_dark); - setThemedDrawable(view, R.id.countryDropDownIcon, R.drawable.ic_action_arrow_drop_down); numberOfContributorsIcon = (ImageView) view.findViewById(R.id.numberOfContributorsIcon); numberOfEditsIcon = (ImageView) view.findViewById(R.id.numberOfEditsIcon);