forked from mirrors/Fedilab
Release 3.11.0
This commit is contained in:
parent
269b83607c
commit
0772f47b13
5 changed files with 113 additions and 39 deletions
|
@ -13,8 +13,8 @@ android {
|
|||
defaultConfig {
|
||||
minSdk 21
|
||||
targetSdk 32
|
||||
versionCode 445
|
||||
versionName "3.10.2"
|
||||
versionCode 446
|
||||
versionName "3.11.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
flavorDimensions "default"
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
[
|
||||
{
|
||||
"version": "3.11.0",
|
||||
"code": "446",
|
||||
"note": "Added:\n- Display all messages in threads from remote instances (when possible)\n- Allow to unmute/unfollow/unpin a tag from tag timelines\n- Display most used accounts in header menu for an easy switch\n- Automatically add the tag when composing from a tag timeline\n- Add a translate button at the bottom of messages (default: disabled)\n- Add account role in profiles\n- Translate morse\n\nChanged:\n- Disable animations after a refresh\n\nFixed:\n- Contact not working when composing\n- Status bar for black theme\n- Message duplicated in conversations when edited\n- Color issue on Android 5\n- Several crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.10.2",
|
||||
"code": "445",
|
||||
|
|
|
@ -80,8 +80,9 @@ import java.lang.ref.WeakReference;
|
|||
import java.text.Normalizer;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
@ -124,11 +125,52 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
public static boolean autocomplete = false;
|
||||
public static String[] ALPHA = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
|
||||
"s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", ",", "?",
|
||||
".", "'"};
|
||||
".", "'", "!", "/", "(", ")", "&", ":", ";", "=", "+", "-", "_",
|
||||
"\"", "$", "@", "¿", "¡"
|
||||
};
|
||||
public static String[] MORSE = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..",
|
||||
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", ".----",
|
||||
"..---", "...--", "....-", ".....", "-....", "--...", "---..", "----.", "-----", "-.-.--", "--..--",
|
||||
"..--..", ".-.-.-", ".----.",};
|
||||
"..--..", ".-.-.-", ".----.", "-.-.--", "-..-.", "-.--.", "-.--.-", ".-...", "---...", "-.-.-.", "-...-", ".-.-.", "-....-", "..--.-",
|
||||
".-..-.", "...-..-", ".--.-.", "..-.-", "--...-"
|
||||
};
|
||||
|
||||
public static String[] MORSE2 = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..",
|
||||
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", ".----",
|
||||
"..---", "...--", "....-", ".....", "-....", "--...", "---..", "----.", "-----", "-.-.--", "--..--",
|
||||
"..--..", ".-.-.-", ".----.", "-.-.--", "-..-.", "-.--.", "-.--.-", ".-...", "---...", "-.-.-.", "-...-", ".-.-.", "-....-", "..--.-",
|
||||
".-..-.", "...-..-", ".--.-.", "..-.-", "--...-"
|
||||
};
|
||||
|
||||
public static int countMorseChar(String content) {
|
||||
int count_char = 0;
|
||||
for (String morseCode : MORSE2) {
|
||||
if (content.contains(morseCode) && !morseCode.equals(".") && !morseCode.equals("..") && !morseCode.equals("...") && !morseCode.equals("-") && !morseCode.equals("--")) {
|
||||
count_char++;
|
||||
}
|
||||
}
|
||||
return count_char;
|
||||
}
|
||||
|
||||
public static String morseToText(String morseContent) {
|
||||
LinkedHashMap<String, String> ALPHA_TO_MORSE = new LinkedHashMap<>();
|
||||
for (int i = 0; i < ALPHA.length && i < MORSE.length; i++) {
|
||||
ALPHA_TO_MORSE.put(MORSE[i], ALPHA[i]);
|
||||
}
|
||||
List<String> MORSELIST = Arrays.asList(MORSE2);
|
||||
MORSELIST.sort((s1, s2) -> s2.length() - s1.length());
|
||||
LinkedHashMap<String, String> MORSE_TO_ALPHA = new LinkedHashMap<>();
|
||||
for (String s : MORSELIST) {
|
||||
MORSE_TO_ALPHA.put(s, ALPHA_TO_MORSE.get(s));
|
||||
}
|
||||
for (String morseCode : MORSELIST) {
|
||||
if (MORSE_TO_ALPHA.containsKey(morseCode)) {
|
||||
morseContent = morseContent.replaceAll(Pattern.quote(morseCode), MORSE_TO_ALPHA.get(morseCode));
|
||||
}
|
||||
}
|
||||
return morseContent;
|
||||
}
|
||||
|
||||
private final List<Status> statusList;
|
||||
private final int TYPE_NORMAL = 0;
|
||||
private final BaseAccount account;
|
||||
|
@ -540,7 +582,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
newContent[0] = Normalizer.normalize(newContent[0], Normalizer.Form.NFD);
|
||||
newContent[0] = newContent[0].replaceAll("[^\\p{ASCII}]", "");
|
||||
|
||||
HashMap<String, String> ALPHA_TO_MORSE = new HashMap<>();
|
||||
LinkedHashMap<String, String> ALPHA_TO_MORSE = new LinkedHashMap<>();
|
||||
for (int i = 0; i < ALPHA.length && i < MORSE.length; i++) {
|
||||
ALPHA_TO_MORSE.put(ALPHA[i], MORSE[i]);
|
||||
}
|
||||
|
@ -552,7 +594,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
String morse = ALPHA_TO_MORSE.get(word.substring(i, i + 1).toLowerCase());
|
||||
builder.append(morse).append(" ");
|
||||
}
|
||||
|
||||
builder.append(" ");
|
||||
}
|
||||
newContent[0] = "";
|
||||
|
@ -560,7 +601,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
newContent[0] += mention + " ";
|
||||
}
|
||||
newContent[0] += builder.toString();
|
||||
|
||||
newContent[0] = newContent[0].replaceAll("null", "");
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
Runnable myRunnable = () -> {
|
||||
|
@ -592,7 +633,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
return;
|
||||
}
|
||||
|
||||
String patternh = "^(.|\\s)*(:fedilab_hugs:)$";
|
||||
String patternh = "^(.|\\s)*(:fedilab_hugs:)";
|
||||
final Pattern hPattern = Pattern.compile(patternh);
|
||||
Matcher mh = hPattern.matcher((s.toString().substring(currentCursorPosition[0] - searchLength[0], currentCursorPosition[0])));
|
||||
|
||||
|
@ -601,7 +642,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
return;
|
||||
}
|
||||
|
||||
String patternM = "^(.|\\s)*(:fedilab_morse:)$";
|
||||
String patternM = "^(.|\\s)*(:fedilab_morse:)";
|
||||
final Pattern mPattern = Pattern.compile(patternM);
|
||||
Matcher mm = mPattern.matcher((s.toString().substring(currentCursorPosition[0] - searchLength[0], currentCursorPosition[0])));
|
||||
if (mm.matches()) {
|
||||
|
@ -1328,7 +1369,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
});
|
||||
holder.binding.content.setOnFocusChangeListener((view, focused) -> {
|
||||
if (focused) {
|
||||
currentCursorPosition = position;
|
||||
currentCursorPosition = holder.getLayoutPosition();
|
||||
}
|
||||
});
|
||||
if (statusDraft.cursorPosition <= holder.binding.content.length()) {
|
||||
|
|
|
@ -1901,42 +1901,52 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
private static void translate(Context context, Status statusToDeal,
|
||||
StatusViewHolder holder,
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
|
||||
MyTransL.translatorEngine et = MyTransL.translatorEngine.LIBRETRANSLATE;
|
||||
final MyTransL myTransL = MyTransL.getInstance(et);
|
||||
myTransL.setObfuscation(true);
|
||||
Params params = new Params();
|
||||
params.setSplit_sentences(false);
|
||||
params.setFormat(Params.fType.TEXT);
|
||||
params.setSource_lang("auto");
|
||||
myTransL.setLibretranslateDomain("translate.fedilab.app");
|
||||
String statusToTranslate;
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String translate = sharedpreferences.getString(context.getString(R.string.SET_LIVE_TRANSLATE), MyTransL.getLocale());
|
||||
if (translate != null && translate.equalsIgnoreCase("default")) {
|
||||
translate = MyTransL.getLocale();
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
statusToTranslate = Html.fromHtml(statusToDeal.content, Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
statusToTranslate = Html.fromHtml(statusToDeal.content).toString();
|
||||
myTransL.translate(statusToTranslate, translate, params, new Results() {
|
||||
@Override
|
||||
public void onSuccess(Translate translate) {
|
||||
if (translate.getTranslatedContent() != null) {
|
||||
statusToDeal.translationShown = true;
|
||||
statusToDeal.translationContent = translate.getTranslatedContent();
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
} else {
|
||||
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
|
||||
|
||||
int countMorseChar = ComposeAdapter.countMorseChar(statusToTranslate);
|
||||
if (countMorseChar < 4) {
|
||||
MyTransL.translatorEngine et = MyTransL.translatorEngine.LIBRETRANSLATE;
|
||||
final MyTransL myTransL = MyTransL.getInstance(et);
|
||||
myTransL.setObfuscation(true);
|
||||
Params params = new Params();
|
||||
params.setSplit_sentences(false);
|
||||
params.setFormat(Params.fType.TEXT);
|
||||
params.setSource_lang("auto");
|
||||
myTransL.setLibretranslateDomain("translate.fedilab.app");
|
||||
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String translate = sharedpreferences.getString(context.getString(R.string.SET_LIVE_TRANSLATE), MyTransL.getLocale());
|
||||
if (translate != null && translate.equalsIgnoreCase("default")) {
|
||||
translate = MyTransL.getLocale();
|
||||
}
|
||||
|
||||
|
||||
myTransL.translate(statusToTranslate, translate, params, new Results() {
|
||||
@Override
|
||||
public void onSuccess(Translate translate) {
|
||||
if (translate.getTranslatedContent() != null) {
|
||||
statusToDeal.translationShown = true;
|
||||
statusToDeal.translationContent = translate.getTranslatedContent();
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
} else {
|
||||
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(HttpsConnectionException httpsConnectionException) {
|
||||
@Override
|
||||
public void onFail(HttpsConnectionException httpsConnectionException) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
statusToDeal.translationShown = true;
|
||||
statusToDeal.translationContent = ComposeAdapter.morseToText(statusToTranslate);
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadAndAddAttachment(Context context, LayoutMediaBinding layoutMediaBinding,
|
||||
|
|
18
src/fdroid/fastlane/metadata/android/en/changelogs/446.txt
Normal file
18
src/fdroid/fastlane/metadata/android/en/changelogs/446.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
Added:
|
||||
- Display all messages in threads from remote instances (when possible)
|
||||
- Allow to unmute/unfollow/unpin a tag from tag timelines
|
||||
- Display most used accounts in header menu for an easy switch
|
||||
- Automatically add the tag when composing from a tag timeline
|
||||
- Add a translate button at the bottom of messages (default: disabled)
|
||||
- Add account role in profiles
|
||||
- Translate morse
|
||||
|
||||
Changed:
|
||||
- Disable animations after a refresh
|
||||
|
||||
Fixed:
|
||||
- Contact not working when composing
|
||||
- Status bar for black theme
|
||||
- Message duplicated in conversations when edited
|
||||
- Color issue on Android 5
|
||||
- Several crashes
|
Loading…
Reference in a new issue