add popup for sharing article links

This commit is contained in:
Chumva 2018-05-25 16:14:17 +03:00
parent cb6fe98a00
commit 2660d23d79
2 changed files with 32 additions and 11 deletions

View file

@ -54,15 +54,6 @@
tools:text="En" tools:text="En"
tools:textColor="?attr/wikivoyage_active_color"/> 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> </LinearLayout>
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>

View file

@ -16,6 +16,7 @@ import android.support.v7.widget.Toolbar;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -34,6 +35,7 @@ import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.wikipedia.WikiArticleBaseDialogFragment; import net.osmand.plus.wikipedia.WikiArticleBaseDialogFragment;
import net.osmand.plus.wikipedia.WikiArticleHelper;
import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment;
import net.osmand.plus.wikivoyage.WikivoyageWebViewClient; import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
import net.osmand.plus.wikivoyage.data.TravelArticle; 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 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 long tripId = NO_VALUE;
private ArrayList<String> langs; private ArrayList<String> langs;
private String selectedLang; private String selectedLang;
@ -426,4 +430,30 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
fragmentManager.popBackStackImmediate(pop, 0); fragmentManager.popBackStackImmediate(pop, 0);
} }
} }
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);
}
} }