use of net.osmand.plus.dialogs.WhatsNewDialogFragment in project Osmand by osmandapp.
the class MapActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this));
long tm = System.currentTimeMillis();
app = getMyApplication();
settings = app.getSettings();
app.applyTheme(this);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
boolean portraitMode = AndroidUiHelper.isOrientationPortrait(this);
boolean largeDevice = AndroidUiHelper.isXLargeDevice(this);
landscapeLayout = !portraitMode && !largeDevice;
mapContextMenu.setMapActivity(this);
super.onCreate(savedInstanceState);
// Full screen is not used here
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
if (Build.VERSION.SDK_INT >= 21) {
enterToFullScreen();
// Navigation Drawer:
AndroidUtils.addStatusBarPadding21v(this, findViewById(R.id.menuItems));
}
int statusBarHeight = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int w = dm.widthPixels;
int h = dm.heightPixels - statusBarHeight;
mapView = new OsmandMapTileView(this, w, h);
if (app.getAppInitializer().checkAppVersionChanged() && WhatsNewDialogFragment.SHOW) {
SecondSplashScreenFragment.SHOW = false;
WhatsNewDialogFragment.SHOW = false;
new WhatsNewDialogFragment().show(getSupportFragmentManager(), null);
}
mapActions = new MapActivityActions(this);
mapLayers = new MapActivityLayers(this);
if (mapViewTrackingUtilities == null) {
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
}
dashboardOnMap.createDashboardView();
checkAppInitialization();
parseLaunchIntentLocation();
mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener() {
@Override
public boolean onTrackBallEvent(MotionEvent e) {
showAndHideMapPosition();
return MapActivity.this.onTrackballEvent(e);
}
});
mapView.setAccessibilityActions(new MapAccessibilityActions(this));
mapViewTrackingUtilities.setMapView(mapView);
// to not let it gc
downloaderCallback = new IMapDownloaderCallback() {
@Override
public void tileDownloaded(DownloadRequest request) {
if (request != null && !request.error && request.fileToSave != null) {
ResourceManager mgr = app.getResourceManager();
mgr.tileDownloaded(request);
}
if (request == null || !request.error) {
mapView.tileDownloaded(request);
}
}
};
app.getResourceManager().getMapTileDownloader().addDownloaderCallback(downloaderCallback);
createProgressBarForRouting();
mapLayers.createLayers(mapView);
updateStatusBarColor();
// it tries to continue the last route
if (settings.FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated() && !app.getRoutingHelper().isRouteBeingCalculated()) {
FailSafeFuntions.restoreRoutingMode(this);
} else if (!app.getRoutingHelper().isRoutePlanningMode() && !settings.FOLLOW_THE_ROUTE.get() && app.getTargetPointsHelper().getAllPoints().size() > 0) {
app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
app.getTargetPointsHelper().removeAllWayPoints(false, false);
}
if (!settings.isLastKnownMapLocation()) {
// show first time when application ran
net.osmand.Location location = app.getLocationProvider().getFirstTimeRunDefaultLocation();
mapViewTrackingUtilities.setMapLinkedToLocation(true);
if (location != null) {
mapView.setLatLon(location.getLatitude(), location.getLongitude());
mapView.setIntZoom(14);
}
}
addDialogProvider(mapActions);
OsmandPlugin.onMapActivityCreate(this);
importHelper = new ImportHelper(this, getMyApplication(), getMapView());
wakeLockHelper = new WakeLockHelper(getMyApplication());
if (System.currentTimeMillis() - tm > 50) {
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
}
mapView.refreshMap(true);
mapActions.updateDrawerMenu();
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
screenOffReceiver = new ScreenOffReceiver();
registerReceiver(screenOffReceiver, filter);
app.getAidlApi().onCreateMapActivity(this);
mIsDestroyed = false;
}
Aggregations