Reimplementing CrytpoNews in Native Android(UPDATE #4: Share News Functionality)

The aim of the app is to fetch news from different wordpress websites and display in the application. While the news are displayed, the app gives you the ability to click and view each news within the app. Instead of taking you out of the app, it gives you the comfort of viewing within the app.

History

Previous Update

New Update

  • Share news post

The Share feature was added to make the application interactive and flexible. This makes users get to share interesting crypto news to anyone they wish to instead of manually copying the link from the website (i.e going to the website which is outside the app). Of course, users would like to do this at their comfort in the app.

This is how it was implemented

  • Firstly, the share icon was added to the menu_news_webpage.xml file. This is the icon that will help a user trigger an action to share.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".NewsWebPageActivity">
    <item
        android:id="@+id/action_share"
        android:orderInCategory="100"
        android:title="@string/share"
        android:icon="@mipmap/share_icon"
        app:showAsAction="always" />
</menu>
  • Secondly, in the NewsWebPageActivity.java file, an intent is triggered to share the post with some attributes like subject and text of the post. Accompanied by a post sent, the title with url is displayed to a user before clicking to have a clue of what the post is about.
@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_share) {

            Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
            sharingIntent.setType("text/plain");
            String shareBody = title + " " + url;
            sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
            sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
            startActivity(Intent.createChooser(sharingIntent, "Share via"));

            return true;
        }

Resources

  • Github Pull Request- Link of PR can be found here
  • Apk for download - Download here

Roadmap

  • Searching all news
  • Persisting user news
  • Providing different layouts
  • Providing different themes for user
  • Push Notifications
  • News Posts sharing
  • Incorporating more news and giving the user the flexibility of deciding what he wants to read per time.



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center