mirror of
https://framagit.org/tom79/nitterizeme
synced 2025-02-26 16:37:56 +01:00
Comment #26 - Some fixes
This commit is contained in:
parent
6e7723e58a
commit
b9fcd9acfb
@ -39,6 +39,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@ -353,30 +354,41 @@ public class Utils {
|
|||||||
*/
|
*/
|
||||||
public static String replaceInvidiousParams(Context context, String url) {
|
public static String replaceInvidiousParams(Context context, String url) {
|
||||||
String newUrl = url;
|
String newUrl = url;
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(MainActivity.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
//Theme
|
//Theme
|
||||||
String theme = sharedpreferences.getString(context.getString(R.string.invidious_dark_mode), "0");
|
String theme = sharedpreferences.getString(context.getString(R.string.invidious_dark_mode), "0");
|
||||||
if (theme.compareTo("-1") == 0) { //Remove value
|
if (theme.compareTo("-1") == 0) { //Remove value
|
||||||
newUrl = url.replaceAll("&?dark_mode=(true|false)", "");
|
newUrl = newUrl.replaceAll("&?dark_mode=(true|false)", "");
|
||||||
} else if (theme.compareTo("0") != 0) { //Change value
|
} else if (theme.compareTo("0") != 0) { //Change value
|
||||||
newUrl = url.replaceAll("dark_mode=(true|false)", theme);
|
if (newUrl.contains("dark_mode=")) {
|
||||||
|
newUrl = newUrl.replaceAll("dark_mode=(true|false)", theme);
|
||||||
|
} else {
|
||||||
|
newUrl += "&" + theme;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tint mode
|
//Thin mode
|
||||||
String tint = sharedpreferences.getString(context.getString(R.string.invidious_tint_mode), "0");
|
String thin = sharedpreferences.getString(context.getString(R.string.invidious_thin_mode), "0");
|
||||||
if (tint.compareTo("-1") == 0) { //Remove value
|
if (thin.compareTo("-1") == 0) { //Remove value
|
||||||
newUrl = url.replaceAll("&?thin_mode=(true|false)", "");
|
newUrl = newUrl.replaceAll("&?thin_mode=(true|false)", "");
|
||||||
} else if (tint.compareTo("0") != 0) { //Change value
|
} else if (thin.compareTo("0") != 0) { //Change value
|
||||||
newUrl = url.replaceAll("thin_mode=(true|false)", theme);
|
if (newUrl.contains("thin_mode=")) {
|
||||||
|
newUrl = newUrl.replaceAll("thin_mode=(true|false)", thin);
|
||||||
|
} else {
|
||||||
|
newUrl += "&" + thin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Language
|
//Language
|
||||||
String language = sharedpreferences.getString(context.getString(R.string.invidious_language_mode), "0");
|
String language = sharedpreferences.getString(context.getString(R.string.invidious_language_mode), "0");
|
||||||
if (language.compareTo("-1") == 0) { //Remove value
|
if (language.compareTo("-1") == 0) { //Remove value
|
||||||
newUrl = url.replaceAll("&?hl=\\w{2}(-\\w{2})?", "");
|
newUrl = newUrl.replaceAll("&?hl=\\w{2}(-\\w{2})?", "");
|
||||||
} else if (language.compareTo("0") != 0) { //Change value
|
} else if (language.compareTo("0") != 0) { //Change value
|
||||||
newUrl = url.replaceAll("hl=\\w{2}(-\\w{2})?", language);
|
if (newUrl.contains("hl=")) {
|
||||||
|
newUrl = newUrl.replaceAll("hl=\\w{2}(-\\w{2})?", language);
|
||||||
|
} else {
|
||||||
|
newUrl += "&" + language;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newUrl;
|
return newUrl;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<item>dark_mode=false</item>
|
<item>dark_mode=false</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="invidious_tint_values">
|
<string-array name="invidious_thin_values">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
<item>-1</item>
|
<item>-1</item>
|
||||||
<item>thin_mode=true</item>
|
<item>thin_mode=true</item>
|
||||||
|
@ -152,7 +152,7 @@
|
|||||||
|
|
||||||
<!-- Some local values -->
|
<!-- Some local values -->
|
||||||
<string name="invidious_dark_mode" translatable="false">invidious_dark_mode</string>
|
<string name="invidious_dark_mode" translatable="false">invidious_dark_mode</string>
|
||||||
<string name="invidious_tint_mode" translatable="false">invidious_tint_mode</string>
|
<string name="invidious_thin_mode" translatable="false">invidious_thin_mode</string>
|
||||||
<string name="invidious_language_mode" translatable="false">invidious_language_mode</string>
|
<string name="invidious_language_mode" translatable="false">invidious_language_mode</string>
|
||||||
<string name="invidious_annotations_mode" translatable="false">invidious_annotations_mode</string>
|
<string name="invidious_annotations_mode" translatable="false">invidious_annotations_mode</string>
|
||||||
<string name="invidious_autoplay_mode" translatable="false">invidious_autoplay_mode</string>
|
<string name="invidious_autoplay_mode" translatable="false">invidious_autoplay_mode</string>
|
||||||
|
@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:key="@string/invidious_tint_mode"
|
app:key="@string/invidious_thin_mode"
|
||||||
app:summary="@string/invidious_thin_mode_indication"
|
app:summary="@string/invidious_thin_mode_indication"
|
||||||
app:title="@string/invidious_thin_mode_title"
|
app:title="@string/invidious_thin_mode_title"
|
||||||
android:defaultValue="0"
|
android:defaultValue="0"
|
||||||
android:entries="@array/invidious_enable"
|
android:entries="@array/invidious_enable"
|
||||||
android:entryValues="@array/invidious_tint_values" />
|
android:entryValues="@array/invidious_thin_values" />
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="0"
|
android:defaultValue="0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user