diff --git a/OsmAnd/libs/android-support-v4.jar b/OsmAnd/libs/android-support-v4.jar index c31cede47e..4ebdaa9ed9 100644 Binary files a/OsmAnd/libs/android-support-v4.jar and b/OsmAnd/libs/android-support-v4.jar differ diff --git a/OsmAnd/res/drawable/preference_activity_action_bar_shadow.xml b/OsmAnd/res/drawable/preference_activity_action_bar_shadow.xml new file mode 100644 index 0000000000..dde56dc29b --- /dev/null +++ b/OsmAnd/res/drawable/preference_activity_action_bar_shadow.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/preference_activity.xml b/OsmAnd/res/layout/preference_activity.xml new file mode 100644 index 0000000000..f439357ab3 --- /dev/null +++ b/OsmAnd/res/layout/preference_activity.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 84c424d03e..c11bda9936 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -19,7 +19,7 @@ 6dp 20sp 4dp - + 4dp 12sp diff --git a/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java b/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java new file mode 100644 index 0000000000..5b352737ca --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java @@ -0,0 +1,65 @@ +package net.osmand.plus.activities; + +import android.app.Activity; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.support.v4.view.ViewCompat; +import android.support.v7.widget.Toolbar; +import android.util.TypedValue; +import android.view.View; +import android.view.ViewGroup; +import net.osmand.plus.R; + +public abstract class ActionBarPreferenceActivity extends PreferenceActivity { + private Toolbar _toolbar; + private View _shadowView; + + protected abstract int getPreferencesXmlId(); + + public Toolbar getToolbar() { + return _toolbar; + } + + @SuppressWarnings("deprecation") + @Override + protected void onCreate(final Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.preference_activity); + _toolbar = (Toolbar) findViewById(R.id.abp__toolbar); + if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { + _shadowView = findViewById(R.id.abp__shadowView); + final ViewGroup parent = (ViewGroup) _shadowView.getParent(); + parent.removeView(_shadowView); + _shadowView = null; + } + addPreferencesFromResource(getPreferencesXmlId()); + _toolbar.setClickable(true); + _toolbar.setNavigationIcon(getResIdFromAttribute(this, R.attr.homeAsUpIndicator)); + _toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(final View v) { + finish(); + } + }); + } + + private static int getResIdFromAttribute(final Activity activity, final int attr) { + if (attr == 0) + return 0; + final TypedValue typedvalueattr = new TypedValue(); + activity.getTheme().resolveAttribute(attr, typedvalueattr, true); + return typedvalueattr.resourceId; + } + + protected void setEnabledActionBarShadow(final boolean enable) { + if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { + ViewCompat.setElevation(_toolbar, enable ? 4 : 0); + } else { + if (_shadowView == null) + _shadowView = findViewById(R.id.abp__shadowView); + _shadowView.setVisibility(enable ? View.VISIBLE : View.GONE); + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java index 9590167f24..ef70505aea 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java @@ -11,6 +11,7 @@ import java.util.Comparator; import java.util.LinkedHashSet; import java.util.Set; +import android.view.*; import net.osmand.access.AccessibleToast; import net.osmand.data.AmenityType; import net.osmand.data.LatLon; @@ -28,10 +29,7 @@ import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; import android.view.View.OnClickListener; -import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.EditText; @@ -42,9 +40,6 @@ import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; - /** * */ diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java index be949b23ae..160848340d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import android.content.Intent; import android.support.v7.app.ActionBarActivity; +import android.view.MenuItem; import android.view.Window; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.OsmandApplication; @@ -51,7 +52,7 @@ public class FavouritesActivity extends ActionBarActivity { //class in com.actionbarsherlock.view and NOT android.view ((OsmandApplication) getApplication()).applyTheme(this); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); - getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); + //getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); super.onCreate(icicle); setSupportProgressBarIndeterminateVisibility(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); @@ -140,7 +141,7 @@ public class FavouritesActivity extends ActionBarActivity { @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java index 17ab6ddc74..53aee144a8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java @@ -1,6 +1,7 @@ package net.osmand.plus.activities; import android.support.v7.app.ActionBarActivity; +import android.view.MenuItem; import net.osmand.plus.OsmandApplication; import android.os.Bundle; @@ -21,7 +22,7 @@ public class FavouritesListActivity extends ActionBarActivity { } @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesListFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesListFragment.java index b0d1f70c1c..d0c8c3d703 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesListFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesListFragment.java @@ -6,6 +6,7 @@ package net.osmand.plus.activities; import java.util.Comparator; import java.util.List; +import android.support.v4.app.ListFragment; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.plus.ContextMenuAdapter; @@ -33,12 +34,10 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.TextView.BufferType; -import com.actionbarsherlock.app.SherlockListFragment; - /** * */ -public class FavouritesListFragment extends SherlockListFragment implements SearchActivityChild { +public class FavouritesListFragment extends ListFragment implements SearchActivityChild { public static final String SELECT_FAVORITE_POINT_INTENT_KEY = "SELECT_FAVORITE_POINT_INTENT_KEY"; public static final int SELECT_FAVORITE_POINT_RESULT_OK = 1; diff --git a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java index 1098466ada..2305bf6f30 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java @@ -6,6 +6,8 @@ import java.lang.ref.WeakReference; import java.util.List; import java.util.Random; +import android.support.v4.view.MenuItemCompat; +import android.view.*; import net.osmand.Location; import net.osmand.access.AccessibleAlertBuilder; import net.osmand.plus.OsmAndAppCustomization; @@ -45,14 +47,9 @@ import android.text.Spanned; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.util.TypedValue; -import android.view.Gravity; -import android.view.View; -import android.view.ViewTreeObserver; import android.widget.ScrollView; import android.widget.TextView; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; /** */ @@ -384,12 +381,12 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca @Override public boolean onCreateOptionsMenu(Menu menu) { - menu.add(0, HELP_ID, 0, R.string.tips_and_tricks).setIcon(R.drawable.ic_ac_help) - .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - menu.add(0, SETTINGS_ID, 0, R.string.settings).setIcon(R.drawable.ic_ac_settings) - .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - menu.add(0, EXIT_ID, 0, R.string.exit_Button).setIcon(R.drawable.ic_ac_close) - .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + MenuItem menuItem = menu.add(0, HELP_ID, 0, R.string.tips_and_tricks).setIcon(R.drawable.ic_ac_help); + MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + menuItem = menu.add(0, SETTINGS_ID, 0, R.string.settings).setIcon(R.drawable.ic_ac_settings); + MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + menuItem = menu.add(0, EXIT_ID, 0, R.string.exit_Button).setIcon(R.drawable.ic_ac_close); + MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); return true; } diff --git a/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java b/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java index 023d91c5f0..b4de44a7f7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java @@ -1,64 +1,98 @@ package net.osmand.plus.activities; +import android.app.ExpandableListActivity; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.ActionBarActivity; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.AdapterView; +import android.widget.ExpandableListView; +import android.widget.ListAdapter; +import android.widget.ListView; import net.osmand.plus.OsmandApplication; import android.app.ActionBar; -import android.content.pm.ActivityInfo; +import android.graphics.Shader.TileMode; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.view.View; -import com.actionbarsherlock.app.SherlockListActivity; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener; -public abstract class OsmandListActivity extends SherlockListActivity { +public abstract class OsmandListActivity extends + ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { ((OsmandApplication) getApplication()).applyTheme(this); super.onCreate(savedInstanceState); - setActionBarSettings(); - } - - protected void setActionBarSettings() { - getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } - protected OsmandApplication getMyApplication() { - return (OsmandApplication) getApplication(); + + public OsmandApplication getMyApplication() { + return (OsmandApplication)getApplication(); } - - + @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { - case android.R.id.home: - finish(); - return true; + case android.R.id.home: + finish(); + return true; } return false; } - - public void createMenuItem(Menu m, int id, int titleRes, int iconLight, int iconDark, int menuItemType) { - com.actionbarsherlock.view.MenuItem menuItem = m.add(0, id, 0, titleRes); - int res = isLightActionBar() ? iconLight : iconDark; - if(res != 0) { - menuItem = menuItem.setIcon(res); - } - menuItem.setShowAsActionFlags(menuItemType) - .setOnMenuItemClickListener(new OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { - return onOptionsItemSelected(item); - } - }); + public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconLight, int iconDark, int menuItemType) { + int r = isLightActionBar() ? iconLight : iconDark; + MenuItem menuItem = m.add(0, id, 0, titleRes); + if (r != 0) { + menuItem.setIcon(r); + } + menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + return onOptionsItemSelected(item); + } + }); + MenuItemCompat.setShowAsAction(menuItem, menuItemType); + return menuItem; } - + + public void fixBackgroundRepeat(View view) { + Drawable bg = view.getBackground(); + if (bg != null) { + if (bg instanceof BitmapDrawable) { + BitmapDrawable bmp = (BitmapDrawable) bg; + // bmp.mutate(); // make sure that we aren't sharing state anymore + bmp.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); + } + } + } + + + public void setListAdapter(ListAdapter adapter){ + ((ListView)findViewById(android.R.id.list)).setAdapter(adapter); + } + + public ListView getListView() { + return (ListView)findViewById(android.R.id.list); + } + + public ListAdapter getListAdapter() { + return ((ListView)findViewById(android.R.id.list)).getAdapter(); + } + + public void setOnItemClickListener(AdapterView.OnItemClickListener childClickListener){ + ((ListView)findViewById(android.R.id.list)).setOnItemClickListener(childClickListener); + } + public boolean isLightActionBar() { return ((OsmandApplication) getApplication()).getSettings().isLightActionBar(); } + } diff --git a/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java index 7196103954..50dc471da1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java @@ -1,5 +1,7 @@ package net.osmand.plus.activities; +import android.support.v7.app.ActionBarActivity; +import android.view.*; import gnu.trove.list.array.TIntArrayList; import java.text.Collator; @@ -31,11 +33,7 @@ import android.content.DialogInterface; import android.os.AsyncTask; import android.os.Bundle; import android.text.Html; -import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.ArrayAdapter; import android.widget.CheckBox; @@ -48,8 +46,6 @@ import android.widget.SectionIndexer; import android.widget.Spinner; import android.widget.TextView; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; public class SelectedGPXFragment extends OsmandExpandableListFragment { @@ -157,7 +153,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment { } } }); - TextView tv = new TextView(getSherlockActivity()); + TextView tv = new TextView(getActivity()); tv.setText(R.string.none_selected_gpx); tv.setTextSize(24); //((ViewGroup)getExpandableListView().getParent()).addView(tv); @@ -202,12 +198,12 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment { if (gpxDisplayItem.locationStart != null) { adapter.item(R.string.show_gpx_route).listen(listener).reg(); } - OsmandPlugin.onContextMenuActivity(getSherlockActivity(), this, gpxDisplayItem, adapter); + OsmandPlugin.onContextMenuActivity(getActivity(), this, gpxDisplayItem, adapter); } @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } @@ -269,11 +265,11 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment { } public void showProgressBar() { - getSherlockActivity().setSupportProgressBarIndeterminateVisibility(true); + ((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true); } public void hideProgressBar() { - getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false); + ((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(false); } private void selectSplitDistance(final GpxDisplayGroup model) { @@ -341,12 +337,12 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment { protected void onPostExecute(Void result) { adapter.notifyDataSetChanged(); - getSherlockActivity().setProgressBarIndeterminateVisibility(false); - }; + (getActivity()).setProgressBarIndeterminateVisibility(false); + } protected void onPreExecute() { - getSherlockActivity().setProgressBarIndeterminateVisibility(true); - }; + (getActivity()).setProgressBarIndeterminateVisibility(true); + } @Override protected Void doInBackground(Void... params) { diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index 92ecf17932..5722d065f3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -11,6 +11,7 @@ import java.util.Set; import android.os.Build; import android.preference.*; +import android.view.MenuItem; import net.osmand.access.AccessibleToast; import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; @@ -34,7 +35,8 @@ import android.widget.ArrayAdapter; import android.widget.Toast; -public abstract class SettingsBaseActivity extends SherlockPreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener { +public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity + implements OnPreferenceChangeListener, OnPreferenceClickListener { @@ -287,7 +289,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: @@ -301,9 +303,9 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im @Override public void onCreate(Bundle savedInstanceState) { ((OsmandApplication) getApplication()).applyTheme(this); - getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setTitle(R.string.settings_activity); + //getToolbar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); + //getToolbar().setDisplayHomeAsUpEnabled(true); + getToolbar().setTitle(R.string.settings_activity); // R.drawable.tab_settings_screen_icon super.onCreate(savedInstanceState); @@ -316,24 +318,24 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im modes.add(a); } } - getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); + //getToolbar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); List s = new ArrayList(); for (ApplicationMode a : modes) { s.add(a.toHumanString(getMyApplication())); } - ArrayAdapter spinnerAdapter = new ArrayAdapter(getSupportActionBar().getThemedContext(), - R.layout.sherlock_spinner_item, s); - spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); - getSupportActionBar().setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() { - - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - settings.APPLICATION_MODE.set(modes.get(itemPosition)); - updateAllSettings(); - return true; - } - }); +// ArrayAdapter spinnerAdapter = new ArrayAdapter(getSupportActionBar().getThemedContext(), +// R.layout.sherlock_spinner_item, s); +// spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); +// getToolbar().setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() { +// +// @Override +// public boolean onNavigationItemSelected(int itemPosition, long itemId) { +// settings.APPLICATION_MODE.set(modes.get(itemPosition)); +// updateAllSettings(); +// return true; +// } +// }); } setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this)); } @@ -349,7 +351,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im previousAppMode = settings.getApplicationMode(); boolean found = setSelectedAppMode(previousAppMode); if (!found) { - getSupportActionBar().setSelectedNavigationItem(0); + //getToolbar().setSelectedNavigationItem(0); } } else { updateAllSettings(); @@ -383,7 +385,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im boolean found = false; for (ApplicationMode a : modes) { if (am == a) { - getSupportActionBar().setSelectedNavigationItem(ind); + //getSupportActionBar().setSelectedNavigationItem(ind); found = true; break; } diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index cb8477f190..675087f89a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -9,6 +9,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import android.view.Window; import net.osmand.CallbackWithObject; import net.osmand.IProgress; import net.osmand.IndexConstants; @@ -52,7 +53,6 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.Toast; -import com.actionbarsherlock.view.Window; public class SettingsGeneralActivity extends SettingsBaseActivity { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java index 599798a33f..029aabc81e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.Locale; import android.support.v7.app.ActionBarActivity; +import android.view.MenuItem; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.plus.OsmAndLocationProvider; @@ -23,7 +24,6 @@ import net.osmand.util.Algorithms; import android.app.ActionBar; import android.content.Context; import android.content.Intent; -import android.content.pm.ActivityInfo; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; @@ -40,6 +40,7 @@ import android.widget.TabHost; import android.widget.TabHost.TabSpec; import android.widget.TabWidget; import android.widget.TextView; +import android.support.v7.app.ActionBar.OnNavigationListener; public class SearchActivity extends ActionBarActivity implements OsmAndLocationListener { private static final String SEARCH_HISTORY = "Search_History"; @@ -99,7 +100,7 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL ((OsmandApplication) getApplication()).applyTheme(this); super.onCreate(savedInstanceState); long t = System.currentTimeMillis(); - getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); + //getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); setContentView(R.layout.search_main); settings = ((OsmandApplication) getApplication()).getSettings(); @@ -197,7 +198,7 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL } @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java index 34017f3f26..2a39132119 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java @@ -1,6 +1,7 @@ package net.osmand.plus.activities.search; import android.support.v7.app.ActionBarActivity; +import android.view.MenuItem; import net.osmand.plus.OsmandApplication; import android.content.pm.ActivityInfo; import android.os.Bundle; @@ -12,7 +13,7 @@ public class SearchAddressActivity extends ActionBarActivity { protected void onCreate(Bundle savedInstanceState) { ((OsmandApplication) getApplication()).applyTheme(this); super.onCreate(savedInstanceState); - getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); + //getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState == null) { // During initial setup, plug in the details fragment. @@ -23,7 +24,7 @@ public class SearchAddressActivity extends ActionBarActivity { } @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java index 880a9c89c6..1c8e111508 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java @@ -9,6 +9,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import android.view.*; +import android.view.MenuItem.OnMenuItemClickListener; import net.osmand.Collator; import net.osmand.CollatorStringMatcher; import net.osmand.CollatorStringMatcher.StringMatcherMode; @@ -44,11 +46,6 @@ import android.text.Spannable; import android.text.TextWatcher; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.widget.ArrayAdapter; import android.widget.EditText; @@ -59,10 +56,6 @@ import android.widget.TextView; import android.widget.TextView.BufferType; import android.widget.TextView.OnEditorActionListener; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener; - public abstract class SearchByNameAbstractActivity extends OsmandListActivity { @@ -521,13 +514,13 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity public boolean onCreateOptionsMenu(Menu menu) { if (sequentialSearch) { boolean light = ((OsmandApplication) getApplication()).getSettings().isLightActionBar(); - com.actionbarsherlock.view.MenuItem menuItem = menu.add(0, NAVIGATE_TO, 0, R.string.context_menu_item_directions_to) + MenuItem menuItem = menu.add(0, NAVIGATE_TO, 0, R.string.context_menu_item_directions_to) .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark); - menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { + menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override - public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { + public boolean onMenuItemClick(MenuItem item) { select(NAVIGATE_TO); return true; } @@ -544,7 +537,7 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity } menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override - public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { + public boolean onMenuItemClick(MenuItem item) { select(ADD_WAYPOINT); return true; } @@ -555,7 +548,7 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override - public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { + public boolean onMenuItemClick(MenuItem item) { select(SHOW_ON_MAP); return true; } @@ -567,7 +560,7 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override - public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { + public boolean onMenuItemClick(MenuItem item) { select(ADD_TO_FAVORITE); return true; } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashAudioVideoNotesActivity.java b/OsmAnd/src/net/osmand/plus/dashboard/DashAudioVideoNotesActivity.java index 7c97cf3a63..fec2b6f13e 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashAudioVideoNotesActivity.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashAudioVideoNotesActivity.java @@ -2,19 +2,16 @@ package net.osmand.plus.dashboard; import android.app.AlertDialog; import android.content.DialogInterface; -import android.content.Intent; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.*; -import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; -import net.osmand.plus.activities.MainMenuActivity; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import java.util.ArrayList; diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 25788c1686..635a580c3b 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.Map; import android.app.FragmentManager; +import android.view.MenuItem; +import android.view.Window; import net.osmand.IndexConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; @@ -30,7 +32,6 @@ import android.widget.ProgressBar; import android.widget.TabHost; import android.widget.TextView; -import com.actionbarsherlock.view.Window; /** * Created by Denis on 08.09.2014. @@ -182,7 +183,7 @@ public class DownloadActivity extends BaseDownloadActivity { @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: diff --git a/OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java index 83fdc6bc5b..4f692b9e8f 100644 --- a/OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java @@ -3,16 +3,12 @@ package net.osmand.plus.download; import android.content.Context; import android.graphics.Typeface; import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; +import android.support.v4.app.Fragment; +import android.support.v4.app.ListFragment; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.ActionBar; +import android.view.*; import android.widget.*; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockListFragment; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; import net.osmand.access.AccessibleToast; import net.osmand.map.OsmandRegions; import net.osmand.plus.OsmandApplication; @@ -27,7 +23,7 @@ import java.util.Map; /** * Created by Denis on 09.09.2014. */ -public class UpdatesIndexFragment extends SherlockListFragment { +public class UpdatesIndexFragment extends ListFragment { private OsmandRegions osmandRegions; private java.text.DateFormat format; @@ -112,15 +108,14 @@ public class UpdatesIndexFragment extends SherlockListFragment { MenuItem item = menu.add(0, DownloadIndexFragment.RELOAD_ID, 0, R.string.update_downlod_list); item.setIcon(isLightActionBar() ? R.drawable.ic_action_refresh_light : R.drawable.ic_action_refresh_dark); - item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - + MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); SubMenu s = menu.addSubMenu(0, DownloadIndexFragment.MORE_ID, 0, R.string.default_buttons_other_actions); s.add(0, DownloadIndexFragment.SELECT_ALL_ID, 0, R.string.select_all); s.add(0, DownloadIndexFragment.DESELECT_ALL_ID, 0, R.string.deselect_all); s.setIcon(isLightActionBar() ? R.drawable.abs__ic_menu_moreoverflow_holo_light : R.drawable.abs__ic_menu_moreoverflow_holo_dark); - s.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + MenuItemCompat.setShowAsAction(s.getItem(), MenuItemCompat.SHOW_AS_ACTION_ALWAYS); } } diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java index f777fdcd4c..18a529028d 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java @@ -2,6 +2,9 @@ package net.osmand.plus.routepointsnavigation; import java.util.ArrayList; import java.util.List; + +import android.support.v7.view.ActionMode; +import android.view.*; import net.osmand.CallbackWithObject; import net.osmand.data.LatLon; import net.osmand.plus.GPXUtilities; @@ -9,6 +12,7 @@ import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; +import net.osmand.plus.activities.OsmandExpandableListActivity; import net.osmand.plus.activities.OsmandListActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.routepointsnavigation.RoutePointsPlugin.RoutePoint; @@ -23,18 +27,11 @@ import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.util.DisplayMetrics; import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.Window; /** * Created by Bars on 13.06.2014. @@ -145,11 +142,9 @@ public class RoutePointsActivity extends OsmandListActivity { listView.setAdapter(adapter); } - @Override protected void onListItemClick(ListView l, View v, int position, long id) { - super.onListItemClick(l, v, position, id); RoutePoint rp = adapter.getItem(position); - getSherlock().startActionMode(getPointActionModeCallback(rp)); + getSupportActionBar().startActionMode(getPointActionModeCallback(rp)); adapter.notifyDataSetChanged(); } @@ -224,7 +219,7 @@ public class RoutePointsActivity extends OsmandListActivity { private void saveGPXAsync() { new AsyncTask() { protected void onPreExecute() { - getSherlock().setProgressBarIndeterminateVisibility(true); + //getSherlock().setProgressBarIndeterminateVisibility(true); } @Override @@ -236,7 +231,7 @@ public class RoutePointsActivity extends OsmandListActivity { } protected void onPostExecute(Void result) { - getSherlock().setProgressBarIndeterminateVisibility(false); + //getSherlock().setProgressBarIndeterminateVisibility(false); } }.execute(plugin.getCurrentRoute()); @@ -300,7 +295,7 @@ public class RoutePointsActivity extends OsmandListActivity { } @Override - public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { + public boolean onCreateOptionsMenu(Menu menu) { createMenuItem(menu, OK_ID, R.string.default_buttons_ok, R.drawable.ic_action_map_marker_light, R.drawable.ic_action_map_marker_dark , MenuItem.SHOW_AS_ACTION_IF_ROOM); @@ -311,7 +306,7 @@ public class RoutePointsActivity extends OsmandListActivity { } @Override - public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == OK_ID) { finish(); return true;