Taking plugins into account. Optional dashboard on start. Itroduced fragment deletion bug
This commit is contained in:
parent
8925b5fb30
commit
0909559182
12 changed files with 203 additions and 93 deletions
|
@ -2,6 +2,8 @@ package net.osmand.plus;
|
|||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -9,9 +11,9 @@ import net.osmand.IProgress;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibilityPlugin;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.activities.TabActivity.TabItem;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
|
@ -31,7 +33,6 @@ import org.apache.commons.logging.Log;
|
|||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
public abstract class OsmandPlugin {
|
||||
|
@ -88,9 +89,9 @@ public abstract class OsmandPlugin {
|
|||
public String getInstallURL() {
|
||||
return installURL;
|
||||
}
|
||||
|
||||
|
||||
public void disable(OsmandApplication app) {};
|
||||
|
||||
|
||||
|
||||
public static void initPlugins(OsmandApplication app) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
|
@ -165,7 +166,9 @@ public abstract class OsmandPlugin {
|
|||
}
|
||||
app.getSettings().enablePlugin(plugin.getId(), enable);
|
||||
if(activity instanceof MapActivity) {
|
||||
plugin.updateLayers(((MapActivity) activity).getMapView(), (MapActivity) activity);
|
||||
final MapActivity mapActivity = (MapActivity) activity;
|
||||
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
|
||||
mapActivity.getDashboard().refreshDashboardFragments();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -194,6 +197,8 @@ public abstract class OsmandPlugin {
|
|||
public void registerMapContextMenuActions(MapActivity mapActivity, double latitude, double longitude, ContextMenuAdapter adapter, Object selectedObj) {}
|
||||
|
||||
public void registerOptionsMenuItems(MapActivity mapActivity, ContextMenuAdapter helper) {}
|
||||
|
||||
public DashFragmentData getCardFragment() {return null;}
|
||||
|
||||
public void updateLocation(Location location) {}
|
||||
|
||||
|
@ -354,6 +359,14 @@ public abstract class OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static Collection<DashFragmentData> getPluginsCardsList() {
|
||||
HashSet<DashFragmentData> collection = new HashSet<>();
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
final DashFragmentData fragmentData = plugin.getCardFragment();
|
||||
if (fragmentData != null) collection.add(fragmentData);
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
private static boolean isPackageInstalled(String packageInfo,
|
||||
OsmandApplication app) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import android.os.Message;
|
|||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -130,6 +129,8 @@ public class MapActivity extends AccessibleActivity {
|
|||
private IMapDownloaderCallback downloaderCallback;
|
||||
private DrawerLayout drawerLayout;
|
||||
|
||||
public static final String SHOULD_SHOW_DASHBOARD_ON_START = "should_show_dashboard_on_start";
|
||||
|
||||
private Notification getNotification() {
|
||||
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
|
||||
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
@ -384,7 +385,10 @@ public class MapActivity extends AccessibleActivity {
|
|||
long tm = System.currentTimeMillis();
|
||||
if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) {
|
||||
if (!dashboardOnMap.isVisible()) {
|
||||
dashboardOnMap.setDashboardVisibility(true, DashboardOnMap.staticVisibleType);
|
||||
final OsmandSettings.CommonPreference<Boolean> shouldShowDashboardOnStart =
|
||||
settings.registerBooleanPreference(MapActivity.SHOULD_SHOW_DASHBOARD_ON_START, true);
|
||||
if (shouldShowDashboardOnStart.get())
|
||||
dashboardOnMap.setDashboardVisibility(true, DashboardOnMap.staticVisibleType);
|
||||
}
|
||||
}
|
||||
dashboardOnMap.updateLocation(true, true, false);
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.activities.TabActivity.TabItem;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
|
@ -1058,6 +1059,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
if (am != null) {
|
||||
unregisterMediaListener(am);
|
||||
}
|
||||
ifgetCardFragment().tagasdf
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1298,4 +1300,10 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
public int getAssetResourceName() {
|
||||
return R.drawable.audio_video_notes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashFragmentData getCardFragment() {
|
||||
return new DashFragmentData(DashAudioVideoNotesFragment.TAG,
|
||||
DashAudioVideoNotesFragment.class, getName(), 10);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActionBar;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
|
@ -10,10 +8,10 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
|
@ -46,21 +44,14 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.IntermediatePointsDialog;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
|
||||
import net.osmand.plus.dashboard.tools.TransactionBuilder;
|
||||
import net.osmand.plus.development.DashSimulateFragment;
|
||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.monitoring.DashTrackFragment;
|
||||
import net.osmand.plus.osmedit.DashOsmEditsFragment;
|
||||
import net.osmand.plus.osmo.DashOsMoFragment;
|
||||
import net.osmand.plus.parkingpoint.DashParkingFragment;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.DownloadedRegionsLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -84,26 +75,29 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
private static final DefaultShouldShow defaultShouldShow = new DefaultShouldShow();
|
||||
private static final DefaultShouldShow errorShouldShow = new ErrorShouldShow();
|
||||
private static final DashFragmentData.ShouldShowFunction firstTimeShouldShow = new FirstTimeShouldShow();
|
||||
private static final DefaultShouldShow simulateShouldShow = new SimulateShouldShow();
|
||||
private static final DashFragmentData.ShouldShowFunction chooseAppDirShouldShow = new ChooseAppDirShouldShow();
|
||||
|
||||
private static final DashFragmentData[] fragmentsData = new DashFragmentData[]{
|
||||
new DashFragmentData(DashRateUsFragment.TAG, DashRateUsFragment.class, "Rate us", rateUsShouldShow, true),
|
||||
new DashFragmentData(DashFirstTimeFragment.TAG, DashFirstTimeFragment.class, "First time", firstTimeShouldShow, true),
|
||||
new DashFragmentData(DashChooseAppDirFragment.TAG, DashChooseAppDirFragment.class, "Choose app dir", chooseAppDirShouldShow, true),
|
||||
new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class, "Error", errorShouldShow, true),
|
||||
new DashFragmentData(DashNavigationFragment.TAG, DashNavigationFragment.class, "Navigation", defaultShouldShow),
|
||||
new DashFragmentData(DashParkingFragment.TAG, DashParkingFragment.class, "Parking", defaultShouldShow),
|
||||
new DashFragmentData(DashWaypointsFragment.TAG, DashWaypointsFragment.class, "Waypoints", defaultShouldShow),
|
||||
new DashFragmentData(DashSearchFragment.TAG, DashSearchFragment.class, "Search", defaultShouldShow),
|
||||
new DashFragmentData(DashRecentsFragment.TAG, DashRecentsFragment.class, "Recent places", defaultShouldShow),
|
||||
new DashFragmentData(DashFavoritesFragment.TAG, DashFavoritesFragment.class, "Favourites", defaultShouldShow),
|
||||
new DashFragmentData(DashAudioVideoNotesFragment.TAG, DashAudioVideoNotesFragment.class, "Notes", defaultShouldShow),
|
||||
new DashFragmentData(DashTrackFragment.TAG, DashTrackFragment.class, "Track", defaultShouldShow),
|
||||
new DashFragmentData(DashOsMoFragment.TAG, DashOsMoFragment.class, "OsMo", defaultShouldShow),
|
||||
new DashFragmentData(DashOsmEditsFragment.TAG, DashOsmEditsFragment.class, "OsmEdits", defaultShouldShow),
|
||||
new DashFragmentData(DashPluginsFragment.TAG, DashPluginsFragment.class, "Plugins", defaultShouldShow),
|
||||
new DashFragmentData(DashSimulateFragment.TAG, DashSimulateFragment.class, "Simulate", simulateShouldShow),
|
||||
new DashFragmentData(DashRateUsFragment.TAG, DashRateUsFragment.class,
|
||||
"Rate us", rateUsShouldShow, true, 0),
|
||||
new DashFragmentData(DashFirstTimeFragment.TAG, DashFirstTimeFragment.class,
|
||||
"First time", firstTimeShouldShow, true, 1),
|
||||
new DashFragmentData(DashChooseAppDirFragment.TAG, DashChooseAppDirFragment.class,
|
||||
"Choose app dir", chooseAppDirShouldShow, true, 2),
|
||||
new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class,
|
||||
"Error", errorShouldShow, true, 3),
|
||||
new DashFragmentData(DashNavigationFragment.TAG, DashNavigationFragment.class,
|
||||
"Navigation", defaultShouldShow, 4),
|
||||
new DashFragmentData(DashWaypointsFragment.TAG, DashWaypointsFragment.class,
|
||||
"Waypoints", defaultShouldShow, 6),
|
||||
new DashFragmentData(DashSearchFragment.TAG, DashSearchFragment.class,
|
||||
"Search", defaultShouldShow, 7),
|
||||
new DashFragmentData(DashRecentsFragment.TAG, DashRecentsFragment.class,
|
||||
"Recent places", defaultShouldShow, 8),
|
||||
new DashFragmentData(DashFavoritesFragment.TAG, DashFavoritesFragment.class,
|
||||
"Favourites", defaultShouldShow, 9),
|
||||
new DashFragmentData(DashPluginsFragment.TAG, DashPluginsFragment.class,
|
||||
"Plugins", 14)
|
||||
};
|
||||
|
||||
private MapActivity mapActivity;
|
||||
|
@ -140,6 +134,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
private List<LocationPointWrapper> deletedPoints = new ArrayList<LocationPointWrapper>();
|
||||
private Drawable gradientToolbar;
|
||||
|
||||
public DashFragmentData[] getFragmentsData() {
|
||||
return fragmentsData;
|
||||
}
|
||||
|
||||
public enum DashboardType {
|
||||
WAYPOINTS,
|
||||
WAYPOINTS_FLAT,
|
||||
|
@ -358,12 +356,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
actionButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
public static int convertPixelsToDp(float dp, Context context) {
|
||||
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
||||
return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
|
||||
}
|
||||
|
||||
public net.osmand.Location getMyLocation() {
|
||||
return myLocation;
|
||||
}
|
||||
|
@ -467,6 +459,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
//fabButton.showFloatingActionButton();
|
||||
open(dashboardView.findViewById(R.id.animateContent), animation);
|
||||
updateLocation(true, true, false);
|
||||
// addOrUpdateDashboardFragments();
|
||||
} else {
|
||||
mapActivity.getMapViewTrackingUtilities().setDashboard(null);
|
||||
hide(dashboardView.findViewById(R.id.animateContent), animation);
|
||||
|
@ -477,7 +470,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
df.get().onCloseDash();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,7 +661,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
OsmandSettings settings = getMyApplication().getSettings();
|
||||
TransactionBuilder builder =
|
||||
new TransactionBuilder(mapActivity.getSupportFragmentManager(), settings, mapActivity);
|
||||
builder.addFragmentsData(fragmentsData).getFragmentTransaction().commit();
|
||||
Log.v(TAG, "pluginsCards=" + OsmandPlugin.getPluginsCardsList());
|
||||
builder.addFragmentsData(fragmentsData)
|
||||
.addFragmentsData(OsmandPlugin.getPluginsCardsList())
|
||||
.getFragmentTransaction().commit();
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
|
@ -687,7 +682,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
}
|
||||
|
||||
|
||||
public void updateLocation(final boolean centerChanged, final boolean locationChanged, final boolean compassChanged) {
|
||||
public void updateLocation(final boolean centerChanged, final boolean locationChanged,
|
||||
final boolean compassChanged) {
|
||||
if (inLocationUpdate) {
|
||||
return;
|
||||
}
|
||||
|
@ -919,10 +915,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
return dashboardView;
|
||||
}
|
||||
|
||||
public DashFragmentData[] getFragmentsData() {
|
||||
return fragmentsData;
|
||||
}
|
||||
|
||||
public static class SettingsShouldShow implements DashFragmentData.ShouldShowFunction {
|
||||
@Override
|
||||
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
|
||||
|
@ -954,14 +946,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
}
|
||||
}
|
||||
|
||||
private static class SimulateShouldShow extends DefaultShouldShow {
|
||||
@Override
|
||||
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
|
||||
return super.shouldShow(settings, activity, tag)
|
||||
&& OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ChooseAppDirShouldShow extends SettingsShouldShow {
|
||||
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
|
|
|
@ -1,36 +1,59 @@
|
|||
package net.osmand.plus.dashboard.tools;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
|
||||
public final class DashFragmentData {
|
||||
public final class DashFragmentData implements Comparable<DashFragmentData> {
|
||||
public final String tag;
|
||||
public final Class<? extends DashBaseFragment> fragmentClass;
|
||||
public final String title;
|
||||
public final ShouldShowFunction shouldShowFunction;
|
||||
public final boolean customDeletionLogic;
|
||||
public final int position;
|
||||
|
||||
public DashFragmentData(String tag, Class<? extends DashBaseFragment> fragmentClass,
|
||||
String title, ShouldShowFunction shouldShowFunction,
|
||||
boolean customDeletionLogic) {
|
||||
boolean customDeletionLogic, int position) {
|
||||
this.tag = tag;
|
||||
this.fragmentClass = fragmentClass;
|
||||
this.title = title;
|
||||
this.shouldShowFunction = shouldShowFunction;
|
||||
this.customDeletionLogic = customDeletionLogic;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public DashFragmentData(String tag, Class<? extends DashBaseFragment> fragmentClass,
|
||||
String title, ShouldShowFunction shouldShowFunction) {
|
||||
String title, ShouldShowFunction shouldShowFunction, int position) {
|
||||
this.tag = tag;
|
||||
this.fragmentClass = fragmentClass;
|
||||
this.title = title;
|
||||
this.shouldShowFunction = shouldShowFunction;
|
||||
customDeletionLogic = false;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public DashFragmentData(String tag, Class<? extends DashBaseFragment> fragmentClass,
|
||||
String title, int position) {
|
||||
this.tag = tag;
|
||||
this.fragmentClass = fragmentClass;
|
||||
this.title = title;
|
||||
this.shouldShowFunction = new DashboardOnMap.DefaultShouldShow();
|
||||
customDeletionLogic = false;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull DashFragmentData another) {
|
||||
return position - another.position;
|
||||
}
|
||||
|
||||
public interface ShouldShowFunction {
|
||||
boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,82 +13,113 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DashboardSettingsDialogFragment extends DialogFragment {
|
||||
private static final String CHECKED_ITEMS = "checked_items";
|
||||
private MapActivity mapActivity;
|
||||
private DashFragmentData[] fragmentsData;
|
||||
private DashFragmentAdapter adapter;
|
||||
private ArrayList<DashFragmentData> mFragmentsData;
|
||||
private DashFragmentAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
mapActivity = (MapActivity) activity;
|
||||
ArrayList<DashFragmentData> fragmentsList = new ArrayList<>();
|
||||
mFragmentsData = new ArrayList<>();
|
||||
for(DashFragmentData fragmentData : mapActivity.getDashboard().getFragmentsData()) {
|
||||
if (!fragmentData.customDeletionLogic) fragmentsList.add(fragmentData);
|
||||
if (!fragmentData.customDeletionLogic) mFragmentsData.add(fragmentData);
|
||||
}
|
||||
fragmentsData = fragmentsList.toArray(new DashFragmentData[fragmentsList.size()]);
|
||||
mFragmentsData.addAll(OsmandPlugin.getPluginsCardsList());
|
||||
Collections.sort(mFragmentsData);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||
|
||||
View view = LayoutInflater.from(getActivity()).inflate(
|
||||
R.layout.dashboard_settings_dialog_item, null, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.text);
|
||||
textView.setText("Show on start");
|
||||
final OsmandSettings.CommonPreference<Boolean> shouldShowDashboardOnStart =
|
||||
settings.registerBooleanPreference(MapActivity.SHOULD_SHOW_DASHBOARD_ON_START, true);
|
||||
final CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.check_item);
|
||||
compoundButton.setChecked(shouldShowDashboardOnStart.get());
|
||||
textView.setTextColor(shouldShowDashboardOnStart.get() ? 0xFF212121 : 0xFF8c8c8c);
|
||||
compoundButton.setOnCheckedChangeListener(
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
textView.setTextColor(b ? 0xFF212121 : 0xFF8c8c8c);
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey(CHECKED_ITEMS)) {
|
||||
adapter = new DashFragmentAdapter(getActivity(), fragmentsData,
|
||||
mAdapter = new DashFragmentAdapter(getActivity(), mFragmentsData,
|
||||
savedInstanceState.getBooleanArray(CHECKED_ITEMS));
|
||||
} else {
|
||||
adapter = new DashFragmentAdapter(getActivity(), fragmentsData,
|
||||
mAdapter = new DashFragmentAdapter(getActivity(), mFragmentsData,
|
||||
settings);
|
||||
}
|
||||
builder.setTitle(R.string.dahboard_options_dialog_title)
|
||||
.setAdapter(adapter, null)
|
||||
.setAdapter(mAdapter, null)
|
||||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int type) {
|
||||
boolean[] shouldShow = adapter.getCheckedItems();
|
||||
boolean[] shouldShow = mAdapter.getCheckedItems();
|
||||
for (int i = 0; i < shouldShow.length; i++) {
|
||||
settings.registerBooleanPreference(
|
||||
DashboardOnMap.SHOULD_SHOW + fragmentsData[i].tag, true)
|
||||
DashboardOnMap.SHOULD_SHOW + mFragmentsData.get(i).tag, true)
|
||||
.makeGlobal().set(shouldShow[i]);
|
||||
}
|
||||
mapActivity.getDashboard().refreshDashboardFragments();
|
||||
shouldShowDashboardOnStart.set(compoundButton.isChecked());
|
||||
// TODO save as preference
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
return builder.create();
|
||||
final AlertDialog dialog = builder.create();
|
||||
|
||||
ListView listView = dialog.getListView();
|
||||
listView.addHeaderView(view);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putBooleanArray(CHECKED_ITEMS, adapter.getCheckedItems());
|
||||
outState.putBooleanArray(CHECKED_ITEMS, mAdapter.getCheckedItems());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private static class DashFragmentAdapter extends ArrayAdapter<DashFragmentData> {
|
||||
private final boolean[] checkedItems;
|
||||
|
||||
public DashFragmentAdapter(Context context, DashFragmentData[] objects, boolean[] checkedItems) {
|
||||
public DashFragmentAdapter(Context context, List<DashFragmentData> objects,
|
||||
boolean[] checkedItems) {
|
||||
super(context, 0, objects);
|
||||
this.checkedItems = checkedItems;
|
||||
}
|
||||
|
||||
public DashFragmentAdapter(Context context, DashFragmentData[] objects, OsmandSettings settings) {
|
||||
public DashFragmentAdapter(Context context, List<DashFragmentData> objects,
|
||||
OsmandSettings settings) {
|
||||
super(context, 0, objects);
|
||||
checkedItems = new boolean[objects.length];
|
||||
for (int i = 0; i < objects.length; i++) {
|
||||
checkedItems = new boolean[objects.size()];
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
checkedItems[i] = settings.registerBooleanPreference(
|
||||
DashboardOnMap.SHOULD_SHOW + objects[i].tag, true).makeGlobal().get();
|
||||
DashboardOnMap.SHOULD_SHOW + objects.get(i).tag, true).makeGlobal().get();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import net.osmand.plus.dashboard.DashBaseFragment;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +21,7 @@ import java.util.List;
|
|||
public final class TransactionBuilder {
|
||||
private static final String TAG = "TransactionBuilder";
|
||||
private FragmentManager manager;
|
||||
private List<DashFragmentData> fragments = new ArrayList<>();
|
||||
private final List<DashFragmentData> fragments;
|
||||
private OsmandSettings settings;
|
||||
private MapActivity mapActivity;
|
||||
|
||||
|
@ -28,6 +30,7 @@ public final class TransactionBuilder {
|
|||
this.manager = manager;
|
||||
this.settings = settings;
|
||||
this.mapActivity = mapActivity;
|
||||
fragments = new ArrayList<>();
|
||||
}
|
||||
|
||||
public TransactionBuilder addFragmentsData(DashFragmentData... dashFragmentsData) {
|
||||
|
@ -35,9 +38,20 @@ public final class TransactionBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public TransactionBuilder addFragmentsData(Collection<DashFragmentData> dashFragmentsData) {
|
||||
fragments.addAll(dashFragmentsData);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TransactionBuilder addFragment(DashFragmentData fragmentData) {
|
||||
fragments.add(fragmentData);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FragmentTransaction getFragmentTransaction() {
|
||||
Log.v(TAG, "getFragmentTransaction(" + ")");
|
||||
FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||
Collections.sort(fragments);
|
||||
for (DashFragmentData dashFragmentData : fragments) {
|
||||
DashBaseFragment fragment =
|
||||
(DashBaseFragment) manager.findFragmentByTag(dashFragmentData.tag);
|
||||
|
|
|
@ -1,46 +1,51 @@
|
|||
package net.osmand.plus.development;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import android.app.Activity;
|
||||
|
||||
public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
||||
private static final String ID = "osmand.development";
|
||||
private OsmandApplication app;
|
||||
|
||||
|
||||
public OsmandDevelopmentPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
//ApplicationMode.regWidget("fps", new ApplicationMode[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return app.getString(R.string.osmand_development_plugin_description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return app.getString(R.string.debugging_and_development);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerLayers(MapActivity activity) {
|
||||
registerWidget(activity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
if(isActive()) {
|
||||
if (isActive()) {
|
||||
registerWidget(activity);
|
||||
} else {
|
||||
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||
|
@ -50,9 +55,9 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class FPSTextInfoWidget extends TextInfoWidget {
|
||||
|
||||
|
||||
private OsmandMapTileView mv;
|
||||
|
||||
public FPSTextInfoWidget(OsmandMapTileView mv, Activity activity) {
|
||||
|
@ -62,7 +67,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
if(!mv.isMeasureFPS()) {
|
||||
if (!mv.isMeasureFPS()) {
|
||||
mv.setMeasureFPS(true);
|
||||
}
|
||||
setText("", Integer.toString((int) mv.getFPS()) + "/"
|
||||
|
@ -72,7 +77,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void registerWidget(MapActivity activity) {
|
||||
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||
final OsmandMapTileView mv = activity.getMapView();
|
||||
|
@ -83,20 +88,27 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
|||
mapInfoLayer.recreateControls();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getSettingsActivity() {
|
||||
return SettingsDevelopmentActivity.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLogoResourceId() {
|
||||
return R.drawable.ic_plugin_developer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getAssetResourceName() {
|
||||
return R.drawable.osmand_development;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashFragmentData getCardFragment() {
|
||||
return new DashFragmentData(DashSimulateFragment.TAG,
|
||||
DashSimulateFragment.class,
|
||||
getName(),
|
||||
new DashboardOnMap.DefaultShouldShow(), 15);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -461,5 +462,9 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
return ll;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DashFragmentData getCardFragment() {
|
||||
return new DashFragmentData(DashTrackFragment.TAG, DashTrackFragment.class, getName(), 11);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,8 @@ import net.osmand.plus.activities.EnumAdapter;
|
|||
import net.osmand.plus.activities.EnumAdapter.IEnumWithResource;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TabActivity;
|
||||
import net.osmand.plus.dashboard.DashPluginsFragment;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.myplaces.AvailableGPXFragment;
|
||||
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
|
@ -343,5 +345,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
return (osmPoint.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + osmPoint.getId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DashFragmentData getCardFragment() {
|
||||
return new DashFragmentData(DashOsmEditsFragment.TAG, DashOsmEditsFragment.class, getName(), 13);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.download.DownloadFileHelper;
|
||||
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
|
||||
import net.osmand.plus.osmo.OsMoService.SessionInfo;
|
||||
|
@ -530,4 +531,8 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
|||
return app.getSettings().OSMO_USE_HTTPS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashFragmentData getCardFragment() {
|
||||
return new DashFragmentData(DashOsMoFragment.TAG, DashOsMoFragment.class, getName(), 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
|
@ -559,4 +560,9 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
}
|
||||
return ctx.getString(R.string.osmand_parking_position_description, timeLimitDesc.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashFragmentData getCardFragment() {
|
||||
return new DashFragmentData(DashParkingFragment.TAG, DashParkingFragment.class, getName(), 5);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue