Poi dialog header
This commit is contained in:
parent
a46b3e4ba0
commit
00ce351a86
4 changed files with 216 additions and 0 deletions
83
OsmAnd/res/layout/fragment_edit_poi.xml
Normal file
83
OsmAnd/res/layout/fragment_edit_poi.xml
Normal file
|
@ -0,0 +1,83 @@
|
|||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="net.osmand.plus.osmedit.EditPoiFragment">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/OsmandLightTheme.DakrActionbar">
|
||||
|
||||
<!-- TODO change theme -->
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
app:contentInsetLeft="72dp"
|
||||
app:contentInsetStart="72dp"
|
||||
android:theme="@style/OsmandLightTheme.DakrActionbar"/>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_scrollFlags="scroll">
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Name"
|
||||
android:text="@string/lorem_ipsum"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_scrollFlags="scroll">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableRight="@drawable/quickaction_arrow_down"
|
||||
android:hint="POI Type"
|
||||
android:text="@string/lorem_ipsum"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@null"
|
||||
android:src="@android:drawable/ic_menu_help"/>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/color_white"
|
||||
app:tabIndicatorColor="@color/osmand_orange"/>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
7
OsmAnd/res/layout/fragment_edit_poi_advanced.xml
Normal file
7
OsmAnd/res/layout/fragment_edit_poi_advanced.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00F">
|
||||
|
||||
</LinearLayout>
|
7
OsmAnd/res/layout/fragment_edit_poi_normal.xml
Normal file
7
OsmAnd/res/layout/fragment_edit_poi_normal.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#0F0">
|
||||
|
||||
</LinearLayout>
|
119
OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java
Normal file
119
OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java
Normal file
|
@ -0,0 +1,119 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class EditPoiFragment extends Fragment {
|
||||
public static final String TAG = "EditPoiFragment";
|
||||
|
||||
// XXX this fragment wont work on older devices
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_edit_poi, container, false);
|
||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(R.string.poi_create_title);
|
||||
toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction().remove(EditPoiFragment.this).commit();
|
||||
fragmentManager.popBackStack();
|
||||
}
|
||||
});
|
||||
final ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager);
|
||||
MyAdapter pagerAdapter = new MyAdapter(getChildFragmentManager());
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
|
||||
final TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
|
||||
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
|
||||
|
||||
// Hack due to problems with design support library v22.2.1
|
||||
// https://code.google.com/p/android/issues/detail?id=180462
|
||||
// TODO remove in new version
|
||||
if (ViewCompat.isLaidOut(tabLayout)) {
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
} else {
|
||||
tabLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
tabLayout.removeOnLayoutChangeListener(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
int orangeColor = getResources().getColor(R.color.osmand_orange);
|
||||
int grayColor = getResources().getColor(android.R.color.darker_gray);
|
||||
tabLayout.setTabTextColors(grayColor, orangeColor);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public static class MyAdapter extends FragmentPagerAdapter {
|
||||
public MyAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return new NormalDataFragment();
|
||||
case 1:
|
||||
return new AdvancedDataFragment();
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected position");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
// TODO replace with string resources
|
||||
switch (position) {
|
||||
case 0:
|
||||
return "Normal";
|
||||
case 1:
|
||||
return "Advanced";
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected position");
|
||||
}
|
||||
}
|
||||
|
||||
public static class NormalDataFragment extends Fragment {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_edit_poi_normal, container, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdvancedDataFragment extends Fragment {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_edit_poi_advanced, container, false);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue