Skip to content

Commit

Permalink
Fix lint issue with switchpreferencecompat -> switchpreference
Browse files Browse the repository at this point in the history
  • Loading branch information
fat-tire committed Jan 24, 2019
1 parent 949de50 commit 6fd9dca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
40 changes: 20 additions & 20 deletions src/main/java/org/havenapp/main/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
import android.widget.Switch;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;

import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;

Expand All @@ -34,16 +44,6 @@
import java.io.File;
import java.util.Locale;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
import androidx.preference.SwitchPreferenceCompat;
import info.guardianproject.netcipher.proxy.OrbotHelper;


Expand Down Expand Up @@ -86,7 +86,7 @@ public void onCreatePreferences(Bundle bundle, String s) {
}

if (preferences.getSmsActivation()) {
((SwitchPreferenceCompat) findPreference(PreferenceManager.SMS_ACTIVE)).setChecked(true);
((SwitchPreference) findPreference(PreferenceManager.SMS_ACTIVE)).setChecked(true);
}

findPreference(PreferenceManager.SMS_NUMBER).setOnPreferenceClickListener(preference -> {
Expand All @@ -110,7 +110,7 @@ public void onCreatePreferences(Bundle bundle, String s) {
}

if (preferences.getRemoteAccessActive()) {
((SwitchPreferenceCompat) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).setChecked(true);
((SwitchPreference) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).setChecked(true);
}

if (checkValidString(preferences.getRemoteAccessOnion())) {
Expand Down Expand Up @@ -141,7 +141,7 @@ public void onCreatePreferences(Bundle bundle, String s) {

if (preferences.getHeartbeatActive())
{
((SwitchPreferenceCompat) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).setChecked(true);
((SwitchPreference) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).setChecked(true);
if (preferences.getHeartbeatActive()) {
findPreference(PreferenceManager.HEARTBEAT_MONITOR_DELAY).setSummary(preferences.getHeartbeatNotificationTimeMs() / 60000 + " " + getString(R.string.minutes));
}
Expand Down Expand Up @@ -224,7 +224,7 @@ protected void save() {

preferences.setSignalUsername(((EditTextPreference) findPreference(PreferenceManager.REGISTER_SIGNAL)).getText());

boolean remoteAccessActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).isChecked();
boolean remoteAccessActive = ((SwitchPreference) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).isChecked();

preferences.activateRemoteAccess(remoteAccessActive);
String password = ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_CRED)).getText();
Expand All @@ -237,7 +237,7 @@ protected void save() {

preferences.setVoiceVerification(false);

boolean heartbeatMonitorActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).isChecked();
boolean heartbeatMonitorActive = ((SwitchPreference) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).isChecked();

preferences.activateHeartbeat(heartbeatMonitorActive);

Expand Down Expand Up @@ -319,7 +319,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
setPhoneNumber();
break;
case PreferenceManager.REMOTE_ACCESS_ACTIVE:
boolean remoteAccessActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).isChecked();
boolean remoteAccessActive = ((SwitchPreference) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).isChecked();
if (remoteAccessActive) {
checkRemoteAccessOnion();
app.startServer();
Expand Down Expand Up @@ -349,7 +349,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
break;
}
case PreferenceManager.SMS_NUMBER:
boolean smsActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.SMS_ACTIVE)).isChecked();
boolean smsActive = ((SwitchPreference) findPreference(PreferenceManager.SMS_ACTIVE)).isChecked();
if (smsActive && TextUtils.isEmpty(preferences.getSignalUsername())) {
askForPermission(Manifest.permission.SEND_SMS, 6);
askForPermission(Manifest.permission.READ_PHONE_STATE, 6);
Expand Down Expand Up @@ -395,7 +395,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
}
case PreferenceManager.HEARTBEAT_MONITOR_ACTIVE: {
boolean isMonitoring = preferences.getHeartbeatActive();
boolean hbSwitchOn = ((SwitchPreferenceCompat) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).isChecked();
boolean hbSwitchOn = ((SwitchPreference) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).isChecked();
if (!isMonitoring && hbSwitchOn) {
preferences.activateHeartbeat(true);
findPreference(PreferenceManager.HEARTBEAT_MONITOR_DELAY).setSummary(preferences.getHeartbeatNotificationTimeMs() / 60000 + " " + getString(R.string.minutes));
Expand Down Expand Up @@ -423,7 +423,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
preferences.setHeartbeatMonitorNotifications(notificationTimeMs);
findPreference(PreferenceManager.HEARTBEAT_MONITOR_DELAY).setSummary(preferences.getHeartbeatNotificationTimeMs() / 60000 + " " + getString(R.string.minutes));

boolean heartbeatActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).isChecked();
boolean heartbeatActive = ((SwitchPreference) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).isChecked();
if (heartbeatActive && preferences.getMonitorServiceActive()) {
SignalSender sender = SignalSender.getInstance(getActivity(), preferences.getSignalUsername());
sender.stopHeartbeatTimer();
Expand Down Expand Up @@ -452,7 +452,7 @@ private void setDefaultStoragePath () {
}

private void setPhoneNumber() {
boolean smsActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.SMS_ACTIVE)).isChecked();
boolean smsActive = ((SwitchPreference) findPreference(PreferenceManager.SMS_ACTIVE)).isChecked();
String phoneNumber = ((EditTextPreference) findPreference(PreferenceManager.SMS_NUMBER)).getText();
if (smsActive && checkValidString(phoneNumber)) {
preferences.activateSms(true);
Expand Down
6 changes: 3 additions & 3 deletions src/main/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/label_notifications">

<SwitchPreferenceCompat
<SwitchPreference
android:defaultValue="true"
android:key="sms_active"
android:title="@string/sms_label" />
Expand Down Expand Up @@ -101,7 +101,7 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/hearbeat_monitor">

<SwitchPreferenceCompat
<SwitchPreference
android:defaultValue="false"
android:key="heartbeat_monitor_active"
android:title="@string/hearbeat_monitor_enable" />
Expand All @@ -118,7 +118,7 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/remote_access">

<SwitchPreferenceCompat
<SwitchPreference
android:defaultValue="false"
android:key="remote_access_active"
android:summary="@string/remote_access_label"
Expand Down

0 comments on commit 6fd9dca

Please sign in to comment.