mirror of https://github.com/M66B/FairEmail.git
Prepare Adguard download
This commit is contained in:
parent
b2a4cf9ab2
commit
42af314c79
|
@ -55,6 +55,7 @@ import androidx.webkit.WebViewFeature;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -64,6 +65,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
private SwitchCompat swConfirmLinks;
|
private SwitchCompat swConfirmLinks;
|
||||||
private SwitchCompat swSanitizeLinks;
|
private SwitchCompat swSanitizeLinks;
|
||||||
private SwitchCompat swAdguard;
|
private SwitchCompat swAdguard;
|
||||||
|
private Button btnAdguard;
|
||||||
|
private TextView tvAdguardTime;
|
||||||
private SwitchCompat swCheckLinksDbl;
|
private SwitchCompat swCheckLinksDbl;
|
||||||
private SwitchCompat swConfirmFiles;
|
private SwitchCompat swConfirmFiles;
|
||||||
private SwitchCompat swConfirmImages;
|
private SwitchCompat swConfirmImages;
|
||||||
|
@ -134,6 +137,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
swConfirmLinks = view.findViewById(R.id.swConfirmLinks);
|
swConfirmLinks = view.findViewById(R.id.swConfirmLinks);
|
||||||
swSanitizeLinks = view.findViewById(R.id.swSanitizeLinks);
|
swSanitizeLinks = view.findViewById(R.id.swSanitizeLinks);
|
||||||
swAdguard = view.findViewById(R.id.swAdguard);
|
swAdguard = view.findViewById(R.id.swAdguard);
|
||||||
|
btnAdguard = view.findViewById(R.id.btnAdguard);
|
||||||
|
tvAdguardTime = view.findViewById(R.id.tvAdguardTime);
|
||||||
swCheckLinksDbl = view.findViewById(R.id.swCheckLinksDbl);
|
swCheckLinksDbl = view.findViewById(R.id.swCheckLinksDbl);
|
||||||
swConfirmFiles = view.findViewById(R.id.swConfirmFiles);
|
swConfirmFiles = view.findViewById(R.id.swConfirmFiles);
|
||||||
swConfirmImages = view.findViewById(R.id.swConfirmImages);
|
swConfirmImages = view.findViewById(R.id.swConfirmImages);
|
||||||
|
@ -218,6 +223,13 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
btnAdguard.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
prefs.edit().putLong("adguard_last", new Date().getTime()).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
swCheckLinksDbl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swCheckLinksDbl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
@ -609,6 +621,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
if (view == null || getContext() == null)
|
if (view == null || getContext() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
DateFormat DF = SimpleDateFormat.getDateTimeInstance();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
swConfirmLinks.setChecked(prefs.getBoolean("confirm_links", true));
|
swConfirmLinks.setChecked(prefs.getBoolean("confirm_links", true));
|
||||||
|
@ -616,6 +629,11 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
swSanitizeLinks.setEnabled(swConfirmLinks.isChecked());
|
swSanitizeLinks.setEnabled(swConfirmLinks.isChecked());
|
||||||
swAdguard.setChecked(prefs.getBoolean("adguard", false));
|
swAdguard.setChecked(prefs.getBoolean("adguard", false));
|
||||||
swAdguard.setEnabled(swConfirmLinks.isChecked());
|
swAdguard.setEnabled(swConfirmLinks.isChecked());
|
||||||
|
|
||||||
|
long adguard_last = prefs.getLong("adguard_last", -1);
|
||||||
|
tvAdguardTime.setText(adguard_last < 0 ? null : DF.format(adguard_last));
|
||||||
|
tvAdguardTime.setVisibility(adguard_last < 0 ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
swCheckLinksDbl.setChecked(prefs.getBoolean("check_links_dbl", BuildConfig.PLAY_STORE_RELEASE));
|
swCheckLinksDbl.setChecked(prefs.getBoolean("check_links_dbl", BuildConfig.PLAY_STORE_RELEASE));
|
||||||
swCheckLinksDbl.setEnabled(swConfirmLinks.isChecked());
|
swCheckLinksDbl.setEnabled(swConfirmLinks.isChecked());
|
||||||
swConfirmFiles.setChecked(prefs.getBoolean("confirm_files", true));
|
swConfirmFiles.setChecked(prefs.getBoolean("confirm_files", true));
|
||||||
|
@ -660,10 +678,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", false));
|
swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", false));
|
||||||
swLoadEmoji.setChecked(prefs.getBoolean("load_emoji", true));
|
swLoadEmoji.setChecked(prefs.getBoolean("load_emoji", true));
|
||||||
|
|
||||||
long time = prefs.getLong("disconnect_last", -1);
|
long disconnect_last = prefs.getLong("disconnect_last", -1);
|
||||||
DateFormat DF = SimpleDateFormat.getDateTimeInstance();
|
tvDisconnectBlacklistTime.setText(disconnect_last < 0 ? null : DF.format(disconnect_last));
|
||||||
tvDisconnectBlacklistTime.setText(time < 0 ? null : DF.format(time));
|
tvDisconnectBlacklistTime.setVisibility(disconnect_last < 0 ? View.GONE : View.VISIBLE);
|
||||||
tvDisconnectBlacklistTime.setVisibility(time < 0 ? View.GONE : View.VISIBLE);
|
|
||||||
|
|
||||||
swDisconnectAutoUpdate.setChecked(prefs.getBoolean("disconnect_auto_update", false));
|
swDisconnectAutoUpdate.setChecked(prefs.getBoolean("disconnect_auto_update", false));
|
||||||
swDisconnectLinks.setChecked(prefs.getBoolean("disconnect_links", true));
|
swDisconnectLinks.setChecked(prefs.getBoolean("disconnect_links", true));
|
||||||
|
|
|
@ -132,13 +132,48 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:checked="true"
|
|
||||||
android:text="@string/title_advanced_adguard"
|
android:text="@string/title_advanced_adguard"
|
||||||
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/tvSanitizeLinksHint"
|
app:layout_constraintTop_toBottomOf="@id/tvSanitizeLinksHint"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnAdguard"
|
||||||
|
style="?android:attr/buttonStyleSmall"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:drawableEnd="@drawable/twotone_get_app_24"
|
||||||
|
android:drawablePadding="6dp"
|
||||||
|
android:text="@string/title_download"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/swAdguard" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAdguardTime"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:text="December 29, 11:30 AM"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:textStyle="italic"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btnAdguard" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swAdguardWeekly"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="@string/title_advanced_adguard_weekly"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvAdguardTime"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/swCheckLinksDbl"
|
android:id="@+id/swCheckLinksDbl"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -148,7 +183,7 @@
|
||||||
android:text="@string/title_advanced_check_links_dbl"
|
android:text="@string/title_advanced_check_links_dbl"
|
||||||
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/swAdguard"
|
app:layout_constraintTop_toBottomOf="@id/swAdguardWeekly"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
|
|
@ -764,6 +764,7 @@
|
||||||
<string name="title_advanced_sanitize_links">Remove tracking parameters by default</string>
|
<string name="title_advanced_sanitize_links">Remove tracking parameters by default</string>
|
||||||
<string name="title_advanced_sanitize_links_hint">Only when confirming links</string>
|
<string name="title_advanced_sanitize_links_hint">Only when confirming links</string>
|
||||||
<string name="title_advanced_adguard">Use Adguard filter list</string>
|
<string name="title_advanced_adguard">Use Adguard filter list</string>
|
||||||
|
<string name="title_advanced_adguard_weekly">Automatically download weekly</string>
|
||||||
<string name="title_advanced_check_links_dbl">Check domain block lists for suspicious links</string>
|
<string name="title_advanced_check_links_dbl">Check domain block lists for suspicious links</string>
|
||||||
<string name="title_advanced_confirm_images">Show no images by default</string>
|
<string name="title_advanced_confirm_images">Show no images by default</string>
|
||||||
<string name="title_advanced_ask_images">Confirm showing images</string>
|
<string name="title_advanced_ask_images">Confirm showing images</string>
|
||||||
|
|
Loading…
Reference in New Issue