Add share action

This commit is contained in:
Shinokuni 2019-02-12 09:27:16 +00:00
parent 9bf6e2613f
commit d2a6617311
5 changed files with 17 additions and 30 deletions

View File

@ -3,24 +3,17 @@ package com.readrops.app;
import android.arch.lifecycle.ViewModelProvider;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.ShareActionProvider;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@ -31,16 +24,6 @@ import com.readrops.app.utils.DateUtils;
import com.readrops.app.utils.GlideApp;
import com.readrops.app.utils.ReadropsWebView;
import com.readrops.app.utils.Utils;
import com.readrops.readropslibrary.Utils.LibUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import okhttp3.internal.Util;
public class ItemActivity extends AppCompatActivity {
@ -62,7 +45,6 @@ public class ItemActivity extends AppCompatActivity {
private ItemWithFeed itemWithFeed;
private ShareActionProvider shareActionProvider;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -141,7 +123,7 @@ public class ItemActivity extends AppCompatActivity {
}
if (item.getReadTime() > 0) {
int minutes = (int)Math.round(item.getReadTime());
int minutes = (int) Math.round(item.getReadTime());
if (minutes < 1)
readTime.setText(getResources().getString(R.string.read_time_lower_than_1));
else if (minutes > 1)
@ -173,9 +155,6 @@ public class ItemActivity extends AppCompatActivity {
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.item_menu, menu);
MenuItem menuItem = menu.findItem(R.id.item_share);
shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
return true;
}
@ -183,9 +162,16 @@ public class ItemActivity extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.item_share:
//shareActionProvider.set
break;
shareArticle();
return true;
}
return super.onOptionsItemSelected(item);
}
private void shareArticle() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, itemWithFeed.getItem().getTitle() + " - " + itemWithFeed.getItem().getLink());
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
}
}

View File

@ -6,8 +6,7 @@
android:id="@+id/item_share"
android:title="@string/share"
android:icon="@drawable/ic_share_white"
app:showAsAction="ifRoom"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
app:showAsAction="ifRoom" />
</menu>

View File

@ -20,6 +20,6 @@
<string name="read_time">%1$s min</string>
<string name="read_time_lower_than_1">Moins d\'une minute</string>
<string name="read_time_one_minute">1 min</string>
<string name="share">Partager</string>
<string name="share">Partager l\'article</string>
</resources>

View File

@ -22,5 +22,5 @@
<string name="read_time_lower_than_1">Less than a minute</string>
<string name="read_time_one_minute">1 min</string>
<string name="interpoint" translatable="false">·</string>
<string name="share">Share</string>
<string name="share">Share Article</string>
</resources>

View File

@ -1,5 +1,7 @@
package com.readrops.app;
import com.readrops.app.utils.DateUtils;
import org.joda.time.LocalDateTime;
import org.junit.Test;
@ -24,7 +26,7 @@ public class ExampleUnitTest {
try {
// RSS
assertTrue(dateTime.compareTo(DateUtils.stringToDateTime("Fri, 04 Jan 2019 22:21:46 +0000", DateUtils.RSS_DATE_FORMAT)) == 0);
assertTrue(dateTime.compareTo(DateUtils.stringToDateTime("Fri, 04 Jan 2019 22:21:46 +0000", DateUtils.RSS_2_DATE_FORMAT)) == 0);
// ATOM
assertTrue(dateTime.compareTo(DateUtils.stringToDateTime("2019-01-04T22:21:46+00:00", DateUtils.ATOM_JSON_DATE_FORMAT)) == 0);