Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-12-21 12:13:06 +01:00
commit 2ffdf24bd5
5 changed files with 40 additions and 17 deletions

View file

@ -10,6 +10,7 @@
tools:context="net.osmand.plus.osmedit.EditPoiDialogFragment"> tools:context="net.osmand.plus.osmedit.EditPoiDialogFragment">
<android.support.design.widget.TabLayout <android.support.design.widget.TabLayout
android:theme="?attr/appbar_layout_theme"
android:id="@+id/tab_layout" android:id="@+id/tab_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -15,6 +15,7 @@ public class LiveUpdatesActivity extends AbstractDownloadActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_livie_updates); setContentView(R.layout.activity_livie_updates);

View file

@ -2,8 +2,10 @@ package net.osmand.plus.liveupdates;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v7.widget.SwitchCompat; import android.support.v7.widget.SwitchCompat;
@ -309,6 +311,9 @@ public class LiveUpdatesFragment extends Fragment {
OsmandApplication context = fragment.getMyActivity().getMyApplication(); OsmandApplication context = fragment.getMyActivity().getMyApplication();
final OsmandSettings.CommonPreference<Boolean> shouldUpdatePreference = final OsmandSettings.CommonPreference<Boolean> shouldUpdatePreference =
preferenceLiveUpdatesOn(item, fragment.getSettings()); preferenceLiveUpdatesOn(item, fragment.getSettings());
IncrementalChangesManager changesManager = context.getResourceManager().getChangesManager();
final String fileNameWithoutExtension =
Algorithms.getFileNameWithoutExtension(new File(item.getFileName()));
nameTextView.setText(getNameToDisplay(item)); nameTextView.setText(getNameToDisplay(item));
if (shouldUpdatePreference.get()) { if (shouldUpdatePreference.get()) {
@ -316,26 +321,25 @@ public class LiveUpdatesFragment extends Fragment {
final UpdateFrequency frequency = UpdateFrequency.values()[frequencyId]; final UpdateFrequency frequency = UpdateFrequency.values()[frequencyId];
subheaderTextView.setText(frequency.toString()); subheaderTextView.setText(frequency.toString());
subheaderTextView.setTextColor(fragment.getActivity().getResources() subheaderTextView.setTextColor(fragment.getActivity().getResources()
.getColor(R.color.dashboard_blue)); .getColor(R.color.osmand_orange));
icon.setImageDrawable(context.getIconsCache().getContentIcon(R.drawable.ic_map)); icon.setImageDrawable(context.getIconsCache().getIcon(R.drawable.ic_map, R.color.osmand_orange));
icon.setImageDrawable(context.getIconsCache().getIcon(R.drawable.ic_map, R.color.dashboard_blue)); options.setImageDrawable(getSecondaryColorPaintedIcon(R.drawable.ic_overflow_menu_white));
options.setImageResource(R.drawable.ic_overflow_menu_white);
} else { } else {
String size; String size;
if (item.getSize() > 100) { long updatesSize = changesManager.getUpdatesSize(fileNameWithoutExtension);
size = DownloadActivity.formatMb.format(new Object[]{(float) item.getSize() / (1 << 10)}); updatesSize /= (1 << 10);
if (updatesSize > 100) {
size = DownloadActivity.formatMb.format(new Object[]{(float) updatesSize / (1 << 10)});
} else { } else {
size = item.getSize() + " KB"; size = updatesSize + " KB";
} }
subheaderTextView.setText(size); subheaderTextView.setText(size);
subheaderTextView.setTextColor(secondaryColor); subheaderTextView.setTextColor(secondaryColor);
icon.setImageDrawable(context.getIconsCache().getPaintedContentIcon(R.drawable.ic_map, secondaryColor)); icon.setImageDrawable(getSecondaryColorPaintedIcon(R.drawable.ic_map));
options.setImageResource(R.drawable.ic_action_plus); options.setImageDrawable(getSecondaryColorPaintedIcon(R.drawable.ic_action_plus));
} }
IncrementalChangesManager cm = context.getResourceManager().getChangesManager();
final String fileNameWithoutExtension = final long timestamp = changesManager.getTimestamp(fileNameWithoutExtension);
Algorithms.getFileNameWithoutExtension(new File(item.getFileName()));
final long timestamp = cm.getTimestamp(fileNameWithoutExtension);
String formattedDate = LiveUpdatesFragment.formatDateTime(fragment.getActivity(), timestamp); String formattedDate = LiveUpdatesFragment.formatDateTime(fragment.getActivity(), timestamp);
descriptionTextView.setText(context.getString(R.string.last_update, formattedDate)); descriptionTextView.setText(context.getString(R.string.last_update, formattedDate));
@ -350,6 +354,11 @@ public class LiveUpdatesFragment extends Fragment {
view.setOnClickListener(clickListener); view.setOnClickListener(clickListener);
} }
private Drawable getSecondaryColorPaintedIcon(@DrawableRes int drawable) {
return fragment.getMyActivity().getMyApplication().getIconsCache()
.getPaintedContentIcon(drawable, secondaryColor);
}
private String getNameToDisplay(LocalIndexInfo child) { private String getNameToDisplay(LocalIndexInfo child) {
String mapName = FileNameTranslationHelper.getFileName(fragment.getActivity(), String mapName = FileNameTranslationHelper.getFileName(fragment.getActivity(),
fragment.getMyActivity().getMyApplication().getResourceManager().getOsmandRegions(), fragment.getMyActivity().getMyApplication().getResourceManager().getOsmandRegions(),

View file

@ -69,11 +69,11 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
preferenceUpdateFrequency(localIndexInfo, getSettings()); preferenceUpdateFrequency(localIndexInfo, getSettings());
final OsmandSettings.CommonPreference<Integer> timeOfDayPreference = final OsmandSettings.CommonPreference<Integer> timeOfDayPreference =
preferenceTimeOfDayToUpdate(localIndexInfo, getSettings()); preferenceTimeOfDayToUpdate(localIndexInfo, getSettings());
liveUpdatesSwitch.setChecked(liveUpdatePreference.get()); liveUpdatesSwitch.setChecked(true);
downloadOverWiFiSwitch.setChecked(downloadViaWiFiPreference.get()); downloadOverWiFiSwitch.setChecked(downloadViaWiFiPreference.get());
builder.setView(view) builder.setView(view)
.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
final int updateFrequencyInt = updateFrequencySpinner.getSelectedItemPosition(); final int updateFrequencyInt = updateFrequencySpinner.getSelectedItemPosition();

View file

@ -333,6 +333,20 @@ public class IncrementalChangesManager {
return iul; return iul;
} }
public long getUpdatesSize(String fileName){
RegionUpdateFiles ruf = regions.get(fileName.toLowerCase());
long size = 0;
for (List<RegionUpdate> regionUpdates : ruf.dayUpdates.values()) {
for (RegionUpdate regionUpdate : regionUpdates) {
size += regionUpdate.file.length();
}
}
for (RegionUpdate regionUpdate : ruf.monthUpdates.values()) {
size += regionUpdate.file.length();
}
return size;
}
public long getTimestamp(String fileName) { public long getTimestamp(String fileName) {
RegionUpdateFiles ruf = regions.get(fileName.toLowerCase()); RegionUpdateFiles ruf = regions.get(fileName.toLowerCase());
return getTimestamp(ruf); return getTimestamp(ruf);
@ -350,6 +364,4 @@ public class IncrementalChangesManager {
} }
return timestamp; return timestamp;
} }
} }