Fixes for appcompat

This commit is contained in:
Denis 2014-12-30 12:45:33 +02:00
parent 63804077a4
commit dc1956f635
21 changed files with 276 additions and 145 deletions

Binary file not shown.

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:bottom="8dp">
<shape android:shape="rectangle" >
<size android:height="1dp" />
<solid android:color="#43000000" />
</shape>
</item>
<item android:top="1dp">
<shape
android:dither="true"
android:shape="rectangle" >
<gradient
android:angle="270"
android:endColor="#00000000"
android:startColor="#10000000" />
<size android:height="8dp" />
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,34 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.antonioleiva.materialeverywhere.SettingsActivity" >
<android.support.v7.widget.Toolbar
android:id="@+id/abp__toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/abp__shadowView"
android:layout_width="match_parent"
android:layout_height="@dimen/abp__shadow_height"
android:src="@drawable/preference_activity_action_bar_shadow"
tools:ignore="ContentDescription" />
</FrameLayout>
</LinearLayout>

View file

@ -19,7 +19,7 @@
<dimen name="dashPadding">6dp</dimen> <dimen name="dashPadding">6dp</dimen>
<dimen name="dashAboutTextSize">20sp</dimen> <dimen name="dashAboutTextSize">20sp</dimen>
<dimen name="dashCardMargin">4dp</dimen> <dimen name="dashCardMargin">4dp</dimen>
<dimen name="abp__shadow_height">4dp</dimen>
<!-- TextSizes --> <!-- TextSizes -->
<dimen name="showAllButtonTextSize">12sp</dimen> <dimen name="showAllButtonTextSize">12sp</dimen>

View file

@ -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);
}
}
}

View file

@ -11,6 +11,7 @@ import java.util.Comparator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import android.view.*;
import net.osmand.access.AccessibleToast; import net.osmand.access.AccessibleToast;
import net.osmand.data.AmenityType; import net.osmand.data.AmenityType;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -28,10 +29,7 @@ import android.app.AlertDialog.Builder;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
@ -42,9 +40,6 @@ import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
/** /**
* *
*/ */

View file

