Add preference to open item link in external navigator or webview
This commit is contained in:
parent
232a9f1efa
commit
097a5a7aae
@ -26,6 +26,7 @@ import com.readrops.app.database.pojo.ItemWithFeed;
|
||||
import com.readrops.app.utils.DateUtils;
|
||||
import com.readrops.app.utils.GlideApp;
|
||||
import com.readrops.app.utils.ReadropsWebView;
|
||||
import com.readrops.app.utils.SharedPreferencesManager;
|
||||
import com.readrops.app.utils.Utils;
|
||||
import com.readrops.app.viewmodels.ItemViewModel;
|
||||
|
||||
@ -113,7 +114,7 @@ public class ItemActivity extends AppCompatActivity {
|
||||
|
||||
viewModel = ViewModelProvider.AndroidViewModelFactory.getInstance(getApplication()).create(ItemViewModel.class);
|
||||
viewModel.getItemById(itemId).observe(this, this::bindUI);
|
||||
actionButton.setOnClickListener(v -> openLink());
|
||||
actionButton.setOnClickListener(v -> openInNavigator());
|
||||
}
|
||||
|
||||
private void bindUI(ItemWithFeed itemWithFeed) {
|
||||
@ -207,7 +208,12 @@ public class ItemActivity extends AppCompatActivity {
|
||||
shareArticle();
|
||||
return true;
|
||||
case R.id.item_open:
|
||||
openLink();
|
||||
int value = Integer.valueOf(SharedPreferencesManager.readString(this,
|
||||
SharedPreferencesManager.SharedPrefKey.OPEN_ITEMS_IN));
|
||||
if (value == 0)
|
||||
openInNavigator();
|
||||
else
|
||||
openInWebView();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
@ -219,11 +225,18 @@ public class ItemActivity extends AppCompatActivity {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private void openLink() {
|
||||
private void openInNavigator() {
|
||||
Intent urlIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(itemWithFeed.getItem().getLink()));
|
||||
startActivity(urlIntent);
|
||||
}
|
||||
|
||||
private void openInWebView() {
|
||||
Intent intent = new Intent(this, WebViewActivity.class);
|
||||
intent.putExtra(WebViewActivity.WEB_URL, itemWithFeed.getItem().getLink());
|
||||
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void shareArticle() {
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
|
@ -50,15 +50,16 @@ public final class SharedPreferencesManager {
|
||||
|
||||
public enum SharedPrefKey {
|
||||
SHOW_READ_ARTICLES("show_read_articles", false),
|
||||
ITEMS_TO_PARSE_MAX_NB("items_to_parse_max_nb", "20");
|
||||
ITEMS_TO_PARSE_MAX_NB("items_to_parse_max_nb", "20"),
|
||||
OPEN_ITEMS_IN("open_items_in", "0");
|
||||
|
||||
@NonNull
|
||||
private String key;
|
||||
@NonNull
|
||||
private Object defaultValue;
|
||||
|
||||
public Boolean getBooleanDefaultValue() {
|
||||
return (Boolean) defaultValue;
|
||||
public boolean getBooleanDefaultValue() {
|
||||
return (boolean) defaultValue;
|
||||
}
|
||||
|
||||
public String getStringDefaultValue() {
|
||||
|
@ -88,5 +88,8 @@
|
||||
<string name="feeds_colors">Couleurs des flux</string>
|
||||
<string name="global">Général</string>
|
||||
<string name="reload_feeds_colors">Recharger les couleurs des flux</string>
|
||||
<string name="open_items_in">Ouvrir les articles avec</string>
|
||||
<string name="webview">Vue web</string>
|
||||
<string name="external_navigator">Navigateur externe</string>
|
||||
|
||||
</resources>
|
@ -19,4 +19,14 @@
|
||||
<item>@string/unlimited</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="open_items_in">
|
||||
<item>@string/external_navigator</item>
|
||||
<item>@string/webview</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="open_item_in_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -96,4 +96,7 @@
|
||||
<string name="feeds_colors">Feeds Colors</string>
|
||||
<string name="global">Global</string>
|
||||
<string name="reload_feeds_colors">Reload feeds colors</string>
|
||||
<string name="open_items_in">Open items in</string>
|
||||
<string name="webview">Webview</string>
|
||||
<string name="external_navigator">External navigator</string>
|
||||
</resources>
|
||||
|
@ -14,6 +14,13 @@
|
||||
<Preference
|
||||
android:key="reload_feeds_colors"
|
||||
android:title="@string/reload_feeds_colors" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/external_navigator"
|
||||
android:entries="@array/open_items_in"
|
||||
android:entryValues="@array/open_item_in_values"
|
||||
android:key="open_items_in"
|
||||
android:title="@string/open_items_in" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user