mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-08 18:13:24 +02:00
External answer improvement
This commit is contained in:
@@ -47,7 +47,16 @@ public class ActivityAnswer extends ActivityBase {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getSupportActionBar().setSubtitle(getString(R.string.app_answer));
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence query = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
|
||||
final boolean readonly = intent.getBooleanExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, false);
|
||||
|
||||
getSupportActionBar().setSubtitle(query == null ? null : query.toString());
|
||||
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
|
||||
setContentView(view);
|
||||
@@ -81,14 +90,10 @@ public class ActivityAnswer extends ActivityBase {
|
||||
cbm.setPrimaryClip(ClipData.newHtmlText(getString(R.string.app_name), text, html));
|
||||
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
boolean readonly = intent.getBooleanExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, false);
|
||||
if (!readonly) {
|
||||
Intent result = new Intent();
|
||||
result.putExtra(Intent.EXTRA_PROCESS_TEXT, text);
|
||||
setResult(RESULT_OK, result);
|
||||
}
|
||||
if (!readonly) {
|
||||
Intent result = new Intent();
|
||||
result.putExtra(Intent.EXTRA_PROCESS_TEXT, text);
|
||||
setResult(RESULT_OK, result);
|
||||
}
|
||||
|
||||
finish();
|
||||
@@ -127,4 +132,8 @@ public class ActivityAnswer extends ActivityBase {
|
||||
}
|
||||
}.execute(this, new Bundle(), "answers");
|
||||
}
|
||||
|
||||
static boolean canAnswer(Context context) {
|
||||
return BuildConfig.DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +188,8 @@ public class FragmentAnswer extends FragmentBase {
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityAnswer answer) {
|
||||
final Context context = getContext();
|
||||
|
||||
if (copy > 0 && answer != null) {
|
||||
answer.applied = 0;
|
||||
answer.last_applied = null;
|
||||
@@ -215,14 +217,14 @@ public class FragmentAnswer extends FragmentBase {
|
||||
public Drawable getDrawable(String source) {
|
||||
if (source != null && source.startsWith("cid:"))
|
||||
source = null;
|
||||
return ImageHelper.decodeImage(getContext(), -1, source, true, 0, 1.0f, etText);
|
||||
return ImageHelper.decodeImage(context, -1, source, true, 0, 1.0f, etText);
|
||||
}
|
||||
}, null, getContext()));
|
||||
}, null, context));
|
||||
}
|
||||
|
||||
bottom_navigation.findViewById(R.id.action_delete).setVisibility(answer == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (BuildConfig.DEBUG)
|
||||
if (ActivityAnswer.canAnswer(context))
|
||||
cbExternal.setVisibility(View.VISIBLE);
|
||||
grpReady.setVisibility(View.VISIBLE);
|
||||
bottom_navigation.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -90,6 +90,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
|
||||
private SwitchCompat swPowerMenu;
|
||||
private SwitchCompat swExternalSearch;
|
||||
private SwitchCompat swExternalAnswer;
|
||||
private SwitchCompat swShortcuts;
|
||||
private SwitchCompat swFts;
|
||||
private SwitchCompat swClassification;
|
||||
@@ -201,6 +202,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
|
||||
swPowerMenu = view.findViewById(R.id.swPowerMenu);
|
||||
swExternalSearch = view.findViewById(R.id.swExternalSearch);
|
||||
swExternalAnswer = view.findViewById(R.id.swExternalAnswer);
|
||||
swShortcuts = view.findViewById(R.id.swShortcuts);
|
||||
swFts = view.findViewById(R.id.swFts);
|
||||
swClassification = view.findViewById(R.id.swClassification);
|
||||
@@ -274,8 +276,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
Helper.enableComponent(getContext(), ActivitySearch.class, checked);
|
||||
if (BuildConfig.DEBUG)
|
||||
Helper.enableComponent(getContext(), ActivityAnswer.class, checked);
|
||||
}
|
||||
});
|
||||
|
||||
swExternalAnswer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
Helper.enableComponent(getContext(), ActivityAnswer.class, checked);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -838,6 +845,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
|
||||
tvFtsIndexed.setText(null);
|
||||
|
||||
swExternalAnswer.setVisibility(
|
||||
ActivityAnswer.canAnswer(getContext()) ? View.VISIBLE : View.GONE);
|
||||
|
||||
DB db = DB.getInstance(getContext());
|
||||
db.message().liveFts().observe(getViewLifecycleOwner(), new Observer<TupleFtsStats>() {
|
||||
private TupleFtsStats last = null;
|
||||
@@ -981,6 +991,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||
swPowerMenu.setChecked(Helper.isComponentEnabled(getContext(), ServicePowerControl.class));
|
||||
swExternalSearch.setChecked(Helper.isComponentEnabled(getContext(), ActivitySearch.class));
|
||||
swExternalAnswer.setChecked(Helper.isComponentEnabled(getContext(), ActivityAnswer.class));
|
||||
swShortcuts.setChecked(prefs.getBoolean("shortcuts", true));
|
||||
swFts.setChecked(prefs.getBoolean("fts", false));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user