New option: Link Handler. Removed option: Open Link In App.

This commit is contained in:
Alex Ning 2021-10-10 21:51:10 +08:00
parent d40b81d799
commit 43b9abd6ee
24 changed files with 37 additions and 30 deletions

View File

@ -298,10 +298,13 @@ public class LinkResolverActivity extends AppCompatActivity {
return;
}
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.OPEN_LINK_IN_APP, false)) {
int linkHandler = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.LINK_HANDLER, "0"));
if (linkHandler == 0) {
openInBrowser(uri, pm, true);
} else if (linkHandler == 1) {
openInCustomTabs(uri, pm, true);
} else {
openInBrowser(uri, pm, true);
openInWebView(uri);
}
}

View File

@ -1,5 +1,8 @@
package ml.docilealligator.infinityforreddit.settings;
import static android.app.Activity.RESULT_OK;
import static android.content.Intent.ACTION_OPEN_DOCUMENT_TREE;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@ -39,9 +42,6 @@ import ml.docilealligator.infinityforreddit.asynctasks.RestoreSettings;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import static android.app.Activity.RESULT_OK;
import static android.content.Intent.ACTION_OPEN_DOCUMENT_TREE;
/**
* A simple {@link Fragment} subclass.
*/
@ -230,6 +230,8 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
editor.remove(SharedPreferencesUtils.NSFW_KEY_LEGACY);
editor.remove(SharedPreferencesUtils.BLUR_NSFW_KEY_LEGACY);
editor.remove(SharedPreferencesUtils.BLUR_SPOILER_KEY_LEGACY);
editor.remove(SharedPreferencesUtils.CONFIRM_TO_EXIT_LEGACY);
editor.remove(SharedPreferencesUtils.OPEN_LINK_IN_APP_LEGACY);
SharedPreferences.Editor sortTypeEditor = mSortTypeSharedPreferences.edit();
sortTypeEditor.remove(SharedPreferencesUtils.SORT_TYPE_ALL_POST_LEGACY);

View File

