Added action bar activity with only light back icon. Fixed few issues with split action bar in MyFavorites

This commit is contained in:
Bars107 2015-01-28 17:32:57 +02:00
parent 543284bb77
commit d5e0e5cdce
18 changed files with 99 additions and 70 deletions

View file

@ -1,7 +1,7 @@
package net.osmand.access;
import android.support.v7.app.ActionBarActivity;
import android.view.MotionEvent;
import net.osmand.plus.activities.OsmandActionBarActivity;
// Provide some additional accessibility means for activity view elements.
//
@ -9,7 +9,7 @@ import android.view.MotionEvent;
// and then add view elements you wish to be accessible
// to the accessibleContent list.
//
public class AccessibleActivity extends ActionBarActivity implements AccessibleContent.Callback {
public class AccessibleActivity extends OsmandActionBarActivity implements AccessibleContent.Callback {
// List of accessible views. Use accessibleContent.add(element)
// to add element to it.

View file

@ -1,7 +1,6 @@
package net.osmand.plus.activities;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.ProgressBar;
@ -9,7 +8,7 @@ import android.widget.ProgressBar;
* Created by Denis
* on 23.01.15.
*/
public class ActionBarProgressActivity extends ActionBarActivity {
public class ActionBarProgressActivity extends OsmandActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {

View file

@ -30,7 +30,6 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.util.Algorithms;
@ -134,14 +133,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
int orientation = ScreenOrientationHelper.getScreenOrientation(getActivity());
boolean portrait = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
if (portrait) {
menu = ((FavouritesActivity) getActivity()).getClearToolbar(true).getMenu();
} else {
((FavouritesActivity) getActivity()).getClearToolbar(false);
}
MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark,
R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS
@ -163,6 +154,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
});
if (isOrientationPortrait()) {
menu = ((FavouritesActivity) getActivity()).getClearToolbar(true).getMenu();
} else {
((FavouritesActivity) getActivity()).getClearToolbar(false);
}
optionsMenuAdapter = new ContextMenuAdapter(getActivity());
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
@ -197,12 +196,18 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
if (optionsMenuAdapter.getImageId(j, isLightActionBar()) != 0) {
item.setIcon(optionsMenuAdapter.getImageId(j, isLightActionBar()));
item.setIcon(optionsMenuAdapter.getImageId(j, false));
}
}
}
private boolean isOrientationPortrait() {
int orientation = ScreenOrientationHelper.getScreenOrientation(getActivity());
return orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
}
public void doAction(int actionResId) {
if (actionResId == R.string.local_index_mi_delete) {
operationTask = new DeleteGpxTask();
@ -228,12 +233,12 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public void showProgressBar() {
//getActivity().setSupportProgressBarIndeterminateVisibility(true);
((FavouritesActivity)getActivity()).setSupportProgressBarIndeterminateVisibility(true);
}
public void hideProgressBar() {
if (getActivity() != null){
//getActivity().setSupportProgressBarIndeterminateVisibility(false);
((FavouritesActivity)getActivity()).setSupportProgressBarIndeterminateVisibility(false);
}
}
@ -247,8 +252,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private void enableSelectionMode(boolean selectionMode) {
this.selectionMode = selectionMode;
if (isOrientationPortrait()) {
((FavouritesActivity)getActivity()).setToolbarVisibility(!selectionMode);
}
}
private void openShowOnMapMode() {
enableSelectionMode(true);
@ -685,7 +692,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View v = convertView;
final GpxInfo child = (GpxInfo) getChild(groupPosition, childPosition);
final GpxInfo child = getChild(groupPosition, childPosition);
if (v == null) {
LayoutInflater inflater = getActivity().getLayoutInflater();
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
@ -892,12 +899,12 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onPreExecute() {
((ActionBarActivity)getActivity()).setProgressBarIndeterminateVisibility(true);
getActivity().setProgressBarIndeterminateVisibility(true);
}
@Override
protected void onPostExecute(String result) {
((ActionBarActivity)getActivity()).setProgressBarIndeterminateVisibility(false);
getActivity().setProgressBarIndeterminateVisibility(false);
AccessibleToast.makeText(getActivity(), result, Toast.LENGTH_LONG).show();
}
}
@ -944,7 +951,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onPostExecute(String result) {
selectedGpxHelper.runUiListeners();
((ActionBarActivity)getActivity()).setProgressBarIndeterminateVisibility(false);
getActivity().setProgressBarIndeterminateVisibility(false);
if (showOnMap && toShow != null) {
getMyApplication().getSettings().setMapLocationToShow(toShow.lat, toShow.lon,
getMyApplication().getSettings().getLastKnownMapZoom());
@ -975,13 +982,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onPreExecute() {
((ActionBarActivity)getActivity()).setProgressBarIndeterminateVisibility(true);
getActivity().setProgressBarIndeterminateVisibility(true);
}
@Override
protected void onPostExecute(Void result) {
if (getActivity() != null){
((ActionBarActivity)getActivity()).setProgressBarIndeterminateVisibility(false);
getActivity().setProgressBarIndeterminateVisibility(false);
}
if (info.gpx != null){
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, selected, true);

View file

@ -51,11 +51,9 @@ public class FavouritesActivity extends TabActivity {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(icicle);
setSupportProgressBarIndeterminateVisibility(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.favorites_Button);
getSupportActionBar().setElevation(0);
// getSupportActionBar().setTitle("");
// getSupportActionBar().setIcon(R.drawable.tab_search_favorites_icon);
File[] lf = ((OsmandApplication) getApplication()).getAppPath(TRACKS).listFiles();
boolean hasGpx = false;
if(lf != null) {
@ -98,6 +96,7 @@ public class FavouritesActivity extends TabActivity {
}
updateSelectedTracks();
}
//setupHomeButton();
}
@Override

View file

@ -1,18 +1,16 @@
package net.osmand.plus.activities;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import net.osmand.plus.OsmandApplication;
import android.os.Bundle;
public class FavouritesListActivity extends ActionBarActivity {
public class FavouritesListActivity extends OsmandActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
// During initial setup, plug in the details fragment.
FavouritesListFragment details = new FavouritesListFragment();

View file

@ -302,22 +302,12 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
int orientation = ScreenOrientationHelper.getScreenOrientation(getActivity());
boolean portrait = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
if (portrait) {
menu = ((FavouritesActivity) getActivity()).getClearToolbar(true).getMenu();
} else {
((FavouritesActivity) getActivity()).getClearToolbar(false);
}
MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark,
R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
searchView = new SearchView(getActivity());
MenuItemCompat.setActionView(mi, searchView);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
favouritesAdapter.getFilter().filter(query);
@ -331,7 +321,6 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
}
});
MenuItemCompat.setOnActionExpandListener(mi, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
@ -346,6 +335,17 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
}
});
int orientation = ScreenOrientationHelper.getScreenOrientation(getActivity());
boolean portrait = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
if (portrait) {
menu = ((FavouritesActivity) getActivity()).getClearToolbar(true).getMenu();
} else {
((FavouritesActivity) getActivity()).getClearToolbar(false);
}
if (!MenuItemCompat.isActionViewExpanded(mi)) {
createMenuItem(menu, SHARE_ID, R.string.share_fav, R.drawable.ic_action_gshare_dark,
R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);

View file

@ -8,7 +8,6 @@ import java.io.InputStreamReader;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBarActivity;
import android.view.*;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
@ -17,7 +16,7 @@ import android.webkit.WebView;
import android.webkit.WebViewClient;
public class HelpActivity extends ActionBarActivity {
public class HelpActivity extends OsmandActionBarActivity {
private static final String FILE_ANDROID_ASSET_HELP = "file:///android_asset/help/";
public static final String URL = "url";
@ -37,7 +36,6 @@ public class HelpActivity extends ActionBarActivity {
}
super.onCreate(savedInstanceState);
wv = new WebView(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
String title = getString(R.string.help);
String url = "index.html";
if(getIntent() != null) {

View file

@ -0,0 +1,42 @@
package net.osmand.plus.activities;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.plus.R;
/**
* Created by Denis
* on 28.01.15.
*/
public class OsmandActionBarActivity extends ActionBarActivity {
//should be called after set content view
protected void setupHomeButton(){
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
back.setColorFilter(0xffffffff, PorterDuff.Mode.MULTIPLY);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(back);
}
@Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
setupHomeButton();
}
@Override
public void setContentView(View view) {
super.setContentView(view);
setupHomeButton();
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
super.setContentView(view, params);
setupHomeButton();
}
}

View file

@ -23,7 +23,6 @@ public abstract class OsmandExpandableListActivity extends
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

View file

@ -25,7 +25,6 @@ public abstract class OsmandListActivity extends
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

View file

@ -40,7 +40,6 @@ public class PrintDialogActivity extends ActionBarProgressActivity {
}
super.onCreate(icicle);
setSupportProgressBarIndeterminateVisibility(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.print_route);
setContentView(R.layout.print_dialog);

View file

@ -84,7 +84,6 @@ public class SearchActivity extends TabActivity implements OsmAndLocationListene
settings = ((OsmandApplication) getApplication()).getSettings();
Integer tab = settings.SEARCH_TAB.get();
showOnlyOneTab = getIntent() != null && getIntent().getBooleanExtra(SHOW_ONLY_ONE_TAB, false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("");
getSupportActionBar().setElevation(0);

View file

@ -1,14 +1,14 @@
package net.osmand.plus.activities.search;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import net.osmand.plus.OsmandApplication;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import net.osmand.plus.activities.OsmandActionBarActivity;
public class SearchAddressActivity extends ActionBarActivity {
public class SearchAddressActivity extends OsmandActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -17,7 +17,6 @@ public class SearchAddressActivity extends ActionBarActivity {
getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
}
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
// During initial setup, plug in the details fragment.
SearchAddressFragment details = new SearchAddressFragment();

View file

@ -85,8 +85,6 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
}
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.search_activity);
getSupportActionBar().setIcon(R.drawable.tab_search_address_icon);
}

View file

@ -2,18 +2,16 @@ package net.osmand.plus.dashboard;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.*;
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.OsmandActionBarActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import java.util.ArrayList;
@ -23,7 +21,7 @@ import java.util.List;
* Created by Denis
* on 23.12.2014.
*/
public class DashAudioVideoNotesActivity extends ActionBarActivity {
public class DashAudioVideoNotesActivity extends OsmandActionBarActivity {
AudioVideoNotesPlugin plugin;
List<AudioVideoNotesPlugin.Recording> items;
NotesAdapter listAdapter;
@ -42,8 +40,7 @@ public class DashAudioVideoNotesActivity extends ActionBarActivity {
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(R.string.audionotes_plugin_name);
actionBar.setIcon(android.R.color.transparent);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
findViewById(android.R.id.list).setBackgroundColor(getResources().getColor(R.color.dashboard_background));
}

View file

@ -5,12 +5,12 @@ import java.util.LinkedHashSet;
import java.util.Set;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.voice.AbstractPrologCommandPlayer;
import net.osmand.plus.voice.CommandBuilder;
import net.osmand.plus.voice.CommandPlayer;
@ -36,7 +36,7 @@ import android.widget.Toast;
/**
* Test Voice activity
*/
public class TestVoiceActivity extends ActionBarActivity {
public class TestVoiceActivity extends OsmandActionBarActivity {
@ -48,7 +48,6 @@ public class TestVoiceActivity extends ActionBarActivity {
getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
}
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final OsmandApplication app = ((OsmandApplication) getApplication());

View file

@ -8,6 +8,8 @@ import java.util.Map;
import android.app.FragmentManager;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.v4.app.FragmentPagerAdapter;
import net.osmand.IndexConstants;
import net.osmand.plus.OsmandApplication;
@ -151,9 +153,6 @@ public class DownloadActivity extends BaseDownloadActivity {
}
}
changeType(downloadTypes.get(0));
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

View file

@ -5,12 +5,12 @@ import java.util.WeakHashMap;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
@ -33,7 +33,7 @@ import android.widget.TextView;
/**
*/
public class TourViewActivity extends ActionBarActivity {
public class TourViewActivity extends OsmandActionBarActivity {
private enum viewState {
STATE_LOADING,
@ -81,8 +81,6 @@ public class TourViewActivity extends ActionBarActivity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setTitle(R.string.sherpafy_app_name);
setContentView(R.layout.sherpafy_browse_tour);