mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-02 19:10:11 +01:00
Added button to show device's charsets
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user