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">
<android.support.design.widget.TabLayout
android:theme="?attr/appbar_layout_theme"
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

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

View file

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

View file

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

View file

@ -333,6 +333,20 @@ public class IncrementalChangesManager {
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) {
RegionUpdateFiles ruf = regions.get(fileName.toLowerCase());
return getTimestamp(ruf);
@ -350,6 +364,4 @@ public class IncrementalChangesManager {
}
return timestamp;
}
}