quick reply option and switch to full mode

This commit is contained in:
Kasun 2019-06-27 12:24:31 +05:30
parent 6b8d5a3876
commit 6ef77c2417
6 changed files with 72 additions and 21 deletions

View File

@ -612,6 +612,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
boolean new_badge = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEW_BADGE, true);
boolean bot_icon = sharedpreferences.getBoolean(Helper.SET_DISPLAY_BOT_ICON, true);
boolean quick_reply = sharedpreferences.getBoolean(Helper.SET_QUICK_REPLY, true);
int translator = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
@ -2197,30 +2199,46 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_reply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean shown = status.isShortReply();
if( !shown){
for(Status s: statuses){
if(s.isShortReply() && !s.getId().equals(status.getId())){
s.setShortReply(false);
notifyStatusChanged(s);
if (quick_reply) {
boolean shown = status.isShortReply();
if (!shown) {
for (Status s : statuses) {
if (s.isShortReply() && !s.getId().equals(status.getId())) {
s.setShortReply(false);
notifyStatusChanged(s);
}
}
status.setShortReply(true);
holder.quick_reply_container.setVisibility(View.VISIBLE);
InputMethodManager inputMethodManager =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(
holder.quick_reply_text.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0);
holder.quick_reply_text.requestFocus();
} else {
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(holder.quick_reply_text.getWindowToken(), 0);
}
holder.quick_reply_switch_to_full.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CrossActions.doCrossReply(context, status, type, true);
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
}
});
} else {
CrossActions.doCrossReply(context, status, type, true);
if (status.isShortReply()) {
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(holder.quick_reply_text.getWindowToken(), 0);
}
status.setShortReply(true);
holder.quick_reply_container.setVisibility(View.VISIBLE);
InputMethodManager inputMethodManager =
(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(
holder.quick_reply_text.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0);
holder.quick_reply_text.requestFocus();
}else{
status.setShortReply(false);
holder.quick_reply_container.setVisibility(View.GONE);
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(holder.quick_reply_text.getWindowToken(), 0);
}
}
});

View File

@ -699,6 +699,19 @@ public class SettingsFragment extends Fragment {
}
});
boolean quick_reply = sharedpreferences.getBoolean(Helper.SET_QUICK_REPLY, true);
final CheckBox set_quick_reply = rootView.findViewById(R.id.set_quick_reply);
set_quick_reply.setChecked(quick_reply);
set_quick_reply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_QUICK_REPLY, set_quick_reply.isChecked());
editor.apply();
}
});
boolean fit_preview = sharedpreferences.getBoolean(Helper.SET_FULL_PREVIEW, false);
final CheckBox set_fit_preview = rootView.findViewById(R.id.set_fit_preview);
set_fit_preview.setChecked(fit_preview);

View File

@ -412,6 +412,7 @@ public class Helper {
public static final String SET_DISPLAY_FOLLOW_INSTANCE = "set_display_follow_instance";
public static final String SET_DISPLAY_NEW_BADGE = "set_display_new_badge";
public static final String SET_DISPLAY_BOT_ICON = "set_display_bot_icon";
public static final String SET_QUICK_REPLY = "set_quick_reply";
public static final String SET_EMBEDDED_BROWSER = "set_embedded_browser";
public static final String SET_CUSTOM_TABS = "set_custom_tabs";
public static final String SET_JAVASCRIPT = "set_javascript";

View File

@ -333,6 +333,15 @@
android:text="@string/set_display_bot_icon"
android:layout_height="wrap_content" />
<!-- DISPLAY BOT ICON -->
<CheckBox
android:id="@+id/set_quick_reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/settings_checkbox_margin"
android:layout_marginBottom="@dimen/settings_checkbox_margin"
android:text="@string/set_quick_reply" />
<!-- FIT PREVIEWS -->
<CheckBox
android:id="@+id/set_fit_preview"

View File

@ -344,6 +344,15 @@
android:text="@string/set_display_bot_icon"
android:layout_height="wrap_content" />
<!-- DISPLAY BOT ICON -->
<CheckBox
android:id="@+id/set_quick_reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/settings_checkbox_margin"
android:layout_marginBottom="@dimen/settings_checkbox_margin"
android:text="@string/set_quick_reply" />
<!-- FIT PREVIEWS -->
<CheckBox
android:id="@+id/set_fit_preview"

View File

@ -1081,6 +1081,7 @@
<string name="mark_unresolved">Mark as unresolved</string>
<string name="toast_empty_content">Empty content!</string>
<string name="set_display_fedilab_features_button">Display Fedilab features button</string>
<string name="set_quick_reply">Enable quick reply</string>
<plurals name="number_of_vote">
<item quantity="one">%d vote</item>
<item quantity="other">%d votes</item>