From be402f0acd3f543a4b8901a0604c696b01cf9eda Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Tue, 27 Oct 2015 17:32:08 +0200 Subject: [PATCH] setFirstTime() method removed. Refactoring. --- .../src/net/osmand/plus/AppInitializer.java | 37 +++++++++---------- .../DashAudioVideoNotesFragment.java | 13 +++++-- .../plus/dashboard/DashFavoritesFragment.java | 10 ++++- .../plus/dashboard/DashFirstTimeFragment.java | 17 ++++++++- .../dashboard/DashNavigationFragment.java | 10 ++++- .../plus/dashboard/DashPluginsFragment.java | 10 ++++- .../plus/dashboard/DashRecentsFragment.java | 12 ++++-- .../plus/dashboard/DashSearchFragment.java | 9 ++++- .../plus/dashboard/DashWaypointsFragment.java | 8 ++++ .../osmand/plus/dashboard/DashboardOnMap.java | 31 +++++----------- .../dashboard/tools/DashFragmentData.java | 15 ++++---- .../DashboardSettingsDialogFragment.java | 5 ++- .../development/DashSimulateFragment.java | 24 +++++++++--- .../development/OsmandDevelopmentPlugin.java | 6 +-- .../plus/download/DownloadActivity.java | 2 +- .../ui/DataStoragePlaceDialogFragment.java | 5 ++- .../plus/monitoring/DashTrackFragment.java | 11 +++++- .../plus/osmedit/DashOsmEditsFragment.java | 11 +++++- .../osmand/plus/osmo/DashOsMoFragment.java | 20 +++++++--- .../src/net/osmand/plus/osmo/OsMoPlugin.java | 4 +- .../parkingpoint/DashParkingFragment.java | 17 ++++++++- .../parkingpoint/ParkingPositionPlugin.java | 4 +- 22 files changed, 188 insertions(+), 93 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 14f008d95c..3dfb3f20f9 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -1,13 +1,12 @@ package net.osmand.plus; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; import net.osmand.IProgress; import net.osmand.IndexConstants; @@ -42,13 +41,15 @@ import net.osmand.util.Algorithms; import org.xmlpull.v1.XmlPullParserException; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + import btools.routingapp.BRouterServiceConnection; /** @@ -160,11 +161,7 @@ public class AppInitializer implements IProgress { initUiVars(activity); return firstTime; } - - public void setFirstTime(boolean firstTime) { - this.firstTime = firstTime; - } - + public boolean checkAppVersionChanged(Activity activity) { initUiVars(activity); boolean showRecentChangesDialog = !firstTime && appVersionChanged; diff --git a/OsmAnd/src/net/osmand/plus/audionotes/DashAudioVideoNotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/DashAudioVideoNotesFragment.java index ff7980def7..6ebd6ec5e4 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/DashAudioVideoNotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/DashAudioVideoNotesFragment.java @@ -31,9 +31,16 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment { public static final String TAG = "DASH_NOTES_FRAGMENT"; 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); + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; + static final DashFragmentData FRAGMENT_DATA = new DashFragmentData( + TAG, DashAudioVideoNotesFragment.class, SHOULD_SHOW_FUNCTION, 100, ROW_NUMBER_TAG); + AudioVideoNotesPlugin plugin; diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashFavoritesFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashFavoritesFragment.java index 3ebd3bee62..2cc93497d1 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashFavoritesFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashFavoritesFragment.java @@ -37,9 +37,15 @@ public class DashFavoritesFragment extends DashLocationFragment { List points = new ArrayList(); public static final String ROW_NUMBER_TAG = TAG + "_row_number"; + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; public static final DashFragmentData FRAGMENT_DATA = - new DashFragmentData(TAG, DashFavoritesFragment.class, TITLE_ID, - new DashboardOnMap.DefaultShouldShow(), 90, ROW_NUMBER_TAG); + new DashFragmentData(TAG, DashFavoritesFragment.class, SHOULD_SHOW_FUNCTION, 90, ROW_NUMBER_TAG); @Override public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashFirstTimeFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashFirstTimeFragment.java index ad1b331261..7d3e833b29 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashFirstTimeFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashFirstTimeFragment.java @@ -13,6 +13,8 @@ import android.widget.TextView; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.download.DownloadActivity; /** @@ -22,7 +24,12 @@ import net.osmand.plus.download.DownloadActivity; public class DashFirstTimeFragment extends DashBaseFragment { public static final String TAG = "DASH_FIRST_TIME_FRAGMENT"; + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new FirstTimeShouldShow(); + static final DashFragmentData FRAGMENT_DATA = + new DashFragmentData(TAG, DashFirstTimeFragment.class, SHOULD_SHOW_FUNCTION, 110, null); + public static boolean interestedInFirstTime = true; @Override public void onOpenDash() { @@ -66,7 +73,7 @@ public class DashFirstTimeFragment extends DashBaseFragment { view.findViewById(R.id.hide).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - getMyApplication().getAppInitializer().setFirstTime(false); + interestedInFirstTime = false; dashboard.refreshDashboardFragments(); } }); @@ -88,4 +95,12 @@ public class DashFirstTimeFragment extends DashBaseFragment { private void updateCurrentRegion(View view) { ((TextView) view.findViewById(R.id.region)).setText(getMyApplication().getSettings().DRIVING_REGION.get().name); } + + private static class FirstTimeShouldShow extends DashFragmentData.ShouldShowFunction { + @Override + public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { + return activity.getMyApplication().getAppInitializer().isFirstTime(activity) + && DashFirstTimeFragment.interestedInFirstTime; + } + } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashNavigationFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashNavigationFragment.java index 4e85ea36e3..693e38ef91 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashNavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashNavigationFragment.java @@ -16,13 +16,21 @@ import android.widget.TextView; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.ShowRouteInfoActivity; +import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.routing.RoutingHelper; /** */ public class DashNavigationFragment extends DashBaseFragment { public static final String TAG = "DASH_NAVIGATION_FRAGMENT"; - public static final int TITLE_ID = R.string.current_route; + private static final int TITLE_ID = R.string.current_route; + public static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; @Override public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java index bcbc8e2f25..8dc615c555 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java @@ -17,6 +17,7 @@ import android.widget.TextView; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.PluginActivity; +import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.development.OsmandDevelopmentPlugin; import java.util.ArrayList; @@ -30,7 +31,14 @@ import java.util.List; */ public class DashPluginsFragment extends DashBaseFragment { public static final String TAG = "DASH_PLUGINS_FRAGMENT"; - public static final int TITLE_ID = R.string.prefs_plugins; + private static final int TITLE_ID = R.string.prefs_plugins; + public static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; private List plugins; private View.OnClickListener getListener(final OsmandPlugin plugin) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashRecentsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashRecentsFragment.java index 604a631a6a..06293cfa9e 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashRecentsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashRecentsFragment.java @@ -36,9 +36,15 @@ public class DashRecentsFragment extends DashLocationFragment { private List arrows = new ArrayList(); List points = new ArrayList(); 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(), 80, ROW_NUMBER_TAG); + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; + static final DashFragmentData FRAGMENT_DATA = new DashFragmentData( + TAG, DashRecentsFragment.class, SHOULD_SHOW_FUNCTION, 80, ROW_NUMBER_TAG); @Override public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java index 4e4e48d198..7483a4f688 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java @@ -15,6 +15,7 @@ import net.osmand.plus.IconsCache; import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.R; import net.osmand.plus.activities.search.SearchActivity; +import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.helpers.FontCache; /** @@ -22,8 +23,14 @@ import net.osmand.plus.helpers.FontCache; * 24.11.2014. */ public class DashSearchFragment extends DashBaseFragment { - public static final int TITLE_ID = R.string.search_for; public static final String TAG = "DASH_SEARCH_FRAGMENT"; + public static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return R.string.search_for; + } + }; @Override public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java index 6f83812969..e971d570b8 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java @@ -23,6 +23,7 @@ import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; +import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.helpers.WaypointHelper; @@ -39,6 +40,13 @@ public class DashWaypointsFragment extends DashLocationFragment { public static final int TITLE_ID = R.string.waypoints; List points = new ArrayList(); private static boolean SHOW_ALL; + public static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; @Override public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 87e83f3fba..a0af237d48 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -72,30 +72,27 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { public static final String SHOULD_SHOW = "should_show"; private static final DashFragmentData.ShouldShowFunction rateUsShouldShow = new DashRateUsFragment.RateUsShouldShow(); - private static final DefaultShouldShow defaultShouldShow = new DefaultShouldShow(); private static final DashFragmentData.ShouldShowFunction errorShouldShow = new ErrorShouldShow(); - private static final DashFragmentData.ShouldShowFunction firstTimeShouldShow = new FirstTimeShouldShow(); private static final DashFragmentData.ShouldShowFunction chooseAppDirShouldShow = new ChooseAppDirShouldShow(); private final DashFragmentData[] fragmentsData = new DashFragmentData[]{ new DashFragmentData(DashRateUsFragment.TAG, DashRateUsFragment.class, - -1, rateUsShouldShow, 0, null), - new DashFragmentData(DashFirstTimeFragment.TAG, DashFirstTimeFragment.class, - -1, firstTimeShouldShow, 10, null), + rateUsShouldShow, 0, null), + DashFirstTimeFragment.FRAGMENT_DATA, new DashFragmentData(DashChooseAppDirFragment.TAG, DashChooseAppDirFragment.class, - -1, chooseAppDirShouldShow, 20, null), + chooseAppDirShouldShow, 20, null), new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class, - -1, errorShouldShow, 30, null), + errorShouldShow, 30, null), new DashFragmentData(DashNavigationFragment.TAG, DashNavigationFragment.class, - DashNavigationFragment.TITLE_ID, defaultShouldShow, 40, null), + DashNavigationFragment.SHOULD_SHOW_FUNCTION, 40, null), new DashFragmentData(DashWaypointsFragment.TAG, DashWaypointsFragment.class, - DashWaypointsFragment.TITLE_ID, defaultShouldShow, 60, null), + DashWaypointsFragment.SHOULD_SHOW_FUNCTION, 60, null), new DashFragmentData(DashSearchFragment.TAG, DashSearchFragment.class, - DashSearchFragment.TITLE_ID, defaultShouldShow, 70, null), + DashSearchFragment.SHOULD_SHOW_FUNCTION, 70, null), DashRecentsFragment.FRAGMENT_DATA, DashFavoritesFragment.FRAGMENT_DATA, new DashFragmentData(DashPluginsFragment.TAG, DashPluginsFragment.class, - DashPluginsFragment.TITLE_ID, defaultShouldShow, 140, null) + DashPluginsFragment.SHOULD_SHOW_FUNCTION, 140, null) }; private MapActivity mapActivity; @@ -933,7 +930,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { return list; } - public static class SettingsShouldShow implements DashFragmentData.ShouldShowFunction { + public static class SettingsShouldShow extends DashFragmentData.ShouldShowFunction { @Override public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { return settings.registerBooleanPreference(SHOULD_SHOW + tag, true) @@ -949,7 +946,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { } } - private static class ErrorShouldShow implements DashFragmentData.ShouldShowFunction { + private static class ErrorShouldShow extends DashFragmentData.ShouldShowFunction { // If settings null. No changes in setting will be made. @Override public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { @@ -958,14 +955,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { } } - private static class FirstTimeShouldShow extends SettingsShouldShow { - @Override - public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { - return activity.getMyApplication().getAppInitializer().isFirstTime(activity) - && super.shouldShow(settings, activity, tag); - } - } - private static class ChooseAppDirShouldShow extends SettingsShouldShow { public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashFragmentData.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashFragmentData.java index 01f28520a8..b13618ec3e 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashFragmentData.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashFragmentData.java @@ -1,27 +1,23 @@ package net.osmand.plus.dashboard.tools; import android.support.annotation.NonNull; -import android.support.annotation.StringRes; 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 implements Comparable { public final String tag; public final Class fragmentClass; - public final int titleStringId; public final ShouldShowFunction shouldShowFunction; public final int position; public final String rowNumberTag; public DashFragmentData(String tag, Class fragmentClass, - @StringRes int titleStringId, ShouldShowFunction shouldShowFunction, + ShouldShowFunction shouldShowFunction, int position, String rowNumberTag) { this.tag = tag; this.fragmentClass = fragmentClass; - this.titleStringId = titleStringId; this.shouldShowFunction = shouldShowFunction; this.position = position; this.rowNumberTag = rowNumberTag; @@ -36,10 +32,13 @@ public final class DashFragmentData implements Comparable { return rowNumberTag != null; } public boolean canBeDisabled() { - return titleStringId != -1; + return shouldShowFunction.getTitleId() != -1; } - public interface ShouldShowFunction { - boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag); + public static abstract class ShouldShowFunction { + public abstract boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag); + public int getTitleId() { + return -1; + } } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java index 18b4d1dd6f..8ee361023e 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java @@ -211,7 +211,8 @@ public class DashboardSettingsDialogFragment extends DialogFragment @Override public void onClick(View v) { DashViewHolder localViewHolder = (DashViewHolder) v.getTag(); - String header = getContext().getString(getItem(localViewHolder.position).titleStringId); + String header = getContext().getString(getItem(localViewHolder.position) + .shouldShowFunction.getTitleId()); String subheader = getContext().getResources().getString(R.string.count_of_lines); final String stringPosition = String.valueOf(localViewHolder.position); NumberPickerDialogFragment.createInstance(header, subheader, stringPosition, getNumberOfRows(localViewHolder.position), MAXIMUM_NUMBER_OF_ROWS) @@ -246,7 +247,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment } else { numberOfRowsTextView.setVisibility(View.GONE); } - textView.setText(fragmentData.titleStringId); + textView.setText(fragmentData.shouldShowFunction.getTitleId()); textView.setTextColor(dashFragmentAdapter.isChecked(position)? textColorPrimary : textColorSecondary); this.position = position; diff --git a/OsmAnd/src/net/osmand/plus/development/DashSimulateFragment.java b/OsmAnd/src/net/osmand/plus/development/DashSimulateFragment.java index 02996425b3..07f3159fd7 100644 --- a/OsmAnd/src/net/osmand/plus/development/DashSimulateFragment.java +++ b/OsmAnd/src/net/osmand/plus/development/DashSimulateFragment.java @@ -1,8 +1,5 @@ package net.osmand.plus.development; -import net.osmand.plus.OsmAndLocationProvider; -import net.osmand.plus.R; -import net.osmand.plus.dashboard.DashBaseFragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; @@ -14,10 +11,27 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; +import net.osmand.plus.OsmAndLocationProvider; +import net.osmand.plus.R; +import net.osmand.plus.dashboard.DashBaseFragment; +import net.osmand.plus.dashboard.DashboardOnMap; +import net.osmand.plus.dashboard.tools.DashFragmentData; + public class DashSimulateFragment extends DashBaseFragment { - public static final String TAG = "DASH_SIMULATE_FRAGMENT"; - public static final int TITLE_ID = R.string.simulate_your_location; + private static final String TAG = "DASH_SIMULATE_FRAGMENT"; + private static final int TITLE_ID = R.string.simulate_your_location; + + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; + static final DashFragmentData FRAGMENT_DATA = new DashFragmentData(DashSimulateFragment.TAG, + DashSimulateFragment.class, + SHOULD_SHOW_FUNCTION, 150, null); @Override public void onOpenDash() { diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index 981720a1d2..8f19b8607a 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -12,7 +12,6 @@ import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.ContributionVersionActivity; 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; @@ -128,9 +127,6 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { @Override public DashFragmentData getCardFragment() { - return new DashFragmentData(DashSimulateFragment.TAG, - DashSimulateFragment.class, - DashSimulateFragment.TITLE_ID, - new DashboardOnMap.DefaultShouldShow(), 150, null); + return DashSimulateFragment.FRAGMENT_DATA; } } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 6a0cf3ff41..0d2c886246 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -572,7 +572,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl final boolean firstTime = getMyApplication().getAppInitializer().isFirstTime(this); final boolean externalExists = getMyApplication().getSettings().getSecondaryStorage() != null; - if (firstTime && externalExists) { + if (firstTime && externalExists && DataStoragePlaceDialogFragment.isInterestedInFirstTime) { new DataStoragePlaceDialogFragment().show(getFragmentManager(), null); } } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java index 0b5ec4672f..7355e85838 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java @@ -31,6 +31,7 @@ public class DataStoragePlaceDialogFragment extends DialogFragment { private File internalStorage; private File externalStorage; + public static boolean isInterestedInFirstTime = true; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @@ -140,7 +141,7 @@ public class DataStoragePlaceDialogFragment extends DialogFragment { public void onClick(View v) { saveFilesLocation(OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT, internalStorage, getActivity()); - getMyApplication().getAppInitializer().setFirstTime(false); + isInterestedInFirstTime = false; dismiss(); } }; @@ -151,7 +152,7 @@ public class DataStoragePlaceDialogFragment extends DialogFragment { public void onClick(View v) { saveFilesLocation(OsmandSettings.EXTERNAL_STORAGE_TYPE_EXTERNAL_FILE, externalStorage, getActivity()); - getMyApplication().getAppInitializer().setFirstTime(false); + isInterestedInFirstTime = false; dismiss(); } }; diff --git a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java index f3b867e3a8..d457877e73 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java @@ -45,9 +45,16 @@ public class DashTrackFragment extends DashBaseFragment { public static final int TITLE_ID = R.string.shared_string_my_tracks; private static final String ROW_NUMBER_TAG = TAG + "_row_number"; + + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; static final DashFragmentData FRAGMENT_DATA = - new DashFragmentData(TAG, DashTrackFragment.class, TITLE_ID, - new DashboardOnMap.DefaultShouldShow(), 110, ROW_NUMBER_TAG); + new DashFragmentData(TAG, DashTrackFragment.class, SHOULD_SHOW_FUNCTION, 110, ROW_NUMBER_TAG); private boolean updateEnable; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java index 7a126a424f..497fc291f0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java @@ -36,9 +36,16 @@ public class DashOsmEditsFragment extends DashBaseFragment public static final int TITLE_ID = R.string.osm_settings; private static final String ROW_NUMBER_TAG = TAG + "_row_number"; + + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; static final DashFragmentData FRAGMENT_DATA = - new DashFragmentData(TAG, DashOsmEditsFragment.class, TITLE_ID, - new DashboardOnMap.DefaultShouldShow(), 130, ROW_NUMBER_TAG); + new DashFragmentData(TAG, DashOsmEditsFragment.class, SHOULD_SHOW_FUNCTION, 130, ROW_NUMBER_TAG); OsmEditingPlugin plugin; diff --git a/OsmAnd/src/net/osmand/plus/osmo/DashOsMoFragment.java b/OsmAnd/src/net/osmand/plus/osmo/DashOsMoFragment.java index 6e56604bb7..acdbd6977b 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/DashOsMoFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmo/DashOsMoFragment.java @@ -4,7 +4,6 @@ import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; -import android.os.Message; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -25,6 +24,8 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashLocationFragment; +import net.osmand.plus.dashboard.DashboardOnMap; +import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice; import net.osmand.util.MapUtils; @@ -42,6 +43,15 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups public static final String TAG = "DASH_OSMO_FRAGMENT"; + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return R.string.osmo_plugin_name; + } + }; + static final DashFragmentData FRAGMENT_DATA = new DashFragmentData( + DashOsMoFragment.TAG, DashOsMoFragment.class, SHOULD_SHOW_FUNCTION, 120, null); private Handler uiHandler = new Handler(); OsMoPlugin plugin; @@ -79,9 +89,9 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups plugin.setGroupsActivity(getActivity()); } setupOsMoView(); - + } - + @Override public void onDetach() { super.onDetach(); @@ -89,7 +99,7 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups plugin.setGroupsActivity(null); } } - + @Override public void onDestroy() { super.onDestroy(); @@ -218,7 +228,7 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups if (!device.isActive() && !device.isEnabled() && devices.size() > 2) { it.remove(); } - + } sortDevices(devices); diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index 7cbb7d3c82..7a1e63c010 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -22,7 +22,6 @@ 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.DashboardOnMap; import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.download.DownloadFileHelper; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice; @@ -534,7 +533,6 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor { @Override public DashFragmentData getCardFragment() { - return new DashFragmentData(DashOsMoFragment.TAG, DashOsMoFragment.class, - R.string.osmo_plugin_name, new DashboardOnMap.DefaultShouldShow(), 120, null); + return DashOsMoFragment.FRAGMENT_DATA; } } diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java b/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java index da6e5a6445..c81b5723f8 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java @@ -18,6 +18,8 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashLocationFragment; +import net.osmand.plus.dashboard.DashboardOnMap; +import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.helpers.FontCache; import java.util.Calendar; @@ -27,10 +29,21 @@ import java.util.Calendar; * 26.01.2015. */ public class DashParkingFragment extends DashLocationFragment { - public static final String TAG = "DASH_PARKING_FRAGMENT"; - public static final int TITLE_ID = R.string.osmand_parking_plugin_name; + private static final String TAG = "DASH_PARKING_FRAGMENT"; + private static final int TITLE_ID = R.string.osmand_parking_plugin_name; ParkingPositionPlugin plugin; + private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = + new DashboardOnMap.DefaultShouldShow() { + @Override + public int getTitleId() { + return TITLE_ID; + } + }; + static final DashFragmentData FRAGMENT_DATA = new DashFragmentData( + DashParkingFragment.TAG, DashParkingFragment.class, + SHOULD_SHOW_FUNCTION, 50, null); + @Override public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.dash_parking_fragment, container, false); diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 54ce3c250e..026e3d443c 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -27,7 +27,6 @@ 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.DashboardOnMap; import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.views.AnimateDraggingMapThread; @@ -600,7 +599,6 @@ public class ParkingPositionPlugin extends OsmandPlugin { @Override public DashFragmentData getCardFragment() { - return new DashFragmentData(DashParkingFragment.TAG, DashParkingFragment.class, - DashParkingFragment.TITLE_ID, new DashboardOnMap.DefaultShouldShow(), 50, null); + return DashParkingFragment.FRAGMENT_DATA; } }