Fix small issues
This commit is contained in:
parent
22f8d73776
commit
f20e27d913
6 changed files with 95 additions and 59 deletions
|
@ -1,12 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
android:background="@color/color_white">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/Icon"
|
||||
|
@ -32,9 +33,8 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/AdditionalText"
|
||||
android:layout_width="40dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginLeft="7dp"
|
||||
android:textColor="@color/sherpafy_add_text"
|
||||
android:textSize="16sp" />
|
||||
|
@ -52,6 +52,8 @@
|
|||
android:textSize="16sp" />
|
||||
|
||||
<WebView android:id="@+id/Description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"/>
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.sherpafy;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
|
@ -21,6 +22,8 @@ public class SherpafyHtmlFragment extends SherlockFragment {
|
|||
Bundle savedInstanceState) {
|
||||
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||
wv = new WebView(getActivity());
|
||||
WebSettings settings = wv.getSettings();
|
||||
settings.setDefaultTextEncodingName("utf-8");
|
||||
return wv;
|
||||
}
|
||||
|
||||
|
@ -34,5 +37,13 @@ public class SherpafyHtmlFragment extends SherlockFragment {
|
|||
}
|
||||
wv.loadData("<html><body>"+data+"</body></html", "text/html", "utf-8");
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
((TourViewActivity) getSherlockActivity()).showSelectedItem();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
|
@ -27,15 +27,19 @@ public class SherpafyLoadingFragment extends SherlockFragment {
|
|||
@Override
|
||||
public void onViewCreated(final View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if(app.isApplicationInitializing()) {
|
||||
app.checkApplicationIsBeingInitialized(getActivity(), (TextView) view.findViewById(R.id.ProgressMessage),
|
||||
(ProgressBar) view.findViewById(R.id.ProgressBar), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((TextView) view.findViewById(R.id.ProgressMessage)).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.ProgressBar).setVisibility(View.GONE);
|
||||
((TourViewActivity)getSherlockActivity()).selectMenu(R.string.sherpafy_tours);
|
||||
((TourViewActivity)getSherlockActivity()).showSelectedItem();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
((TourViewActivity)getSherlockActivity()).showSelectedItem();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -75,7 +75,9 @@ public class SherpafyStageFragment extends SherlockFragment {
|
|||
// createMenuItem(menu, ACTION_GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
|
||||
// MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
if (tour != null) {
|
||||
((TourViewActivity) getSherlockActivity()).createMenuItem(menu, START, R.string.start_tour,
|
||||
boolean current = customization.getSelectedStage() == stage;
|
||||
((TourViewActivity) getSherlockActivity()).createMenuItem(menu, START,
|
||||
current ? R.string.continue_stage : R.string.start_stage ,
|
||||
0, 0,
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
}
|
||||
|
@ -83,7 +85,10 @@ public class SherpafyStageFragment extends SherlockFragment {
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == START) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
((TourViewActivity) getSherlockActivity()).selectMenu(tour);
|
||||
return true;
|
||||
} else if(item.getItemId() == START) {
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
@ -115,8 +120,7 @@ public class SherpafyStageFragment extends SherlockFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////
|
||||
private ImageGetter getImageGetter(final View v) {
|
||||
return new Html.ImageGetter() {
|
||||
@Override
|
||||
|
|
|
@ -38,18 +38,13 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
|
||||
public SherpafyTourFragment() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private enum StageItemType {
|
||||
OVERVIEW,
|
||||
INSTRUCTIONS,
|
||||
GALLERY,
|
||||
STAGE,
|
||||
TEXT
|
||||
OVERVIEW, INSTRUCTIONS, GALLERY, STAGE, TEXT
|
||||
}
|
||||
|
||||
|
||||
private static class StageItem {
|
||||
|
||||
|
||||
boolean stage;
|
||||
String txt;
|
||||
String header;
|
||||
|
@ -62,7 +57,7 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
this.header = header;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
@ -71,41 +66,41 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
|
||||
setHasOptionsMenu(true);
|
||||
String id = getArguments().getString("TOUR");
|
||||
for(TourInformation ti : customization.getTourInformations()) {
|
||||
if(ti.getId().equals(id)) {
|
||||
for (TourInformation ti : customization.getTourInformations()) {
|
||||
if (ti.getId().equals(id)) {
|
||||
tour = ti;
|
||||
getSherlockActivity().getSupportActionBar().setTitle(tour.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
if(position > 0) {
|
||||
if (position > 0) {
|
||||
StageItem si = (StageItem) getListAdapter().getItem(position - 1);
|
||||
if(si.type instanceof StageInformation) {
|
||||
if (si.type instanceof StageInformation) {
|
||||
((TourViewActivity) getSherlockActivity()).selectMenu(si.type);
|
||||
} else {
|
||||
if(si.type ==StageItemType.GALLERY) {
|
||||
//((TourViewActivity) getSherlockActivity()).showGallery(tour);
|
||||
} else if(si.type ==StageItemType.OVERVIEW) {
|
||||
if (si.type == StageItemType.GALLERY) {
|
||||
// ((TourViewActivity) getSherlockActivity()).showGallery(tour);
|
||||
} else if (si.type == StageItemType.OVERVIEW) {
|
||||
((TourViewActivity) getSherlockActivity()).showHtmlFragment(si.header, tour.getFulldescription());
|
||||
} else if(si.type ==StageItemType.INSTRUCTIONS) {
|
||||
} else if (si.type == StageItemType.INSTRUCTIONS) {
|
||||
((TourViewActivity) getSherlockActivity()).showHtmlFragment(si.header, tour.getInstructions());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
// createMenuItem(menu, ACTION_GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
|
||||
// MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
if (tour != null) {
|
||||
((TourViewActivity) getSherlockActivity()).createMenuItem(menu, START, R.string.start_tour,
|
||||
boolean current = customization.getSelectedTour() == tour;
|
||||
((TourViewActivity) getSherlockActivity()).createMenuItem(menu, START,
|
||||
current ? R.string.continue_tour : R.string.start_tour ,
|
||||
0, 0,
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
((TourViewActivity) getSherlockActivity()).createMenuItem(menu, SHARE_ID, R.string.share_fav,
|
||||
|
@ -113,12 +108,12 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == SHARE_ID) {
|
||||
if (item.getItemId() == SHARE_ID) {
|
||||
ShareDialog sd = new ShareDialog(getActivity());
|
||||
if(this.tour.getHomeUrl().equals("")) {
|
||||
if (this.tour.getHomeUrl().equals("")) {
|
||||
sd.shareURLOrText(null, this.tour.getName(), null);
|
||||
} else {
|
||||
sd.shareURLOrText(this.tour.getHomeUrl(), this.tour.getName() + " " + this.tour.getHomeUrl(), null);
|
||||
|
@ -128,8 +123,7 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
@ -138,15 +132,15 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
imageView.setScaleType(ScaleType.CENTER_CROP);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
List<StageItem> items = new ArrayList<SherpafyTourFragment.StageItem>();
|
||||
items.add(new StageItem(StageItemType.TEXT, "", getString(R.string.sherpafy_tour_info_txt), false));
|
||||
items.add(new StageItem(StageItemType.OVERVIEW, getString(R.string.sherpafy_overview),
|
||||
items.add(new StageItem(StageItemType.OVERVIEW, getString(R.string.sherpafy_overview),
|
||||
getString(R.string.sherpafy_overview_desr), false));
|
||||
items.add(new StageItem(StageItemType.INSTRUCTIONS, getString(R.string.sherpafy_instructions),
|
||||
items.add(new StageItem(StageItemType.INSTRUCTIONS, getString(R.string.sherpafy_instructions),
|
||||
getString(R.string.sherpafy_instructions_desr), false));
|
||||
items.add(new StageItem(StageItemType.GALLERY, getString(R.string.sherpafy_gallery),
|
||||
getString(R.string.sherpafy_gallery_descr), false));
|
||||
|
@ -158,21 +152,19 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
}
|
||||
stageAdapter = new StageAdapter(items);
|
||||
imageView.setImageBitmap(tour.getImageBitmap());
|
||||
if(imageView != null) {
|
||||
if (imageView != null) {
|
||||
getListView().addHeaderView(imageView);
|
||||
}
|
||||
setListAdapter(stageAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
setListAdapter(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class StageAdapter extends ArrayAdapter<StageItem> {
|
||||
|
||||
public StageAdapter(List<StageItem> list) {
|
||||
|
@ -191,7 +183,7 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
ImageView img = (ImageView) row.findViewById(R.id.Icon);
|
||||
TextView text = (TextView) row.findViewById(R.id.Text);
|
||||
TextView addtext = (TextView) row.findViewById(R.id.AdditionalText);
|
||||
|
||||
|
||||
if (ti.type instanceof StageInformation) {
|
||||
double d = ((StageInformation) ti.type).getDistance();
|
||||
if (d > 0) {
|
||||
|
@ -202,13 +194,13 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
} else {
|
||||
addtext.setText("");
|
||||
}
|
||||
if(Algorithms.isEmpty(ti.header)) {
|
||||
if (Algorithms.isEmpty(ti.header)) {
|
||||
header.setVisibility(View.GONE);
|
||||
} else {
|
||||
header.setVisibility(View.VISIBLE);
|
||||
header.setText(ti.header);
|
||||
}
|
||||
if(Algorithms.isEmpty(ti.txt)) {
|
||||
if (Algorithms.isEmpty(ti.txt)) {
|
||||
text.setVisibility(View.GONE);
|
||||
} else {
|
||||
text.setVisibility(View.VISIBLE);
|
||||
|
@ -219,26 +211,25 @@ public class SherpafyTourFragment extends SherlockListFragment {
|
|||
text.setTextColor(StageImageDrawable.MENU_COLOR);
|
||||
}
|
||||
}
|
||||
if(ti.type == StageItemType.TEXT){
|
||||
if (ti.type == StageItemType.TEXT) {
|
||||
img.setVisibility(View.GONE);
|
||||
img.setImageDrawable(null);
|
||||
} else if(ti.type instanceof StageInformation) {
|
||||
} else if (ti.type instanceof StageInformation) {
|
||||
StageInformation si = (StageInformation) ti.type;
|
||||
img.setVisibility(View.VISIBLE);
|
||||
img.setImageDrawable(new StageImageDrawable(getActivity(),
|
||||
StageImageDrawable.STAGE_COLOR, (si.getOrder() + 1) +"", 0 ));
|
||||
img.setImageDrawable(new StageImageDrawable(getActivity(), StageImageDrawable.STAGE_COLOR, (si
|
||||
.getOrder() + 1) + "", 0));
|
||||
} else {
|
||||
img.setVisibility(View.VISIBLE);
|
||||
img.setImageDrawable(new StageImageDrawable(getActivity(),
|
||||
StageImageDrawable.INFO_COLOR, ti.header.substring(0, 1) +"", 0 ));
|
||||
img.setImageDrawable(new StageImageDrawable(getActivity(), StageImageDrawable.INFO_COLOR, ti.header
|
||||
.substring(0, 1) + "", 0));
|
||||
}
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -97,14 +97,17 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
|
||||
displaySize = new Point();
|
||||
getWindowManager().getDefaultDisplay().getSize(displaySize);
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, new SherpafyLoadingFragment())
|
||||
.commit();
|
||||
if (getMyApplication().isApplicationInitializing()) {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, new SherpafyLoadingFragment()).commit();
|
||||
} else {
|
||||
showSelectedItem();
|
||||
}
|
||||
|
||||
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light,
|
||||
R.string.default_buttons_other_actions, R.string.close);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ArrayAdapter<Object> setupAdapter() {
|
||||
return new ArrayAdapter<Object>(this, R.layout.sherpafy_drawer_list_item){
|
||||
|
@ -202,7 +205,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
}
|
||||
|
||||
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
if (item.getItemId() == android.R.id.home && mDrawerToggle.isDrawerIndicatorEnabled()) {
|
||||
if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
|
||||
mDrawerLayout.closeDrawer(mDrawerList);
|
||||
} else {
|
||||
|
@ -223,6 +226,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
fragments.put(item, fragment);
|
||||
}
|
||||
state = STATE_SELECT_TOUR;
|
||||
setDrawerIndicatorVisible(true);
|
||||
} else if(item instanceof TourInformation) {
|
||||
state = STATE_TOUR_VIEW;
|
||||
if (fragment == null) {
|
||||
|
@ -232,6 +236,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
fragment.setArguments(bl);
|
||||
fragments.put(item, fragment);
|
||||
}
|
||||
setDrawerIndicatorVisible(true);
|
||||
} else if(item instanceof StageInformation) {
|
||||
state = STATE_STAGE_OVERVIEW;
|
||||
if (fragment == null) {
|
||||
|
@ -242,6 +247,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
fragment.setArguments(bl);
|
||||
fragments.put(item, fragment);
|
||||
}
|
||||
setDrawerIndicatorVisible(false);
|
||||
}
|
||||
if(fragment != null) {
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
|
||||
|
@ -273,11 +279,29 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
}
|
||||
updateActionBarTitle();
|
||||
}
|
||||
|
||||
private void setDrawerIndicatorVisible(boolean b) {
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(b);
|
||||
}
|
||||
|
||||
|
||||
public void showSelectedItem() {
|
||||
if(selectedItem == null) {
|
||||
selectMenu(selectedItem);
|
||||
} else {
|
||||
if(customization.getSelectedStage() != null) {
|
||||
selectMenu(customization.getSelectedStage());
|
||||
} else if(customization.getSelectedTour() != null) {
|
||||
selectMenu(customization.getSelectedTour());
|
||||
} else {
|
||||
selectMenu(R.string.sherpafy_tours);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showHtmlFragment(String title, String cont) {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
setDrawerIndicatorVisible(false);
|
||||
SherpafyHtmlFragment fragment = new SherpafyHtmlFragment();
|
||||
Bundle bl = new Bundle();
|
||||
bl.putString(SherpafyHtmlFragment.HTML, cont);
|
||||
|
|
Loading…
Reference in a new issue