forked from organicmaps/organicmaps
download map after launch but in Map screen
This commit is contained in:
parent
8917001a27
commit
58b81266e8
7 changed files with 79 additions and 39 deletions
|
@ -48,11 +48,11 @@ import app.organicmaps.base.BaseMwmFragmentActivity;
|
|||
import app.organicmaps.base.OnBackPressListener;
|
||||
import app.organicmaps.bookmarks.BookmarkCategoriesActivity;
|
||||
import app.organicmaps.bookmarks.data.BookmarkManager;
|
||||
import app.organicmaps.bookmarks.data.FeatureId;
|
||||
import app.organicmaps.bookmarks.data.MapObject;
|
||||
import app.organicmaps.display.DisplayChangedListener;
|
||||
import app.organicmaps.display.DisplayManager;
|
||||
import app.organicmaps.display.DisplayType;
|
||||
import app.organicmaps.downloader.CountryItem;
|
||||
import app.organicmaps.downloader.DownloaderActivity;
|
||||
import app.organicmaps.downloader.DownloaderFragment;
|
||||
import app.organicmaps.downloader.MapManager;
|
||||
|
@ -84,7 +84,6 @@ import app.organicmaps.routing.NavigationService;
|
|||
import app.organicmaps.routing.RoutePointInfo;
|
||||
import app.organicmaps.routing.RoutingBottomMenuListener;
|
||||
import app.organicmaps.routing.RoutingController;
|
||||
import app.organicmaps.routing.RoutingErrorDialogFragment;
|
||||
import app.organicmaps.routing.RoutingOptions;
|
||||
import app.organicmaps.routing.RoutingPlanFragment;
|
||||
import app.organicmaps.routing.RoutingPlanInplaceController;
|
||||
|
@ -550,26 +549,49 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (Map.isEngineCreated())
|
||||
onRenderingInitializationFinished();
|
||||
|
||||
routeForSiteFromMainActivityHandling();
|
||||
tjkMapDownloadingHandling();
|
||||
|
||||
SiteLocation endPoint = getIntent().getParcelableExtra("end_point");
|
||||
if(endPoint != null)
|
||||
routeForSiteFromMainActivityHandling(endPoint);
|
||||
}
|
||||
|
||||
private void routeForSiteFromMainActivityHandling() {
|
||||
|
||||
private void tjkMapDownloadingHandling() {
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
Runnable delayedAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showRouteForSiteFromMainActivity();
|
||||
Runnable delayedAction = () -> {
|
||||
CountryItem mCurrentCountry = CountryItem.fill("Tajikistan");
|
||||
|
||||
if(mCurrentCountry.status != CountryItem.STATUS_DONE) {
|
||||
// navigate to Dushanbe so it automatically downloads Tajikistan map
|
||||
blockScreen();
|
||||
Framework.nativeZoomToPoint(38.5598, 68.7870, 10, true);
|
||||
}
|
||||
};
|
||||
handler.postDelayed(delayedAction, 1000);
|
||||
}
|
||||
|
||||
private void showRouteForSiteFromMainActivity() {
|
||||
SiteLocation endPoint = getIntent().getParcelableExtra("end_point");
|
||||
private void routeForSiteFromMainActivityHandling(SiteLocation endPoint) {
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
Runnable delayedAction = () -> {
|
||||
showRouteForSiteFromMainActivity(endPoint);
|
||||
};
|
||||
handler.postDelayed(delayedAction, 1000);
|
||||
}
|
||||
|
||||
private void showRouteForSiteFromMainActivity(SiteLocation endPoint) {
|
||||
startLocationToPoint(endPoint.toMapObject());
|
||||
}
|
||||
|
||||
public void blockScreen() {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
|
||||
}
|
||||
|
||||
public void removeScreenBlock() {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
|
||||
}
|
||||
|
||||
|
||||
private void refreshLightStatusBar()
|
||||
{
|
||||
UiUtils.setLightStatusBar(this, !(
|
||||
|
@ -1647,9 +1669,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void onCommonBuildError(int lastResultCode, @NonNull String[] lastMissingMaps)
|
||||
{
|
||||
RoutingErrorDialogFragment fragment = RoutingErrorDialogFragment.create(getSupportFragmentManager().getFragmentFactory(),
|
||||
getApplicationContext(), lastResultCode, lastMissingMaps);
|
||||
fragment.show(getSupportFragmentManager(), RoutingErrorDialogFragment.class.getSimpleName());
|
||||
// RoutingErrorDialogFragment fragment = RoutingErrorDialogFragment.create(getSupportFragmentManager().getFragmentFactory(),
|
||||
// getApplicationContext(), lastResultCode, lastMissingMaps);
|
||||
// fragment.show(getSupportFragmentManager(), RoutingErrorDialogFragment.class.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package app.organicmaps.downloader;
|
||||
|
||||
import static androidx.core.content.ContextCompat.startActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -19,6 +24,8 @@ import app.organicmaps.util.Config;
|
|||
import app.organicmaps.util.ConnectionState;
|
||||
import app.organicmaps.util.StringUtils;
|
||||
import app.organicmaps.util.UiUtils;
|
||||
import app.tourism.MainActivity;
|
||||
import app.tourism.data.dto.SiteLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -28,8 +35,6 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
|
||||
private final MwmActivity mActivity;
|
||||
private final View mFrame;
|
||||
private final TextView mParent;
|
||||
private final TextView mTitle;
|
||||
private final TextView mSize;
|
||||
private final WheelProgressView mProgress;
|
||||
private final Button mButton;
|
||||
|
@ -63,6 +68,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +82,19 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
}
|
||||
};
|
||||
|
||||
private void navigationToMainActivityHandling() {
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
Runnable delayedAction = () -> {
|
||||
if(mCurrentCountry.present) {
|
||||
mActivity.removeScreenBlock();
|
||||
Intent intent = new Intent(mActivity, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(mActivity, intent, null);
|
||||
}
|
||||
};
|
||||
handler.postDelayed(delayedAction, 1000);
|
||||
}
|
||||
|
||||
private final MapManager.CurrentCountryChangedListener mCountryChangedListener = new MapManager.CurrentCountryChangedListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -103,6 +122,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
|
||||
private void updateProgressState(boolean shouldAutoDownload)
|
||||
{
|
||||
navigationToMainActivityHandling();
|
||||
updateStateInternal(shouldAutoDownload);
|
||||
}
|
||||
|
||||
|
@ -118,21 +138,15 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
mCurrentCountry.status == CountryItem.STATUS_APPLYING);
|
||||
boolean failed = (mCurrentCountry.status == CountryItem.STATUS_FAILED);
|
||||
|
||||
|
||||
|
||||
showFrame = (enqueued || progress || failed ||
|
||||
mCurrentCountry.status == CountryItem.STATUS_DOWNLOADABLE);
|
||||
|
||||
if (showFrame)
|
||||
{
|
||||
boolean hasParent = !CountryItem.isRoot(mCurrentCountry.topmostParentId);
|
||||
|
||||
UiUtils.showIf(progress || enqueued, mProgress);
|
||||
UiUtils.showIf(!progress && !enqueued, mButton);
|
||||
UiUtils.showIf(hasParent, mParent);
|
||||
|
||||
if (hasParent)
|
||||
mParent.setText(mCurrentCountry.topmostParentName);
|
||||
|
||||
mTitle.setText(mCurrentCountry.name);
|
||||
|
||||
String sizeText;
|
||||
|
||||
|
@ -188,8 +202,6 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
{
|
||||
mActivity = activity;
|
||||
mFrame = activity.findViewById(R.id.onmap_downloader);
|
||||
mParent = mFrame.findViewById(R.id.downloader_parent);
|
||||
mTitle = mFrame.findViewById(R.id.downloader_title);
|
||||
mSize = mFrame.findViewById(R.id.downloader_size);
|
||||
|
||||
View controls = mFrame.findViewById(R.id.downloader_controls_frame);
|
||||
|
@ -208,6 +220,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
if (mCurrentCountry == null)
|
||||
return;
|
||||
|
||||
mActivity.blockScreen();
|
||||
boolean retry = (mCurrentCountry.status == CountryItem.STATUS_FAILED);
|
||||
if (retry)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@ package app.tourism
|
|||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
|
@ -17,6 +18,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import app.organicmaps.DownloadResourcesLegacyActivity
|
||||
import app.organicmaps.downloader.CountryItem
|
||||
import app.tourism.data.dto.SiteLocation
|
||||
import app.tourism.ui.theme.OrganicMapsTheme
|
||||
|
||||
|
@ -24,6 +26,12 @@ import app.tourism.ui.theme.OrganicMapsTheme
|
|||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val mCurrentCountry = CountryItem.fill("Tajikistan")
|
||||
if(!mCurrentCountry.present) {
|
||||
val intent = Intent(this, DownloadResourcesLegacyActivity::class.java)
|
||||
startActivity(this, intent, null)
|
||||
}
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
OrganicMapsTheme {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
<LinearLayout
|
||||
android:layout_width="212dp"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/margin_base"
|
||||
|
@ -20,14 +20,6 @@
|
|||
android:background="@drawable/onmap_downloader_background"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/downloader_parent"
|
||||
android:layout_width="@dimen/square_block_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_eighth"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body2"
|
||||
android:gravity="center_horizontal"
|
||||
tools:text="Some country very loooooooooong country"/>
|
||||
<TextView
|
||||
android:id="@+id/downloader_title"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -36,7 +28,8 @@
|
|||
android:fontFamily="@string/robotoMedium"
|
||||
android:textStyle="normal"
|
||||
android:gravity="center_horizontal"
|
||||
tools:text="Some name very loooooooooong name"
|
||||
android:text="@string/wait_tjk_map_downloading"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="UnusedAttribute"/>
|
||||
<TextView
|
||||
android:id="@+id/downloader_size"
|
||||
|
|
|
@ -2160,5 +2160,7 @@
|
|||
<string name="type.amenity.events_venue">Место проведения мероприятий</string>
|
||||
<string name="type.shop.auction">Аукцион</string>
|
||||
<string name="type.shop.collector">Коллекции</string>
|
||||
<string name="brand_name"> Комитет по туризму при Правительстве Республики Таджикистан </string>
|
||||
<string name="brand_name"> Комитет по туризму при Правительстве Республики Таджикистан </string>
|
||||
<string name="smth_went_wrong">Упс, что-то пошло не так</string>
|
||||
<string name="wait_tjk_map_downloading">Пожалуйста, подождите, идет загрузка карты Таджикистана? Оставайтесь в приложении</string>
|
||||
</resources>
|
||||
|
|
|
@ -2203,4 +2203,6 @@
|
|||
//todo
|
||||
<string name="brand_name"> Комитет по туризму при Правительстве Республики Таджикистан </string>
|
||||
<string name="title_activity_main">MainActivity</string>
|
||||
<string name="smth_went_wrong">Oops, something went wrong</string>
|
||||
<string name="wait_tjk_map_downloading">Please, wait, The Tajikistan map is being downloaded, don\'t get out the of app</string>
|
||||
</resources>
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
#Thu Jun 06 15:38:47 TJT 2024
|
||||
#Mon Jun 10 23:17:53 TJT 2024
|
||||
android.native.buildOutput=verbose
|
||||
android.nonFinalResIds=false
|
||||
android.nonTransitiveRClass=true
|
||||
android.useAndroidX=true
|
||||
enableVulkanDiagnostics=OFF
|
||||
org.gradle.caching=true
|
||||
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1024M" -Xms256m
|
||||
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx1536M" -Xms256m
|
||||
propCompileSdkVersion=34
|
||||
propMinSdkVersion=21
|
||||
propTargetSdkVersion=34
|
||||
|
|
Loading…
Add table
Reference in a new issue