@ -8,6 +8,7 @@ import java.util.ArrayList;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import android.view.Window; import android.view.Window;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -51,7 +52,7 @@ public class FavouritesActivity extends ActionBarActivity {
//class in com.actionbarsherlock.view and NOT android.view //class in com.actionbarsherlock.view and NOT android.view
((OsmandApplication) getApplication()).applyTheme(this); ((OsmandApplication) getApplication()).applyTheme(this);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); 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); super.onCreate(icicle);
setSupportProgressBarIndeterminateVisibility(false); setSupportProgressBarIndeterminateVisibility(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -140,7 +141,7 @@ public class FavouritesActivity extends ActionBarActivity {
@Override @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
switch (itemId) { switch (itemId) {
case android.R.id.home: case android.R.id.home:

View file

@ -1,6 +1,7 @@
package net.osmand.plus.activities; package net.osmand.plus.activities;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import android.os.Bundle; import android.os.Bundle;
@ -21,7 +22,7 @@ public class FavouritesListActivity extends ActionBarActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
switch (itemId) { switch (itemId) {
case android.R.id.home: case android.R.id.home:

View file

@ -6,6 +6,7 @@ package net.osmand.plus.activities;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import android.support.v4.app.ListFragment;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
@ -33,12 +34,10 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.BufferType; 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 String SELECT_FAVORITE_POINT_INTENT_KEY = "SELECT_FAVORITE_POINT_INTENT_KEY";
public static final int SELECT_FAVORITE_POINT_RESULT_OK = 1; public static final int SELECT_FAVORITE_POINT_RESULT_OK = 1;

View file

@ -6,6 +6,8 @@ import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import android.support.v4.view.MenuItemCompat;
import android.view.*;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.access.AccessibleAlertBuilder; import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndAppCustomization;
@ -45,14 +47,9 @@ import android.text.Spanned;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; 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 @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, HELP_ID, 0, R.string.tips_and_tricks).setIcon(R.drawable.ic_ac_help) MenuItem menuItem = menu.add(0, HELP_ID, 0, R.string.tips_and_tricks).setIcon(R.drawable.ic_ac_help);
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
menu.add(0, SETTINGS_ID, 0, R.string.settings).setIcon(R.drawable.ic_ac_settings) menuItem = menu.add(0, SETTINGS_ID, 0, R.string.settings).setIcon(R.drawable.ic_ac_settings);
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
menu.add(0, EXIT_ID, 0, R.string.exit_Button).setIcon(R.drawable.ic_ac_close) menuItem = menu.add(0, EXIT_ID, 0, R.string.exit_Button).setIcon(R.drawable.ic_ac_close);
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
return true; return true;
} }

View file

@ -1,64 +1,98 @@
package net.osmand.plus.activities; 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 net.osmand.plus.OsmandApplication;
import android.app.ActionBar; 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.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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this); ((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setActionBarSettings();
}
protected void setActionBarSettings() {
getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
protected OsmandApplication getMyApplication() {
return (OsmandApplication) getApplication(); public OsmandApplication getMyApplication() {
return (OsmandApplication)getApplication();
} }
@Override @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
switch (itemId) { switch (itemId) {
case android.R.id.home: case android.R.id.home:
finish(); finish();
return true; return true;
} }
return false; 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() { public boolean isLightActionBar() {
return ((OsmandApplication) getApplication()).getSettings().isLightActionBar(); return ((OsmandApplication) getApplication()).getSettings().isLightActionBar();
} }
} }

View file

@ -1,5 +1,7 @@
package net.osmand.plus.activities; package net.osmand.plus.activities;
import android.support.v7.app.ActionBarActivity;
import android.view.*;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
import java.text.Collator; import java.text.Collator;
@ -31,11 +33,7 @@ import android.content.DialogInterface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html; import android.text.Html;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
@ -48,8 +46,6 @@ import android.widget.SectionIndexer;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
public class SelectedGPXFragment extends OsmandExpandableListFragment { 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.setText(R.string.none_selected_gpx);
tv.setTextSize(24); tv.setTextSize(24);
//((ViewGroup)getExpandableListView().getParent()).addView(tv); //((ViewGroup)getExpandableListView().getParent()).addView(tv);
@ -202,12 +198,12 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
if (gpxDisplayItem.locationStart != null) { if (gpxDisplayItem.locationStart != null) {
adapter.item(R.string.show_gpx_route).listen(listener).reg(); adapter.item(R.string.show_gpx_route).listen(listener).reg();
} }
OsmandPlugin.onContextMenuActivity(getSherlockActivity(), this, gpxDisplayItem, adapter); OsmandPlugin.onContextMenuActivity(getActivity(), this, gpxDisplayItem, adapter);
} }
@Override @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -269,11 +265,11 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
} }
public void showProgressBar() { public void showProgressBar() {
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(true); ((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);
} }
public void hideProgressBar() { public void hideProgressBar() {
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false); ((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(false);
} }
private void selectSplitDistance(final GpxDisplayGroup model) { private void selectSplitDistance(final GpxDisplayGroup model) {
@ -341,12 +337,12 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
getSherlockActivity().setProgressBarIndeterminateVisibility(false); (getActivity()).setProgressBarIndeterminateVisibility(false);
}; }
protected void onPreExecute() { protected void onPreExecute() {
getSherlockActivity().setProgressBarIndeterminateVisibility(true); (getActivity()).setProgressBarIndeterminateVisibility(true);
}; }
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {

View file

@ -11,6 +11,7 @@ import java.util.Set;
import android.os.Build; import android.os.Build;
import android.preference.*; import android.preference.*;
import android.view.MenuItem;
import net.osmand.access.AccessibleToast; import net.osmand.access.AccessibleToast;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -34,7 +35,8 @@ import android.widget.ArrayAdapter;
import android.widget.Toast; 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 @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
switch (itemId) { switch (itemId) {
case android.R.id.home: case android.R.id.home:
@ -301,9 +303,9 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this); ((OsmandApplication) getApplication()).applyTheme(this);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); //getToolbar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); //getToolbar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.settings_activity); getToolbar().setTitle(R.string.settings_activity);
// R.drawable.tab_settings_screen_icon // R.drawable.tab_settings_screen_icon
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -316,24 +318,24 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
modes.add(a); modes.add(a);
} }
} }
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); //getToolbar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
List<String> s = new ArrayList<String>(); List<String> s = new ArrayList<String>();
for (ApplicationMode a : modes) { for (ApplicationMode a : modes) {
s.add(a.toHumanString(getMyApplication())); s.add(a.toHumanString(getMyApplication()));
} }
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(getSupportActionBar().getThemedContext(), // ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(getSupportActionBar().getThemedContext(),
R.layout.sherlock_spinner_item, s); // R.layout.sherlock_spinner_item, s);
spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); // spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() { // getToolbar().setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() {
//
@Override // @Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) { // public boolean onNavigationItemSelected(int itemPosition, long itemId) {
settings.APPLICATION_MODE.set(modes.get(itemPosition)); // settings.APPLICATION_MODE.set(modes.get(itemPosition));
updateAllSettings(); // updateAllSettings();
return true; // return true;
} // }
}); // });
} }
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this)); setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
} }
@ -349,7 +351,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
previousAppMode = settings.getApplicationMode(); previousAppMode = settings.getApplicationMode();
boolean found = setSelectedAppMode(previousAppMode); boolean found = setSelectedAppMode(previousAppMode);
if (!found) { if (!found) {
getSupportActionBar().setSelectedNavigationItem(0); //getToolbar().setSelectedNavigationItem(0);
} }
} else { } else {
updateAllSettings(); updateAllSettings();
@ -383,7 +385,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
boolean found = false; boolean found = false;
for (ApplicationMode a : modes) { for (ApplicationMode a : modes) {
if (am == a) { if (am == a) {
getSupportActionBar().setSelectedNavigationItem(ind); //getSupportActionBar().setSelectedNavigationItem(ind);
found = true; found = true;
break; break;
} }

View file

@ -9,6 +9,7 @@ import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import android.view.Window;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
@ -52,7 +53,6 @@ import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import com.actionbarsherlock.view.Window;
public class SettingsGeneralActivity extends SettingsBaseActivity { public class SettingsGeneralActivity extends SettingsBaseActivity {

View file

@ -9,6 +9,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider;
@ -23,7 +24,6 @@ import net.osmand.util.Algorithms;
import android.app.ActionBar; import android.app.ActionBar;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
@ -40,6 +40,7 @@ import android.widget.TabHost;
import android.widget.TabHost.TabSpec; import android.widget.TabHost.TabSpec;
import android.widget.TabWidget; import android.widget.TabWidget;
import android.widget.TextView; import android.widget.TextView;
import android.support.v7.app.ActionBar.OnNavigationListener;
public class SearchActivity extends ActionBarActivity implements OsmAndLocationListener { public class SearchActivity extends ActionBarActivity implements OsmAndLocationListener {
private static final String SEARCH_HISTORY = "Search_History"; private static final String SEARCH_HISTORY = "Search_History";
@ -99,7 +100,7 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
((OsmandApplication) getApplication()).applyTheme(this); ((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
long t = System.currentTimeMillis(); 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); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
setContentView(R.layout.search_main); setContentView(R.layout.search_main);
settings = ((OsmandApplication) getApplication()).getSettings(); settings = ((OsmandApplication) getApplication()).getSettings();
@ -197,7 +198,7 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
} }
@Override @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
switch (itemId) { switch (itemId) {
case android.R.id.home: case android.R.id.home:

View file

@ -1,6 +1,7 @@
package net.osmand.plus.activities.search; package net.osmand.plus.activities.search;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.os.Bundle; import android.os.Bundle;
@ -12,7 +13,7 @@ public class SearchAddressActivity extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this); ((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); //getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) { if (savedInstanceState == null) {
// During initial setup, plug in the details fragment. // During initial setup, plug in the details fragment.
@ -23,7 +24,7 @@ public class SearchAddressActivity extends ActionBarActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
switch (itemId) { switch (itemId) {
case android.R.id.home: case android.R.id.home:

View file

@ -9,6 +9,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import android.view.*;
import android.view.MenuItem.OnMenuItemClickListener;
import net.osmand.Collator; import net.osmand.Collator;
import net.osmand.CollatorStringMatcher; import net.osmand.CollatorStringMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode; import net.osmand.CollatorStringMatcher.StringMatcherMode;
@ -44,11 +46,6 @@ import android.text.Spannable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan; 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.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
@ -59,10 +56,6 @@ import android.widget.TextView;
import android.widget.TextView.BufferType; import android.widget.TextView.BufferType;
import android.widget.TextView.OnEditorActionListener; 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<T> extends OsmandListActivity { public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity {
@ -521,13 +514,13 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
if (sequentialSearch) { if (sequentialSearch) {
boolean light = ((OsmandApplication) getApplication()).getSettings().isLightActionBar(); 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); .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light
: R.drawable.ic_action_gdirections_dark); : R.drawable.ic_action_gdirections_dark);
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
select(NAVIGATE_TO); select(NAVIGATE_TO);
return true; return true;
} }
@ -544,7 +537,7 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
} }
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
select(ADD_WAYPOINT); select(ADD_WAYPOINT);
return true; return true;
} }
@ -555,7 +548,7 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
select(SHOW_ON_MAP); select(SHOW_ON_MAP);
return true; return true;
} }
@ -567,7 +560,7 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
select(ADD_TO_FAVORITE); select(ADD_TO_FAVORITE);
return true; return true;
} }

View file

@ -2,19 +2,16 @@ package net.osmand.plus.dashboard;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.view.*; import android.view.*;
import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MainMenuActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -7,6 +7,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.view.MenuItem;
import android.view.Window;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -30,7 +32,6 @@ import android.widget.ProgressBar;
import android.widget.TabHost; import android.widget.TabHost;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.view.Window;
/** /**
* Created by Denis on 08.09.2014. * Created by Denis on 08.09.2014.
@ -182,7 +183,7 @@ public class DownloadActivity extends BaseDownloadActivity {
@Override @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
switch (itemId) { switch (itemId) {
case android.R.id.home: case android.R.id.home:

View file

@ -3,16 +3,12 @@ package net.osmand.plus.download;
import android.content.Context; import android.content.Context;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.support.v4.app.Fragment;
import android.view.View; import android.support.v4.app.ListFragment;
import android.view.ViewGroup; import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.view.*;
import android.widget.*; 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.access.AccessibleToast;
import net.osmand.map.OsmandRegions; import net.osmand.map.OsmandRegions;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -27,7 +23,7 @@ import java.util.Map;
/** /**
* Created by Denis on 09.09.2014. * Created by Denis on 09.09.2014.
*/ */
public class UpdatesIndexFragment extends SherlockListFragment { public class UpdatesIndexFragment extends ListFragment {
private OsmandRegions osmandRegions; private OsmandRegions osmandRegions;
private java.text.DateFormat format; 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); MenuItem item = menu.add(0, DownloadIndexFragment.RELOAD_ID, 0, R.string.update_downlod_list);
item.setIcon(isLightActionBar() ? R.drawable.ic_action_refresh_light : item.setIcon(isLightActionBar() ? R.drawable.ic_action_refresh_light :
R.drawable.ic_action_refresh_dark); 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); 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.SELECT_ALL_ID, 0, R.string.select_all);
s.add(0, DownloadIndexFragment.DESELECT_ALL_ID, 0, R.string.deselect_all); s.add(0, DownloadIndexFragment.DESELECT_ALL_ID, 0, R.string.deselect_all);
s.setIcon(isLightActionBar() ? R.drawable.abs__ic_menu_moreoverflow_holo_light s.setIcon(isLightActionBar() ? R.drawable.abs__ic_menu_moreoverflow_holo_light
: R.drawable.abs__ic_menu_moreoverflow_holo_dark); : 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);
} }
} }

