Merge branch 'master' of github.com:M66B/FairEmail

This commit is contained in:
M66B 2019-12-31 18:36:27 +01:00
commit 6e148b3b6d
5 changed files with 36 additions and 10 deletions

View File

@ -110,7 +110,7 @@
<activity
android:name=".ActivitySearch"
android:enabled="false"
android:enabled="true"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"

View File

@ -21,8 +21,10 @@ package eu.faircode.email;
import android.app.ActivityManager;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -44,6 +46,7 @@ import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceManager;
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swExternalSearch;
private SwitchCompat swEnglish;
private SwitchCompat swWatchdog;
private SwitchCompat swUpdates;
@ -83,6 +86,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
// Get controls
swExternalSearch = view.findViewById(R.id.swExternalSearch);
swEnglish = view.findViewById(R.id.swEnglish);
swWatchdog = view.findViewById(R.id.swWatchdog);
swUpdates = view.findViewById(R.id.swUpdates);
@ -108,6 +112,19 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swExternalSearch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
PackageManager pm = getContext().getPackageManager();
pm.setComponentEnabledSetting(
new ComponentName(getContext(), ActivitySearch.class),
checked
? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
});
swEnglish.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -278,6 +295,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private void setOptions() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
PackageManager pm = getContext().getPackageManager();
int state = pm.getComponentEnabledSetting(new ComponentName(getContext(), ActivitySearch.class));
swExternalSearch.setChecked(state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
swEnglish.setChecked(prefs.getBoolean("english", false));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
swUpdates.setChecked(prefs.getBoolean("updates", true));

View File

@ -21,7 +21,6 @@ package eu.faircode.email;
import android.Manifest;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -404,13 +403,6 @@ public class FragmentSetup extends FragmentBase {
tvNoIdentities.setVisibility(done ? View.GONE : View.VISIBLE);
}
});
// Backward compatibility
PackageManager pm = getContext().getPackageManager();
pm.setComponentEnabledSetting(
new ComponentName(getContext(), ActivitySearch.class),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
@Override

View File

@ -24,6 +24,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swExternalSearch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="true"
android:text="@string/title_advanced_external_search"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAdvancedHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swEnglish"
android:layout_width="0dp"
@ -32,7 +44,7 @@
android:text="@string/title_advanced_english"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAdvancedHint"
app:layout_constraintTop_toBottomOf="@id/swExternalSearch"
app:switchPadding="12dp" />
<TextView

View File

@ -363,6 +363,7 @@
<string name="title_advanced_manage_keys">Manage private keys</string>
<string name="title_advanced_aes_key_size" translatable="false">Max AES key size: %1$d</string>
<string name="title_advanced_external_search">Allow other apps to search in messages</string>
<string name="title_advanced_english">Force English language</string>
<string name="title_advanced_watchdog">Periodically check if FairEmail is still active</string>
<string name="title_advanced_updates">Check for updates</string>