diff --git a/app/src/main/java/app/fedilab/android/client/Entities/Status.java b/app/src/main/java/app/fedilab/android/client/Entities/Status.java index d2ea99573..3e0820aca 100644 --- a/app/src/main/java/app/fedilab/android/client/Entities/Status.java +++ b/app/src/main/java/app/fedilab/android/client/Entities/Status.java @@ -648,7 +648,8 @@ public class Status implements Parcelable{ if( invidious ) { while (matcher.find()) { final String youtubeId = matcher.group(2); - content = content.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement("invidio.us/watch?v=" + youtubeId)); + String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST); + content = content.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(invidiousHost + "/watch?v=" + youtubeId)); } } diff --git a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java index 150c1ca17..a5e2e9d82 100644 --- a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java +++ b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java @@ -2587,7 +2587,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct if (invidious) { while (matcher.find()) { final String youtubeId = matcher.group(2); - url = url.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement("invidio.us/embed/" + youtubeId+"?feature=oembed")); + String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST); + url = url.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(invidiousHost+"/embed/" + youtubeId+"?feature=oembed")); } } diff --git a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java index 6381a19fd..07d8b1c34 100644 --- a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java +++ b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java @@ -743,6 +743,10 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable set_blur_sensitive_text.setOnClickListener(v -> set_blur_sensitive.performClick()); + + TextView set_invidious_host = rootView.findViewById(R.id.set_invidious_host); + + boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false); final CheckBox set_invidious = rootView.findViewById(R.id.set_invidious); set_invidious.setChecked(invidious); @@ -753,6 +757,37 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putBoolean(Helper.SET_INVIDIOUS, set_invidious.isChecked()); editor.apply(); + if( set_invidious.isChecked() ){ + set_invidious_host.setVisibility(View.VISIBLE); + }else{ + set_invidious_host.setVisibility(View.GONE); + } + } + }); + if( invidious ){ + set_invidious_host.setVisibility(View.VISIBLE); + }else{ + set_invidious_host.setVisibility(View.GONE); + } + + String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, null); + if( invidiousHost != null){ + set_invidious_host.setText(invidiousHost); + } + set_invidious_host.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + @Override + public void afterTextChanged(Editable s) { + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putString(Helper.SET_INVIDIOUS_HOST, s.toString().trim()); + editor.apply(); } }); diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 2e09e1963..c95b30b48 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -428,6 +428,8 @@ public class Helper { public static final String SET_FILTER_REGEX_PUBLIC = "set_filter_regex_public"; public static final String SET_INVIDIOUS = "set_invidious"; + public static final String SET_INVIDIOUS_HOST = "set_invidious_host"; + public static final String DEFAULT_INVIDIOUS_HOST = "invidio.us"; public static final String SET_NOTIF_VALIDATION = "set_share_validation"; public static final String SET_NOTIF_VALIDATION_FAV = "set_share_validation_fav"; public static final String SET_WIFI_ONLY = "set_wifi_only"; diff --git a/app/src/main/res/layout/fragment_settings_reveal.xml b/app/src/main/res/layout/fragment_settings_reveal.xml index 36b1aa17d..182d89e08 100644 --- a/app/src/main/res/layout/fragment_settings_reveal.xml +++ b/app/src/main/res/layout/fragment_settings_reveal.xml @@ -182,6 +182,11 @@ android:layout_height="wrap_content" /> + Live notifications will be enabled for this account. Clear cache when leaving The cache (media, cached messages, data from the built-in browser) will be automatically cleared when leaving the application. - Replace Youtuve with Invidio.us + Replace Youtube with Invidio.us Invidious is an alternative front-end to YouTube + Enter your custom host or leave blank for using invidio.us \ No newline at end of file