Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9418002cb7
12 changed files with 156 additions and 91 deletions
|
@ -143,7 +143,7 @@ public class AmenityMenuController extends MenuController {
|
|||
Map<String, String> additionalInfo = amenity.getAdditionalInfo();
|
||||
if (additionalInfo != null) {
|
||||
String ref = additionalInfo.get("ref");
|
||||
if (!TextUtils.isEmpty(ref)) {
|
||||
if (!TextUtils.isEmpty(ref) && !ref.equals(name)) {
|
||||
return name + " (" + ref + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -531,9 +531,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||
searchQuery += " ";
|
||||
String newQueryText = searchQuery + " ";
|
||||
searchEditText.setText(newQueryText);
|
||||
searchEditText.setSelection(newQueryText.length());
|
||||
AndroidUtils.hideSoftKeyboard(getActivity(), searchEditText);
|
||||
runSearch();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -11,7 +11,8 @@ import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
|
||||
public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragment {
|
||||
public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = WikivoyageShowPicturesDialogFragment.class.getSimpleName();
|
||||
|
||||
public static final int SHOW_PICTURES_CHANGED = 1;
|
||||
|
@ -21,38 +22,38 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFrag
|
|||
|
||||
View view = inflater.inflate(R.layout.fragment_wikivoyage_show_images_first_time, container, false);
|
||||
view.findViewById(R.id.button_no).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.OFF);
|
||||
}
|
||||
sendResult();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.OFF);
|
||||
}
|
||||
sendResult();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.button_wifi).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.WIFI);
|
||||
}
|
||||
sendResult();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.WIFI);
|
||||
}
|
||||
sendResult();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.button_yes).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.ON);
|
||||
}
|
||||
sendResult();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
app.getSettings().WIKIVOYAGE_SHOW_IMAGES.set(WikivoyageShowImages.ON);
|
||||
}
|
||||
sendResult();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -25,16 +25,16 @@ import java.net.URLDecoder;
|
|||
public class WikivoyageWebViewClient extends WebViewClient {
|
||||
|
||||
private OsmandApplication app;
|
||||
private FragmentManager mFragmentManager;
|
||||
private Context mContext;
|
||||
private FragmentManager fragmentManager;
|
||||
private Context context;
|
||||
|
||||
private static final String PAGE_PREFIX = "https://";
|
||||
private static final String WEB_DOMAIN = ".wikivoyage.com/wiki/";
|
||||
|
||||
public WikivoyageWebViewClient(FragmentActivity context, FragmentManager fm) {
|
||||
app = (OsmandApplication) context.getApplication();
|
||||
mFragmentManager = fm;
|
||||
mContext = context;
|
||||
fragmentManager = fm;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,8 +50,7 @@ public class WikivoyageWebViewClient extends WebViewClient {
|
|||
}
|
||||
long articleId = app.getTravelDbHelper().getArticleId(articleName, lang);
|
||||
if (articleId != 0) {
|
||||
WikivoyageArticleDialogFragment.showInstance(app, mFragmentManager,
|
||||
articleId, lang);
|
||||
WikivoyageArticleDialogFragment.showInstance(app, fragmentManager, articleId, lang);
|
||||
} else {
|
||||
warnAboutExternalLoad(url);
|
||||
}
|
||||
|
@ -62,17 +61,17 @@ public class WikivoyageWebViewClient extends WebViewClient {
|
|||
}
|
||||
|
||||
private void warnAboutExternalLoad(final String url) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
||||
builder.setTitle(url);
|
||||
builder.setMessage(R.string.online_webpage_warning);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
mContext.startActivity(i);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.show();
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(url)
|
||||
.setMessage(R.string.online_webpage_warning)
|
||||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
context.startActivity(i);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,9 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
|||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
Context ctx = getContext();
|
||||
Bundle args = getArguments();
|
||||
if (args == null) {
|
||||
if (ctx == null || args == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,11 +55,9 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
|||
|
||||
items.add(new TitleItem(getString(R.string.shared_string_contents)));
|
||||
|
||||
expListView = new ExpandableListView(getContext());
|
||||
ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), contentItem);
|
||||
|
||||
expListView.setAdapter(listAdapter);
|
||||
Drawable transparent = ContextCompat.getDrawable(getContext(), R.color.color_transparent);
|
||||
Drawable transparent = ContextCompat.getDrawable(ctx, R.color.color_transparent);
|
||||
expListView = new ExpandableListView(ctx);
|
||||
expListView.setAdapter(new ExpandableListAdapter(ctx, contentItem));
|
||||
expListView.setDivider(transparent);
|
||||
expListView.setGroupIndicator(transparent);
|
||||
expListView.setSelector(transparent);
|
||||
|
@ -70,7 +69,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
|||
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
||||
@Override
|
||||
public boolean onChildClick(ExpandableListView parent, View v,
|
||||
int groupPosition, int childPosition, long id) {
|
||||
int groupPosition, int childPosition, long id) {
|
||||
WikivoyageContentItem wikivoyageContentItem = contentItem.getSubItems().get(groupPosition);
|
||||
String link = wikivoyageContentItem.getSubItems().get(childPosition).getLink();
|
||||
String name = wikivoyageContentItem.getLink().substring(1);
|
||||
|
@ -90,18 +89,19 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
|||
return true;
|
||||
}
|
||||
});
|
||||
LinearLayout container = new LinearLayout(getContext());
|
||||
|
||||
LinearLayout container = new LinearLayout(ctx);
|
||||
container.addView(expListView);
|
||||
|
||||
items.add(new SimpleBottomSheetItem.Builder().setCustomView(container).create());
|
||||
}
|
||||
|
||||
private void sendResults(String link, String name) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(CONTENTS_LINK_KEY, link);
|
||||
intent.putExtra(CONTENTS_TITLE_KEY, name);
|
||||
Fragment fragment = getTargetFragment();
|
||||
if (fragment != null) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(CONTENTS_LINK_KEY, link);
|
||||
intent.putExtra(CONTENTS_TITLE_KEY, name);
|
||||
fragment.onActivityResult(getTargetRequestCode(), REQUEST_LINK_CODE, intent);
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
|||
|
||||
@Override
|
||||
public View getGroupView(final int groupPosition, final boolean isExpanded,
|
||||
View convertView, ViewGroup parent) {
|
||||
View convertView, ViewGroup parent) {
|
||||
String headerTitle = (String) getGroup(groupPosition);
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(context)
|
||||
|
@ -216,7 +216,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
|||
indicator.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(isExpanded){
|
||||
if (isExpanded) {
|
||||
expListView.collapseGroup(groupPosition);
|
||||
} else {
|
||||
expListView.expandGroup(groupPosition);
|
||||
|
|
|
@ -24,8 +24,6 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
||||
|
@ -107,7 +105,6 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
|
||||
private TextView articleToolbarText;
|
||||
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Nullable
|
||||
@Override
|
||||
|
@ -124,7 +121,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container);
|
||||
|
||||
setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar));
|
||||
|
||||
|
||||
articleToolbarText = (TextView) mainView.findViewById(R.id.article_toolbar_text);
|
||||
ColorStateList selectedLangColorStateList = AndroidUtils.createPressedColorStateList(
|
||||
getContext(), nightMode,
|
||||
|
@ -164,8 +161,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
fragment.show(fm, WikivoyageArticleContentsFragment.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
trackButton = (TextView) mainView.findViewById(R.id.gpx_button);
|
||||
trackButton.setCompoundDrawablesWithIntrinsicBounds(
|
||||
getActiveIcon(R.drawable.ic_action_track_16), null, null, null
|
||||
|
@ -216,7 +212,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
String link = data.getStringExtra(WikivoyageArticleContentsFragment.CONTENTS_LINK_KEY);
|
||||
String title = data.getStringExtra(WikivoyageArticleContentsFragment.CONTENTS_TITLE_KEY);
|
||||
moveToAnchor(link, title);
|
||||
} else if (requestCode == WikivoyageShowPicturesDialogFragment.SHOW_PICTURES_CHANGED) {
|
||||
} else if (requestCode == WikivoyageShowPicturesDialogFragment.SHOW_PICTURES_CHANGED) {
|
||||
updateWebSettings();
|
||||
populateArticle();
|
||||
}
|
||||
|
@ -327,8 +323,8 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
return;
|
||||
}
|
||||
articleToolbarText.setText(article.getTitle());
|
||||
if(article.getGpxFile() != null) {
|
||||
trackButton.setText(getString(R.string.points) + " (" + article.getGpxFile().getPointsSize() +")");
|
||||
if (article.getGpxFile() != null) {
|
||||
trackButton.setText(getString(R.string.points) + " (" + article.getGpxFile().getPointsSize() + ")");
|
||||
}
|
||||
|
||||
TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.wikivoyage.data;
|
|||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import net.osmand.Collator;
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
|
@ -9,9 +10,9 @@ import net.osmand.IndexConstants;
|
|||
import net.osmand.OsmAndCollator;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -71,12 +72,14 @@ public class TravelDbHelper {
|
|||
private static final String SEARCH_COL_LANG = "lang";
|
||||
|
||||
private final OsmandApplication application;
|
||||
|
||||
private TravelLocalDataHelper localDataHelper;
|
||||
private Collator collator;
|
||||
|
||||
private SQLiteConnection connection = null;
|
||||
|
||||
private File selectedTravelBook = null;
|
||||
private List<File> existingTravelBooks = new ArrayList<>();
|
||||
private Collator collator;
|
||||
private TravelLocalDataHelper localDataHelper;
|
||||
|
||||
|
||||
public TravelDbHelper(OsmandApplication application) {
|
||||
this.application = application;
|
||||
|
@ -92,7 +95,7 @@ public class TravelDbHelper {
|
|||
File[] possibleFiles = application.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles();
|
||||
String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get();
|
||||
existingTravelBooks.clear();
|
||||
if (possibleFiles != null) {
|
||||
if (possibleFiles != null && possibleFiles.length > 0) {
|
||||
for (File f : possibleFiles) {
|
||||
if (f.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {
|
||||
existingTravelBooks.add(f);
|
||||
|
@ -103,6 +106,8 @@ public class TravelDbHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedTravelBook = null;
|
||||
}
|
||||
localDataHelper.refreshCachedData();
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
|||
Object item = getItemByPosition();
|
||||
if (item != null && item instanceof TravelArticle) {
|
||||
final TravelArticle article = (TravelArticle) item;
|
||||
final TravelLocalDataHelper ldh = app.getTravelDbHelper().getLocalDataHelper();;
|
||||
final TravelLocalDataHelper ldh = app.getTravelDbHelper().getLocalDataHelper();
|
||||
ldh.removeArticleFromSaved(article);
|
||||
Snackbar snackbar = Snackbar.make(itemView, R.string.article_removed, Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
||||
|
|
|
@ -82,6 +82,12 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Trav
|
|||
diffRes.dispatchUpdatesTo(adapter);
|
||||
}
|
||||
|
||||
public void updateAdapter() {
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object> getItems() {
|
||||
List<Object> items = new ArrayList<>();
|
||||
List<TravelArticle> savedArticles = dataHelper.getSavedArticles();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.wikivoyage.explore;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -22,10 +23,10 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.PicassoUtils;
|
||||
import net.osmand.plus.LockableViewPager;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
||||
import net.osmand.plus.wikivoyage.search.WikivoyageSearchDialogFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -36,6 +37,9 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
private static final int EXPLORE_POSITION = 0;
|
||||
private static final int SAVED_ARTICLES_POSITION = 1;
|
||||
|
||||
private ExploreTabFragment exploreTabFragment;
|
||||
private SavedArticlesTabFragment savedArticlesTabFragment;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -48,6 +52,24 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
FragmentManager childFm = getChildFragmentManager();
|
||||
List<Fragment> fragments = childFm.getFragments();
|
||||
if (fragments != null) {
|
||||
for (Fragment fragment : fragments) {
|
||||
if (fragment instanceof ExploreTabFragment) {
|
||||
exploreTabFragment = (ExploreTabFragment) fragment;
|
||||
} else if (fragment instanceof SavedArticlesTabFragment) {
|
||||
savedArticlesTabFragment = (SavedArticlesTabFragment) fragment;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exploreTabFragment == null) {
|
||||
exploreTabFragment = new ExploreTabFragment();
|
||||
}
|
||||
if (savedArticlesTabFragment == null) {
|
||||
savedArticlesTabFragment = new SavedArticlesTabFragment();
|
||||
}
|
||||
|
||||
final View mainView = inflate(R.layout.fragment_wikivoyage_explore_dialog, container);
|
||||
|
||||
setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar));
|
||||
|
@ -55,9 +77,15 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm == null) {
|
||||
return;
|
||||
}
|
||||
WikivoyageOptionsBottomSheetDialogFragment fragment = new WikivoyageOptionsBottomSheetDialogFragment();
|
||||
fragment.setUsedOnMap(false);
|
||||
fragment.show(getChildFragmentManager(), WikivoyageOptionsBottomSheetDialogFragment.TAG);
|
||||
fragment.setTargetFragment(WikivoyageExploreDialogFragment.this,
|
||||
WikivoyageOptionsBottomSheetDialogFragment.REQUEST_CODE);
|
||||
fragment.show(fm, WikivoyageOptionsBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -76,7 +104,7 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
final LockableViewPager viewPager = (LockableViewPager) mainView.findViewById(R.id.view_pager);
|
||||
viewPager.setOffscreenPageLimit(2);
|
||||
viewPager.setSwipeLocked(true);
|
||||
viewPager.setAdapter(new ViewPagerAdapter(getChildFragmentManager()));
|
||||
viewPager.setAdapter(new ViewPagerAdapter(childFm));
|
||||
|
||||
final ColorStateList navColorStateList = createBottomNavColorStateList();
|
||||
final BottomNavigationView bottomNav = (BottomNavigationView) mainView.findViewById(R.id.bottom_navigation);
|
||||
|
@ -105,6 +133,19 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == WikivoyageOptionsBottomSheetDialogFragment.REQUEST_CODE) {
|
||||
if (resultCode == WikivoyageOptionsBottomSheetDialogFragment.DOWNLOAD_IMAGES_CHANGED
|
||||
|| resultCode == WikivoyageOptionsBottomSheetDialogFragment.CACHE_CLEARED) {
|
||||
if (savedArticlesTabFragment != null) {
|
||||
savedArticlesTabFragment.updateAdapter();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ColorStateList createBottomNavColorStateList() {
|
||||
return AndroidUtils.createCheckedColorStateList(getContext(), nightMode,
|
||||
R.color.icon_color, R.color.wikivoyage_active_light,
|
||||
|
@ -121,13 +162,12 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
}
|
||||
}
|
||||
|
||||
private static class ViewPagerAdapter extends FragmentPagerAdapter {
|
||||
private class ViewPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private final List<Fragment> fragments = new ArrayList<>();
|
||||
private final List<BaseOsmAndFragment> fragments = Arrays.asList(exploreTabFragment, savedArticlesTabFragment);
|
||||
|
||||
ViewPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
fragments.addAll(Arrays.asList(new ExploreTabFragment(), new SavedArticlesTabFragment()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package net.osmand.plus.wikivoyage.explore;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.Gravity;
|
||||
|
@ -31,6 +33,10 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
|||
|
||||
public final static String TAG = "WikivoyageOptionsBottomSheetDialogFragment";
|
||||
|
||||
public static final int REQUEST_CODE = 0;
|
||||
public static final int DOWNLOAD_IMAGES_CHANGED = 1;
|
||||
public static final int CACHE_CLEARED = 2;
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
|
@ -65,7 +71,6 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
|||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
final PopupMenu popup = new PopupMenu(v.getContext(), v, Gravity.END);
|
||||
for (final WikivoyageShowImages showImages : WikivoyageShowImages.values()) {
|
||||
MenuItem item = popup.getMenu().add(getString(showImages.name));
|
||||
|
@ -73,12 +78,12 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
|||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
showImagesPref.set(showImages);
|
||||
sendResult(DOWNLOAD_IMAGES_CHANGED);
|
||||
dismiss();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
popup.show();
|
||||
}
|
||||
})
|
||||
|
@ -95,6 +100,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
|||
public void onClick(View v) {
|
||||
new WebView(getContext()).clearCache(true);
|
||||
PicassoUtils.clearAllPicassoCache();
|
||||
sendResult(CACHE_CLEARED);
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
|
@ -119,7 +125,19 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
|||
items.add(clearHistoryItem);
|
||||
}
|
||||
|
||||
protected void selectTravelBookDialog() {
|
||||
private void sendResult(int resultCode) {
|
||||
Fragment fragment = getTargetFragment();
|
||||
if (fragment != null) {
|
||||
fragment.onActivityResult(getTargetRequestCode(), resultCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void selectTravelBookDialog() {
|
||||
Context ctx = getContext();
|
||||
if (ctx == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final TravelDbHelper dbHelper = getMyApplication().getTravelDbHelper();
|
||||
final List<File> list = dbHelper.getExistingTravelBooks();
|
||||
String[] ls = new String[list.size()];
|
||||
|
@ -127,7 +145,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
|||
ls[i] = dbHelper.formatTravelBookName(list.get(i));
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(getContext())
|
||||
new AlertDialog.Builder(ctx)
|
||||
.setTitle(R.string.select_travel_book)
|
||||
.setItems(ls, new OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.picasso.NetworkPolicy;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestCreator;
|
||||
|
||||
|
|
Loading…
Reference in a new issue