use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class ImportCompleteFragment method openFavouritesActivity.
private void openFavouritesActivity(Activity activity, int tabType) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
Intent favoritesActivity = new Intent(activity, appCustomization.getFavoritesActivity());
favoritesActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
app.getSettings().FAVORITES_TAB.set(tabType);
startActivity(favoritesActivity);
}
use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class MapActivity method onResume.
@Override
protected void onResume() {
super.onResume();
MapActivity mapViewMapActivity = getMapView().getMapActivity();
if (activityRestartNeeded || !getMapLayers().hasMapActivity() || (mapViewMapActivity != null && mapViewMapActivity != this)) {
activityRestartNeeded = false;
recreate();
return;
}
long tm = System.currentTimeMillis();
FragmentManager fragmentManager = getSupportFragmentManager();
if (app.getMapMarkersHelper().getPlanRouteContext().isFragmentVisible()) {
PlanRouteFragment.showInstance(this);
}
if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) {
if (!dashboardOnMap.isVisible()) {
if (settings.SHOW_DASHBOARD_ON_START.get()) {
dashboardOnMap.setDashboardVisibility(true, DashboardOnMap.staticVisibleType);
} else {
OsmAndAppCustomization customization = app.getAppCustomization();
if (customization.isFeatureEnabled(FRAGMENT_CRASH_ID) && CrashBottomSheetDialogFragment.shouldShow(settings, this)) {
SecondSplashScreenFragment.SHOW = false;
CrashBottomSheetDialogFragment.showInstance(fragmentManager);
} else if (customization.isFeatureEnabled(FRAGMENT_RATE_US_ID) && RateUsHelper.shouldShowRateDialog(app)) {
SecondSplashScreenFragment.SHOW = false;
RateUsHelper.showRateDialog(this);
}
}
} else {
dashboardOnMap.updateDashboard();
}
}
dashboardOnMap.updateLocation(true, true, false);
boolean showStorageMigrationScreen = false;
if (getFragment(WhatsNewDialogFragment.TAG) == null || WhatsNewDialogFragment.wasNotShown()) {
if (getFragment(SharedStorageWarningFragment.TAG) == null && SharedStorageWarningFragment.dialogShowRequired(app)) {
showStorageMigrationScreen = true;
SecondSplashScreenFragment.SHOW = false;
SharedStorageWarningFragment.showInstance(getSupportFragmentManager(), true);
}
}
getMyApplication().getNotificationHelper().refreshNotifications();
// fixing bug with action bar appearing on android 2.3.3
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
// for voice navigation
ApplicationMode routingAppMode = getRoutingHelper().getAppMode();
if (routingAppMode != null && settings.AUDIO_MANAGER_STREAM.getModeValue(routingAppMode) != null) {
setVolumeControlStream(settings.AUDIO_MANAGER_STREAM.getModeValue(routingAppMode));
} else {
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
applicationModeListener = change -> app.runInUIThread(this::updateApplicationModeSettings);
settings.APPLICATION_MODE.addListener(applicationModeListener);
updateApplicationModeSettings();
// if destination point was changed try to recalculate route
TargetPointsHelper targets = app.getTargetPointsHelper();
RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isFollowingMode() && (!Algorithms.objectEquals(targets.getPointToNavigate().point, routingHelper.getFinalLocation()) || !Algorithms.objectEquals(targets.getIntermediatePointsLatLonNavigation(), routingHelper.getIntermediatePoints()))) {
targets.updateRouteAndRefresh(true);
}
app.getLocationProvider().resumeAllUpdates();
OsmandMapTileView mapView = getMapView();
if (settings.isLastKnownMapLocation() && !intentLocation) {
LatLon l = settings.getLastKnownMapLocation();
mapView.setLatLon(l.getLatitude(), l.getLongitude());
mapView.setIntZoom(settings.getLastKnownMapZoom());
} else {
intentLocation = false;
}
settings.MAP_ACTIVITY_ENABLED.set(true);
showAndHideMapPosition();
readLocationToShow();
OsmandPlugin.checkInstalledMarketPlugins(app, this);
OsmandPlugin.onMapActivityResume(this);
intentHelper.parseContentIntent();
mapView.refreshMap(true);
if (atlasMapRendererView != null) {
atlasMapRendererView.handleOnResume();
}
app.getLauncherShortcutsHelper().updateLauncherShortcuts();
app.getDownloadThread().setUiActivity(this);
boolean routeWasFinished = routingHelper.isRouteWasFinished();
if (routeWasFinished && !DestinationReachedMenu.wasShown()) {
DestinationReachedMenu.show(this);
}
routingHelper.addListener(this);
app.getMapMarkersHelper().addListener(this);
QuickSearchDialogFragment searchDialogFragment = getQuickSearchDialogFragment();
if (searchDialogFragment != null) {
if (searchDialogFragment.isSearchHidden()) {
searchDialogFragment.hide();
searchDialogFragment.restoreToolbar();
}
}
if (System.currentTimeMillis() - tm > 50) {
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
}
boolean showOsmAndWelcomeScreen = true;
final Intent intent = getIntent();
if (intent != null && intent.hasExtra(FirstUsageWelcomeFragment.SHOW_OSMAND_WELCOME_SCREEN)) {
showOsmAndWelcomeScreen = intent.getBooleanExtra(FirstUsageWelcomeFragment.SHOW_OSMAND_WELCOME_SCREEN, true);
}
boolean showWelcomeScreen = ((app.getAppInitializer().isFirstTime() && Version.isDeveloperVersion(app)) || !app.getResourceManager().isAnyMapInstalled()) && FirstUsageWelcomeFragment.SHOW && settings.SHOW_OSMAND_WELCOME_SCREEN.get() && showOsmAndWelcomeScreen && !showStorageMigrationScreen;
if (!showWelcomeScreen && !permissionDone && !app.getAppInitializer().isFirstTime()) {
if (!permissionAsked) {
if (app.isExternalStorageDirectoryReadOnly() && !showStorageMigrationScreen && fragmentManager.findFragmentByTag(SharedStorageWarningFragment.TAG) == null && fragmentManager.findFragmentByTag(SettingsScreenType.DATA_STORAGE.fragmentName) == null) {
if (DownloadActivity.hasPermissionToWriteExternalStorage(this)) {
Bundle args = new Bundle();
args.putBoolean(FIRST_USAGE, true);
BaseSettingsFragment.showInstance(this, SettingsScreenType.DATA_STORAGE, null, args, null);
} else {
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}
}
} else {
if (permissionGranted) {
RestartActivity.doRestart(this, getString(R.string.storage_permission_restart_is_required));
} else if (fragmentManager.findFragmentByTag(SettingsScreenType.DATA_STORAGE.fragmentName) == null) {
Bundle args = new Bundle();
args.putBoolean(FIRST_USAGE, true);
BaseSettingsFragment.showInstance(this, SettingsScreenType.DATA_STORAGE, null, args, null);
}
permissionAsked = false;
permissionGranted = false;
permissionDone = true;
}
}
enableDrawer();
if (showWelcomeScreen && FirstUsageWelcomeFragment.showInstance(fragmentManager)) {
SecondSplashScreenFragment.SHOW = false;
} else if (SendAnalyticsBottomSheetDialogFragment.shouldShowDialog(app)) {
SendAnalyticsBottomSheetDialogFragment.showInstance(app, fragmentManager, null);
}
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.showInstance(fragmentManager)) {
SecondSplashScreenFragment.SHOW = false;
SecondSplashScreenFragment.VISIBLE = true;
mapView.setOnDrawMapListener(this);
splashScreenTimer = new Timer();
splashScreenTimer.schedule(new TimerTask() {
@Override
public void run() {
app.runInUIThread(() -> dismissSecondSplashScreen());
}
}, SECOND_SPLASH_TIME_OUT);
} else {
if (SecondSplashScreenFragment.VISIBLE) {
dismissSecondSplashScreen();
}
applyScreenOrientation();
}
settings.MAP_SCREEN_ORIENTATION.addListener(mapScreenOrientationSettingListener);
settings.USE_SYSTEM_SCREEN_TIMEOUT.addListener(useSystemScreenTimeoutListener);
extendedMapActivity.onResume(this);
}
use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class OsmandApplication method onCreate.
// Typeface
@Override
public void onCreate() {
if (RestartActivity.isRestartProcess(this)) {
return;
}
long timeToStart = System.currentTimeMillis();
if (Version.isDeveloperVersion(this)) {
try {
Class.forName("net.osmand.plus.base.EnableStrictMode").newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
super.onCreate();
createInUiThread();
uiHandler = new Handler();
appCustomization = new OsmAndAppCustomization();
appCustomization.setup(this);
osmandSettings = appCustomization.getOsmandSettings();
appInitializer.initVariables();
if (appInitializer.isAppVersionChanged() && appInitializer.getPrevAppVersion() < AppVersionUpgradeOnInit.VERSION_2_3) {
osmandSettings.freezeExternalStorageDirectory();
} else if (appInitializer.isFirstTime()) {
osmandSettings.initExternalStorageDirectory();
}
externalStorageDirectory = osmandSettings.getExternalStorageDirectory();
if (!FileUtils.isWritable(externalStorageDirectory)) {
externalStorageDirectoryReadOnly = true;
externalStorageDirectory = osmandSettings.getInternalAppPath();
}
Algorithms.removeAllFiles(getAppPath(IndexConstants.TEMP_DIR));
if (appInitializer.isAppVersionChanged()) {
// Reset mapillary tile sources
File tilesPath = getAppPath(IndexConstants.TILES_INDEX_DIR);
File mapillaryVectorTilesPath = new File(tilesPath, TileSourceManager.getMapillaryVectorSource().getName());
Algorithms.removeAllFiles(mapillaryVectorTilesPath);
// Remove travel sqlite db files
removeSqliteDbTravelFiles();
}
localeHelper.checkPreferredLocale();
appInitializer.onCreateApplication();
// if(!osmandSettings.FOLLOW_THE_ROUTE.get()) {
// targetPointsHelper.clearPointToNavigate(false);
// }
osmandMap.getMapLayers().createLayers(osmandMap.getMapView());
osmandMap.getMapLayers().updateLayers(null);
startApplication();
System.out.println("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
timeToStart = System.currentTimeMillis();
OsmandPlugin.initPlugins(this);
System.out.println("Time to init plugins " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
SearchUICore.setDebugMode(OsmandPlugin.isDevelopment());
// OsmandPlugin.isDevelopment();
BackupHelper.DEBUG = true;
}
use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class ContextMenuAdapter method createListAdapter.
public ArrayAdapter<ContextMenuItem> createListAdapter(final Activity activity, final boolean lightTheme) {
final int layoutId = DEFAULT_LAYOUT_ID;
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
final OsmAndAppCustomization customization = app.getAppCustomization();
List<ContextMenuItem> itemsToRemove = new ArrayList<>();
for (ContextMenuItem item : items) {
String id = item.getId();
if (item.isHidden() || !TextUtils.isEmpty(id) && !customization.isFeatureEnabled(id)) {
itemsToRemove.add(item);
}
}
items.removeAll(itemsToRemove);
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title, items.toArray(new ContextMenuItem[0]), app, lightTheme, changeAppModeListener);
}
use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class ContextMenuAdapter method isItemHidden.
private boolean isItemHidden(@NonNull String id) {
OsmAndAppCustomization customization = app.getAppCustomization();
if (!customization.isFeatureEnabled(id)) {
return true;
}
ContextMenuItemsPreference contextMenuItemsPreference = app.getSettings().getContextMenuItemsPreference(id);
if (contextMenuItemsPreference == null) {
return false;
}
List<String> hiddenIds = contextMenuItemsPreference.get().getHiddenIds();
if (!Algorithms.isEmpty(hiddenIds)) {
return hiddenIds.contains(id);
}
return false;
}
Aggregations