Merge pull request #5490 from osmandapp/WikivoyageSharingLinks
Add popup for sharing article links
This commit is contained in:
commit
c62f0ae66c
2 changed files with 33 additions and 11 deletions
|
@ -54,15 +54,6 @@
|
|||
tools:text="En"
|
||||
tools:textColor="?attr/wikivoyage_active_color"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/options_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="top"
|
||||
android:contentDescription="@string/shared_string_options"
|
||||
tools:src="@drawable/ic_overflow_menu_white"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -34,6 +35,7 @@ import net.osmand.plus.activities.TrackActivity;
|
|||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.wikipedia.WikiArticleBaseDialogFragment;
|
||||
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
||||
import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment;
|
||||
import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
|
||||
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||
|
@ -61,6 +63,8 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
|
|||
|
||||
private static final String EMPTY_URL = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4//";
|
||||
|
||||
private static final int MENU_ITEM_SHARE = 0;
|
||||
|
||||
private long tripId = NO_VALUE;
|
||||
private ArrayList<String> langs;
|
||||
private String selectedLang;
|
||||
|
@ -426,4 +430,31 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
|
|||
fragmentManager.popBackStackImmediate(pop, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupToolbar(Toolbar toolbar) {
|
||||
super.setupToolbar(toolbar);
|
||||
toolbar.setOverflowIcon(getIcon(R.drawable.ic_overflow_menu_white, R.color.icon_color));
|
||||
|
||||
Menu menu = toolbar.getMenu();
|
||||
MenuItem.OnMenuItemClickListener itemClickListener = new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == MENU_ITEM_SHARE) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, WikiArticleHelper.buildTravelUrl(article.getTitle(), article.getLang()));
|
||||
intent.setType("text/plain");
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.shared_string_share)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
MenuItem itemShow = menu.add(0, MENU_ITEM_SHARE, 0, R.string.shared_string_share);
|
||||
itemShow.setOnMenuItemClickListener(itemClickListener);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue