SD Maid v5.6.3版本的 MD5 值为:b283f6effbd880c54f4e4da72852de99
以下内容为反编译后的 FilterEditorMainFragment.java 源代码,内容仅作参考
package eu.thedarken.sdm.systemcleaner.ui.filter.user;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.format.Formatter;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.d;
import androidx.appcompat.widget.Toolbar;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.thedarken.sdm.App;
import eu.thedarken.sdm.R;
import eu.thedarken.sdm.systemcleaner.core.filter.Filter;
import eu.thedarken.sdm.systemcleaner.core.filter.c;
import eu.thedarken.sdm.systemcleaner.ui.filter.user.FilterEditorMainFragment;
import eu.thedarken.sdm.tools.forensics.Location;
import eu.thedarken.sdm.ui.entrybox.EntryBox;
import io.reactivex.rxjava3.internal.operators.single.i;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.regex.Pattern;
import ta.a0;
import ta.n0;
import ta.p;
import uc.p;
public class FilterEditorMainFragment extends p implements a0, EntryBox.c {
public static final String f4807f0 = App.d("FilterEditorMainFragment");
public boolean f4808e0 = false;
@BindView
EntryBox<String> mBaseEntryBox;
@BindView
Spinner mContentSpinner;
@BindView
EditText mDescription;
@BindView
EditText mEtLabel;
@BindView
EntryBox<String> mExcludesBox;
@BindView
EntryBox<Location> mLocationsBox;
@BindView
EditText mMaxSize;
@BindView
TextView mMaxSizeLabel;
@BindView
EditText mMinSize;
@BindView
TextView mMinSizeLabel;
@BindView
EntryBox<String> mNameEndsBox;
@BindView
EntryBox<String> mNameStartsBox;
@BindView
EntryBox<String> mPathContainsBox;
@BindView
EntryBox<Pattern> mRegexBox;
@BindView
Toolbar mToolbar;
@BindView
Spinner mTypeSpinner;
@BindView
EditText maxAge;
@BindView
TextView maxAgeLabel;
@BindView
EditText minAge;
@BindView
TextView minAgeLabel;
public class a extends n0 {
public a() {
}
@Override
public final void afterTextChanged(Editable editable) {
FilterEditorMainFragment filterEditorMainFragment = FilterEditorMainFragment.this;
filterEditorMainFragment.mToolbar.setTitle(editable.toString());
filterEditorMainFragment.O3();
}
}
public class b extends n0 {
public b() {
}
@Override
public final void afterTextChanged(Editable editable) {
FilterEditorMainFragment filterEditorMainFragment = FilterEditorMainFragment.this;
filterEditorMainFragment.mToolbar.setSubtitle(editable.toString());
filterEditorMainFragment.O3();
}
}
public class c implements AdapterView.OnItemSelectedListener {
public c() {
}
@Override
public final void onItemSelected(AdapterView<?> adapterView, View view, int i10, long j10) {
FilterEditorMainFragment.this.O3();
}
@Override
public final void onNothingSelected(AdapterView<?> adapterView) {
FilterEditorMainFragment.this.O3();
}
}
public class d implements AdapterView.OnItemSelectedListener {
public d() {
}
@Override
public final void onItemSelected(AdapterView<?> adapterView, View view, int i10, long j10) {
FilterEditorMainFragment.this.O3();
}
@Override
public final void onNothingSelected(AdapterView<?> adapterView) {
FilterEditorMainFragment.this.O3();
}
}
public class e extends n0 {
public e() {
}
@Override
public final void afterTextChanged(Editable editable) {
FilterEditorMainFragment filterEditorMainFragment = FilterEditorMainFragment.this;
if (editable.length() <= 0) {
return;
}
try {
filterEditorMainFragment.mMinSizeLabel.setText(Formatter.formatFileSize(filterEditorMainFragment.K2(), Long.parseLong(editable.toString())));
} catch (NumberFormatException e10) {
ne.a.d(FilterEditorMainFragment.f4807f0).n(e10);
editable.clear();
}
filterEditorMainFragment.O3();
}
}
public class f extends n0 {
public f() {
}
@Override
public final void afterTextChanged(Editable editable) {
FilterEditorMainFragment filterEditorMainFragment = FilterEditorMainFragment.this;
if (editable.length() <= 0) {
return;
}
try {
filterEditorMainFragment.mMaxSizeLabel.setText(Formatter.formatFileSize(filterEditorMainFragment.K2(), Long.parseLong(editable.toString())));
} catch (NumberFormatException e10) {
ne.a.d(FilterEditorMainFragment.f4807f0).n(e10);
editable.clear();
}
filterEditorMainFragment.O3();
}
}
public class g extends n0 {
public g() {
}
@Override
public final void afterTextChanged(Editable editable) {
FilterEditorMainFragment filterEditorMainFragment = FilterEditorMainFragment.this;
if (editable.length() <= 0) {
return;
}
try {
filterEditorMainFragment.minAgeLabel.setText(DateUtils.getRelativeTimeSpanString(System.currentTimeMillis() - Long.parseLong(editable.toString()), System.currentTimeMillis(), 60000L));
} catch (NumberFormatException e10) {
ne.a.d(FilterEditorMainFragment.f4807f0).n(e10);
editable.clear();
}
filterEditorMainFragment.O3();
}
}
public class h extends n0 {
public h() {
}
@Override
public final void afterTextChanged(Editable editable) {
FilterEditorMainFragment filterEditorMainFragment = FilterEditorMainFragment.this;
if (editable.length() <= 0) {
return;
}
try {
filterEditorMainFragment.maxAgeLabel.setText(DateUtils.getRelativeTimeSpanString(System.currentTimeMillis() - Long.parseLong(editable.toString()), System.currentTimeMillis(), 60000L));
} catch (NumberFormatException e10) {
ne.a.d(FilterEditorMainFragment.f4807f0).n(e10);
editable.clear();
}
filterEditorMainFragment.O3();
}
}
@Override
public final void M3(Menu menu, MenuInflater menuInflater) {
menuInflater.inflate(R.menu.filter_editor, menu);
}
@Override
public final void N3(Menu menu) {
MenuItem findItem = menu.findItem(R.id.menu_delete);
ka.a aVar = ((FilterEditorActivity) y3()).A;
c.a P3 = P3();
P3.getClass();
eu.thedarken.sdm.systemcleaner.core.filter.c cVar = new eu.thedarken.sdm.systemcleaner.core.filter.c(P3);
aVar.getClass();
boolean z4 = false;
findItem.setVisible(!cVar.isStockFilter() && new File(aVar.f7559e, cVar.a()).exists());
MenuItem findItem2 = menu.findItem(R.id.menu_save);
if (Q3() && R3()) {
z4 = true;
}
findItem2.setVisible(z4);
}
public final void O3() {
Toolbar toolbar;
int i10;
if (this.f4808e0) {
T3();
if (R3() || !Q3()) {
toolbar = this.mToolbar;
i10 = R.drawable.ic_cancel_white_24dp;
} else {
toolbar = this.mToolbar;
i10 = R.drawable.ic_arrow_back_white_24dp;
}
toolbar.setNavigationIcon(i10);
y3().invalidateOptionsMenu();
}
}
public final c.a P3() {
return ((FilterEditorActivity) I2()).y;
}
@Override
public final boolean Q0() {
U3();
return true;
}
public final boolean Q3() {
Filter m3 = P3().m();
boolean isEmpty = m3.getLabel().isEmpty();
if (m3.getRegex().isEmpty() && m3.getPossibleBasePathes().isEmpty() && m3.getPossibleNameEndings().isEmpty() && m3.getPossibleNameInits().isEmpty() && m3.getPossiblePathContains().isEmpty()) {
isEmpty = true;
}
return !isEmpty;
}
public final boolean R3() {
eu.thedarken.sdm.systemcleaner.core.filter.c cVar;
ka.a aVar = ((FilterEditorActivity) y3()).A;
aVar.getClass();
Iterator it = ((Collection) new i(1, new d8.c(2, aVar)).f()).iterator();
while (true) {
if (!it.hasNext()) {
cVar = null;
break;
}
cVar = (eu.thedarken.sdm.systemcleaner.core.filter.c) it.next();
if (cVar.getIdentifier().equals(P3().f4759a)) {
break;
}
}
if (cVar != null) {
c.a P3 = P3();
P3.getClass();
return !new eu.thedarken.sdm.systemcleaner.core.filter.c(P3).equals(cVar);
}
return true;
}
public final void S3() {
c.a P3 = P3();
P3.getClass();
eu.thedarken.sdm.systemcleaner.core.filter.c cVar = new eu.thedarken.sdm.systemcleaner.core.filter.c(P3);
try {
ka.a.d(cVar, ((FilterEditorActivity) y3()).A.f7559e);
Toast.makeText(I2(), (int) R.string.button_done, 0).show();
} catch (IOException e10) {
ne.a.d(f4807f0).o(e10, "Failed to save filter: %s", cVar);
Toast.makeText(I2(), (int) R.string.error, 0).show();
}
O3();
}
public final void T3() {
c.a P3;
Filter.TargetType targetType;
c.a P32;
Boolean bool;
P3().h(this.mEtLabel.getText().toString());
P3().d(this.mDescription.getText().toString());
if (this.mTypeSpinner.getSelectedItemPosition() == 1) {
P3 = P3();
targetType = Filter.TargetType.DIRECTORY;
} else if (this.mTypeSpinner.getSelectedItemPosition() != 2) {
P3().l(null);
if (this.mContentSpinner.getSelectedItemPosition() != 1) {
P32 = P3();
bool = Boolean.TRUE;
} else if (this.mContentSpinner.getSelectedItemPosition() != 2) {
P3().g(null);
String obj = this.mMinSize.getText().toString();
P3().h = TextUtils.isEmpty(obj) ? null : Long.valueOf(Long.parseLong(obj));
String obj2 = this.mMaxSize.getText().toString();
P3().f4764g = TextUtils.isEmpty(obj2) ? null : Long.valueOf(Long.parseLong(obj2));
String obj3 = this.minAge.getText().toString();
P3().f4766j = TextUtils.isEmpty(obj3) ? null : Long.valueOf(Long.parseLong(obj3));
String obj4 = this.maxAge.getText().toString();
P3().f4765i = TextUtils.isEmpty(obj4) ? null : Long.valueOf(Long.parseLong(obj4));
P3().n.clear();
P3().n.addAll(this.mBaseEntryBox.getContent());
P3().f4770o.clear();
P3().f4770o.addAll(this.mPathContainsBox.getContent());
P3().f4771p.clear();
P3().f4771p.addAll(this.mNameStartsBox.getContent());
P3().f4772q.clear();
P3().f4772q.addAll(this.mNameEndsBox.getContent());
P3().f4773r.clear();
P3().f4773r.addAll(this.mExcludesBox.getContent());
P3().f4769m.clear();
P3().f4769m.addAll(this.mLocationsBox.getContent());
P3().f4774s.clear();
P3().f4774s.addAll(this.mRegexBox.getContent());
} else {
P32 = P3();
bool = Boolean.FALSE;
}
P32.g(bool);
String obj5 = this.mMinSize.getText().toString();
P3().h = TextUtils.isEmpty(obj5) ? null : Long.valueOf(Long.parseLong(obj5));
String obj22 = this.mMaxSize.getText().toString();
P3().f4764g = TextUtils.isEmpty(obj22) ? null : Long.valueOf(Long.parseLong(obj22));
String obj32 = this.minAge.getText().toString();
P3().f4766j = TextUtils.isEmpty(obj32) ? null : Long.valueOf(Long.parseLong(obj32));
String obj42 = this.maxAge.getText().toString();
P3().f4765i = TextUtils.isEmpty(obj42) ? null : Long.valueOf(Long.parseLong(obj42));
P3().n.clear();
P3().n.addAll(this.mBaseEntryBox.getContent());
P3().f4770o.clear();
P3().f4770o.addAll(this.mPathContainsBox.getContent());
P3().f4771p.clear();
P3().f4771p.addAll(this.mNameStartsBox.getContent());
P3().f4772q.clear();
P3().f4772q.addAll(this.mNameEndsBox.getContent());
P3().f4773r.clear();
P3().f4773r.addAll(this.mExcludesBox.getContent());
P3().f4769m.clear();
P3().f4769m.addAll(this.mLocationsBox.getContent());
P3().f4774s.clear();
P3().f4774s.addAll(this.mRegexBox.getContent());
} else {
P3 = P3();
targetType = Filter.TargetType.FILE;
}
P3.l(targetType);
if (this.mContentSpinner.getSelectedItemPosition() != 1) {
}
P32.g(bool);
String obj52 = this.mMinSize.getText().toString();
P3().h = TextUtils.isEmpty(obj52) ? null : Long.valueOf(Long.parseLong(obj52));
String obj222 = this.mMaxSize.getText().toString();
P3().f4764g = TextUtils.isEmpty(obj222) ? null : Long.valueOf(Long.parseLong(obj222));
String obj322 = this.minAge.getText().toString();
P3().f4766j = TextUtils.isEmpty(obj322) ? null : Long.valueOf(Long.parseLong(obj322));
String obj422 = this.maxAge.getText().toString();
P3().f4765i = TextUtils.isEmpty(obj422) ? null : Long.valueOf(Long.parseLong(obj422));
P3().n.clear();
P3().n.addAll(this.mBaseEntryBox.getContent());
P3().f4770o.clear();
P3().f4770o.addAll(this.mPathContainsBox.getContent());
P3().f4771p.clear();
P3().f4771p.addAll(this.mNameStartsBox.getContent());
P3().f4772q.clear();
P3().f4772q.addAll(this.mNameEndsBox.getContent());
P3().f4773r.clear();
P3().f4773r.addAll(this.mExcludesBox.getContent());
P3().f4769m.clear();
P3().f4769m.addAll(this.mLocationsBox.getContent());
P3().f4774s.clear();
P3().f4774s.addAll(this.mRegexBox.getContent());
}
public final void U3() {
if (!Q3() || !R3()) {
y3().finish();
return;
}
d.a aVar = new d.a(A3());
aVar.f435a.f413g = "You have unsaved changes.";
aVar.f(R.string.button_save, new DialogInterface.OnClickListener(this) {
public final FilterEditorMainFragment f9413i;
{
this.f9413i = this;
}
@Override
public final void onClick(DialogInterface dialogInterface, int i10) {
int i11 = r2;
FilterEditorMainFragment filterEditorMainFragment = this.f9413i;
switch (i11) {
case 0:
String str = FilterEditorMainFragment.f4807f0;
filterEditorMainFragment.S3();
filterEditorMainFragment.y3().finish();
return;
default:
String str2 = FilterEditorMainFragment.f4807f0;
filterEditorMainFragment.y3().finish();
return;
}
}
});
aVar.c(R.string.button_close, new DialogInterface.OnClickListener(this) {
public final FilterEditorMainFragment f9413i;
{
this.f9413i = this;
}
@Override
public final void onClick(DialogInterface dialogInterface, int i10) {
int i11 = r2;
FilterEditorMainFragment filterEditorMainFragment = this.f9413i;
switch (i11) {
case 0:
String str = FilterEditorMainFragment.f4807f0;
filterEditorMainFragment.S3();
filterEditorMainFragment.y3().finish();
return;
default:
String str2 = FilterEditorMainFragment.f4807f0;
filterEditorMainFragment.y3().finish();
return;
}
}
});
aVar.e(R.string.button_cancel, new z5.c(21));
aVar.j();
}
@Override
public final void X2(Bundle bundle) {
super.X2(bundle);
eu.thedarken.sdm.systemcleaner.core.filter.c cVar = (eu.thedarken.sdm.systemcleaner.core.filter.c) P3().m();
this.mEtLabel.setText(cVar.getLabel());
this.mDescription.setText(cVar.getDescription());
if (cVar.getFileEmpty() == Boolean.TRUE) {
this.mContentSpinner.setSelection(1);
} else if (cVar.getFileEmpty() == Boolean.FALSE) {
this.mContentSpinner.setSelection(2);
}
if (cVar.getTargetType() == Filter.TargetType.DIRECTORY) {
this.mTypeSpinner.setSelection(1);
} else if (cVar.getTargetType() == Filter.TargetType.FILE) {
this.mTypeSpinner.setSelection(2);
}
this.mMinSize.setText(cVar.getMinimumSize() != null ? cVar.getMinimumSize().toString() : "");
this.mMaxSize.setText(cVar.getMaximumSize() != null ? cVar.getMaximumSize().toString() : "");
this.minAge.setText(cVar.getMinimumAge() != null ? cVar.getMinimumAge().toString() : "");
this.maxAge.setText(cVar.getMaximumAge() != null ? cVar.getMaximumAge().toString() : "");
this.mBaseEntryBox.setContent(cVar.getPossibleBasePathes());
this.mPathContainsBox.setContent(cVar.getPossiblePathContains());
this.mNameStartsBox.setContent(cVar.getPossibleNameInits());
this.mNameEndsBox.setContent(cVar.getPossibleNameEndings());
this.mExcludesBox.setContent(cVar.getExclusions());
this.mLocationsBox.setContent(cVar.getLocations());
this.mRegexBox.setContent(cVar.getRegex());
this.f4808e0 = true;
((FilterEditorActivity) I2()).z1(this.mToolbar);
((FilterEditorActivity) I2()).x1().p(true);
}
@Override
public final void a3(Bundle bundle) {
E3(true);
super.a3(bundle);
}
@Override
public final View c3(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
View inflate = layoutInflater.inflate(R.layout.systemcleaner_filtereditor_fragment, viewGroup, false);
K3(ButterKnife.a(inflate, this));
return inflate;
}
@Override
public final boolean i3(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.menu_save) {
S3();
return true;
} else if (menuItem.getItemId() == R.id.menu_delete) {
c.a P3 = P3();
P3.getClass();
((FilterEditorActivity) y3()).A.a(new eu.thedarken.sdm.systemcleaner.core.filter.c(P3));
y3().finish();
return false;
} else if (menuItem.getItemId() == 16908332) {
U3();
return true;
} else if (menuItem.getItemId() == R.id.menu_help) {
p.d d10 = new ta.p(K2()).d("https://github.com/d4rken/sdmaid-public/wiki/Systemcleaner#userfilter");
d10.d = I2();
d10.f9767e = true;
d10.c();
return false;
} else {
return false;
}
}
@Override
public final void m3(Bundle bundle) {
T3();
}
@Override
public final void p3(View view, Bundle bundle) {
this.mToolbar.setNavigationIcon(R.drawable.ic_cancel_white_24dp);
EntryBox<String> entryBox = this.mBaseEntryBox;
entryBox.setHelpText("<font color=" + a0.b.b(A3(), R.color.green) + ">/storage/emulated/0/Cake/</font>folder/some-file.ext");
EntryBox<String> entryBox2 = this.mPathContainsBox;
entryBox2.setHelpText("/storage/emulated/0/Cake/<font color=" + a0.b.b(A3(), R.color.green) + ">folder/</font>some-file.ext");
EntryBox<String> entryBox3 = this.mNameStartsBox;
entryBox3.setHelpText("/storage/emulated/0/Cake/folder/<font color=" + a0.b.b(A3(), R.color.green) + ">some-</font>file.ext");
EntryBox<String> entryBox4 = this.mNameEndsBox;
entryBox4.setHelpText("/storage/emulated/0/Cake/folder/some-file<font color=" + a0.b.b(A3(), R.color.green) + ">.ext</font>");
EntryBox<String> entryBox5 = this.mExcludesBox;
entryBox5.setHelpText("<font color=" + a0.b.b(A3(), R.color.deep_orange) + ">/DCIM/</font>");
EntryBox<Location> entryBox6 = this.mLocationsBox;
StringBuilder sb2 = new StringBuilder();
Location location = Location.SDCARD;
sb2.append(location.name());
sb2.append(": '/storage/emulated/0'<br>");
Location location2 = Location.PUBLIC_DATA;
sb2.append(location2);
sb2.append(": '/storage/emulated/0/Android/data'");
Location location3 = Location.PRIVATE_DATA;
sb2.append(location3);
sb2.append(": '/data/user/0'");
entryBox6.setHelpText(sb2.toString());
this.mRegexBox.setHelpText(".*?(CustomerOrder-2018-12-[0-9]{1,2}\\.pdf)");
this.mEtLabel.addTextChangedListener(new a());
this.mDescription.addTextChangedListener(new b());
this.mContentSpinner.setOnItemSelectedListener(new c());
this.mTypeSpinner.setOnItemSelectedListener(new d());
this.mMinSize.addTextChangedListener(new e());
this.mMaxSize.addTextChangedListener(new f());
this.minAge.addTextChangedListener(new g());
this.maxAge.addTextChangedListener(new h());
this.mBaseEntryBox.setDataListener(this);
this.mBaseEntryBox.setDataEditor(new wc.f());
this.mExcludesBox.setDataListener(this);
this.mExcludesBox.setDataEditor(new wc.f());
this.mNameEndsBox.setDataListener(this);
this.mNameEndsBox.setDataEditor(new wc.f());
this.mNameStartsBox.setDataListener(this);
this.mNameStartsBox.setDataEditor(new wc.f());
this.mPathContainsBox.setDataListener(this);
this.mPathContainsBox.setDataEditor(new wc.f());
this.mLocationsBox.setDataListener(this);
EntryBox<Location> entryBox7 = this.mLocationsBox;
Location location4 = Location.APP_ASEC;
entryBox7.setDataEditor(new wc.d(location, location2, Location.PUBLIC_MEDIA, Location.PUBLIC_OBB, Location.PORTABLE, Location.DOWNLOAD_CACHE, Location.UNKNOWN, Location.DATA, Location.APP_APP, Location.APP_APP_PRIVATE, location4, location4, Location.APP_LIB, Location.DALVIK_DEX, Location.DALVIK_PROFILE, location3));
this.mRegexBox.setDataListener(this);
this.mRegexBox.setDataEditor(new wc.e());
super.p3(view, bundle);
}
}