[android] add: Editor host activity/fragment.

This commit is contained in:
Alexander Marchuk 2015-12-08 13:06:51 +03:00 committed by Sergey Yershov
parent 83907f9a7e
commit c364f24b28
4 changed files with 74 additions and 1 deletions

View file

@ -228,6 +228,17 @@
android:value="com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity"/>
</activity>
<activity
android:name="com.mapswithme.maps.editor.EditorActivity"
android:configChanges="orientation|screenLayout|screenSize"
android:label="@string/pp_place_edit"
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>
<!-- facebook -->
<activity
android:name="com.facebook.FacebookActivity"

View file

@ -42,6 +42,8 @@ import com.mapswithme.maps.bookmarks.ChooseBookmarkCategoryFragment;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.bookmarks.data.MapObject.ApiPoint;
import com.mapswithme.maps.editor.EditorActivity;
import com.mapswithme.maps.editor.EditorFragment;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.location.LocationPredictor;
import com.mapswithme.maps.routing.NavigationController;
@ -96,7 +98,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
private static final String[] DOCKED_FRAGMENTS = { SearchFragment.class.getName(),
DownloadFragment.class.getName(),
RoutingPlanFragment.class.getName() };
RoutingPlanFragment.class.getName(),
EditorFragment.class.getName() };
// Instance state
private static final String STATE_PP_OPENED = "PpOpened";
private static final String STATE_MAP_OBJECT = "MapObject";
@ -247,6 +250,18 @@ public class MwmActivity extends BaseMwmFragmentActivity
SearchActivity.start(this, query);
}
public void showEditor(MapObject point)
{
if (mIsFragmentContainer)
{
final Bundle args = new Bundle();
args.putParcelable(EditorFragment.EXTRA_POINT, point);
replaceFragment(EditorFragment.class, args, null);
}
else
EditorActivity.start(this, point);
}
private void shareMyLocation()
{
final Location loc = LocationHelper.INSTANCE.getLastLocation();

View file

@ -0,0 +1,31 @@
package com.mapswithme.maps.editor;
import android.app.Activity;
import android.content.Intent;
import android.support.v4.app.Fragment;
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
import com.mapswithme.maps.bookmarks.data.MapObject;
public class EditorActivity extends BaseMwmFragmentActivity
{
@Override
protected Class<? extends Fragment> getFragmentClass()
{
return EditorFragment.class;
}
@Override
public void onBackPressed()
{
final EditorFragment fragment = (EditorFragment)getSupportFragmentManager().findFragmentByTag(getFragmentClass().getName());
if ((fragment == null) || !fragment.isAdded() || !fragment.onBackPressed())
super.onBackPressed();
}
public static void start(Activity activity, MapObject point)
{
activity.startActivity(new Intent(activity, EditorActivity.class)
.putExtra(EditorFragment.EXTRA_POINT, point));
}
}

View file

@ -0,0 +1,16 @@
package com.mapswithme.maps.editor;
import com.mapswithme.maps.base.BaseMwmFragment;
import com.mapswithme.maps.base.OnBackPressListener;
public class EditorFragment extends BaseMwmFragment
implements OnBackPressListener
{
public static final String EXTRA_POINT = "point";
@Override
public boolean onBackPressed()
{
return false;
}
}