@ -93,7 +93,7 @@ public class SharedPreferencesUtils {
public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments";
public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts";
public static final String MUTE_VIDEO = "mute_video";
public static final String OPEN_LINK_IN_APP = "open_link_in_app";
public static final String LINK_HANDLER = "link_handler";
public static final String VIDEO_AUTOPLAY = "video_autoplay";
public static final String VIDEO_AUTOPLAY_VALUE_ALWAYS_ON = "2";
public static final String VIDEO_AUTOPLAY_VALUE_ON_WIFI = "1";
@ -363,4 +363,5 @@ public class SharedPreferencesUtils {
public static final String BLUR_NSFW_KEY_LEGACY = "blur_nsfw";
public static final String BLUR_SPOILER_KEY_LEGACY = "blur_spoiler";
public static final String CONFIRM_TO_EXIT_LEGACY = "confirm_to_exit";
public static final String OPEN_LINK_IN_APP_LEGACY = "open_link_in_app";
}

View File

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_app_bar_bottom_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="48dp"
android:visibility="gone"
app:fabAlignmentMode="center">

View File

@ -311,7 +311,6 @@ Tippen für Neuversuch."</string>
<string name="settings_gestures_and_buttons_title">"Gesten &amp; Knöpfe"</string>
<string name="settings_save_front_page_scrolled_position_title">"Scrollposition in HOME speichern"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Neue Beitrage nach dem Aktualisieren von HOME anzeigen (Frontseite, Sortierung: Beste)"</string>
<string name="settings_open_link_in_app_title">"Link in App öffnen"</string>
<string name="settigns_video_title">"Video"</string>
<string name="settings_video_autoplay_title">"Videos automatisch abspielen"</string>
<string name="settings_mute_autoplaying_videos_title">"Automatisch abgespielte Videos stummschalten"</string>

View File

@ -318,7 +318,6 @@ Premio means prize, so it's better suited the first word instead of the second o
<string name="settings_gestures_and_buttons_title">"Gestos y Botones"</string>
<string name="settings_save_front_page_scrolled_position_title">"Guardar Posición en INICIO"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Ver nuevas publicaciones después de actualizar la página de INICIO (Página inicial, ordenar por: Lo mejor)"</string>
<string name="settings_open_link_in_app_title">"Abrir enlaces dentro de la App"</string>
<string name="settigns_video_title">"Vídeo"</string>
<string name="settings_video_autoplay_title">"Reproducción automática de Vídeo"</string>
<string name="settings_mute_autoplaying_videos_title">"Silenciar Videos reproducidos automáticamente"</string>

View File

@ -325,7 +325,6 @@ Appuyez pour réessayer."</string>
<string name="settings_gestures_and_buttons_title">"Gestes &amp; Boutons"</string>
<string name="settings_save_front_page_scrolled_position_title">"Sauvegarder la position défilée dans l'accueil"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Parcourir les nouveaux messages après actualisation dans l'accueil (Front Page, type de tri : Meilleur)"</string>
<string name="settings_open_link_in_app_title">"Ouvrir les lien dans l'application"</string>
<string name="settigns_video_title">"Vidéo"</string>
<!-- Fuzzy -->

View File

@ -330,7 +330,6 @@ Behavior -->
<string name="settings_gestures_and_buttons_title">"जैस्चर्स एवं बटन्स"</string>
<string name="settings_save_front_page_scrolled_position_title">"होम पर स्क्रौल की स्थिति स्थिर करें "</string>
<string name="settings_save_front_page_scrolled_position_summary">"होम में ताजा करने पर नई पोस्ट्स देखें (मुख पृष्ट, क्रम: श्रेष्ठ)"</string>
<string name="settings_open_link_in_app_title">"लिंक एप में खोलें "</string>
<string name="settigns_video_title">"वीडियो "</string>
<string name="settings_video_autoplay_title">"वीडियो स्वचालन"</string>
<string name="settings_mute_autoplaying_videos_title">"स्वचालित वीडियोज को मौन करें "</string>

View File

@ -279,7 +279,6 @@
<string name="settings_gestures_and_buttons_title">"Geste i tipke"</string>
<string name="settings_save_front_page_scrolled_position_title">"Spremi poziciju na NASLOVNICA"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Pregledavaj nove objave nakon osvježivanja u NASLOVNICA (Početna stranica, vrsta sortiranja: Najbolje)"</string>
<string name="settings_open_link_in_app_title">"Otvori poveznicu unutar aplikacije"</string>
<string name="settigns_video_title">"Video"</string>
<string name="settings_video_autoplay_title">"Automatsko pokretanje videozapisa"</string>
<string name="settings_mute_autoplaying_videos_title">"Automatski pokrenuti videozapisi bez zvuka"</string>

View File

@ -287,7 +287,6 @@
<string name="settings_gestures_and_buttons_title">"Gesztusok és gombok"</string>
<string name="settings_save_front_page_scrolled_position_title">"Görgetés pozíciójának mentése a Kezdőlapon"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Böngéssz új posztokat a Kezdőlap frissítése után (Kezdőlap, rendezés típusa: Legjobb)"</string>
<string name="settings_open_link_in_app_title">"Nyisd meg a linket appon belül"</string>
<string name="settigns_video_title">"Videó"</string>
<string name="settings_video_autoplay_title">"Videó autómatikus lejátszása"</string>
<string name="settings_mute_autoplaying_videos_title">"Autómatikusan lejátszó videók némítása"</string>

View File

@ -302,7 +302,6 @@ Tocca per riprovare."</string>
<string name="settings_gestures_and_buttons_title">"Gesti e pulsanti"</string>
<string name="settings_save_front_page_scrolled_position_title">"Salva posizione di scorrimento nella HOME"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Sfoglia i nuovi post dopo l'aggiornamento in HOME (pagina iniziale, tipo di ordinamento: migliore)"</string>
<string name="settings_open_link_in_app_title">"Apri Link nell'App"</string>
<string name="settigns_video_title">"Video"</string>
<string name="settings_video_autoplay_title">"Autoriproduzione video"</string>
<string name="settings_mute_autoplaying_videos_title">"Muta video autoriprodotti"</string>

View File

@ -328,7 +328,6 @@
<string name="settings_gestures_and_buttons_title">"ジェスチャーとボタン"</string>
<string name="settings_save_front_page_scrolled_position_title">"ホーム画面のスクロール位置を保存"</string>
<string name="settings_save_front_page_scrolled_position_summary">"ホームを更新後は新しい投稿を表示 (フロントページ、並べ替え: ベスト)"</string>
<string name="settings_open_link_in_app_title">"リンクをアプリ内で開く"</string>
<string name="settigns_video_title">"動画"</string>
<string name="settings_video_autoplay_title">"動画を自動再生"</string>
<string name="settings_mute_autoplaying_videos_title">"自動再生の動画をミュート"</string>

View File

@ -296,7 +296,6 @@ Tik om opnieuw te proberen."</string>
<string name="settings_gestures_and_buttons_title">"Gebaren &amp; Knoppen"</string>
<string name="settings_save_front_page_scrolled_position_title">"Bewaar de scrollpositie in HOME"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Blader door nieuwe posts na het vernieuwen in HOME (voorpagina, sorteertype: Beste)"</string>
<string name="settings_open_link_in_app_title">"Open Link In App"</string>
<string name="settigns_video_title">"Video"</string>
<string name="settings_video_autoplay_title">"Video Automatisch Afspelen"</string>
<string name="settings_mute_autoplaying_videos_title">"Demp Automatisch Afspelende Video's"</string>

View File

@ -289,7 +289,6 @@
<string name="settings_gestures_and_buttons_title">"Gesty i przyciski"</string>
<string name="settings_save_front_page_scrolled_position_title">"Zapisz pozycję na stronie głównej"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Przeglądaj nowe posty po odświeżeniu strony głównej"</string>
<string name="settings_open_link_in_app_title">"Otwórz link w aplikacji"</string>
<string name="settigns_video_title">"Wideo"</string>
<string name="settings_video_autoplay_title">"Autoodtwarzanie wideo"</string>
<string name="settings_mute_autoplaying_videos_title">"Wycisz automatycznie odtwarzane wideo"</string>

View File

@ -301,7 +301,6 @@ Toque para tentar novamente."</string>
<string name="settings_gestures_and_buttons_title">"Gestos e Botões"</string>
<string name="settings_save_front_page_scrolled_position_title">"Posição de rolagem salva na tela inicial"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Navegue por posts novos depois de atualizar a tela inicial ( Primeira Página, modo de classificação: Melhores)"</string>
<string name="settings_open_link_in_app_title">"Abrir Link no App"</string>
<string name="settigns_video_title">"Vídeo"</string>
<string name="settings_video_autoplay_title">"Reprodução Automática de Vídeo"</string>
<string name="settings_mute_autoplaying_videos_title">"Silenciar Vídeos Reproduzidos Automaticamente"</string>

View File

@ -299,7 +299,6 @@ Toque para tentar novamente."</string>
<string name="settings_gestures_and_buttons_title">"Gestos e Botões"</string>
<string name="settings_save_front_page_scrolled_position_title">"Guardar Posição de Deslizamento em INÍCIO"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Explorar novas publicações após recarregar INÍCIO (Página Principal, ordenado por: Melhor)"</string>
<string name="settings_open_link_in_app_title">"Abrir Ligação na Aplicação"</string>
<string name="settigns_video_title">"Vídeo"</string>
<string name="settings_video_autoplay_title">"Reprodução Automática de Vídeos"</string>
<string name="settings_mute_autoplaying_videos_title">"Vídeos em auto-reprodução Sem Som"</string>

View File

@ -299,7 +299,6 @@
<string name="settings_gestures_and_buttons_title">"Жесты и кнопки"</string>
<string name="settings_save_front_page_scrolled_position_title">"Сохранять прокрученную позицию на «Главной»"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Просмотр новых постов после обновления на «Главной» (Заглавная страница, сортировка: лучшее)"</string>
<string name="settings_open_link_in_app_title">"Открыть ссылку в приложении"</string>
<string name="settigns_video_title">"Видео"</string>
<string name="settings_video_autoplay_title">"Автовоспроизведение видео"</string>
<string name="settings_mute_autoplaying_videos_title">"Отключать звук у автовоспроизводящихся видео"</string>

View File

@ -300,7 +300,6 @@ Tekrar denemek için tıklayın."</string>
<string name="settings_gestures_and_buttons_title">"İşaretler ve Düğmeler"</string>
<string name="settings_save_front_page_scrolled_position_title">"Ana Sayfada Kaydırma Konumunu Kaydet"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Ana Sayfa yenilendikten sonra yeni gönderilere göz atın (Ön Sayfa, sıralama türü: En iyi)"</string>
<string name="settings_open_link_in_app_title">"Bağlantıları Uygulamada Aç"</string>
<string name="settigns_video_title">"Video"</string>
<string name="settings_video_autoplay_title">"Otomatik Video Oynatma"</string>
<string name="settings_mute_autoplaying_videos_title">"Otomatik Oynatılan Videoları Sessize Al"</string>

View File

@ -363,7 +363,6 @@
<string name="settings_gestures_and_buttons_title">Жести і кнопки</string>
<string name="settings_save_front_page_scrolled_position_title">Зберігати позицію прокрутки в ДОМІВЦІ</string>
<string name="settings_save_front_page_scrolled_position_summary">Оглядати нові дописи після оновлення ДОМІВКИ (Перша сторінка, тип сортування: Кращі)</string>
<string name="settings_open_link_in_app_title">Відкривати посилання в програмі</string>
<string name="settigns_video_title">Відеозаписи</string>
<string name="settings_video_autoplay_title">Автовідтворення відео</string>
<string name="settings_mute_autoplaying_videos_title">Глушити автовідтворювані відео</string>

View File

@ -300,7 +300,6 @@ Nhấn để thử lại."</string>
<string name="settings_gestures_and_buttons_title">"Cử chỉ &amp; Nút"</string>
<string name="settings_save_front_page_scrolled_position_title">"Giữ vị trí cuộn trong Trang chủ"</string>
<string name="settings_save_front_page_scrolled_position_summary">"Duyệt các bài viết mới sau khi làm mới trong TRANG CHỦ (Trang chính, loại sắp xếp: Hay nhất)"</string>
<string name="settings_open_link_in_app_title">"Mở liên kết trong ứng dụng"</string>
<string name="settigns_video_title">"VIDEO"</string>
<string name="settings_video_autoplay_title">"Tự động phát Video"</string>
<string name="settings_mute_autoplaying_videos_title">"Tắt tiếng những Video tự động phát"</string>

View File

@ -293,7 +293,6 @@
<string name="settings_gestures_and_buttons_title">"手势和按钮"</string>
<string name="settings_save_front_page_scrolled_position_title">"在首页记住浏览的位置"</string>
<string name="settings_save_front_page_scrolled_position_summary">"刷新首页浏览新帖(排序为精选)"</string>
<string name="settings_open_link_in_app_title">"在应用内打开网页"</string>
<string name="settigns_video_title">"视频"</string>
<string name="settings_video_autoplay_title">"自动播放视频"</string>
<string name="settings_mute_autoplaying_videos_title">"静音自动播放的视频"</string>

View File

@ -542,4 +542,16 @@
<item>200</item>
</string-array>
<string-array name="link_handler">
<item>@string/settings_link_handler_value_external_browser</item>
<item>@string/settings_link_handler_value_custom_tab</item>
<item>@string/settings_link_handler_value_internal_browser</item>
</string-array>
<string-array name="link_handler_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>

View File

@ -365,7 +365,7 @@
<string name="settings_gestures_and_buttons_title">Gestures &amp; Buttons</string>
<string name="settings_save_front_page_scrolled_position_title">Save Scrolled Position in HOME</string>
<string name="settings_save_front_page_scrolled_position_summary">Browse new posts after refreshing in HOME (Front Page, sort type: Best)</string>
<string name="settings_open_link_in_app_title">Open Link In App</string>
<string name="settings_link_handler_title">Link Handler</string>
<string name="settigns_video_title">Video</string>
<string name="settings_video_autoplay_title">Video Autoplay</string>
<string name="settings_mute_autoplaying_videos_title">Mute Autoplaying Videos</string>
@ -610,6 +610,9 @@
<string name="settings_app_lock_timeout_title">App Lock Timeout</string>
<string name="settings_enable_fold_support_title">Enable folding phone support</string>
<string name="settings_default_playback_speed_title">Default Playback Speed</string>
<string name="settings_link_handler_value_external_browser">External Browser</string>
<string name="settings_link_handler_value_custom_tab">Custom Tab</string>
<string name="settings_link_handler_value_internal_browser">Internal Browser</string>
<string name="no_link_available">Cannot get the link</string>
@ -1148,7 +1151,7 @@
<string name="exclude_user">Exclude this user</string>
<string name="exclude_flair">Exclude this flair</string>
<string name="contain_flair">Contain this flair</string>
<string name="exclude_domain">Exclude Domain</string>
<string name="exclude_domain">Exclude this domain</string>
<string name="suggest_title">Suggest Title</string>
<string name="suggest_title_failed">Failed to suggest a title</string>

View File

@ -7,11 +7,14 @@
app:title="@string/settings_save_front_page_scrolled_position_title"
app:summary="@string/settings_save_front_page_scrolled_position_summary" />
<SwitchPreference
app:defaultValue="false"
<ListPreference
app:defaultValue="0"
app:entries="@array/link_handler"
app:entryValues="@array/link_handler_values"
app:icon="@drawable/ic_link"
app:key="open_link_in_app"
app:title="@string/settings_open_link_in_app_title" />
app:key="link_handler"
app:title="@string/settings_link_handler_title"
app:useSimpleSummaryProvider="true" />
<ListPreference
app:defaultValue="0"