forked from organicmaps/organicmaps
Up navigation refactoring & bugfixes.
This commit is contained in:
parent
558f8b30e2
commit
6cb21d3a04
8 changed files with 97 additions and 38 deletions
|
@ -2,6 +2,7 @@
|
|||
<manifest
|
||||
package="com.mapswithme.maps"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:installLocation="auto"
|
||||
android:sharedUserId="com.mapswithme"
|
||||
android:sharedUserLabel="@string/shared_user_label">
|
||||
|
@ -56,7 +57,8 @@
|
|||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/MwmTheme">
|
||||
android:theme="@style/MwmTheme"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<meta-data
|
||||
android:name="com.facebook.sdk.ApplicationId"
|
||||
|
@ -166,33 +168,53 @@
|
|||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.MWMActivity"
|
||||
android:theme="@style/MwmTheme.Map"
|
||||
android:launchMode="singleTask">
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/MwmTheme.Map">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.country.DownloadActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/download_maps">
|
||||
android:label="@string/download_maps"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".search.SearchActivity"
|
||||
android:name="com.mapswithme.maps.search.SearchActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/search_map"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity"
|
||||
android:windowSoftInputMode="stateVisible|adjustResize">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.settings.SettingsActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/settings_and_more">
|
||||
android:label="@string/settings_and_more"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.settings.StoragePathActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/maps_storage">
|
||||
android:label="@string/maps_storage"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
@ -206,13 +228,23 @@
|
|||
<activity
|
||||
android:name="com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/bookmarks">
|
||||
android:label="@string/bookmarks"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.bookmarks.BookmarkListActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/bookmarks">
|
||||
android:label="@string/bookmarks"
|
||||
android:parentActivityName="com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity android:name="com.facebook.LoginActivity"/>
|
||||
|
@ -240,7 +272,6 @@
|
|||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
|
@ -15,9 +15,20 @@ public class DownloadActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final String fragmentClassName = DownloadFragment.class.getName();
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
DownloadFragment downloadFragment = (DownloadFragment) Fragment.instantiate(this, DownloadFragment.class.getName(), getIntent().getExtras());
|
||||
transaction.replace(android.R.id.content, downloadFragment, "fragment");
|
||||
DownloadFragment downloadFragment = (DownloadFragment) Fragment.instantiate(this, fragmentClassName, getIntent().getExtras());
|
||||
transaction.replace(android.R.id.content, downloadFragment, fragmentClassName);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
DownloadFragment fragment = (DownloadFragment) getSupportFragmentManager().findFragmentByTag(DownloadFragment.class.getName());
|
||||
if (fragment != null && fragment.onBackPressed())
|
||||
return;
|
||||
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ class DownloadAdapter extends BaseDownloadAdapter implements CountryTree.Country
|
|||
{
|
||||
CountryTree.showLeafOnMap(position);
|
||||
resetCountryListener();
|
||||
mFragment.onBackPressed();
|
||||
mFragment.onBackPressed();
|
||||
mFragment.navigateUpToParent();
|
||||
}
|
||||
|
||||
protected void expandGroup(int position)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.mapswithme.country;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.database.DataSetObserver;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -10,11 +10,9 @@ import android.widget.ListAdapter;
|
|||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.MWMActivity;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmListFragment;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
public class DownloadFragment extends BaseMwmListFragment implements View.OnClickListener, ActiveCountryTree.ActiveCountryListener, OnBackPressListener
|
||||
{
|
||||
|
@ -53,17 +51,9 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
|
||||
private void initToolbar()
|
||||
{
|
||||
UiUtils.showHomeUpButton(getToolbar());
|
||||
getToolbar().setTitle(getString(R.string.maps));
|
||||
getToolbar().setNavigationOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
mTvUpdateAll = (TextView) getToolbar().findViewById(R.id.tv__update_all);
|
||||
final Toolbar toolbar = getToolbar();
|
||||
toolbar.setTitle(getString(R.string.maps));
|
||||
mTvUpdateAll = (TextView) toolbar.findViewById(R.id.tv__update_all);
|
||||
mTvUpdateAll.setOnClickListener(this);
|
||||
mTvUpdateAll.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -76,7 +66,6 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
ActiveCountryTree.removeListener(mListenerSlotId);
|
||||
}
|
||||
|
||||
|
||||
private BaseDownloadAdapter getDownloadAdapter()
|
||||
{
|
||||
return (BaseDownloadAdapter) getListView().getAdapter();
|
||||
|
@ -116,10 +105,8 @@ public class DownloadFragment extends BaseMwmListFragment implements View.OnClic
|
|||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
startActivity(new Intent(getActivity(), MWMActivity.class));
|
||||
}
|
||||
navigateUpToParent();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -250,9 +250,7 @@ public class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCoun
|
|||
{
|
||||
ActiveCountryTree.showOnMap(getGroupByAbsPosition(position), getPositionInGroup(position));
|
||||
resetCountryListener();
|
||||
// TODO think about refactoring.
|
||||
mFragment.onBackPressed();
|
||||
mFragment.onBackPressed();
|
||||
mFragment.navigateUpToParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.mapswithme.country.DownloadFragment;
|
|||
import com.mapswithme.country.StorageOptions;
|
||||
import com.mapswithme.maps.Framework.OnBalloonListener;
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
import com.mapswithme.maps.activity.CustomNavigateUpListener;
|
||||
import com.mapswithme.maps.ads.LikesManager;
|
||||
import com.mapswithme.maps.api.ParsedMmwRequest;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
|
@ -92,7 +93,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class MWMActivity extends BaseMwmFragmentActivity
|
||||
implements LocationHelper.LocationListener, OnBalloonListener, View.OnTouchListener, BasePlacePageAnimationController.OnVisibilityChangedListener,
|
||||
OnClickListener, Framework.RoutingListener, MapFragment.MapRenderingListener
|
||||
OnClickListener, Framework.RoutingListener, MapFragment.MapRenderingListener, CustomNavigateUpListener
|
||||
{
|
||||
public static final String EXTRA_TASK = "map_task";
|
||||
private final static String TAG = "MWMActivity";
|
||||
|
@ -1698,6 +1699,16 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customOnNavigateUp()
|
||||
{
|
||||
if (popFragment())
|
||||
{
|
||||
InputUtils.hideKeyboard(mBottomButtons);
|
||||
mFadeView.fadeOut();
|
||||
}
|
||||
}
|
||||
|
||||
public interface MapTask extends Serializable
|
||||
{
|
||||
public boolean run(MWMActivity target);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.mapswithme.maps.activity;
|
||||
|
||||
/**
|
||||
* Interface for activities to implement to perform custom 'up' navigation
|
||||
* (when up arrow in actionbar/toolbar is pressed)
|
||||
*/
|
||||
public interface CustomNavigateUpListener
|
||||
{
|
||||
void customOnNavigateUp();
|
||||
}
|
|
@ -1,11 +1,14 @@
|
|||
package com.mapswithme.maps.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.activity.CustomNavigateUpListener;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
public abstract class BaseMwmListFragment extends ListFragment
|
||||
|
@ -26,7 +29,7 @@ public abstract class BaseMwmListFragment extends ListFragment
|
|||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
getActivity().onBackPressed();
|
||||
navigateUpToParent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -50,4 +53,13 @@ public abstract class BaseMwmListFragment extends ListFragment
|
|||
super.onPause();
|
||||
org.alohalytics.Statistics.logEvent("$onPause", this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
public void navigateUpToParent()
|
||||
{
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof CustomNavigateUpListener)
|
||||
((CustomNavigateUpListener) activity).customOnNavigateUp();
|
||||
else
|
||||
NavUtils.navigateUpFromSameTask(activity);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue