Fix rss 2.0 creator tag support and add it to the item activity

This commit is contained in:
Shinokuni 2019-02-08 15:12:12 +00:00
parent 8bf62465ff
commit cc88fc8334
4 changed files with 25 additions and 10 deletions

View File

@ -10,11 +10,13 @@ import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.readrops.app.database.ItemWithFeed;
import com.readrops.app.database.entities.Item; import com.readrops.app.database.entities.Item;
import com.readrops.app.utils.GlideApp; import com.readrops.app.utils.GlideApp;
import com.readrops.app.utils.ReadropsWebView; import com.readrops.app.utils.ReadropsWebView;
@ -35,6 +37,10 @@ public class ItemActivity extends AppCompatActivity {
private TextView author; private TextView author;
private TextView readTime; private TextView readTime;
private CollapsingToolbarLayout toolbarLayout;
private ReadropsWebView webView;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -50,7 +56,7 @@ public class ItemActivity extends AppCompatActivity {
if (getSupportActionBar() != null) if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CollapsingToolbarLayout toolbarLayout = findViewById(R.id.collapsing_layout); toolbarLayout = findViewById(R.id.collapsing_layout);
AppBarLayout appBarLayout = findViewById(R.id.app_bar_layout); AppBarLayout appBarLayout = findViewById(R.id.app_bar_layout);
if (imageUrl == null) if (imageUrl == null)
appBarLayout.setExpanded(false); appBarLayout.setExpanded(false);
@ -61,20 +67,26 @@ public class ItemActivity extends AppCompatActivity {
.load(imageUrl) .load(imageUrl)
.into(imageView); .into(imageView);
ReadropsWebView webView = findViewById(R.id.item_webview); webView = findViewById(R.id.item_webview);
title = findViewById(R.id.activity_item_title); title = findViewById(R.id.activity_item_title);
author = findViewById(R.id.activity_item_author); author = findViewById(R.id.activity_item_author);
readTime = findViewById(R.id.activity_item_readtime); readTime = findViewById(R.id.activity_item_readtime);
viewModel = ViewModelProvider.AndroidViewModelFactory.getInstance(getApplication()).create(ItemViewModel.class); viewModel = ViewModelProvider.AndroidViewModelFactory.getInstance(getApplication()).create(ItemViewModel.class);
viewModel.getItemById(itemId).observe(this, itemWithFeed -> { viewModel.getItemById(itemId).observe(this, this::bindUI);
Item item = itemWithFeed.getItem(); }
toolbarLayout.setTitle(itemWithFeed.getFeedName()); private void bindUI(ItemWithFeed itemWithFeed) {
toolbar.setTitle(itemWithFeed.getFeedName()); Item item = itemWithFeed.getItem();
title.setText(item.getTitle());
webView.setItem(itemWithFeed); toolbarLayout.setTitle(itemWithFeed.getFeedName());
}); title.setText(item.getTitle());
if (item.getAuthor() != null) {
author.setText(getString(R.string.by_author, item.getAuthor()));
author.setVisibility(View.VISIBLE);
}
webView.setItem(itemWithFeed);
} }
} }

View File

@ -16,5 +16,6 @@
<string name="add_feed_no_result">Aucune adresse de flux trouvée</string> <string name="add_feed_no_result">Aucune adresse de flux trouvée</string>
<string name="add_feed_connexion_error">Erreur de connexion au site</string> <string name="add_feed_connexion_error">Erreur de connexion au site</string>
<string name="add_feed_unknownhost_error">Site inconnu</string> <string name="add_feed_unknownhost_error">Site inconnu</string>
<string name="by_author">par %1$s</string>
</resources> </resources>

View File

@ -17,4 +17,5 @@
<string name="add_feed_no_result">No feed url found</string> <string name="add_feed_no_result">No feed url found</string>
<string name="add_feed_connexion_error">Connection error</string> <string name="add_feed_connexion_error">Connection error</string>
<string name="add_feed_unknownhost_error">Unknown host</string> <string name="add_feed_unknownhost_error">Unknown host</string>
<string name="by_author">by %1$s</string>
</resources> </resources>

View File

@ -25,7 +25,8 @@ public class RSSItem extends AItem {
@Namespace(prefix = "media") @Namespace(prefix = "media")
private RSSMediaContent mediaContent; private RSSMediaContent mediaContent;
@Element(name = "author", required = false) @Element(name = "creator", required = false)
@Namespace(prefix = "dc", reference = "http://purl.org/dc/elements/1.1/")
private String author; private String author;
@Element(name = "pubDate", required = false) @Element(name = "pubDate", required = false)