Simplification

pull/210/head
M66B 2 years ago
parent 3889d99903
commit 1e886e7241

@ -472,6 +472,6 @@ public class ActivitySignature extends ActivityBase {
int end = args.getInt("end");
String title = args.getString("title");
etText.setSelection(start, end);
StyleHelper.apply(-1, R.id.menu_link, this, null, etText, link, title);
StyleHelper.apply(R.id.menu_link, this, null, etText, link, title);
}
}

@ -561,7 +561,7 @@ public class FragmentAnswer extends FragmentBase {
int end = args.getInt("end");
String title = args.getString("title");
etText.setSelection(start, end);
StyleHelper.apply(-1, R.id.menu_link, getViewLifecycleOwner(), null, etText, link, title);
StyleHelper.apply(R.id.menu_link, getViewLifecycleOwner(), null, etText, link, title);
}
private void onDelete() {

@ -1921,7 +1921,7 @@ public class FragmentCompose extends FragmentBase {
startSearch();
return true;
} else if (itemId == R.id.menu_clear) {
StyleHelper.apply(-1, R.id.menu_clear, getViewLifecycleOwner(), null, etBody);
StyleHelper.apply(R.id.menu_clear, getViewLifecycleOwner(), null, etBody);
return true;
} else if (itemId == R.id.menu_legend) {
onMenuLegend();
@ -4216,7 +4216,7 @@ public class FragmentCompose extends FragmentBase {
int end = args.getInt("end");
String title = args.getString("title");
etBody.setSelection(start, end);
StyleHelper.apply(-1, R.id.menu_link, getViewLifecycleOwner(), null, etBody, link, title);
StyleHelper.apply(R.id.menu_link, getViewLifecycleOwner(), null, etBody, link, title);
}
private void onActionDiscardConfirmed() {
@ -7155,17 +7155,17 @@ public class FragmentCompose extends FragmentBase {
return true;
case KeyEvent.KEYCODE_B:
if (etBody.hasSelection())
return StyleHelper.apply(-1, R.id.menu_bold, getViewLifecycleOwner(), null, etBody);
return StyleHelper.apply(R.id.menu_bold, getViewLifecycleOwner(), null, etBody);
else
return false;
case KeyEvent.KEYCODE_I:
if (etBody.hasSelection())
return StyleHelper.apply(-1, R.id.menu_italic, getViewLifecycleOwner(), null, etBody);
return StyleHelper.apply(R.id.menu_italic, getViewLifecycleOwner(), null, etBody);
else
return false;
case KeyEvent.KEYCODE_U:
if (etBody.hasSelection())
return StyleHelper.apply(-1, R.id.menu_underline, getViewLifecycleOwner(), null, etBody);
return StyleHelper.apply(R.id.menu_underline, getViewLifecycleOwner(), null, etBody);
else
return false;
}

@ -123,7 +123,7 @@ public class StyleHelper {
View.OnClickListener styleListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
StyleHelper.apply(-1, v.getId(), owner, v, etBody);
StyleHelper.apply(v.getId(), owner, v, etBody);
}
};
@ -345,6 +345,10 @@ public class StyleHelper {
};
}
static boolean apply(int itemId, LifecycleOwner owner, View anchor, EditText etBody, Object... args) {
return apply(-1, itemId, owner, anchor, etBody, args);
}
static boolean apply(int groupId, int itemId, LifecycleOwner owner, View anchor, EditText etBody, Object... args) {
Log.i("Style action=" + groupId + ":" + itemId);

Loading…
Cancel
Save