Add ability to skip first screen via custom setting or intent boolean extra

This commit is contained in:
Chumva 2019-05-08 14:03:50 +03:00
parent 2d4891ff73
commit 1e860a9e54
3 changed files with 36 additions and 9 deletions

View file

@ -35,7 +35,6 @@ import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.search.core.ObjectType;
import net.osmand.util.Algorithms;
import java.io.File;
@ -831,6 +830,7 @@ public class OsmandSettings {
public final CommonPreference<Boolean> SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference("show_card_to_choose_drawer", false).makeGlobal();
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_START = new BooleanPreference("should_show_dashboard_on_start", false).makeGlobal();
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_MAP_SCREEN = new BooleanPreference("show_dashboard_on_map_screen", false).makeGlobal();
public final CommonPreference<Boolean> SHOW_OSMAND_WELCOME_SCREEN = new BooleanPreference("show_osmand_welcome_screen", true).makeGlobal();
public final CommonPreference<String> API_NAV_DRAWER_ITEMS_JSON = new StringPreference("api_nav_drawer_items_json", "{}").makeGlobal();
public final CommonPreference<String> API_CONNECTED_APPS_JSON = new StringPreference("api_connected_apps_json", "[]").makeGlobal();

View file

@ -48,7 +48,6 @@ import net.osmand.StateChangedListener;
import net.osmand.ValueHolder;
import net.osmand.access.MapAccessibilityActions;
import net.osmand.aidl.OsmandAidlApi.AMapPointUpdateListener;
import net.osmand.aidl.contextmenu.ContextMenuButtonsParams;
import net.osmand.aidl.map.ALatLon;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.core.android.AtlasMapRendererView;
@ -121,7 +120,6 @@ import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
import net.osmand.plus.views.AidlMapLayer;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapInfoLayer;
@ -744,6 +742,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
OsmandPlugin.onMapActivityResume(this);
boolean showOsmAndWelcomeScreen = true;
final Intent intent = getIntent();
if (intent != null) {
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
@ -773,6 +772,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
}
}
if (intent.hasExtra(FirstUsageWelcomeFragment.SHOW_OSMAND_WELCOME_SCREEN)) {
showOsmAndWelcomeScreen = intent.getBooleanExtra(FirstUsageWelcomeFragment.SHOW_OSMAND_WELCOME_SCREEN, true);
}
if (intent.hasExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS)) {
Bundle openMapMarkersGroupsExtra = intent.getBundleExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS);
if (openMapMarkersGroupsExtra != null) {
@ -808,8 +810,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
}
boolean showWelcomeScreen = ((app.getAppInitializer().isFirstTime() && Version.isDeveloperVersion(app))
|| !app.getResourceManager().isAnyMapInstalled()) && FirstUsageWelcomeFragment.SHOW;
boolean showWelcomeScreen = ((app.getAppInitializer().isFirstTime() && Version.isDeveloperVersion(app)) || !app.getResourceManager().isAnyMapInstalled())
&& FirstUsageWelcomeFragment.SHOW && settings.SHOW_OSMAND_WELCOME_SCREEN.get() && showOsmAndWelcomeScreen;
if (!showWelcomeScreen && !permissionDone && !app.getAppInitializer().isFirstTime()) {
if (!permissionAsked) {
@ -845,7 +847,16 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
OsmLiveCancelledDialog.showInstance(getSupportFragmentManager());
}
FirstUsageWelcomeFragment.SHOW = false;
if (isFirstScreenShowing() && (!settings.SHOW_OSMAND_WELCOME_SCREEN.get() || !showOsmAndWelcomeScreen)) {
FirstUsageWelcomeFragment welcomeFragment = getFirstUsageWelcomeFragment();
if (welcomeFragment != null) {
welcomeFragment.closeWelcomeFragment();
}
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
if (wizardFragment != null) {
wizardFragment.closeWizard();
}
}
if (SecondSplashScreenFragment.SHOW) {
SecondSplashScreenFragment.SHOW = false;
SecondSplashScreenFragment.VISIBLE = true;
@ -1670,6 +1681,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
}
public FirstUsageWelcomeFragment getFirstUsageWelcomeFragment() {
FirstUsageWelcomeFragment welcomeFragment = (FirstUsageWelcomeFragment) getSupportFragmentManager().findFragmentByTag(FirstUsageWelcomeFragment.TAG);
if (welcomeFragment != null && !welcomeFragment.isDetached()) {
return welcomeFragment;
} else {
return null;
}
}
public FirstUsageWizardFragment getFirstUsageWizardFragment() {
FirstUsageWizardFragment wizardFragment = (FirstUsageWizardFragment) getSupportFragmentManager().findFragmentByTag(FirstUsageWizardFragment.TAG);
if (wizardFragment != null && !wizardFragment.isDetached()) {

View file

@ -1,16 +1,14 @@
package net.osmand.plus.firstusage;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.AppCompatButton;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import net.osmand.plus.R;
@ -18,6 +16,7 @@ import net.osmand.plus.activities.MapActivity;
public class FirstUsageWelcomeFragment extends Fragment {
public static final String TAG = "FirstUsageWelcomeFragment";
public static final String SHOW_OSMAND_WELCOME_SCREEN = "show_osmand_welcome_screen";
public static boolean SHOW = true;
@Nullable
@Override
@ -51,4 +50,12 @@ public class FirstUsageWelcomeFragment extends Fragment {
super.onPause();
((MapActivity)getActivity()).enableDrawer();
}
public void closeWelcomeFragment() {
FragmentActivity activity = getActivity();
if (activity != null) {
activity.getSupportFragmentManager().beginTransaction()
.remove(FirstUsageWelcomeFragment.this).commit();
}
}
}