mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Added button to show device's charsets
This commit is contained in:
parent
fc6f577a79
commit
e4c275f982
3 changed files with 54 additions and 2 deletions
|
@ -23,6 +23,7 @@ import android.app.ActivityManager;
|
|||
import android.app.NotificationManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -41,6 +42,7 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
|
@ -48,6 +50,9 @@ import androidx.lifecycle.Observer;
|
|||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import io.requery.android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
@ -74,6 +79,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
private TextView tvMemoryClass;
|
||||
private TextView tvStorageSpace;
|
||||
private TextView tvFingerprint;
|
||||
private Button btnCharsets;
|
||||
|
||||
private Group grpDebug;
|
||||
|
||||
|
@ -123,6 +129,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
tvMemoryClass = view.findViewById(R.id.tvMemoryClass);
|
||||
tvStorageSpace = view.findViewById(R.id.tvStorageSpace);
|
||||
tvFingerprint = view.findViewById(R.id.tvFingerprint);
|
||||
btnCharsets = view.findViewById(R.id.btnCharsets);
|
||||
|
||||
grpDebug = view.findViewById(R.id.grpDebug);
|
||||
|
||||
|
@ -278,6 +285,40 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
}
|
||||
});
|
||||
|
||||
btnCharsets.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new SimpleTask<SortedMap<String, Charset>>() {
|
||||
@Override
|
||||
protected SortedMap<String, Charset> onExecute(Context context, Bundle args) {
|
||||
return Charset.availableCharsets();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, SortedMap<String, Charset> charsets) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String key : charsets.keySet())
|
||||
sb.append(charsets.get(key).displayName()).append("\r\n");
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setTitle(R.string.title_advanced_charsets)
|
||||
.setMessage(sb.toString())
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// Do nothing
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(FragmentOptionsMisc.this, new Bundle(), "setup:charsets");
|
||||
}
|
||||
});
|
||||
|
||||
tvFtsIndexed.setText(null);
|
||||
|
||||
DB db = DB.getInstance(getContext());
|
||||
|
|
|
@ -352,10 +352,20 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvStorageSpace" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCharsets"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_charsets"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvFingerprint" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpDebug"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvProcessors,tvMemoryClass,tvStorageSpace,tvFingerprint" />
|
||||
app:constraint_referenced_ids="tvProcessors,tvMemoryClass,tvStorageSpace,tvFingerprint,btnCharsets" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -444,11 +444,12 @@
|
|||
<string name="title_advanced_crash_reports">Send error reports</string>
|
||||
<string name="title_advanced_debug">Debug mode</string>
|
||||
<string name="title_advanced_cleanup">Cleanup</string>
|
||||
<string name="title_advanced_last_cleanup">Last cleanup: %1$s</string>
|
||||
<string name="title_advanced_more">More options</string>
|
||||
<string name="title_advanced_processors" translatable="false">Processors: %1$d</string>
|
||||
<string name="title_advanced_memory_class" translatable="false">Memory class: %1$s</string>
|
||||
<string name="title_advanced_storage_space" translatable="false">Storage space: %1$s/%2$s</string>
|
||||
<string name="title_advanced_last_cleanup">Last cleanup: %1$s</string>
|
||||
<string name="title_advanced_charsets" translatable="false">Charsets</string>
|
||||
|
||||
<string name="title_advanced_enabled_hint">Globally disable or enable receiving of messages</string>
|
||||
<string name="title_advanced_manual_hint">If synchronization is disabled, it is still possible to synchronize manually by pulling down the message list.</string>
|
||||
|
|
Loading…
Reference in a new issue