suggestions = new ArrayList<>();
- for (String tag : tags) {
- Suggestion suggestion = new Suggestion();
- suggestion.setContent(tag);
- suggestion.setType(Suggestion.suggestionType.TAG);
- suggestions.add(suggestion);
- }
- RecyclerView suggestionsRV = findViewById(R.id.suggestions);
- suggestionsRV.setLayoutManager(new LinearLayoutManager(this));
- SuggestionsAdapter suggestionsAdapter = new SuggestionsAdapter(suggestions);
- suggestionsRV.setAdapter(suggestionsAdapter);
- suggestionsRV.setVisibility(View.VISIBLE);
- final String oldContent = wysiwygEditText.getText().toString();
- if (oldContent.length() >= currentCursorPosition) {
- String[] searchA = oldContent.substring(0, currentCursorPosition).split("#");
- if (searchA.length > 0) {
- final String search = searchA[searchA.length - 1];
- suggestionsRV.addOnItemTouchListener(new RecyclerItemClickListener(this, new RecyclerItemClickListener.OnItemClickListener() {
- @Override
- public void onItemClick(final View view, final int position) {
- final Suggestion suggestion = suggestionsAdapter.getItem(position);
-
-
- String deltaSearch = "";
- int searchLength = searchDeep;
- if (currentCursorPosition < searchDeep) { //Less than 15 characters are written before the cursor position
- searchLength = currentCursorPosition;
- }
- if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
- deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
- else {
- if (currentCursorPosition >= oldContent.length())
- deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length());
- }
-
- if (!search.equals(""))
- deltaSearch = deltaSearch.replace("#" + search, "");
- String newContent = oldContent.substring(0, currentCursorPosition - searchLength);
- newContent += deltaSearch;
- newContent += "#" + suggestion.getContent() + " ";
- int newPosition = newContent.length();
- if (currentCursorPosition < oldContent.length())
- newContent += oldContent.substring(currentCursorPosition, oldContent.length());
- wysiwygEditText.setText(newContent);
- toot_space_left.setText(String.valueOf(countLength(wysiwyg, toot_cw_content)));
- wysiwygEditText.setSelection(newPosition);
- suggestionsRV.setVisibility(View.GONE);
-
- }
- }));
+ if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
+ deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
+ else {
+ if (currentCursorPosition >= oldContent.length())
+ deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length());
}
+
+ if (!search.equals(""))
+ deltaSearch = deltaSearch.replace("#" + search, "");
+ String newContent = oldContent.substring(0, currentCursorPosition - searchLength);
+ newContent += deltaSearch;
+ newContent += "#" + tag + " ";
+ int newPosition = newContent.length();
+ if (currentCursorPosition < oldContent.length())
+ newContent += oldContent.substring(currentCursorPosition, oldContent.length());
+ toot_content.setText(newContent);
+ toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
+ toot_content.setSelection(newPosition);
+ TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
+ toot_content.setThreshold(1);
+ toot_content.setAdapter(tagsSearchAdapter);
+
}
- }
+ });
}
}
@@ -3137,18 +2193,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
//noinspection deprecation
content = Html.fromHtml(content).toString();
}
- if (status.getPoll() != null) {
- poll = status.getPoll();
- poll_action.setVisibility(View.VISIBLE);
- if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
- toot_picture.setVisibility(View.GONE);
- picture_scrollview.setVisibility(View.GONE);
- }
- }
-
if (attachments != null && attachments.size() > 0) {
toot_picture_container.setVisibility(View.VISIBLE);
- picture_scrollview.setVisibility(View.VISIBLE);
int i = 0;
for (final Attachment attachment : attachments) {
String url = attachment.getPreview_url();
@@ -3211,35 +2257,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
//Sensitive content
toot_sensitive.setChecked(status.isSensitive());
- if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0) {
- toot_cw_content.setText(status.getSpoiler_text());
- toot_cw_content.setVisibility(View.VISIBLE);
- } else {
- toot_cw_content.setText("");
- toot_cw_content.setVisibility(View.GONE);
- }
- if (!displayWYSIWYG()) {
- toot_content.setText(content);
- } else {
- if (content != null) {
- content = content.replaceAll("]*><\\/p>", "");
- }
- wysiwyg.render(content);
- try {
- } catch (Exception e) {
- e.printStackTrace();
- Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
- }
- }
- toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
- if (!displayWYSIWYG()) {
- toot_content.setSelection(toot_content.getText().length());
- } else {
- if (wysiwygEditText != null) {
- wysiwygEditText.setSelection(wysiwygEditText.getText().length());
- }
- }
+ toot_content.setText(content);
+ toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
+ toot_content.setSelection(toot_content.getText().length());
switch (status.getVisibility()) {
case "public":
@@ -3280,12 +2301,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
}
invalidateOptionsMenu();
- initialContent = displayWYSIWYG() ? wysiwyg.getContentAsHTML() : toot_content.getText().toString();
- if (!displayWYSIWYG()) {
- toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
- } else {
- toot_space_left.setText(String.valueOf(countLength(wysiwyg, toot_cw_content)));
- }
+ initialContent = toot_content.getText().toString();
+ toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
}
@@ -3320,7 +2337,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
if (attachments != null && attachments.size() > 0) {
toot_picture_container.setVisibility(View.VISIBLE);
- picture_scrollview.setVisibility(View.VISIBLE);
int i = 0;
for (final Attachment attachment : attachments) {
String url = attachment.getPreview_url();
@@ -3383,16 +2399,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
//Sensitive content
toot_sensitive.setChecked(status.isSensitive());
- if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0) {
- toot_cw_content.setText(status.getSpoiler_text());
- toot_cw_content.setVisibility(View.VISIBLE);
- } else {
- toot_cw_content.setText("");
- toot_cw_content.setVisibility(View.GONE);
- }
-
toot_content.setText(content);
- toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
+ toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
toot_content.setSelection(toot_content.getText().length());
switch (status.getVisibility()) {
case "public":
@@ -3425,8 +2433,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
setTitle(R.string.toot_title);
}
invalidateOptionsMenu();
- initialContent = displayWYSIWYG() ? wysiwyg.getContentAsHTML() : toot_content.getText().toString();
- toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
+ initialContent = toot_content.getText().toString();
+ toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
}
private void tootReply() {
@@ -3518,13 +2526,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
break;
}
- if (tootReply.getSpoiler_text() != null && tootReply.getSpoiler_text().length() > 0) {
- toot_cw_content.setText(tootReply.getSpoiler_text());
- toot_cw_content.setVisibility(View.VISIBLE);
- }
-
if (tootReply != null) {
- manageMentions(getApplicationContext(), social, userIdReply, toot_content, toot_cw_content, toot_space_left, tootReply);
+ manageMentions(getApplicationContext(), social, userIdReply, toot_content, toot_space_left, tootReply);
}
boolean forwardTags = sharedpreferences.getBoolean(Helper.SET_FORWARD_TAGS_IN_REPLY, false);
if (tootReply != null && forwardTags && tootReply.getTags() != null && tootReply.getTags().size() > 0) {
@@ -3534,15 +2537,15 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot_content.setText(toot_content.getText() + " #" + tag.getName());
}
toot_content.setSelection(currentCursorPosition);
- toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
+ toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
}
}
- initialContent = displayWYSIWYG() ? wysiwyg.getContentAsHTML() : toot_content.getText().toString();
+ initialContent = toot_content.getText().toString();
}
- public static void manageMentions(Context context, UpdateAccountInfoAsyncTask.SOCIAL social, String userIdReply, MastalabAutoCompleteTextView contentView, EditText CWView, TextView counterView, Status tootReply) {
+ public static void manageMentions(Context context, UpdateAccountInfoAsyncTask.SOCIAL social, String userIdReply, MastalabAutoCompleteTextView contentView, TextView counterView, Status tootReply) {
//Retrieves mentioned accounts + OP and adds them at the beginin of the toot
ArrayList mentionedAccountsAdded = new ArrayList<>();
@@ -3577,7 +2580,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
else
contentView.append(" ");
}
- counterView.setText(String.valueOf(countLength(social, contentView, CWView)));
+ counterView.setText(String.valueOf(countLength(social, contentView)));
contentView.requestFocus();
if (capitalize) {
@@ -3734,10 +2737,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
public void onClick(DialogInterface dialog, int whichButton) {
if (poll != null)
poll = null;
- poll_action.setVisibility(View.GONE);
toot_picture.setVisibility(View.VISIBLE);
if (attachments != null && attachments.size() > 0)
- picture_scrollview.setVisibility(View.VISIBLE);
dialog.dismiss();
}
});
@@ -3825,10 +2826,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
Toasty.error(getApplicationContext(), getString(R.string.poll_duplicated_entry), Toast.LENGTH_SHORT).show();
}
}
- poll_action.setVisibility(View.VISIBLE);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
toot_picture.setVisibility(View.GONE);
- picture_scrollview.setVisibility(View.GONE);
}
}
});
@@ -3841,13 +2840,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
private void storeToot(boolean message, boolean forced) {
//Nothing to store here....
String currentContent;
- if (displayWYSIWYG()) {
- currentContent = wysiwyg.getContentAsHTML().trim();
- } else {
- currentContent = toot_content.getText().toString().trim();
- }
+ currentContent = toot_content.getText().toString().trim();
if (!forced) {
- if (currentContent.length() == 0 && (attachments == null || attachments.size() < 1) && toot_cw_content.getText().toString().trim().length() == 0)
+ if (currentContent.length() == 0 && (attachments == null || attachments.size() < 1) )
return;
if (initialContent.trim().equals(currentContent))
return;
@@ -3855,8 +2850,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
Status toot = new Status();
toot.setSensitive(isSensitive);
toot.setMedia_attachments(attachments);
- if (toot_cw_content.getText().toString().trim().length() > 0)
- toot.setSpoiler_text(toot_cw_content.getText().toString().trim());
toot.setVisibility(visibility);
toot.setContent(currentContent);
@@ -3926,27 +2919,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
- @Override
- public void onRetrieveAccountsReply(ArrayList accounts) {
- final boolean[] checkedValues = new boolean[accounts.size()];
- int i = 0;
- for (Account account : accounts) {
- checkedValues[i] = toot_content.getText().toString().contains("@" + account.getAcct());
- i++;
- }
- final AlertDialog.Builder builderSingle = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
- AccountsReplyAdapter accountsReplyAdapter = new AccountsReplyAdapter(accounts, checkedValues);
- builderSingle.setTitle(getString(R.string.select_accounts)).setAdapter(accountsReplyAdapter, null);
- builderSingle.setNegativeButton(R.string.validate, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- toot_content.setSelection(toot_content.getText().length());
- }
- });
- builderSingle.show();
- }
-
public void changeAccountReply(boolean isChecked, String acct) {
if (isChecked) {
if (!toot_content.getText().toString().contains(acct))
@@ -3991,195 +2963,27 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
- public static int countLength(UpdateAccountInfoAsyncTask.SOCIAL social, MastalabAutoCompleteTextView toot_content, EditText toot_cw_content) {
- if (toot_content == null || toot_cw_content == null) {
+
+ public static int countLength(UpdateAccountInfoAsyncTask.SOCIAL social, MastalabAutoCompleteTextView toot_content) {
+ if (toot_content == null) {
return -1;
}
String content = toot_content.getText().toString();
- String cwContent = toot_cw_content.getText().toString();
String contentCount = content;
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
- contentCount = contentCount.replaceAll("(^|[^/\\w])@(([a-z0-9_]+)@[a-z0-9\\.\\-]+[a-z0-9]+)", "$1@$3");
+ contentCount = contentCount.replaceAll("(^|[^/\\w])@(([a-z0-9_]+)@[a-z0-9.\\-]+[a-z0-9]+)", "$1@$3");
Matcher matcherALink = Patterns.WEB_URL.matcher(contentCount);
while (matcherALink.find()) {
final String url = matcherALink.group(1);
+ assert url != null;
contentCount = contentCount.replace(url, "abcdefghijklmnopkrstuvw");
}
}
- int contentLength = contentCount.length() - countWithEmoji(content);
- int cwLength = cwContent.length() - countWithEmoji(cwContent);
- return cwLength + contentLength;
- }
-
- int countLength(Editor wysiwyg, EditText toot_cw_content) {
- if (wysiwyg == null || toot_cw_content == null) {
- return -1;
- }
- String content = wysiwyg.getContentAsHTML();
- String cwContent = toot_cw_content.getText().toString();
- int contentLength = content.length() - countWithEmoji(content);
- int cwLength = cwContent.length() - countWithEmoji(cwContent);
- return cwLength + contentLength;
- }
-
- private void recordAudio() {
- String filePath = getCacheDir() + "/fedilab_recorded_audio.wav";
- int color = getResources().getColor(R.color.mastodonC1);
- AndroidAudioRecorder.with(this)
- // Required
- .setFilePath(filePath)
- .setColor(color)
- .setRequestCode(SEND_VOICE_MESSAGE)
-
- // Optional
- .setSource(AudioSource.MIC)
- .setChannel(AudioChannel.STEREO)
- .setSampleRate(AudioSampleRate.HZ_44100)
- .setAutoStart(true)
- .setKeepDisplayOn(true)
- // Start recording
- .record();
+ return contentCount.length() - countWithEmoji(content);
}
- private boolean displayWYSIWYG() {
- if (social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
- return false;
- }
- SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
- return sharedpreferences.getBoolean(Helper.SET_WYSIWYG, false);
- }
-
- private void renderEditor() {
-
-
- findViewById(R.id.action_h1).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.updateTextStyle(EditorTextStyle.H1);
- }
- });
-
- findViewById(R.id.action_h2).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.updateTextStyle(EditorTextStyle.H2);
- }
- });
-
- findViewById(R.id.action_h3).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.updateTextStyle(EditorTextStyle.H3);
- }
- });
-
- findViewById(R.id.action_bold).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.updateTextStyle(EditorTextStyle.BOLD);
- }
- });
-
- findViewById(R.id.action_Italic).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.updateTextStyle(EditorTextStyle.ITALIC);
- }
- });
-
- findViewById(R.id.action_indent).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.updateTextStyle(EditorTextStyle.INDENT);
- }
- });
-
- findViewById(R.id.action_outdent).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.updateTextStyle(EditorTextStyle.OUTDENT);
- }
- });
-
- findViewById(R.id.action_bulleted).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.insertList(false);
- }
- });
-
- findViewById(R.id.action_color).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- new ColorPickerPopup.Builder(getApplicationContext())
- .enableAlpha(false)
- .okTitle(getString(R.string.validate))
- .cancelTitle(getString(R.string.cancel))
- .showIndicator(true)
- .showValue(true)
- .build()
- .show(findViewById(android.R.id.content), new ColorPickerPopup.ColorPickerObserver() {
- @Override
- public void onColorPicked(int color) {
- wysiwyg.updateTextColor(colorHex(color));
- }
-
- });
- }
- });
- //Remove colours
- findViewById(R.id.action_color).setVisibility(View.GONE);
-
- findViewById(R.id.action_unordered_numbered).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.insertList(true);
- }
- });
-
- findViewById(R.id.action_hr).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.insertDivider();
- }
- });
-
- findViewById(R.id.action_insert_image).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.openImagePicker();
- }
- });
-
- findViewById(R.id.action_insert_link).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.insertLink();
- }
- });
-
-
- findViewById(R.id.action_erase).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.clearAllContents();
- }
- });
- //Remove eraser
- findViewById(R.id.action_erase).setVisibility(View.GONE);
-
- findViewById(R.id.action_blockquote).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- wysiwyg.updateTextStyle(EditorTextStyle.BLOCKQUOTE);
- wysiwyg.updateTextColor("#000000");
- }
- });
-
- wysiwyg.render();
- }
private String colorHex(int color) {
int r = Color.red(color);
diff --git a/app/src/main/res/layout/activity_pixelfed_compose.xml b/app/src/main/res/layout/activity_pixelfed_compose.xml
index f2be6dca6..3cf4e2ab7 100644
--- a/app/src/main/res/layout/activity_pixelfed_compose.xml
+++ b/app/src/main/res/layout/activity_pixelfed_compose.xml
@@ -30,34 +30,33 @@
android:paddingTop="@dimen/toot_padding"
android:paddingRight="@dimen/toot_padding"
android:paddingBottom="@dimen/toot_padding">
-
-
-
-
+ android:orientation="vertical"
+ >
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+ android:text="@string/post" />
@@ -292,8 +210,7 @@
android:id="@+id/toot_sensitive"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/toot_sensitive"
- android:visibility="gone" />
+ android:text="@string/toot_sensitive" />
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index aaed4cbc4..81daa4231 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1227,4 +1227,7 @@
Change app icon
Click to change the app icon
Post
+ Visibility of the post
+ Click here to add photos
+ Accepted Formats: jpeg, png, gif \n\nMax File Size: 15 MB \n\nAlbums can contain up to 4 photos or videos
\ No newline at end of file