Refactoring

pull/156/head
M66B 6 years ago
parent 3e9e56d878
commit b490e49ee7

@ -47,13 +47,13 @@ import androidx.preference.PreferenceManager;
public class FragmentOptionsConnection extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsConnection extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swMetered; private SwitchCompat swMetered;
private Spinner spDownload; private Spinner spDownload;
private SwitchCompat swRlah;
private SwitchCompat swRoaming; private SwitchCompat swRoaming;
private SwitchCompat swRlah;
private TextView tvConnectionType; private TextView tvConnectionType;
private TextView tvConnectionRoaming; private TextView tvConnectionRoaming;
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"metered", "download", "rlah", "roaming" "metered", "download", "roaming", "rlah"
}; };
@Override @Override
@ -68,8 +68,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swMetered = view.findViewById(R.id.swMetered); swMetered = view.findViewById(R.id.swMetered);
spDownload = view.findViewById(R.id.spDownload); spDownload = view.findViewById(R.id.spDownload);
swRlah = view.findViewById(R.id.swRlah);
swRoaming = view.findViewById(R.id.swRoaming); swRoaming = view.findViewById(R.id.swRoaming);
swRlah = view.findViewById(R.id.swRlah);
tvConnectionType = view.findViewById(R.id.tvConnectionType); tvConnectionType = view.findViewById(R.id.tvConnectionType);
tvConnectionRoaming = view.findViewById(R.id.tvConnectionRoaming); tvConnectionRoaming = view.findViewById(R.id.tvConnectionRoaming);
@ -101,19 +101,19 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
} }
}); });
swRlah.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swRoaming.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("rlah", checked).apply(); prefs.edit().putBoolean("roaming", checked).apply();
ServiceSynchronize.reload(getContext(), "rlah=" + checked); ServiceSynchronize.reload(getContext(), "roaming=" + checked);
} }
}); });
swRoaming.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swRlah.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("roaming", checked).apply(); prefs.edit().putBoolean("rlah", checked).apply();
ServiceSynchronize.reload(getContext(), "roaming=" + checked); ServiceSynchronize.reload(getContext(), "rlah=" + checked);
} }
}); });
@ -192,8 +192,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
break; break;
} }
swRlah.setChecked(prefs.getBoolean("rlah", true));
swRoaming.setChecked(prefs.getBoolean("roaming", true)); swRoaming.setChecked(prefs.getBoolean("roaming", true));
swRlah.setChecked(prefs.getBoolean("rlah", true));
} }
private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() { private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {

@ -76,48 +76,48 @@
app:layout_constraintTop_toBottomOf="@id/tvDownload" /> app:layout_constraintTop_toBottomOf="@id/tvDownload" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swRlah" android:id="@+id/swRoaming"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_rlah" android:text="@string/title_advanced_roaming"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spDownload" app:layout_constraintTop_toBottomOf="@id/spDownload"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView
android:id="@+id/tvRlah" android:id="@+id/tvRoamingHint"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="48dp" android:layout_marginEnd="48dp"
android:text="@string/title_advanced_rlah_hint" android:text="@string/title_advanced_roaming_hint"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small" android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swRlah" /> app:layout_constraintTop_toBottomOf="@id/swRoaming" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swRoaming" android:id="@+id/swRlah"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_roaming" android:text="@string/title_advanced_rlah"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRlah" app:layout_constraintTop_toBottomOf="@id/tvRoamingHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView
android:id="@+id/tvRoamingHint" android:id="@+id/tvRlahHint"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="48dp" android:layout_marginEnd="48dp"
android:text="@string/title_advanced_roaming_hint" android:text="@string/title_advanced_rlah_hint"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small" android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swRoaming" /> app:layout_constraintTop_toBottomOf="@id/swRlah" />
<TextView <TextView
android:id="@+id/tvConnectionType" android:id="@+id/tvConnectionType"
@ -130,7 +130,7 @@
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvRoamingHint" /> app:layout_constraintTop_toBottomOf="@+id/tvRlahHint" />
<TextView <TextView
android:id="@+id/tvConnectionRoaming" android:id="@+id/tvConnectionRoaming"

Loading…
Cancel
Save