Forward tags in replies

This commit is contained in:
tom79 2019-05-13 18:15:45 +02:00
parent 61c492fd0d
commit ee2b397a8e
6 changed files with 47 additions and 0 deletions

View File

@ -131,6 +131,7 @@ import fr.gouv.etalab.mastodon.client.Entities.PollOptions;
import fr.gouv.etalab.mastodon.client.Entities.Results;
import fr.gouv.etalab.mastodon.client.Entities.Status;
import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
import fr.gouv.etalab.mastodon.client.Entities.Tag;
import fr.gouv.etalab.mastodon.client.Entities.Version;
import fr.gouv.etalab.mastodon.client.HttpsConnection;
import fr.gouv.etalab.mastodon.drawers.AccountsReplyAdapter;
@ -483,6 +484,8 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
toot_content.setText(String.format("\n\nvia @%s\n\n%s\n\n", tootMention, urlMention));
toot_space_left.setText(String.valueOf(toot_content.length()));
}
initialContent = toot_content.getText().toString();
@ -526,6 +529,8 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
toot_space_left.setText(String.valueOf(toot_content.length()));
}
}
attachments = new ArrayList<>();
int charsInCw = 0;
int charsInToot = 0;
@ -2691,6 +2696,16 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
toot_content.setSelection(toot_content.getText().length()); //Put cursor at the end
}
}
boolean forwardTags = sharedpreferences.getBoolean(Helper.SET_FORWARD_TAGS_IN_REPLY, false);
if( tootReply != null && forwardTags && tootReply.getTags() != null && tootReply.getTags().size() > 0){
int currentCursorPosition = toot_content.getSelectionStart();
toot_content.setText(toot_content.getText() +"\n");
for(Tag tag: tootReply.getTags()){
toot_content.setText(toot_content.getText() +" #"+tag.getName());
}
toot_content.setSelection(currentCursorPosition);
toot_space_left.setText(String.valueOf(toot_content.length()));
}
}
initialContent = toot_content.getText().toString();

View File

@ -650,6 +650,19 @@ public class SettingsFragment extends Fragment {
}
});
// forward tags in replies
boolean forward_tags = sharedpreferences.getBoolean(Helper.SET_FORWARD_TAGS_IN_REPLY, false);
final CheckBox set_forward_tags = rootView.findViewById(R.id.set_forward_tags);
set_forward_tags.setChecked(forward_tags);
set_forward_tags.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_FORWARD_TAGS_IN_REPLY, set_forward_tags.isChecked());
editor.apply();
}
});
String custom_sharing_url = sharedpreferences.getString(Helper.SET_CUSTOM_SHARING_URL,"");
if (custom_sharing_url.equals("")) {
custom_sharing_url = "http://cs.example.net/add?token=umVe1zurZk47ihElSOQcBG05KUSA2v-GSet4_fFnJ4M&url=${url}&title=${title}&source=${source}&id=${id}&description=${description}&keywords=${keywords}&creator=${creator}&thumbnailurl=${thumbnailurl}";

View File

@ -308,6 +308,7 @@ public class Helper {
public static final String SET_CAPITALIZE = "set_capitalize";
public static final String SET_PICTURE_RESIZE = "set_picture_resize";
public static final String SET_SHOW_BOOKMARK = "set_show_bookmark";
public static final String SET_FORWARD_TAGS_IN_REPLY = "set_forward_tags_in_reply";
public static final String SET_FULL_PREVIEW = "set_full_preview";
public static final String SET_COMPACT_MODE = "set_compact_mode";
public static final String SET_CONSOLE_MODE = "set_console_mode";

View File

@ -362,6 +362,15 @@
android:text="@string/settings_title_custom_sharing"
android:layout_height="wrap_content" />
<!-- ADD TAGS -->
<CheckBox
android:id="@+id/set_forward_tags"
android:layout_width="wrap_content"
android:layout_marginTop="@dimen/settings_checkbox_margin"
android:layout_marginBottom="@dimen/settings_checkbox_margin"
android:text="@string/set_forward_tags"
android:layout_height="wrap_content" />
<EditText
android:hint="@string/settings_custom_sharing_url"
android:id="@+id/custom_sharing_url"

View File

@ -367,6 +367,14 @@
android:layout_marginBottom="@dimen/settings_checkbox_margin"
android:text="@string/settings_title_custom_sharing"
android:layout_height="wrap_content" />
<!-- ADD TAGS -->
<CheckBox
android:id="@+id/set_forward_tags"
android:layout_width="wrap_content"
android:layout_marginTop="@dimen/settings_checkbox_margin"
android:layout_marginBottom="@dimen/settings_checkbox_margin"
android:text="@string/set_forward_tags"
android:layout_height="wrap_content" />
<EditText
android:hint="@string/settings_custom_sharing_url"

View File

@ -946,6 +946,7 @@
<string name="set_sensitive_content">Always mark media as sensitive</string>
<string name="gnu_instance">GNU instance</string>
<string name="cached_status">Cached status</string>
<string name="set_forward_tags">Forward tags in replies</string>
<plurals name="number_of_vote">
<item quantity="one">%d vote</item>