Hide push notification settings if google service isn't available
This commit is contained in:
parent
29edd90393
commit
767254b64a
4 changed files with 22 additions and 0 deletions
|
@ -1352,6 +1352,12 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
+ Compatibility.getAppStandbyBucketNameFromValue(bucket));
|
||||
}
|
||||
|
||||
boolean googlePlayServiceAvailable = DeviceUtils.isGooglePlayServicesAvailable(this);
|
||||
if (!googlePlayServiceAvailable) {
|
||||
Log.w(
|
||||
"[Linphone Activity] Device doesn't have Google Play Services, push notifications won't work !");
|
||||
}
|
||||
|
||||
IntentUtils.handleIntent(this, getIntent());
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.linphone.core.ProxyConfig;
|
|||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.fragments.FragmentsAvailable;
|
||||
import org.linphone.settings.LinphonePreferences.AccountBuilder;
|
||||
import org.linphone.utils.DeviceUtils;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
|
||||
public class AccountPreferencesFragment extends PreferenceFragment
|
||||
|
@ -483,6 +484,9 @@ public class AccountPreferencesFragment extends PreferenceFragment
|
|||
if (!mIsNewAccount) {
|
||||
pushNotif.setChecked(mPrefs.isPushNotifEnabledForProxy(mN));
|
||||
}
|
||||
if (!DeviceUtils.isGooglePlayServicesAvailable(getActivity())) {
|
||||
pushNotif.setLayoutResource(R.layout.hidden);
|
||||
}
|
||||
|
||||
PreferenceCategory manage =
|
||||
(PreferenceCategory)
|
||||
|
|
|
@ -1480,6 +1480,10 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
|
||||
((CheckBoxPreference) findPreference(getString(R.string.pref_push_notification_key)))
|
||||
.setChecked(mPrefs.isPushNotificationEnabled());
|
||||
if (!DeviceUtils.isGooglePlayServicesAvailable(getActivity())) {
|
||||
findPreference(getString(R.string.pref_push_notification_key))
|
||||
.setLayoutResource(R.layout.hidden);
|
||||
}
|
||||
((CheckBoxPreference) findPreference(getString(R.string.pref_ipv6_key)))
|
||||
.setChecked(mPrefs.isUsingIpv6());
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import android.widget.Button;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import java.util.List;
|
||||
import org.linphone.R;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
|
@ -221,4 +223,10 @@ public class DeviceUtils {
|
|||
.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
return list.size() > 0;
|
||||
}
|
||||
|
||||
public static boolean isGooglePlayServicesAvailable(Context context) {
|
||||
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
|
||||
int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(context);
|
||||
return resultCode == ConnectionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue