Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c030cbf4c0
7 changed files with 211 additions and 135 deletions
|
@ -1,35 +1,47 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="50dp">
|
android:orientation="vertical" >
|
||||||
<View android:layout_width="match_parent"
|
<View
|
||||||
android:background="@color/dashboard_divider"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"/>
|
android:layout_height="1dp"
|
||||||
<LinearLayout android:orientation="horizontal"
|
android:background="@color/dashboard_divider" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:paddingRight="12dp"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<LinearLayout android:orientation="vertical"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<TextView android:id="@+id/plugin_name"
|
|
||||||
android:textColor="@color/dashboard_black"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:lines="1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
<TextView android:id="@+id/plugin_descr"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:lines="1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/check_item_rel"/>
|
<LinearLayout
|
||||||
</LinearLayout>
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
|
android:paddingRight="12dp" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/plugin_name"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:lines="1"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textColor="@color/dashboard_black" />
|
||||||
|
|
||||||
|
<include layout="@layout/check_item_rel" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/plugin_descr"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="3" />
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -17,6 +17,7 @@ import net.osmand.plus.activities.search.SearchActivity;
|
||||||
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
||||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -164,7 +165,10 @@ public class FavouritesListFragment extends SherlockListFragment implements Sear
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(FavouritePoint model){
|
public String getName(FavouritePoint model){
|
||||||
return model.getCategory() + " : " + model.getName();
|
if(Algorithms.isEmpty(model.getCategory())) {
|
||||||
|
return model.getName();
|
||||||
|
}
|
||||||
|
return model.getCategory() + ": " + model.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -680,6 +680,17 @@ public class MapActivityActions implements DialogProvider {
|
||||||
final OsmandApplication app = mapActivity.getMyApplication();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
||||||
currentDrawer = DrawerType.MAIN_MENU;
|
currentDrawer = DrawerType.MAIN_MENU;
|
||||||
|
|
||||||
|
optionsMenuHelper.item(R.string.home_button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light )
|
||||||
|
.listen(new OnContextMenuClick() {
|
||||||
|
@Override
|
||||||
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
|
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
|
||||||
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
mapActivity.startActivity(newIntent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}).reg();
|
||||||
|
|
||||||
// 1. Where am I
|
// 1. Where am I
|
||||||
optionsMenuHelper.item(R.string.where_am_i).
|
optionsMenuHelper.item(R.string.where_am_i).
|
||||||
|
@ -886,7 +897,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
|
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
|
||||||
optionsMenuHelper.item(R.string.home_button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light )
|
optionsMenuHelper.item(R.string.exit_Button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light )
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
|
@ -894,7 +905,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
|
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
|
||||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
// not exit
|
// not exit
|
||||||
// newIntent.putExtra(DashboardActivity.APP_EXIT_KEY, DashboardActivity.APP_EXIT_CODE);
|
newIntent.putExtra(MainMenuActivity.APP_EXIT_KEY, MainMenuActivity.APP_EXIT_CODE);
|
||||||
mapActivity.startActivity(newIntent);
|
mapActivity.startActivity(newIntent);
|
||||||
// In future when map will be main screen this should change
|
// In future when map will be main screen this should change
|
||||||
// app.closeApplication(mapActivity);
|
// app.closeApplication(mapActivity);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TabHost.TabSpec;
|
import android.widget.TabHost.TabSpec;
|
||||||
|
@ -67,6 +68,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo
|
||||||
|
|
||||||
public static final String SEARCH_LAT = "net.osmand.search_lat"; //$NON-NLS-1$
|
public static final String SEARCH_LAT = "net.osmand.search_lat"; //$NON-NLS-1$
|
||||||
public static final String SEARCH_LON = "net.osmand.search_lon"; //$NON-NLS-1$
|
public static final String SEARCH_LON = "net.osmand.search_lon"; //$NON-NLS-1$
|
||||||
|
public static final String SHOW_ONLY_ONE_TAB = "SHOW_ONLY_ONE_TAB"; //$NON-NLS-1$
|
||||||
|
|
||||||
Button searchPOIButton;
|
Button searchPOIButton;
|
||||||
private LatLon searchPoint = null;
|
private LatLon searchPoint = null;
|
||||||
|
@ -78,8 +80,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private TabsAdapter mTabsAdapter;
|
private TabsAdapter mTabsAdapter;
|
||||||
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
||||||
|
private boolean showOnlyOneTab;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface SearchActivityChild {
|
public interface SearchActivityChild {
|
||||||
|
@ -106,37 +107,55 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo
|
||||||
setContentView(R.layout.search_main);
|
setContentView(R.layout.search_main);
|
||||||
settings = ((OsmandApplication) getApplication()).getSettings();
|
settings = ((OsmandApplication) getApplication()).getSettings();
|
||||||
Integer tab = settings.SEARCH_TAB.get();
|
Integer tab = settings.SEARCH_TAB.get();
|
||||||
|
showOnlyOneTab = getIntent() != null && getIntent().getBooleanExtra(SHOW_ONLY_ONE_TAB, false);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setTitle("");
|
getSupportActionBar().setTitle("");
|
||||||
// getSupportActionBar().setTitle(R.string.select_search_position);
|
// getSupportActionBar().setTitle(R.string.select_search_position);
|
||||||
|
|
||||||
final TextView tabinfo = (TextView) findViewById(R.id.textViewADesc);
|
|
||||||
|
|
||||||
TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs);
|
|
||||||
tabs.setBackgroundResource(R.drawable.tab_icon_background);
|
|
||||||
|
|
||||||
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
|
|
||||||
tabHost.setup();
|
|
||||||
|
|
||||||
ViewPager mViewPager = (ViewPager)findViewById(R.id.pager);
|
|
||||||
mTabsAdapter = new TabsAdapter(this, tabHost, tabinfo, mViewPager, settings);
|
|
||||||
TabSpec poiTab = tabHost.newTabSpec(SEARCH_POI).setIndicator(getTabIndicator(tabHost, R.drawable.tab_search_poi_icon, R.string.poi));
|
|
||||||
mTabsAdapter.addTab(poiTab, SearchPoiFilterActivity.class, null);
|
|
||||||
|
|
||||||
TabSpec addressSpec = tabHost.newTabSpec(SEARCH_ADDRESS).setIndicator(
|
|
||||||
getTabIndicator(tabHost, R.drawable.tab_search_address_icon, R.string.address));
|
|
||||||
mTabsAdapter.addTab(addressSpec, searchOnLine? SearchAddressOnlineFragment.class : SearchAddressFragment.class, null);
|
|
||||||
// mTabsAdapter.addTab(addressSpec, SearchAddressOnlineActivity.class, null);
|
|
||||||
TabSpec locationTab = tabHost.newTabSpec(SEARCH_LOCATION).setIndicator(getTabIndicator(tabHost, R.drawable.tab_search_location_icon, R.string.search_tabs_location));
|
|
||||||
mTabsAdapter.addTab(locationTab, NavigatePointFragment.class, null);
|
|
||||||
TabSpec favoriteTab = tabHost.newTabSpec(SEARCH_FAVORITES).setIndicator(getTabIndicator(tabHost, R.drawable.tab_search_favorites_icon, R.string.favorite));
|
|
||||||
mTabsAdapter.addTab(favoriteTab, FavouritesListFragment.class, null);
|
|
||||||
TabSpec historyTab = tabHost.newTabSpec(SEARCH_HISTORY).setIndicator(getTabIndicator(tabHost, R.drawable.tab_search_history_icon, R.string.history));
|
|
||||||
mTabsAdapter.addTab(historyTab, SearchHistoryFragment.class, null);
|
|
||||||
TabSpec transportTab = tabHost.newTabSpec(SEARCH_TRANSPORT).setIndicator(getTabIndicator(tabHost, R.drawable.tab_search_transport_icon, R.string.transport));
|
|
||||||
mTabsAdapter.addTab(transportTab, SearchTransportFragment.class, null);
|
|
||||||
tabHost.setCurrentTab(tab);
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!showOnlyOneTab) {
|
||||||
|
final TextView tabinfo = (TextView) findViewById(R.id.textViewADesc);
|
||||||
|
TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs);
|
||||||
|
tabs.setBackgroundResource(R.drawable.tab_icon_background);
|
||||||
|
|
||||||
|
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
|
||||||
|
tabHost.setup();
|
||||||
|
ViewPager mViewPager = (ViewPager)findViewById(R.id.pager);
|
||||||
|
mTabsAdapter = new TabsAdapter(this, tabHost, tabinfo, mViewPager, settings);
|
||||||
|
TabSpec poiTab = tabHost.newTabSpec(SEARCH_POI).setIndicator(
|
||||||
|
getTabIndicator(tabHost, R.drawable.tab_search_poi_icon, R.string.poi));
|
||||||
|
mTabsAdapter.addTab(poiTab, getFragment(POI_TAB_INDEX), null);
|
||||||
|
TabSpec addressSpec = tabHost.newTabSpec(SEARCH_ADDRESS).setIndicator(
|
||||||
|
getTabIndicator(tabHost, R.drawable.tab_search_address_icon, R.string.address));
|
||||||
|
mTabsAdapter.addTab(addressSpec, getFragment(ADDRESS_TAB_INDEX), null);
|
||||||
|
|
||||||
|
TabSpec locationTab = tabHost.newTabSpec(SEARCH_LOCATION).setIndicator(
|
||||||
|
getTabIndicator(tabHost, R.drawable.tab_search_location_icon, R.string.search_tabs_location));
|
||||||
|
mTabsAdapter.addTab(locationTab, getFragment(LOCATION_TAB_INDEX), null);
|
||||||
|
TabSpec favoriteTab = tabHost.newTabSpec(SEARCH_FAVORITES).setIndicator(
|
||||||
|
getTabIndicator(tabHost, R.drawable.tab_search_favorites_icon, R.string.favorite));
|
||||||
|
mTabsAdapter.addTab(favoriteTab, getFragment(FAVORITES_TAB_INDEX), null);
|
||||||
|
TabSpec historyTab = tabHost.newTabSpec(SEARCH_HISTORY).setIndicator(
|
||||||
|
getTabIndicator(tabHost, R.drawable.tab_search_history_icon, R.string.history));
|
||||||
|
mTabsAdapter.addTab(historyTab, getFragment(HISTORY_TAB_INDEX), null);
|
||||||
|
TabSpec transportTab = tabHost.newTabSpec(SEARCH_TRANSPORT).setIndicator(
|
||||||
|
getTabIndicator(tabHost, R.drawable.tab_search_transport_icon, R.string.transport));
|
||||||
|
mTabsAdapter.addTab(transportTab, getFragment(TRANSPORT_TAB_INDEX), null);
|
||||||
|
tabHost.setCurrentTab(tab);
|
||||||
|
} else {
|
||||||
|
FrameLayout fl = new FrameLayout(this);
|
||||||
|
fl.setId(R.id.layout);
|
||||||
|
setContentView(fl);
|
||||||
|
Class<?> cl = getFragment(tab);
|
||||||
|
try {
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.layout, (Fragment) cl.newInstance()).commit();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
setTopSpinner();
|
setTopSpinner();
|
||||||
|
|
||||||
Log.i("net.osmand", "Start on create " + (System.currentTimeMillis() - t ));
|
Log.i("net.osmand", "Start on create " + (System.currentTimeMillis() - t ));
|
||||||
|
@ -162,6 +181,23 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Class<?> getFragment(int tab) {
|
||||||
|
if(tab == POI_TAB_INDEX) {
|
||||||
|
return SearchPoiFilterActivity.class;
|
||||||
|
} else if(tab == ADDRESS_TAB_INDEX) {
|
||||||
|
return searchOnLine ? SearchAddressOnlineFragment.class : SearchAddressFragment.class;
|
||||||
|
} else if(tab == LOCATION_TAB_INDEX) {
|
||||||
|
return NavigatePointFragment.class;
|
||||||
|
} else if(tab == HISTORY_TAB_INDEX) {
|
||||||
|
return SearchHistoryFragment.class;
|
||||||
|
} else if(tab == TRANSPORT_TAB_INDEX) {
|
||||||
|
return SearchTransportFragment.class;
|
||||||
|
} else if(tab == FAVORITES_TAB_INDEX) {
|
||||||
|
return FavouritesListFragment.class;
|
||||||
|
}
|
||||||
|
return SearchPoiFilterActivity.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
||||||
|
@ -438,24 +474,24 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabChanged(String tabId) {
|
public void onTabChanged(String tabId) {
|
||||||
int position = mTabHost.getCurrentTab();
|
int position = mTabHost.getCurrentTab();
|
||||||
osmSettings.SEARCH_TAB.set(position);
|
osmSettings.SEARCH_TAB.set(position);
|
||||||
mViewPager.setCurrentItem(position);
|
mViewPager.setCurrentItem(position);
|
||||||
if (SEARCH_POI.equals(tabId)) {
|
if (SEARCH_POI.equals(tabId)) {
|
||||||
tabInfo.setText(R.string.poi_search_desc);
|
tabInfo.setText(R.string.poi_search_desc);
|
||||||
} else if (SEARCH_ADDRESS.equals(tabId)) {
|
} else if (SEARCH_ADDRESS.equals(tabId)) {
|
||||||
tabInfo.setText(searchOnLine? R.string.search_osm_nominatim : R.string.address_search_desc);
|
tabInfo.setText(searchOnLine ? R.string.search_osm_nominatim : R.string.address_search_desc);
|
||||||
} else if (SEARCH_LOCATION.equals(tabId)) {
|
} else if (SEARCH_LOCATION.equals(tabId)) {
|
||||||
tabInfo.setText(R.string.navpoint_search_desc);
|
tabInfo.setText(R.string.navpoint_search_desc);
|
||||||
} else if (SEARCH_TRANSPORT.equals(tabId)) {
|
} else if (SEARCH_TRANSPORT.equals(tabId)) {
|
||||||
tabInfo.setText(R.string.transport_search_desc);
|
tabInfo.setText(R.string.transport_search_desc);
|
||||||
} else if (SEARCH_FAVORITES.equals(tabId)) {
|
} else if (SEARCH_FAVORITES.equals(tabId)) {
|
||||||
tabInfo.setText(R.string.favourites_search_desc);
|
tabInfo.setText(R.string.favourites_search_desc);
|
||||||
} else if (SEARCH_HISTORY.equals(tabId)) {
|
} else if (SEARCH_HISTORY.equals(tabId)) {
|
||||||
tabInfo.setText(R.string.history_search_desc);
|
tabInfo.setText(R.string.history_search_desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package net.osmand.plus.dashboard;
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||||
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -12,11 +20,6 @@ import android.widget.Button;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.helpers.FontCache;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Denis on 21.11.2014.
|
* Created by Denis on 21.11.2014.
|
||||||
|
@ -24,6 +27,8 @@ import java.util.List;
|
||||||
public class DashPluginsFragment extends DashBaseFragment {
|
public class DashPluginsFragment extends DashBaseFragment {
|
||||||
|
|
||||||
public static final String TAG = "DASH_PLUGINS_FRAGMENT";
|
public static final String TAG = "DASH_PLUGINS_FRAGMENT";
|
||||||
|
private ArrayList<OsmandPlugin> showedPlugins;
|
||||||
|
private ArrayList<CompoundButton> checks;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
@ -37,43 +42,67 @@ public class DashPluginsFragment extends DashBaseFragment {
|
||||||
startActivityForResult(new Intent(getActivity(), getMyApplication().getAppCustomization().getPluginsActivity()), 1);
|
startActivityForResult(new Intent(getActivity(), getMyApplication().getAppCustomization().getPluginsActivity()), 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
LinearLayout layout = (LinearLayout) view.findViewById(R.id.plugins);
|
||||||
|
addPlugins(inflater, layout);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
LinearLayout layout = (LinearLayout) getView().findViewById(R.id.plugins);
|
for (int i = 0; i < checks.size(); i++) {
|
||||||
layout.removeAllViews();
|
final CompoundButton ch = checks.get(i);
|
||||||
addPlugins(layout);
|
final OsmandPlugin o = showedPlugins.get(i);
|
||||||
|
ch.setOnCheckedChangeListener(null);
|
||||||
|
ch.setChecked(OsmandPlugin.getEnabledPlugins().contains(o));
|
||||||
|
ch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
OsmandPlugin.enablePlugin(getMyApplication(), o, b);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlugins(View parent){
|
private void addPlugins(LayoutInflater inflater, View parent) {
|
||||||
LinearLayout layout = (LinearLayout) parent;
|
LinearLayout layout = (LinearLayout) parent;
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
|
||||||
|
|
||||||
List<OsmandPlugin> availablePlugins = OsmandPlugin.getAvailablePlugins();
|
List<OsmandPlugin> availablePlugins = OsmandPlugin.getAvailablePlugins();
|
||||||
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getEnabledPlugins();
|
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getEnabledPlugins();
|
||||||
for (int i=0; i < availablePlugins.size(); i++){
|
List<OsmandPlugin> toShow = new ArrayList<OsmandPlugin>();
|
||||||
if (i> 2){
|
showedPlugins = new ArrayList<OsmandPlugin>();
|
||||||
|
checks = new ArrayList<CompoundButton>();
|
||||||
|
for(OsmandPlugin o : availablePlugins) {
|
||||||
|
if(!(o instanceof OsmandDevelopmentPlugin)) {
|
||||||
|
if(enabledPlugins.contains(o)) {
|
||||||
|
showedPlugins.add(o);
|
||||||
|
} else{
|
||||||
|
toShow.add(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.shuffle(toShow, new Random(System.currentTimeMillis()));
|
||||||
|
while (!toShow.isEmpty()) {
|
||||||
|
showedPlugins.add(toShow.remove(0));
|
||||||
|
if (showedPlugins.size() > 2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < showedPlugins.size(); i++) {
|
||||||
final OsmandPlugin plugin = availablePlugins.get(i);
|
final OsmandPlugin plugin = availablePlugins.get(i);
|
||||||
View view = inflater.inflate(R.layout.dash_plugin_item, null, false);
|
View view = inflater.inflate(R.layout.dash_plugin_item, null, false);
|
||||||
((TextView) view.findViewById(R.id.plugin_name)).setText(plugin.getName());
|
((TextView) view.findViewById(R.id.plugin_name)).setText(plugin.getName());
|
||||||
((TextView) view.findViewById(R.id.plugin_descr)).setText(plugin.getDescription());
|
((TextView) view.findViewById(R.id.plugin_descr)).setText(plugin.getDescription());
|
||||||
|
|
||||||
CompoundButton check = (CompoundButton) view.findViewById(R.id.check_item);
|
CompoundButton check = (CompoundButton) view.findViewById(R.id.check_item);
|
||||||
|
checks.add(check);
|
||||||
check.setChecked(enabledPlugins.contains(plugin));
|
check.setChecked(enabledPlugins.contains(plugin));
|
||||||
check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
// int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources()
|
||||||
@Override
|
// .getDisplayMetrics());
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
// LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);
|
||||||
OsmandPlugin.enablePlugin(getMyApplication(),plugin, b);
|
// view.setLayoutParams(lp);
|
||||||
}
|
|
||||||
});
|
|
||||||
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics());
|
|
||||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);
|
|
||||||
view.setLayoutParams(lp);
|
|
||||||
layout.addView(view);
|
layout.addView(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,9 @@ import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AutoCompleteTextView;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +36,14 @@ public class DashSearchFragment extends DashBaseFragment {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void searchActivity(final Activity activity, final OsmAndAppCustomization appCustomization, int tab) {
|
||||||
|
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
|
||||||
|
search.putExtra(SearchActivity.SHOW_ONLY_ONE_TAB, true);
|
||||||
|
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
getMyApplication().getSettings().SEARCH_TAB.set(tab);
|
||||||
|
activity.startActivity(search);
|
||||||
|
}
|
||||||
|
|
||||||
private void setupButtons(View view){
|
private void setupButtons(View view){
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
||||||
|
@ -48,60 +52,42 @@ public class DashSearchFragment extends DashBaseFragment {
|
||||||
(view.findViewById(R.id.poi)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.poi)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
|
searchActivity(activity, appCustomization, SearchActivity.POI_TAB_INDEX);
|
||||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.POI_TAB_INDEX);
|
|
||||||
activity.startActivity(search);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(view.findViewById(R.id.address)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.address)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
|
searchActivity(activity, appCustomization, SearchActivity.ADDRESS_TAB_INDEX);
|
||||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.ADDRESS_TAB_INDEX);
|
|
||||||
activity.startActivity(search);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(view.findViewById(R.id.coord)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.coord)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
|
searchActivity(activity, appCustomization, SearchActivity.LOCATION_TAB_INDEX);
|
||||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.LOCATION_TAB_INDEX);
|
|
||||||
activity.startActivity(search);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(view.findViewById(R.id.fav_btn)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.fav_btn)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
|
searchActivity(activity, appCustomization, SearchActivity.FAVORITES_TAB_INDEX);
|
||||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.FAVORITES_TAB_INDEX);
|
|
||||||
activity.startActivity(search);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(view.findViewById(R.id.history)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.history)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
|
searchActivity(activity, appCustomization, SearchActivity.HISTORY_TAB_INDEX);
|
||||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.HISTORY_TAB_INDEX);
|
|
||||||
activity.startActivity(search);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(view.findViewById(R.id.transport)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.transport)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
|
searchActivity(activity, appCustomization, SearchActivity.TRANSPORT_TAB_INDEX);
|
||||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.TRANSPORT_TAB_INDEX);
|
|
||||||
activity.startActivity(search);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package net.osmand.plus.dashboard;
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||||
|
import net.osmand.plus.download.BaseDownloadActivity;
|
||||||
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
|
import net.osmand.plus.download.IndexItem;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -12,15 +19,6 @@ import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
|
||||||
import net.osmand.plus.download.BaseDownloadActivity;
|
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
|
||||||
import net.osmand.plus.download.DownloadEntry;
|
|
||||||
import net.osmand.plus.download.IndexItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Denis on 21.11.2014.
|
* Created by Denis on 21.11.2014.
|
||||||
|
|
Loading…
Reference in a new issue