2019-05-06 09:10:13 +02:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
This file is part of FairEmail.
|
|
|
|
|
|
|
|
|
|
FairEmail is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
FairEmail is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2020-01-05 18:32:53 +01:00
|
|
|
Copyright 2018-2020 by Marcel Bokhorst (M66B)
|
2019-05-06 09:10:13 +02:00
|
|
|
*/
|
|
|
|
|
|
2019-05-16 19:09:51 +02:00
|
|
|
import android.app.ActivityManager;
|
2019-06-22 16:34:46 +02:00
|
|
|
import android.app.NotificationManager;
|
2019-12-31 12:07:45 +01:00
|
|
|
import android.content.ComponentName;
|
2019-05-16 19:09:51 +02:00
|
|
|
import android.content.Context;
|
2019-05-06 09:10:13 +02:00
|
|
|
import android.content.SharedPreferences;
|
2019-12-31 12:07:45 +01:00
|
|
|
import android.content.pm.PackageManager;
|
2019-08-24 13:13:48 +02:00
|
|
|
import android.graphics.Paint;
|
2019-05-06 09:10:13 +02:00
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.view.LayoutInflater;
|
2019-05-06 14:41:03 +02:00
|
|
|
import android.view.Menu;
|
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
|
import android.view.MenuItem;
|
2019-05-06 09:10:13 +02:00
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
2019-07-10 09:35:20 +02:00
|
|
|
import android.widget.Button;
|
2019-05-06 09:10:13 +02:00
|
|
|
import android.widget.CompoundButton;
|
|
|
|
|
import android.widget.TextView;
|
2019-07-10 09:35:20 +02:00
|
|
|
import android.widget.Toast;
|
2019-05-06 09:10:13 +02:00
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
import androidx.appcompat.widget.SwitchCompat;
|
2019-05-26 12:41:41 +02:00
|
|
|
import androidx.constraintlayout.widget.Group;
|
2019-09-10 08:53:07 +02:00
|
|
|
import androidx.lifecycle.Lifecycle;
|
2020-01-15 10:29:16 +01:00
|
|
|
import androidx.lifecycle.Observer;
|
2019-05-06 09:10:13 +02:00
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
|
|
|
2020-01-16 09:44:54 +01:00
|
|
|
import io.requery.android.database.sqlite.SQLiteDatabase;
|
|
|
|
|
|
2019-05-06 09:10:13 +02:00
|
|
|
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
2019-12-31 12:07:45 +01:00
|
|
|
private SwitchCompat swExternalSearch;
|
2020-01-14 21:58:27 +01:00
|
|
|
private SwitchCompat swFts;
|
2020-01-15 10:29:16 +01:00
|
|
|
private TextView tvFtsIndexed;
|
2020-01-16 18:21:03 +01:00
|
|
|
private TextView tvFtsPro;
|
2019-05-06 09:10:13 +02:00
|
|
|
private SwitchCompat swEnglish;
|
2019-05-12 20:15:16 +02:00
|
|
|
private SwitchCompat swWatchdog;
|
2019-05-06 09:10:13 +02:00
|
|
|
private SwitchCompat swUpdates;
|
2019-08-24 12:30:33 +02:00
|
|
|
private SwitchCompat swExperiments;
|
2019-08-24 13:13:48 +02:00
|
|
|
private TextView tvExperimentsHint;
|
2019-05-10 08:53:45 +02:00
|
|
|
private SwitchCompat swCrashReports;
|
2019-12-22 07:23:43 +01:00
|
|
|
private TextView tvUuid;
|
2019-05-06 09:10:13 +02:00
|
|
|
private SwitchCompat swDebug;
|
2019-10-05 09:37:57 +02:00
|
|
|
private Button btnReset;
|
2019-07-10 09:35:20 +02:00
|
|
|
private Button btnCleanup;
|
2019-12-22 07:23:43 +01:00
|
|
|
private TextView tvLastCleanup;
|
2019-05-06 09:10:13 +02:00
|
|
|
|
2019-06-15 21:25:49 +02:00
|
|
|
private TextView tvProcessors;
|
2019-05-23 18:45:11 +02:00
|
|
|
private TextView tvMemoryClass;
|
2019-10-19 21:53:19 +02:00
|
|
|
private TextView tvStorageSpace;
|
2019-12-22 07:23:43 +01:00
|
|
|
private TextView tvFingerprint;
|
2019-05-26 12:41:41 +02:00
|
|
|
|
|
|
|
|
private Group grpDebug;
|
2019-05-06 09:10:13 +02:00
|
|
|
|
2019-05-06 14:41:03 +02:00
|
|
|
private final static String[] RESET_OPTIONS = new String[]{
|
2020-01-14 21:58:27 +01:00
|
|
|
"fts", "english", "watchdog", "updates", "experiments", "crash_reports", "debug"
|
2019-05-06 14:41:03 +02:00
|
|
|
};
|
|
|
|
|
|
2019-05-09 07:32:48 +02:00
|
|
|
private final static String[] RESET_QUESTIONS = new String[]{
|
2020-01-13 11:33:34 +01:00
|
|
|
"welcome", "crash_reports_asked", "review_asked", "review_later", "why",
|
2020-02-02 15:06:12 +01:00
|
|
|
"reply_hint", "html_always_images", "print_html_confirmed", "automove",
|
2020-01-04 17:29:28 +01:00
|
|
|
"identities_asked", "cc_bcc", "inline_image_hint", "compose_reference", "send_dialog",
|
|
|
|
|
"setup_advanced"
|
2019-05-09 07:32:48 +02:00
|
|
|
};
|
|
|
|
|
|
2019-05-06 09:10:13 +02:00
|
|
|
@Override
|
|
|
|
|
@Nullable
|
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
2019-06-12 16:15:46 +02:00
|
|
|
setSubtitle(R.string.title_setup);
|
2019-05-06 14:41:03 +02:00
|
|
|
setHasOptionsMenu(true);
|
2019-05-06 09:10:13 +02:00
|
|
|
|
|
|
|
|
View view = inflater.inflate(R.layout.fragment_options_misc, container, false);
|
|
|
|
|
|
|
|
|
|
// Get controls
|
|
|
|
|
|
2019-12-31 12:07:45 +01:00
|
|
|
swExternalSearch = view.findViewById(R.id.swExternalSearch);
|
2020-01-14 21:58:27 +01:00
|
|
|
swFts = view.findViewById(R.id.swFts);
|
2020-01-15 10:29:16 +01:00
|
|
|
tvFtsIndexed = view.findViewById(R.id.tvFtsIndexed);
|
2020-01-16 18:21:03 +01:00
|
|
|
tvFtsPro = view.findViewById(R.id.tvFtsPro);
|
2019-05-06 09:10:13 +02:00
|
|
|
swEnglish = view.findViewById(R.id.swEnglish);
|
2019-05-12 20:15:16 +02:00
|
|
|
swWatchdog = view.findViewById(R.id.swWatchdog);
|
2019-05-06 09:10:13 +02:00
|
|
|
swUpdates = view.findViewById(R.id.swUpdates);
|
2019-08-24 12:30:33 +02:00
|
|
|
swExperiments = view.findViewById(R.id.swExperiments);
|
2019-08-24 13:13:48 +02:00
|
|
|
tvExperimentsHint = view.findViewById(R.id.tvExperimentsHint);
|
2019-05-10 08:53:45 +02:00
|
|
|
swCrashReports = view.findViewById(R.id.swCrashReports);
|
2019-12-22 07:23:43 +01:00
|
|
|
tvUuid = view.findViewById(R.id.tvUuid);
|
2019-05-06 09:10:13 +02:00
|
|
|
swDebug = view.findViewById(R.id.swDebug);
|
2019-10-05 09:37:57 +02:00
|
|
|
btnReset = view.findViewById(R.id.btnReset);
|
2019-07-10 09:35:20 +02:00
|
|
|
btnCleanup = view.findViewById(R.id.btnCleanup);
|
2019-12-22 07:23:43 +01:00
|
|
|
tvLastCleanup = view.findViewById(R.id.tvLastCleanup);
|
2019-05-06 09:10:13 +02:00
|
|
|
|
2019-06-15 21:25:49 +02:00
|
|
|
tvProcessors = view.findViewById(R.id.tvProcessors);
|
2019-05-23 18:45:11 +02:00
|
|
|
tvMemoryClass = view.findViewById(R.id.tvMemoryClass);
|
2019-10-19 21:53:19 +02:00
|
|
|
tvStorageSpace = view.findViewById(R.id.tvStorageSpace);
|
2019-12-22 07:23:43 +01:00
|
|
|
tvFingerprint = view.findViewById(R.id.tvFingerprint);
|
2019-05-26 12:41:41 +02:00
|
|
|
|
|
|
|
|
grpDebug = view.findViewById(R.id.grpDebug);
|
2019-05-06 09:10:13 +02:00
|
|
|
|
2019-05-06 15:30:30 +02:00
|
|
|
setOptions();
|
|
|
|
|
|
2019-05-06 09:10:13 +02:00
|
|
|
// Wire controls
|
|
|
|
|
|
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
|
2019-12-31 12:07:45 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-14 21:58:27 +01:00
|
|
|
swFts.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
|
prefs.edit().putBoolean("fts", checked).apply();
|
2020-01-16 09:44:54 +01:00
|
|
|
|
2020-01-15 10:29:16 +01:00
|
|
|
WorkerFts.init(getContext(), true);
|
|
|
|
|
|
2020-01-16 09:44:54 +01:00
|
|
|
if (!checked) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
|
|
|
|
|
FtsDbHelper.delete(sdb);
|
|
|
|
|
FtsDbHelper.optimize(sdb);
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
db.message().resetFts();
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(FragmentOptionsMisc.this, args, "fts:reset");
|
|
|
|
|
}
|
2020-01-14 21:58:27 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-16 18:21:03 +01:00
|
|
|
Helper.linkPro(tvFtsPro);
|
|
|
|
|
|
2019-05-06 09:10:13 +02:00
|
|
|
swEnglish.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
|
prefs.edit().putBoolean("english", checked).commit(); // apply won't work here
|
2019-05-10 08:54:06 +02:00
|
|
|
restart();
|
2019-05-06 09:10:13 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-05-12 20:15:16 +02:00
|
|
|
swWatchdog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
|
prefs.edit().putBoolean("watchdog", checked).apply();
|
|
|
|
|
WorkerWatchdog.init(getContext());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-05-06 09:10:13 +02:00
|
|
|
swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
|
prefs.edit().putBoolean("updates", checked).apply();
|
2019-06-22 16:34:46 +02:00
|
|
|
if (!checked) {
|
|
|
|
|
NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
|
nm.cancel(Helper.NOTIFICATION_UPDATE);
|
|
|
|
|
}
|
2019-05-06 09:10:13 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-08-24 13:13:48 +02:00
|
|
|
tvExperimentsHint.setPaintFlags(tvExperimentsHint.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
|
tvExperimentsHint.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
Helper.viewFAQ(getContext(), 125);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-08-24 12:30:33 +02:00
|
|
|
swExperiments.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
|
prefs.edit().putBoolean("experiments", checked).apply();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-05-10 08:53:45 +02:00
|
|
|
swCrashReports.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
2019-07-31 08:43:50 +02:00
|
|
|
prefs.edit()
|
|
|
|
|
.remove("crash_reports_asked")
|
|
|
|
|
.putBoolean("crash_reports", checked)
|
|
|
|
|
.apply();
|
2019-08-12 13:17:55 +02:00
|
|
|
Log.setCrashReporting(checked);
|
2019-05-10 08:53:45 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-05-06 09:10:13 +02:00
|
|
|
swDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
|
prefs.edit().putBoolean("debug", checked).apply();
|
2019-05-29 08:51:08 +02:00
|
|
|
grpDebug.setVisibility(checked || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
2019-05-06 09:10:13 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-10-05 09:37:57 +02:00
|
|
|
btnReset.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
onResetQuestions();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-07-10 09:35:20 +02:00
|
|
|
btnCleanup.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
onCleanup();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-15 10:29:16 +01:00
|
|
|
tvFtsIndexed.setText(null);
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(getContext());
|
|
|
|
|
db.message().liveFts().observe(getViewLifecycleOwner(), new Observer<TupleFtsStats>() {
|
2020-01-16 09:44:54 +01:00
|
|
|
private TupleFtsStats last = null;
|
|
|
|
|
|
2020-01-15 10:29:16 +01:00
|
|
|
@Override
|
|
|
|
|
public void onChanged(TupleFtsStats stats) {
|
|
|
|
|
if (stats == null)
|
|
|
|
|
tvFtsIndexed.setText(null);
|
2020-01-16 09:44:54 +01:00
|
|
|
else if (last == null || !last.equals(stats))
|
|
|
|
|
tvFtsIndexed.setText(getString(R.string.title_advanced_fts_indexed,
|
|
|
|
|
stats.fts,
|
|
|
|
|
stats.total,
|
|
|
|
|
Helper.humanReadableByteCount(FtsDbHelper.size(getContext()), true)));
|
|
|
|
|
last = stats;
|
2020-01-15 10:29:16 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-05-06 09:10:13 +02:00
|
|
|
setLastCleanup(prefs.getLong("last_cleanup", -1));
|
|
|
|
|
|
|
|
|
|
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroyView() {
|
|
|
|
|
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
|
|
|
|
|
super.onDestroyView();
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-06 14:41:03 +02:00
|
|
|
@Override
|
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
2019-09-10 08:53:07 +02:00
|
|
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
|
|
|
|
setOptions();
|
|
|
|
|
if ("last_cleanup".equals(key))
|
|
|
|
|
setLastCleanup(prefs.getLong(key, -1));
|
|
|
|
|
}
|
2019-05-06 14:41:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
2019-10-05 09:37:57 +02:00
|
|
|
inflater.inflate(R.menu.menu_options, menu);
|
2019-05-06 14:41:03 +02:00
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
case R.id.menu_default:
|
2019-09-01 22:33:32 +02:00
|
|
|
onMenuDefault();
|
2019-05-09 07:32:48 +02:00
|
|
|
return true;
|
2019-05-06 14:41:03 +02:00
|
|
|
default:
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-01 22:33:32 +02:00
|
|
|
private void onMenuDefault() {
|
2019-05-06 14:41:03 +02:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
SharedPreferences.Editor editor = prefs.edit();
|
2019-09-01 22:33:32 +02:00
|
|
|
for (String option : RESET_OPTIONS)
|
2019-05-06 14:41:03 +02:00
|
|
|
editor.remove(option);
|
|
|
|
|
editor.apply();
|
2019-07-14 12:32:32 +02:00
|
|
|
ToastEx.makeText(getContext(), R.string.title_setup_done, Toast.LENGTH_LONG).show();
|
2019-05-06 14:41:03 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-05 09:37:57 +02:00
|
|
|
private void onResetQuestions() {
|
2019-09-01 22:33:32 +02:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
SharedPreferences.Editor editor = prefs.edit();
|
|
|
|
|
for (String option : RESET_QUESTIONS)
|
|
|
|
|
editor.remove(option);
|
|
|
|
|
for (String key : prefs.getAll().keySet())
|
2019-10-04 15:25:04 +02:00
|
|
|
if (key.endsWith(".show_full") || key.endsWith(".show_images"))
|
2019-09-01 22:33:32 +02:00
|
|
|
editor.remove(key);
|
|
|
|
|
editor.apply();
|
|
|
|
|
ToastEx.makeText(getContext(), R.string.title_setup_done, Toast.LENGTH_LONG).show();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-10 09:35:20 +02:00
|
|
|
private void onCleanup() {
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPreExecute(Bundle args) {
|
|
|
|
|
btnCleanup.setEnabled(false);
|
2019-08-01 10:04:56 +02:00
|
|
|
ToastEx.makeText(getContext(), R.string.title_executing, Toast.LENGTH_LONG).show();
|
2019-07-10 09:35:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPostExecute(Bundle args) {
|
|
|
|
|
btnCleanup.setEnabled(true);
|
2019-08-13 18:22:52 +02:00
|
|
|
ToastEx.makeText(getContext(), R.string.title_completed, Toast.LENGTH_LONG).show();
|
2019-07-10 09:35:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
WorkerCleanup.cleanup(context, true);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
2019-12-06 08:50:46 +01:00
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
2019-07-10 09:35:20 +02:00
|
|
|
}
|
|
|
|
|
}.execute(this, new Bundle(), "cleanup:run");
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-06 09:10:13 +02:00
|
|
|
private void setOptions() {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
|
2019-12-31 12:07:45 +01:00
|
|
|
PackageManager pm = getContext().getPackageManager();
|
|
|
|
|
int state = pm.getComponentEnabledSetting(new ComponentName(getContext(), ActivitySearch.class));
|
|
|
|
|
|
|
|
|
|
swExternalSearch.setChecked(state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
|
2020-01-14 21:58:27 +01:00
|
|
|
swFts.setChecked(prefs.getBoolean("fts", false));
|
2019-05-06 09:10:13 +02:00
|
|
|
swEnglish.setChecked(prefs.getBoolean("english", false));
|
2019-05-12 20:15:16 +02:00
|
|
|
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
|
2019-05-06 09:10:13 +02:00
|
|
|
swUpdates.setChecked(prefs.getBoolean("updates", true));
|
2019-08-11 12:58:03 +02:00
|
|
|
swUpdates.setVisibility(
|
2019-09-10 09:05:21 +02:00
|
|
|
Helper.isPlayStoreInstall() || !Helper.hasValidFingerprint(getContext())
|
2019-08-11 12:58:03 +02:00
|
|
|
? View.GONE : View.VISIBLE);
|
2019-08-24 12:30:33 +02:00
|
|
|
swExperiments.setChecked(prefs.getBoolean("experiments", false));
|
2019-05-10 08:53:45 +02:00
|
|
|
swCrashReports.setChecked(prefs.getBoolean("crash_reports", false));
|
2019-11-08 12:17:07 +01:00
|
|
|
tvUuid.setText(prefs.getString("uuid", null));
|
2019-05-06 09:10:13 +02:00
|
|
|
swDebug.setChecked(prefs.getBoolean("debug", false));
|
|
|
|
|
|
2019-06-15 21:25:49 +02:00
|
|
|
tvProcessors.setText(getString(R.string.title_advanced_processors, Runtime.getRuntime().availableProcessors()));
|
|
|
|
|
|
2019-05-16 19:09:51 +02:00
|
|
|
ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
|
|
|
|
|
int class_mb = am.getMemoryClass();
|
2019-05-23 18:45:11 +02:00
|
|
|
tvMemoryClass.setText(getString(R.string.title_advanced_memory_class, class_mb + " MB"));
|
2019-10-19 21:53:19 +02:00
|
|
|
|
|
|
|
|
tvStorageSpace.setText(getString(R.string.title_advanced_storage_space,
|
2019-12-24 10:53:42 +01:00
|
|
|
Helper.humanReadableByteCount(Helper.getAvailableStorageSpace(), true),
|
|
|
|
|
Helper.humanReadableByteCount(Helper.getTotalStorageSpace(), true)));
|
2019-12-22 07:23:43 +01:00
|
|
|
tvFingerprint.setText(Helper.getFingerprint(getContext()));
|
2019-10-19 21:53:19 +02:00
|
|
|
|
2019-05-29 08:51:08 +02:00
|
|
|
grpDebug.setVisibility(swDebug.isChecked() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
2019-05-06 09:10:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setLastCleanup(long time) {
|
2019-07-15 21:28:25 +02:00
|
|
|
java.text.DateFormat DTF = Helper.getDateTimeInstance(getContext());
|
2019-05-06 09:10:13 +02:00
|
|
|
tvLastCleanup.setText(
|
|
|
|
|
getString(R.string.title_advanced_last_cleanup,
|
2019-07-15 21:28:25 +02:00
|
|
|
time < 0 ? "-" : DTF.format(time)));
|
2019-05-06 09:10:13 +02:00
|
|
|
}
|
|
|
|
|
}
|