[android] Fixed handling initial intent in the base activity during system recovering on different screens

This commit is contained in:
Alexander Zatsepin 2018-07-25 17:06:12 +03:00 committed by Roman Kuznetsov
parent cb8824f57f
commit 7a53568ea1
5 changed files with 13 additions and 38 deletions

View file

@ -497,12 +497,8 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity
if (intent == null)
return false;
final Intent extra = intent.getParcelableExtra(SplashActivity.EXTRA_INTENT);
if (extra == null)
return false;
for (final IntentProcessor ip : mIntentProcessors)
if (ip.isSupported(extra) && ip.process(extra))
if (ip.isSupported(intent) && ip.process(intent))
return true;
return false;

View file

@ -553,7 +553,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
mSearchController = new FloatingSearchToolbarController(this, this);
mSearchController.setVisibilityListener(this);
SearchEngine.INSTANCE.addListener(this);
SharingHelper.INSTANCE.initialize();
@ -1178,9 +1177,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (intent == null)
return false;
if (intent.hasExtra(SplashActivity.EXTRA_INTENT))
intent = intent.getParcelableExtra(SplashActivity.EXTRA_INTENT);
Notifier.processNotificationExtras(intent);
if (intent.hasExtra(EXTRA_TASK))
@ -1304,6 +1300,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
protected void onStart()
{
super.onStart();
SearchEngine.INSTANCE.addListener(this);
Framework.nativeSetMapObjectListener(this);
BookmarkManager.INSTANCE.addLoadingListener(this);
RoutingController.get().attach(this);
@ -1319,6 +1316,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
protected void onStop()
{
super.onStop();
SearchEngine.INSTANCE.removeListener(this);
Framework.nativeRemoveMapObjectListener();
BookmarkManager.INSTANCE.removeLoadingListener(this);
LocationHelper.INSTANCE.detach(!isFinishing());

View file

@ -7,7 +7,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
@ -35,9 +34,8 @@ import com.my.tracker.MyTracker;
public class SplashActivity extends AppCompatActivity
implements BaseNewsFragment.NewsDialogListener, BaseActivity
{
public static final String EXTRA_INTENT = "extra_intent";
private static final String EXTRA_ACTIVITY_TO_START = "extra_activity_to_start";
private static final String EXTRA_INITIAL_INTENT = "extra_initial_intent";
public static final String EXTRA_INITIAL_INTENT = "extra_initial_intent";
private static final int REQUEST_PERMISSIONS = 1;
private static final long FIRST_START_DELAY = 1000;
private static final long DELAY = 100;
@ -346,10 +344,10 @@ public class SplashActivity extends AppCompatActivity
(Class<? extends Activity>) input.getSerializableExtra(EXTRA_ACTIVITY_TO_START));
}
Intent extraIntent = input.hasExtra(EXTRA_INITIAL_INTENT) ?
Intent initialIntent = input.hasExtra(EXTRA_INITIAL_INTENT) ?
input.getParcelableExtra(EXTRA_INITIAL_INTENT) :
input;
result.putExtra(EXTRA_INTENT, extraIntent);
result.putExtra(EXTRA_INITIAL_INTENT, initialIntent);
}
startActivity(result);
finish();

View file

@ -29,8 +29,6 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity
{
private final BaseActivityDelegate mBaseDelegate = new BaseActivityDelegate(this);
private boolean mInitializationCompleted = false;
@Override
@NonNull
public Activity get()
@ -61,6 +59,13 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity
@Override
protected final void onCreate(@Nullable Bundle savedInstanceState)
{
// An intent that was skipped due to core wasn't initialized has to be used
// as a target intent for this activity, otherwise all input extras will be lost
// in a splash activity loop.
Intent initialIntent = getIntent().getParcelableExtra(SplashActivity.EXTRA_INITIAL_INTENT);
if (initialIntent != null)
setIntent(initialIntent);
if (!MwmApplication.get().arePlatformAndCoreInitialized()
|| !PermissionsUtils.isExternalStorageGranted())
{
@ -68,7 +73,6 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity
goToSplashScreen(getIntent());
return;
}
mInitializationCompleted = true;
mBaseDelegate.onCreate();
super.onCreate(savedInstanceState);
@ -103,11 +107,6 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity
attachDefaultFragment();
}
protected boolean isInitializationCompleted()
{
return mInitializationCompleted;
}
@ColorRes
protected int getStatusBarColor()
{

View file

@ -1,30 +1,14 @@
package com.mapswithme.maps.bookmarks;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import com.mapswithme.maps.SplashActivity;
import com.mapswithme.maps.base.BaseToolbarActivity;
import com.mapswithme.maps.base.OnBackPressListener;
import com.mapswithme.util.Utils;
public class BookmarksCatalogActivity extends BaseToolbarActivity
{
@Override
protected void safeOnCreate(@Nullable Bundle savedInstanceState)
{
// TODO: Move this logic to BaseMwmFragmentActivity after release 8.3.x
// to avoid code duplication for other activities that will be in the same user case.
// https://jira.mail.ru/browse/MAPSME-8195
Intent intent = getIntent().getParcelableExtra(SplashActivity.EXTRA_INTENT);
if (intent != null)
setIntent(intent);
super.safeOnCreate(savedInstanceState);
}
@Override
protected Class<? extends Fragment> getFragmentClass()
{