Restore gr3ger double casting fix

This commit is contained in:
Oizaro 2020-09-01 00:06:05 +02:00
parent 9201652c57
commit 27f79a39f5
5 changed files with 35 additions and 1 deletions

View File

@ -1,10 +1,16 @@
package org.microg.gms.ui;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.navigation.NavOptions;
import androidx.navigation.fragment.NavHostFragment;
import androidx.preference.Preference;
import androidx.preference.SwitchPreferenceCompat;
import com.google.android.gms.cast.media.CastMediaRouteProviderService;
import com.mgoogle.android.gms.R;
@ -18,6 +24,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
public static final String PREF_ABOUT = "pref_about";
public static final String PREF_GCM = "pref_gcm";
public static final String PREF_CHECKIN = "pref_checkin";
public static final String PREF_CAST_DOUBLE_FIX_ENABLED = "pref_cast_double_fix_enabled";
public SettingsFragment() {
preferencesResource = R.xml.preferences_start;
@ -41,6 +48,14 @@ public class SettingsFragment extends ResourceSettingsFragment {
UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openAbout, null);
return true;
});
findPreference(PREF_CAST_DOUBLE_FIX_ENABLED).setOnPreferenceChangeListener((preference, newValue) -> {
boolean isEnabled = (boolean) newValue;
getContext().getPackageManager().setComponentEnabledSetting(
new ComponentName(getContext().getApplicationContext(), CastMediaRouteProviderService.class),
isEnabled ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
return true;
});
if (GcmPrefs.get(getContext()).isEnabled()) {
GcmDatabase database = new GcmDatabase(getContext());
int regCount = database.getRegistrationList().size();

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorAccent"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M21,3L3,3c-1.1,0 -2,0.9 -2,2v3h2L3,5h18v14h-7v2h7c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2zM1,18v3h3c0,-1.66 -1.34,-3 -3,-3zM1,14v2c2.76,0 5,2.24 5,5h2c0,-3.87 -3.13,-7 -7,-7zM1,10v2c4.97,0 9,4.03 9,9h2c0,-6.08 -4.93,-11 -11,-11z"
android:fillColor="#000000"/>
</vector>

View File

@ -107,6 +107,8 @@ Questa operazione può richiedere alcuni minuti."</string>
<string name="pref_gcm_confirm_new_apps_summary">Chiedi conferma all\'utente prima di registrare una nuova applicazione per le notifiche push.</string>
<string name="pref_about_title">A proposito di microG</string>
<string name="pref_cast_double_fix">Correzione Cast duplicato</string>
<string name="pref_cast_double_fix_summary">Attiva questa opzione in caso di voci duplicate nel menù di cast</string>
<string name="gcm_status_pref_auto">Automatico</string>
<string name="gcm_status_pref_manual">Manuale</string>

View File

@ -102,6 +102,7 @@ This can take a couple of minutes."</string>
<string name="pref_gcm_confirm_new_apps_summary">Ask before registering a new app to receive push notifications</string>
<string name="pref_about_title">About Vanced microG</string>
<string name="pref_cast_double_fix">Cast duplication fix</string>
<string name="pref_switcher_title">Register device</string>
<string name="pref_checkin_enable_summary">Registers your device to Google services and creates a unique device identifier. Vanced microG strips identifying bits other than your Google account name from registration data.</string>
@ -132,5 +133,5 @@ This can take a couple of minutes."</string>
<string name="prefcat_push_apps_registered_title">Registered apps</string>
<string name="prefcat_push_apps_unregistered_title">Unregistered apps</string>
<string name="prefcat_push_networks_title">Networks to use for push notifications</string>
<string name="pref_cast_double_fix_summary">Enable this if you see duplicates in your casting menu</string>
</resources>

View File

@ -42,6 +42,12 @@
android:targetClass="org.microg.gms.ui.GoogleMoreFragment$AsActivity"
android:targetPackage="com.mgoogle.android.gms" />
</Preference>
<SwitchPreferenceCompat
android:key="pref_cast_double_fix_enabled"
android:title="@string/pref_cast_double_fix"
android:icon="@drawable/ic_cast_black"
android:summary="@string/pref_cast_double_fix_summary"
android:defaultValue="false"/>
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_category_no_label">
<Preference