Skip to content

Commit

Permalink
Fix #604 and #591 - Add option to choose which browser to use
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Development committed Jan 28, 2018
1 parent 7fedff5 commit 7aea76c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
package de.luhmer.owncloudnewsreader;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.customtabs.CustomTabsIntent;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
Expand Down Expand Up @@ -233,13 +236,29 @@ private void init_webView() {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(ContextCompat.getColor(getActivity(), R.color.colorPrimaryDarkTheme));
builder.setShowTitle(true);
builder.setStartAnimations(getActivity(), R.anim.slide_in_right, R.anim.slide_out_left);
builder.setExitAnimations(getActivity(), R.anim.slide_in_left, R.anim.slide_out_right);
builder.build().launchUrl(getActivity(), Uri.parse(url));
return true;
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
int selectedBrowser = Integer.parseInt(mPrefs.getString(SettingsActivity.SP_DISPLAY_BROWSER, "0"));

boolean result = true;
switch(selectedBrowser) {
case 0: // Custom Tabs
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(ContextCompat.getColor(getActivity(), R.color.colorPrimaryDarkTheme));
builder.setShowTitle(true);
builder.setStartAnimations(getActivity(), R.anim.slide_in_right, R.anim.slide_out_left);
builder.setExitAnimations(getActivity(), R.anim.slide_in_left, R.anim.slide_out_right);
builder.build().launchUrl(getActivity(), Uri.parse(url));
result = true;
break;
case 1: // External Browser
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
break;
case 2: // Built in
result = super.shouldOverrideUrlLoading(view, url);
break;
}
return result;
//return super.shouldOverrideUrlLoading(view, url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
public static final String SP_MAX_CACHE_SIZE = "sp_max_cache_size";
public static final String SP_TITLE_LINES_COUNT = "sp_title_lines_count";
public static final String SP_SORT_ORDER = "sp_sort_order";
public static final String SP_DISPLAY_BROWSER = "sp_display_browser";


//public static final String PREF_SIGN_IN_DIALOG = "sPref_signInDialog";
Expand Down Expand Up @@ -475,12 +476,14 @@ private static void bindDisplayPreferences(PreferenceFragment prefFrag, Preferen
bindPreferenceSummaryToValue(prefFrag.findPreference(SP_APP_THEME));
bindPreferenceSummaryToValue(prefFrag.findPreference(SP_FEED_LIST_LAYOUT));
bindPreferenceSummaryToValue(prefFrag.findPreference(SP_TITLE_LINES_COUNT));
bindPreferenceSummaryToValue(prefFrag.findPreference(SP_DISPLAY_BROWSER));
}
else
{
bindPreferenceSummaryToValue(prefAct.findPreference(SP_APP_THEME));
bindPreferenceSummaryToValue(prefAct.findPreference(SP_FEED_LIST_LAYOUT));
bindPreferenceSummaryToValue(prefAct.findPreference(SP_TITLE_LINES_COUNT));
bindPreferenceSummaryToValue(prefAct.findPreference(SP_DISPLAY_BROWSER));
}
}

Expand Down
14 changes: 14 additions & 0 deletions News-Android-App/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<string name="pref_title_app_theme">App theme</string>
<string name="pref_title_feed_list_layout">Feed list layout</string>
<string name="pref_display_title_lines_count">Line Count for title</string>
<string name="pref_display_browser">Browser</string>

<string name="pref_display_news_detail_actionbar_icons_title">Action icons (Detail View)</string>
<string-array name="pref_display_news_detail_actionbar_icons" translatable="false">
Expand Down Expand Up @@ -182,6 +183,18 @@
<item>2</item>
<item>1</item>
</string-array>

<string-array name="pref_display_browser">
<item>Built-in Chrome-Custom-Tabs</item>
<item>Built-in Browser</item>
<item>External browser</item>
</string-array>
<string-array name="pref_display_browser_values" translatable="false">
<item>0</item>
<item>2</item>
<item>1</item>
</string-array>

<string-array name="pref_display_feed_list_layout">
<item>Simple</item>
<item>Extended</item>
Expand Down Expand Up @@ -262,6 +275,7 @@
<item>5000</item>
<item>10000</item>
</string-array>

<string-array name="array_sync_interval">
<item>5 Minutes</item>
<item>15 Minutes</item>
Expand Down
10 changes: 8 additions & 2 deletions News-Android-App/src/main/res/xml/pref_display.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@
android:entryValues="@array/pref_display_feed_list_layout_values"
android:key="sp_feed_list_layout"
android:title="@string/pref_title_feed_list_layout" />


<ListPreference
android:defaultValue="2"
android:entries="@array/pref_title_lines_count"
android:entryValues="@array/pref_title_lines_count_values"
android:key="sp_title_lines_count"
android:title="@string/pref_display_title_lines_count" />

<ListPreference
android:defaultValue="0"
android:entries="@array/pref_display_browser"
android:entryValues="@array/pref_display_browser_values"
android:key="sp_display_browser"
android:title="@string/pref_display_browser" />

<MultiSelectListPreference
android:entries="@array/pref_display_news_detail_actionbar_icons"
Expand Down

0 comments on commit 7aea76c

Please sign in to comment.