Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-10-20 13:25:29 +02:00
commit 271ceb516e
11 changed files with 64 additions and 37 deletions

View file

@ -56,7 +56,6 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.TabActivity.TabItem; import net.osmand.plus.activities.TabActivity.TabItem;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
@ -1311,8 +1310,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
@Override @Override
public DashFragmentData getCardFragment() { public DashFragmentData getCardFragment() {
return new DashFragmentData(DashAudioVideoNotesFragment.TAG, return DashAudioVideoNotesFragment.FRAGMENT_DATA;
DashAudioVideoNotesFragment.class, DashAudioVideoNotesFragment.TITLE_ID,
new DashboardOnMap.DefaultShouldShow(), 100, null);
} }
} }

View file

@ -16,6 +16,8 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashBaseFragment; import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -28,6 +30,10 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
public static final String TAG = "DASH_NOTES_FRAGMENT"; public static final String TAG = "DASH_NOTES_FRAGMENT";
public static final int TITLE_ID = R.string.map_widget_av_notes; public static final int TITLE_ID = R.string.map_widget_av_notes;
private static final String ROW_NUMBER_TAG = TAG + "_row_number";
static final DashFragmentData FRAGMENT_DATA =
new DashFragmentData(TAG, DashAudioVideoNotesFragment.class, TITLE_ID,
new DashboardOnMap.DefaultShouldShow(), 100, ROW_NUMBER_TAG);
AudioVideoNotesPlugin plugin; AudioVideoNotesPlugin plugin;
@ -56,13 +62,13 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
public void setupNotes() { public void setupNotes() {
View mainView = getView(); View mainView = getView();
if (plugin == null){ if (plugin == null) {
mainView.setVisibility(View.GONE); mainView.setVisibility(View.GONE);
return; return;
} }
List<AudioVideoNotesPlugin.Recording> notes = new ArrayList<AudioVideoNotesPlugin.Recording>(plugin.getAllRecordings()); List<AudioVideoNotesPlugin.Recording> notes = new ArrayList<AudioVideoNotesPlugin.Recording>(plugin.getAllRecordings());
if (notes.size() == 0){ if (notes.size() == 0) {
mainView.setVisibility(View.GONE); mainView.setVisibility(View.GONE);
return; return;
} else { } else {
@ -71,11 +77,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.items); LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.items);
notesLayout.removeAllViews(); notesLayout.removeAllViews();
if (notes.size() > 3){ DashboardOnMap.handleNumberOfRows(notes, getMyApplication().getSettings(), ROW_NUMBER_TAG);
while (notes.size() != 3){
notes.remove(3);
}
}
for (final AudioVideoNotesPlugin.Recording recording : notes) { for (final AudioVideoNotesPlugin.Recording recording : notes) {
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
@ -107,7 +109,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
} }
public static Drawable getNoteView(final AudioVideoNotesPlugin.Recording recording, View view, public static Drawable getNoteView(final AudioVideoNotesPlugin.Recording recording, View view,
final OsmandApplication ctx) { final OsmandApplication ctx) {
String name = recording.getName(ctx); String name = recording.getName(ctx);
TextView nameText = ((TextView) view.findViewById(R.id.name)); TextView nameText = ((TextView) view.findViewById(R.id.name));
nameText.setText(name); nameText.setText(name);

View file

@ -17,6 +17,7 @@ import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
@ -36,6 +37,9 @@ public class DashFavoritesFragment extends DashLocationFragment {
List<FavouritePoint> points = new ArrayList<FavouritePoint>(); List<FavouritePoint> points = new ArrayList<FavouritePoint>();
public static final String ROW_NUMBER_TAG = TAG + "_row_number"; public static final String ROW_NUMBER_TAG = TAG + "_row_number";
public static final DashFragmentData FRAGMENT_DATA =
new DashFragmentData(TAG, DashFavoritesFragment.class, TITLE_ID,
new DashboardOnMap.DefaultShouldShow(), 90, ROW_NUMBER_TAG);
@Override @Override
public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -81,13 +85,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
} }
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items); LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews(); favorites.removeAllViews();
int numberOfRows = DashboardOnMap.handleNumberOfRows(points, getMyApplication().getSettings(), ROW_NUMBER_TAG);
getMyApplication().getSettings().registerIntPreference(ROW_NUMBER_TAG, 3).get();
if (points.size() > numberOfRows) {
while (points.size() != numberOfRows) {
points.remove(numberOfRows);
}
}
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>(); List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for (final FavouritePoint point : points) { for (final FavouritePoint point : points) {
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();

View file

@ -18,6 +18,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchHistoryFragment; import net.osmand.plus.activities.search.SearchHistoryFragment;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
@ -34,6 +35,10 @@ public class DashRecentsFragment extends DashLocationFragment {
private List<ImageView> arrows = new ArrayList<ImageView>(); private List<ImageView> arrows = new ArrayList<ImageView>();
List<HistoryEntry> points = new ArrayList<HistoryEntry>(); List<HistoryEntry> points = new ArrayList<HistoryEntry>();
private static final String ROW_NUMBER_TAG = TAG + "_row_number";
static final DashFragmentData FRAGMENT_DATA =
new DashFragmentData(TAG, DashRecentsFragment.class, TITLE_ID,
new DashboardOnMap.DefaultShouldShow(), 100, ROW_NUMBER_TAG);
@Override @Override
public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -76,9 +81,7 @@ public class DashRecentsFragment extends DashLocationFragment {
LinearLayout recents = (LinearLayout) mainView.findViewById(R.id.items); LinearLayout recents = (LinearLayout) mainView.findViewById(R.id.items);
recents.removeAllViews(); recents.removeAllViews();
if (points.size() > 3) { DashboardOnMap.handleNumberOfRows(points, getMyApplication().getSettings(), ROW_NUMBER_TAG);
points = points.subList(0, 3);
}
LatLon loc = getDefaultLocation(); LatLon loc = getDefaultLocation();
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>(); List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for (final HistoryEntry historyEntry : points) { for (final HistoryEntry historyEntry : points) {

View file

@ -33,6 +33,7 @@ import com.github.ksoichiro.android.observablescrollview.ScrollState;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.osm.edit.OSMSettings;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
@ -92,11 +93,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
DashWaypointsFragment.TITLE_ID, defaultShouldShow, 60, null), DashWaypointsFragment.TITLE_ID, defaultShouldShow, 60, null),
new DashFragmentData(DashSearchFragment.TAG, DashSearchFragment.class, new DashFragmentData(DashSearchFragment.TAG, DashSearchFragment.class,
DashSearchFragment.TITLE_ID, defaultShouldShow, 70, null), DashSearchFragment.TITLE_ID, defaultShouldShow, 70, null),
new DashFragmentData(DashRecentsFragment.TAG, DashRecentsFragment.class, DashRecentsFragment.FRAGMENT_DATA,
DashRecentsFragment.TITLE_ID, defaultShouldShow, 80, null), DashFavoritesFragment.FRAGMENT_DATA,
new DashFragmentData(DashFavoritesFragment.TAG, DashFavoritesFragment.class,
DashFavoritesFragment.TITLE_ID, defaultShouldShow, 90,
DashFavoritesFragment.ROW_NUMBER_TAG),
new DashFragmentData(DashPluginsFragment.TAG, DashPluginsFragment.class, new DashFragmentData(DashPluginsFragment.TAG, DashPluginsFragment.class,
DashPluginsFragment.TITLE_ID, defaultShouldShow, 140, null) DashPluginsFragment.TITLE_ID, defaultShouldShow, 140, null)
}; };
@ -922,6 +920,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
return dashboardView; return dashboardView;
} }
public static <T> List<T> handleNumberOfRows(List<T> list, OsmandSettings settings,
String rowNumberTag) {
int numberOfRows = settings.registerIntPreference(rowNumberTag, 3)
.makeGlobal().get();
if (list.size() > numberOfRows) {
while (list.size() != numberOfRows) {
list.remove(numberOfRows);
}
}
return list;
}
public static class SettingsShouldShow implements DashFragmentData.ShouldShowFunction { public static class SettingsShouldShow implements DashFragmentData.ShouldShowFunction {
@Override @Override
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {

View file

@ -1,5 +1,6 @@
package net.osmand.plus.dashboard.tools; package net.osmand.plus.dashboard.tools;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.util.Log; import android.util.Log;
@ -49,7 +50,6 @@ public final class TransactionBuilder {
} }
public FragmentTransaction getFragmentTransaction() { public FragmentTransaction getFragmentTransaction() {
Log.v(TAG, "getFragmentTransaction(" + ")");
FragmentTransaction fragmentTransaction = manager.beginTransaction(); FragmentTransaction fragmentTransaction = manager.beginTransaction();
Collections.sort(fragments); Collections.sort(fragments);
for (DashFragmentData dashFragmentData : fragments) { for (DashFragmentData dashFragmentData : fragments) {

View file

@ -59,6 +59,7 @@ public class DownloadActivity extends BaseDownloadActivity {
DownloadResources indexes = getDownloadThread().getIndexes(); DownloadResources indexes = getDownloadThread().getIndexes();
if (!indexes.isDownloadedFromInternet) { if (!indexes.isDownloadedFromInternet) {
getDownloadThread().runReloadIndexFiles(); getDownloadThread().runReloadIndexFiles();
} }
setContentView(R.layout.download); setContentView(R.layout.download);

View file

@ -25,6 +25,8 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashBaseFragment; import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.myplaces.AvailableGPXFragment; import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
@ -42,6 +44,11 @@ public class DashTrackFragment extends DashBaseFragment {
public static final String TAG = "DASH_TRACK_FRAGMENT"; public static final String TAG = "DASH_TRACK_FRAGMENT";
public static final int TITLE_ID = R.string.shared_string_my_tracks; public static final int TITLE_ID = R.string.shared_string_my_tracks;
private static final String ROW_NUMBER_TAG = TAG + "_row_number";
static final DashFragmentData FRAGMENT_DATA =
new DashFragmentData(TAG, DashTrackFragment.class, TITLE_ID,
new DashboardOnMap.DefaultShouldShow(), 110, ROW_NUMBER_TAG);
private boolean updateEnable; private boolean updateEnable;
@Override @Override
@ -116,6 +123,8 @@ public class DashTrackFragment extends DashBaseFragment {
return; return;
} else { } else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE); (mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
DashboardOnMap.handleNumberOfRows(list,
getMyApplication().getSettings(), ROW_NUMBER_TAG);
} }
LinearLayout tracks = (LinearLayout) mainView.findViewById(R.id.items); LinearLayout tracks = (LinearLayout) mainView.findViewById(R.id.items);

View file

@ -469,8 +469,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
@Override @Override
public DashFragmentData getCardFragment() { public DashFragmentData getCardFragment() {
return new DashFragmentData(DashTrackFragment.TAG, DashTrackFragment.class, return DashTrackFragment.FRAGMENT_DATA;
DashTrackFragment.TITLE_ID, new DashboardOnMap.DefaultShouldShow(), 110, null);
} }
} }

View file

@ -18,6 +18,8 @@ import net.osmand.plus.ProgressImplementation;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashBaseFragment; import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,6 +35,11 @@ public class DashOsmEditsFragment extends DashBaseFragment
public static final String TAG = "DASH_OSM_EDITS_FRAGMENT"; public static final String TAG = "DASH_OSM_EDITS_FRAGMENT";
public static final int TITLE_ID = R.string.osm_settings; public static final int TITLE_ID = R.string.osm_settings;
private static final String ROW_NUMBER_TAG = TAG + "_row_number";
static final DashFragmentData FRAGMENT_DATA =
new DashFragmentData(TAG, DashOsmEditsFragment.class, TITLE_ID,
new DashboardOnMap.DefaultShouldShow(), 130, ROW_NUMBER_TAG);
OsmEditingPlugin plugin; OsmEditingPlugin plugin;
@Override @Override
@ -78,6 +85,8 @@ public class DashOsmEditsFragment extends DashBaseFragment
return; return;
} else { } else {
mainView.setVisibility(View.VISIBLE); mainView.setVisibility(View.VISIBLE);
DashboardOnMap.handleNumberOfRows(dataPoints,
getMyApplication().getSettings(), ROW_NUMBER_TAG);
} }
LinearLayout osmLayout = (LinearLayout) mainView.findViewById(R.id.items); LinearLayout osmLayout = (LinearLayout) mainView.findViewById(R.id.items);

View file

@ -349,7 +349,6 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override @Override
public DashFragmentData getCardFragment() { public DashFragmentData getCardFragment() {
return new DashFragmentData(DashOsmEditsFragment.TAG, DashOsmEditsFragment.class, return DashOsmEditsFragment.FRAGMENT_DATA;
DashOsmEditsFragment.TITLE_ID, new DashboardOnMap.DefaultShouldShow(), 130, null);
} }
} }