Design fixes

This commit is contained in:
GaidamakUA 2015-12-30 14:18:15 +02:00
parent 51887b97e6
commit d6e9b1e291
5 changed files with 17 additions and 12 deletions

View file

@ -127,7 +127,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/updateTimesOfDayList" android:id="@+id/updateTimesOfDayLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="54dp" android:layout_height="54dp"
android:layout_marginLeft="24dp" android:layout_marginLeft="24dp"

View file

@ -35,7 +35,7 @@
</string-array> </string-array>
<string-array name="update_times_of_day"> <string-array name="update_times_of_day">
<item>Morning</item> <item>Morning</item>
<item>Evening</item> <item>Night</item>
</string-array> </string-array>
<string name="rendering_attr_horseRoutes_name">Horse routes</string> <string name="rendering_attr_horseRoutes_name">Horse routes</string>
<string name="no_address_found">No address determined</string> <string name="no_address_found">No address determined</string>

View file

@ -28,7 +28,7 @@ public class LiveUpdatesAlarmReceiver extends BroadcastReceiver {
final OsmandSettings settings = application.getSettings(); final OsmandSettings settings = application.getSettings();
if (!preferenceDownloadViaWiFi(localIndexInfo, settings).get() || wifi.isWifiEnabled()) { if (!preferenceDownloadViaWiFi(localIndexInfo, settings).get() || wifi.isWifiEnabled()) {
new PerformLiveUpdateAsyncTask(context, localIndexInfo).execute(fileName); new PerformLiveUpdateAsyncTask(context, localIndexInfo, false).execute(fileName);
} else { } else {
PerformLiveUpdateAsyncTask.tryRescheduleDownload(context, settings, localIndexInfo); PerformLiveUpdateAsyncTask.tryRescheduleDownload(context, settings, localIndexInfo);
} }

View file

@ -64,7 +64,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
final CheckBox downloadOverWiFiCheckBox = (CheckBox) view.findViewById(R.id.downloadOverWiFiSwitch); final CheckBox downloadOverWiFiCheckBox = (CheckBox) view.findViewById(R.id.downloadOverWiFiSwitch);
final Spinner updateFrequencySpinner = (Spinner) view.findViewById(R.id.updateFrequencySpinner); final Spinner updateFrequencySpinner = (Spinner) view.findViewById(R.id.updateFrequencySpinner);
final Spinner updateTimesOfDaySpinner = (Spinner) view.findViewById(R.id.updateTimesOfDaySpinner); final Spinner updateTimesOfDaySpinner = (Spinner) view.findViewById(R.id.updateTimesOfDaySpinner);
final View updateTimesOfDayList = view.findViewById(R.id.updateTimesOfDayList); final View updateTimesOfDayLayout = view.findViewById(R.id.updateTimesOfDayLayout);
final TextView sizeTextView = (TextView) view.findViewById(R.id.sizeTextView); final TextView sizeTextView = (TextView) view.findViewById(R.id.sizeTextView);
// final Button removeUpdatesButton = (Button) view.findViewById(R.id.removeUpdatesButton); // final Button removeUpdatesButton = (Button) view.findViewById(R.id.removeUpdatesButton);
@ -96,6 +96,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
updateTimesOfDaySpinner.setAdapter(new ArrayAdapter<String>(getActivity(), updateTimesOfDaySpinner.setAdapter(new ArrayAdapter<String>(getActivity(),
R.layout.action_spinner_item, R.layout.action_spinner_item,
getResources().getStringArray(R.array.update_times_of_day))); getResources().getStringArray(R.array.update_times_of_day)));
updateTimesOfDaySpinner.setSelection(timeOfDayPreference.get());
updateFrequencySpinner.setAdapter(new ArrayAdapter<String>(getActivity(), updateFrequencySpinner.setAdapter(new ArrayAdapter<String>(getActivity(),
R.layout.action_spinner_item, R.layout.action_spinner_item,
@ -107,11 +108,11 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
UpdateFrequency updateFrequency = UpdateFrequency.values()[position]; UpdateFrequency updateFrequency = UpdateFrequency.values()[position];
switch (updateFrequency) { switch (updateFrequency) {
case HOURLY: case HOURLY:
updateTimesOfDayList.setVisibility(View.GONE); updateTimesOfDayLayout.setVisibility(View.GONE);
break; break;
case DAILY: case DAILY:
case WEEKLY: case WEEKLY:
updateTimesOfDayList.setVisibility(View.VISIBLE); updateTimesOfDayLayout.setVisibility(View.VISIBLE);
break; break;
} }
} }
@ -126,6 +127,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
// public void onClick(View v) { // public void onClick(View v) {
// changesManager.deleteUpdates(fileNameWithoutExtension); // changesManager.deleteUpdates(fileNameWithoutExtension);
// getLiveUpdatesFragment().notifyLiveUpdatesChanged(); // getLiveUpdatesFragment().notifyLiveUpdatesChanged();
// preferenceLastCheck(localIndexInfo, getSettings()).resetToDefault();
// updateSize(fileNameWithoutExtension, changesManager, sizeTextView); // updateSize(fileNameWithoutExtension, changesManager, sizeTextView);
// } // }
// }); // });
@ -137,7 +139,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
if (liveUpdatePreference.get() != liveUpdatesSwitch.isChecked()) { if (liveUpdatePreference.get() != liveUpdatesSwitch.isChecked()) {
liveUpdatePreference.set(liveUpdatesSwitch.isChecked()); liveUpdatePreference.set(liveUpdatesSwitch.isChecked());
if (liveUpdatesSwitch.isChecked()) { if (liveUpdatesSwitch.isChecked()) {
runLiveUpdate(localIndexInfo); runLiveUpdate(localIndexInfo, false);
} }
} }
downloadViaWiFiPreference.set(downloadOverWiFiCheckBox.isChecked()); downloadViaWiFiPreference.set(downloadOverWiFiCheckBox.isChecked());
@ -166,16 +168,16 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
.setNeutralButton(R.string.update_now, new DialogInterface.OnClickListener() { .setNeutralButton(R.string.update_now, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
runLiveUpdate(localIndexInfo); runLiveUpdate(localIndexInfo, true);
updateSize(fileNameWithoutExtension, changesManager, sizeTextView); updateSize(fileNameWithoutExtension, changesManager, sizeTextView);
} }
}); });
return builder.create(); return builder.create();
} }
void runLiveUpdate(final LocalIndexInfo info) { void runLiveUpdate(final LocalIndexInfo info, boolean forceUpdate) {
final String fnExt = Algorithms.getFileNameWithoutExtension(new File(info.getFileName())); final String fnExt = Algorithms.getFileNameWithoutExtension(new File(info.getFileName()));
new PerformLiveUpdateAsyncTask(getActivity(), info).execute(new String[]{fnExt}); new PerformLiveUpdateAsyncTask(getActivity(), info, forceUpdate).execute(new String[]{fnExt});
} }
private void updateSize(String fileNameWithoutExtension, private void updateSize(String fileNameWithoutExtension,

View file

@ -28,10 +28,13 @@ public class PerformLiveUpdateAsyncTask
extends AsyncTask<String, Object, IncrementalChangesManager.IncrementalUpdateList> { extends AsyncTask<String, Object, IncrementalChangesManager.IncrementalUpdateList> {
private final Context context; private final Context context;
private final LocalIndexInfo localIndexInfo; private final LocalIndexInfo localIndexInfo;
private final boolean forceUpdate;
public PerformLiveUpdateAsyncTask(Context context, LocalIndexInfo localIndexInfo) { public PerformLiveUpdateAsyncTask(Context context, LocalIndexInfo localIndexInfo,
boolean forceUpdate) {
this.context = context; this.context = context;
this.localIndexInfo = localIndexInfo; this.localIndexInfo = localIndexInfo;
this.forceUpdate = forceUpdate;
} }
@Override @Override
@ -89,7 +92,7 @@ public class PerformLiveUpdateAsyncTask
boolean downloadViaWiFi = boolean downloadViaWiFi =
LiveUpdatesHelper.preferenceDownloadViaWiFi(localIndexInfo, settings).get(); LiveUpdatesHelper.preferenceDownloadViaWiFi(localIndexInfo, settings).get();
if (getMyApplication().getSettings().isInternetConnectionAvailable()) { if (getMyApplication().getSettings().isInternetConnectionAvailable()) {
if (settings.isWifiConnected() || !downloadViaWiFi) { if (forceUpdate || settings.isWifiConnected() || !downloadViaWiFi) {
long szLong = 0; long szLong = 0;
int i = 0; int i = 0;
for (IndexItem es : downloadThread.getCurrentDownloadingItems()) { for (IndexItem es : downloadThread.getCurrentDownloadingItems()) {