diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml
index 1b0e648f6b..20cb764861 100644
--- a/OsmAnd/AndroidManifest.xml
+++ b/OsmAnd/AndroidManifest.xml
@@ -65,7 +65,6 @@
-
+ android:padding="32dp"
+ android:background="@color/color_black">
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 776e74c4cc..a50573a36f 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -5,7 +5,11 @@ import android.app.Activity;
import android.app.AlarmManager;
import android.app.Dialog;
import android.app.PendingIntent;
-import android.content.*;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.net.Uri;
@@ -14,10 +18,18 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.DisplayMetrics;
-import android.view.*;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewStub;
+import android.view.Window;
+import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
@@ -32,22 +44,41 @@ import androidx.fragment.app.FragmentManager.BackStackEntry;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback;
-import net.osmand.*;
+
+import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities.GPXFile;
+import net.osmand.Location;
+import net.osmand.PlatformUtil;
+import net.osmand.SecondSplashScreenFragment;
+import net.osmand.StateChangedListener;
+import net.osmand.ValueHolder;
import net.osmand.access.MapAccessibilityActions;
import net.osmand.aidl.AidlMapPointWrapper;
import net.osmand.aidl.OsmandAidlApi.AMapPointUpdateListener;
import net.osmand.core.android.AtlasMapRendererView;
-import net.osmand.data.*;
+import net.osmand.data.LatLon;
+import net.osmand.data.PointDescription;
+import net.osmand.data.QuadPoint;
+import net.osmand.data.QuadRect;
+import net.osmand.data.RotatedTileBox;
import net.osmand.map.MapTileDownloader.DownloadRequest;
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
-import net.osmand.plus.*;
+import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
+import net.osmand.plus.HuaweiDrmHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
+import net.osmand.plus.OnDismissDialogFragmentListener;
+import net.osmand.plus.OsmAndConstants;
+import net.osmand.plus.OsmAndLocationSimulation;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.R;
+import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
+import net.osmand.plus.Version;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.base.ContextMenuFragment;
@@ -56,14 +87,24 @@ import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.chooseplan.OsmLiveCancelledDialog;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
-import net.osmand.plus.dialogs.*;
+import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment;
+import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment;
+import net.osmand.plus.dialogs.RateUsBottomSheetDialogFragment;
+import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment;
+import net.osmand.plus.dialogs.WhatsNewDialogFragment;
+import net.osmand.plus.dialogs.XMasDialogFragment;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
import net.osmand.plus.firstusage.FirstUsageWelcomeFragment;
import net.osmand.plus.firstusage.FirstUsageWizardFragment;
-import net.osmand.plus.helpers.*;
+import net.osmand.plus.helpers.AndroidUiHelper;
+import net.osmand.plus.helpers.DiscountHelper;
+import net.osmand.plus.helpers.ImportHelper;
+import net.osmand.plus.helpers.IntentHelper;
+import net.osmand.plus.helpers.LockHelper;
import net.osmand.plus.helpers.LockHelper.LockUIAdapter;
+import net.osmand.plus.helpers.ScrollHelper;
import net.osmand.plus.helpers.ScrollHelper.OnScrollEventListener;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
@@ -77,7 +118,11 @@ import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.mapmarkers.PlanRouteFragment;
-import net.osmand.plus.measurementtool.*;
+import net.osmand.plus.measurementtool.GpxApproximationFragment;
+import net.osmand.plus.measurementtool.MeasurementEditingContext;
+import net.osmand.plus.measurementtool.MeasurementToolFragment;
+import net.osmand.plus.measurementtool.GpxData;
+import net.osmand.plus.measurementtool.SnapTrackWarningBottomSheet;
import net.osmand.plus.quickaction.QuickActionListFragment;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager;
@@ -91,14 +136,25 @@ import net.osmand.plus.routing.TransportRoutingHelper.TransportRouteCalculationP
import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
+import net.osmand.plus.server.ApiRouter;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.fragments.*;
+import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
+import net.osmand.plus.settings.fragments.ConfigureMenuItemsFragment;
+import net.osmand.plus.settings.fragments.ConfigureProfileFragment;
+import net.osmand.plus.settings.fragments.DataStorageFragment;
+import net.osmand.plus.settings.fragments.ImportCompleteFragment;
+import net.osmand.plus.settings.fragments.ImportSettingsFragment;
+import net.osmand.plus.settings.fragments.ProfileAppearanceFragment;
import net.osmand.plus.track.TrackAppearanceFragment;
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
-import net.osmand.plus.views.*;
+import net.osmand.plus.views.AnimateDraggingMapThread;
+import net.osmand.plus.views.OsmAndMapLayersView;
+import net.osmand.plus.views.OsmAndMapSurfaceView;
+import net.osmand.plus.views.OsmandMapLayer;
+import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.OsmandMapTileView.OnDrawMapListener;
import net.osmand.plus.views.corenative.NativeCoreContext;
import net.osmand.plus.views.layers.MapControlsLayer;
@@ -109,10 +165,16 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControll
import net.osmand.render.RenderingRulesStorage;
import net.osmand.router.GeneralRouter;
import net.osmand.util.Algorithms;
+
import org.apache.commons.logging.Log;
import java.lang.ref.WeakReference;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
index dde29fa110..4a3b905744 100644
--- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
@@ -3,8 +3,11 @@ package net.osmand.plus.development;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
+import android.os.Bundle;
import android.widget.ArrayAdapter;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
@@ -13,8 +16,9 @@ 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.activities.ServerActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData;
+import net.osmand.plus.firstusage.FirstUsageWizardFragment;
+import net.osmand.plus.server.ServerFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.views.layers.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@@ -80,15 +84,22 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
- Intent intent = new Intent(mapActivity, ServerActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
- mapActivity.startActivity(intent);
+ Fragment fragment = new ServerFragment();
+ showFragment(mapActivity, fragment);
return true;
}
}).createItem());
}
}
+ private static void showFragment(FragmentActivity activity, Fragment fragment) {
+ if (activity != null) {
+ activity.getSupportFragmentManager()
+ .beginTransaction()
+ .replace(R.id.fragmentContainer, fragment, FirstUsageWizardFragment.TAG)
+ .commitAllowingStateLoss();
+ }
+ }
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if (isActive()) {
diff --git a/OsmAnd/src/net/osmand/plus/activities/ServerActivity.java b/OsmAnd/src/net/osmand/plus/server/ServerFragment.java
similarity index 60%
rename from OsmAnd/src/net/osmand/plus/activities/ServerActivity.java
rename to OsmAnd/src/net/osmand/plus/server/ServerFragment.java
index 56acab9945..2b0f9423de 100644
--- a/OsmAnd/src/net/osmand/plus/activities/ServerActivity.java
+++ b/OsmAnd/src/net/osmand/plus/server/ServerFragment.java
@@ -1,33 +1,40 @@
-package net.osmand.plus.activities;
+package net.osmand.plus.server;
import android.net.TrafficStats;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.StrictMode;
import android.text.format.Formatter;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
-
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
-import net.osmand.plus.server.OsmAndHttpServer;
+import net.osmand.plus.base.BaseOsmAndFragment;
import java.io.IOException;
-public class ServerActivity extends AppCompatActivity {
+import static android.content.Context.WIFI_SERVICE;
+
+public class ServerFragment extends BaseOsmAndFragment {
private boolean initialized = false;
private OsmAndHttpServer server;
+ private View view;
@Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- enableStrictMode();
+ public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.server_activity);
- findViewById(R.id.server_start_button).setOnClickListener(new View.OnClickListener() {
+ enableStrictMode();
+ }
+
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ view = inflater.inflate(R.layout.server_fragment, container, false);
+ view.findViewById(R.id.server_start_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!initialized) {
@@ -36,15 +43,20 @@ public class ServerActivity extends AppCompatActivity {
}
}
});
- findViewById(R.id.server_stop_button).setOnClickListener(new View.OnClickListener() {
+ view.findViewById(R.id.server_stop_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- if (initialized) {
- updateTextView(getString(R.string.click_button_to_start_server));
- deInitServer();
- }
+ updateTextView(getString(R.string.click_button_to_start_server));
+ deInitServer();
}
});
+ return view;
+ }
+
+ @Override
+ public void onDestroy() {
+ deInitServer();
+ super.onDestroy();
}
public static void enableStrictMode() {
@@ -62,9 +74,8 @@ public class ServerActivity extends AppCompatActivity {
.build());
}
-
private void updateTextView(String text) {
- ((TextView) findViewById(R.id.server_status_textview)).setText(text);
+ ((TextView) view.findViewById(R.id.server_status_textview)).setText(text);
}
private void initServer() {
@@ -73,11 +84,11 @@ public class ServerActivity extends AppCompatActivity {
OsmAndHttpServer.HOSTNAME = getDeviceAddress();
try {
server = new OsmAndHttpServer();
- server.setApplication((OsmandApplication) this.getApplication());
+ server.setApplication((OsmandApplication) getMyApplication());
initialized = true;
updateTextView("Server started at: http://" + getDeviceAddress() + ":" + OsmAndHttpServer.PORT);
} catch (IOException e) {
- Toast.makeText(this,
+ Toast.makeText(requireContext(),
e.getLocalizedMessage(),
Toast.LENGTH_SHORT).show();
e.printStackTrace();
@@ -85,7 +96,7 @@ public class ServerActivity extends AppCompatActivity {
}
private String getDeviceAddress() {
- WifiManager wm = (WifiManager) this.getApplicationContext().getSystemService(WIFI_SERVICE);
+ WifiManager wm = (WifiManager) requireContext().getSystemService(WIFI_SERVICE);
String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
return ip != null ? ip : "0.0.0.0";
}
@@ -96,12 +107,11 @@ public class ServerActivity extends AppCompatActivity {
server.stop();
}
initialized = false;
- finish();
+ if (getActivity() != null) {
+ try {
+ getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
+ } catch (Exception e) {
+ }
+ }
}
-
- @Override
- protected void onDestroy() {
- deInitServer();
- super.onDestroy();
- }
-}
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java
index 6cf6810403..999d05238f 100644
--- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java
+++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java
@@ -820,7 +820,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
// this method could be called in non UI thread
public void refreshMap(final boolean updateVectorRendering) {
- if (view != null) {
+ if (view != null && view.isShown()) {
boolean nightMode = application.getDaynightHelper().isNightMode();
Boolean currentNightMode = this.nightMode;
boolean forceUpdateVectorDrawing = currentNightMode != null && currentNightMode != nightMode;