View file

@ -2,6 +2,9 @@ package net.osmand.plus.routepointsnavigation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import android.support.v7.view.ActionMode;
import android.view.*;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;
@ -9,6 +12,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandExpandableListActivity;
import net.osmand.plus.activities.OsmandListActivity; import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routepointsnavigation.RoutePointsPlugin.RoutePoint; import net.osmand.plus.routepointsnavigation.RoutePointsPlugin.RoutePoint;
@ -23,18 +27,11 @@ import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; 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. * Created by Bars on 13.06.2014.
@ -145,11 +142,9 @@ public class RoutePointsActivity extends OsmandListActivity {
listView.setAdapter(adapter); listView.setAdapter(adapter);
} }
@Override
protected void onListItemClick(ListView l, View v, int position, long id) { protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
RoutePoint rp = adapter.getItem(position); RoutePoint rp = adapter.getItem(position);
getSherlock().startActionMode(getPointActionModeCallback(rp)); getSupportActionBar().startActionMode(getPointActionModeCallback(rp));
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
@ -224,7 +219,7 @@ public class RoutePointsActivity extends OsmandListActivity {
private void saveGPXAsync() { private void saveGPXAsync() {
new AsyncTask<SelectedRouteGpxFile, Void, Void>() { new AsyncTask<SelectedRouteGpxFile, Void, Void>() {
protected void onPreExecute() { protected void onPreExecute() {
getSherlock().setProgressBarIndeterminateVisibility(true); //getSherlock().setProgressBarIndeterminateVisibility(true);
} }
@Override @Override
@ -236,7 +231,7 @@ public class RoutePointsActivity extends OsmandListActivity {
} }
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
getSherlock().setProgressBarIndeterminateVisibility(false); //getSherlock().setProgressBarIndeterminateVisibility(false);
} }
}.execute(plugin.getCurrentRoute()); }.execute(plugin.getCurrentRoute());
@ -300,7 +295,7 @@ public class RoutePointsActivity extends OsmandListActivity {
} }
@Override @Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
createMenuItem(menu, OK_ID, R.string.default_buttons_ok, createMenuItem(menu, OK_ID, R.string.default_buttons_ok,
R.drawable.ic_action_map_marker_light, R.drawable.ic_action_map_marker_dark , R.drawable.ic_action_map_marker_light, R.drawable.ic_action_map_marker_dark ,
MenuItem.SHOW_AS_ACTION_IF_ROOM); MenuItem.SHOW_AS_ACTION_IF_ROOM);
@ -311,7 +306,7 @@ public class RoutePointsActivity extends OsmandListActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == OK_ID) { if (item.getItemId() == OK_ID) {
finish(); finish();
return true; return true;