Merge branch 'sasha_pasha_branch' of ssh://github.com/osmandapp/Osmand into sasha_pasha_branch
This commit is contained in:
commit
57825b19ce
6 changed files with 250 additions and 0 deletions
5
OsmAnd/res/color/bottom_navigation_color_selector.xml
Normal file
5
OsmAnd/res/color/bottom_navigation_color_selector.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/dashboard_blue" android:state_checked="true"/>
|
||||
<item android:color="@color/icon_color" android:state_checked="false"/>
|
||||
</selector>
|
75
OsmAnd/res/layout/fragment_map_markers_dialog.xml
Normal file
75
OsmAnd/res/layout/fragment_map_markers_dialog.xml
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/map_markers_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/osmand_orange"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:theme="?attr/toolbar_theme"
|
||||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/map_markers"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_list_text_size_large"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/options_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_overflow_menu_white"/>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/map_markers_bottom_navigation"
|
||||
android:layout_below="@+id/map_markers_toolbar">
|
||||
|
||||
<net.osmand.plus.LockableViewPager
|
||||
android:id="@+id/map_markers_view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="5dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:alpha="0.5"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_onmap"/>
|
||||
</FrameLayout>
|
||||
|
||||
<android.support.design.widget.BottomNavigationView
|
||||
android:id="@+id/map_markers_bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="?attr/bg_color"
|
||||
app:itemBackground="?attr/bg_color"
|
||||
app:itemIconTint="@color/bottom_navigation_color_selector"
|
||||
app:itemTextColor="@color/bottom_navigation_color_selector"
|
||||
app:menu="@menu/map_markers_bottom_navigation"/>
|
||||
</RelativeLayout>
|
12
OsmAnd/res/menu/map_markers_bottom_navigation.xml
Normal file
12
OsmAnd/res/menu/map_markers_bottom_navigation.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_active"
|
||||
android:icon="@drawable/ic_map"
|
||||
android:title="@string/osm_live_active"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_history"
|
||||
android:icon="@drawable/ic_action_history2"
|
||||
android:title="@string/shared_string_history"/>
|
||||
</menu>
|
|
@ -0,0 +1,20 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class MapMarkersActiveFragment extends Fragment {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
TextView textView = new TextView(getContext());
|
||||
textView.setText("active fragment");
|
||||
return textView;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomNavigationView;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.plus.LockableViewPager;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragment {
|
||||
|
||||
public static final String TAG = "MapMarkersDialogFragment";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
OsmandApplication app = getMyApplication();
|
||||
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
setStyle(STYLE_NO_FRAME, themeId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
|
||||
|
||||
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
|
||||
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getContext(), "Options", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
final LockableViewPager viewPager = mainView.findViewById(R.id.map_markers_view_pager);
|
||||
viewPager.setSwipeLocked(true);
|
||||
viewPager.setAdapter(new MapMarkersViewPagerAdapter(getChildFragmentManager()));
|
||||
|
||||
BottomNavigationView bottomNav = mainView.findViewById(R.id.map_markers_bottom_navigation);
|
||||
bottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.action_active:
|
||||
viewPager.setCurrentItem(0);
|
||||
return true;
|
||||
case R.id.action_history:
|
||||
viewPager.setCurrentItem(1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return mainView;
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
public static boolean showInstance(@NonNull MapActivity mapActivity) {
|
||||
try {
|
||||
if (mapActivity.isActivityDestroyed()) {
|
||||
return false;
|
||||
}
|
||||
MapMarkersDialogFragment fragment = new MapMarkersDialogFragment();
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), TAG);
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class MapMarkersViewPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private final List<Fragment> fragments;
|
||||
|
||||
MapMarkersViewPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
fragments = Arrays.asList(new MapMarkersActiveFragment(), new MapMarkersHistoryFragment());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return fragments.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return fragments.size();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class MapMarkersHistoryFragment extends Fragment {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
TextView textView = new TextView(getContext());
|
||||
textView.setText("history fragment");
|
||||
return textView;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue