Classifier: changed default, refactoring

pull/191/head
M66B 4 years ago
parent d6dfe44a9c
commit feb422c48e

@ -84,8 +84,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swShortcuts; private SwitchCompat swShortcuts;
private SwitchCompat swFts; private SwitchCompat swFts;
private SwitchCompat swClassification; private SwitchCompat swClassification;
private TextView tvClassMinChance; private TextView tvClassMinProbability;
private SeekBar sbClassMinChance; private SeekBar sbClassMinProbability;
private TextView tvClassMinDifference; private TextView tvClassMinDifference;
private SeekBar sbClassMinDifference; private SeekBar sbClassMinDifference;
private ImageButton ibClassification; private ImageButton ibClassification;
@ -129,7 +129,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"shortcuts", "fts", "shortcuts", "fts",
"classification", "class_min_chance", "class_min_difference", "classification", "class_min_probability", "class_min_difference",
"language", "watchdog", "updates", "language", "watchdog", "updates",
"experiments", "query_threads", "crash_reports", "cleanup_attachments", "experiments", "query_threads", "crash_reports", "cleanup_attachments",
"protocol", "debug", "auth_plain", "auth_login", "auth_sasl" "protocol", "debug", "auth_plain", "auth_login", "auth_sasl"
@ -175,8 +175,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swFts = view.findViewById(R.id.swFts); swFts = view.findViewById(R.id.swFts);
swClassification = view.findViewById(R.id.swClassification); swClassification = view.findViewById(R.id.swClassification);
ibClassification = view.findViewById(R.id.ibClassification); ibClassification = view.findViewById(R.id.ibClassification);
tvClassMinChance = view.findViewById(R.id.tvClassMinChance); tvClassMinProbability = view.findViewById(R.id.tvClassMinProbability);
sbClassMinChance = view.findViewById(R.id.sbClassMinChance); sbClassMinProbability = view.findViewById(R.id.sbClassMinProbability);
tvClassMinDifference = view.findViewById(R.id.tvClassMinDifference); tvClassMinDifference = view.findViewById(R.id.tvClassMinDifference);
sbClassMinDifference = view.findViewById(R.id.sbClassMinDifference); sbClassMinDifference = view.findViewById(R.id.sbClassMinDifference);
tvFtsIndexed = view.findViewById(R.id.tvFtsIndexed); tvFtsIndexed = view.findViewById(R.id.tvFtsIndexed);
@ -296,10 +296,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
} }
}); });
sbClassMinChance.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { sbClassMinProbability.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
prefs.edit().putInt("class_min_chance", progress).apply(); prefs.edit().putInt("class_min_probability", progress).apply();
} }
@Override @Override
@ -800,9 +800,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swClassification.setChecked(prefs.getBoolean("classification", false)); swClassification.setChecked(prefs.getBoolean("classification", false));
int class_min_chance = prefs.getInt("class_min_chance", 20); int class_min_chance = prefs.getInt("class_min_probability", 50);
tvClassMinChance.setText(getString(R.string.title_advanced_class_min_chance, NF.format(class_min_chance))); tvClassMinProbability.setText(getString(R.string.title_advanced_class_min_chance, NF.format(class_min_chance)));
sbClassMinChance.setProgress(class_min_chance); sbClassMinProbability.setProgress(class_min_chance);
int class_min_difference = prefs.getInt("class_min_difference", 50); int class_min_difference = prefs.getInt("class_min_difference", 50);
tvClassMinDifference.setText(getString(R.string.title_advanced_class_min_difference, NF.format(class_min_difference))); tvClassMinDifference.setText(getString(R.string.title_advanced_class_min_difference, NF.format(class_min_difference)));

@ -255,7 +255,7 @@ public class MessageClassifier {
}); });
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
double class_min_chance = prefs.getInt("class_min_chance", 20) / 100.0; double class_min_chance = prefs.getInt("class_min_probability", 50) / 100.0;
double class_min_difference = prefs.getInt("class_min_difference", 50) / 100.0; double class_min_difference = prefs.getInt("class_min_difference", 50) / 100.0;
// Select best class // Select best class

@ -134,7 +134,7 @@
app:srcCompat="@drawable/twotone_info_24" /> app:srcCompat="@drawable/twotone_info_24" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvClassMinChance" android:id="@+id/tvClassMinProbability"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
@ -146,7 +146,7 @@
app:layout_constraintTop_toBottomOf="@id/ibClassification" /> app:layout_constraintTop_toBottomOf="@id/ibClassification" />
<SeekBar <SeekBar
android:id="@+id/sbClassMinChance" android:id="@+id/sbClassMinProbability"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:max="100" android:max="100"
@ -154,7 +154,7 @@
android:progress="20" android:progress="20"
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/tvClassMinChance" /> app:layout_constraintTop_toBottomOf="@id/tvClassMinProbability" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvClassMinDifference" android:id="@+id/tvClassMinDifference"
@ -166,7 +166,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
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/sbClassMinChance" /> app:layout_constraintTop_toBottomOf="@id/sbClassMinProbability" />
<SeekBar <SeekBar
android:id="@+id/sbClassMinDifference" android:id="@+id/sbClassMinDifference"

Loading…
Cancel
Save