Allow to get a quote

maths
Thomas 2 years ago
parent a63f1a9300
commit 625f15fb32

File diff suppressed because it is too large Load Diff

@ -1,15 +0,0 @@
base_theme,1
author,acn128
name,ACN
theme_boost_header_color,-727060
theme_text_header_1_line,-10865760
theme_text_header_2_line,-11719543
theme_statuses_color,-197380
theme_link_color,-13681272
theme_icons_color,-15395562
pref_color_background,-1
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-14059009
theme_text_color,-13027015
theme_primary,-1
1 base_theme 1
2 author acn128
3 name ACN
4 theme_boost_header_color -727060
5 theme_text_header_1_line -10865760
6 theme_text_header_2_line -11719543
7 theme_statuses_color -197380
8 theme_link_color -13681272
9 theme_icons_color -15395562
10 pref_color_background -1
11 pref_color_navigation_bar true
12 pref_color_status_bar true
13 theme_accent -14059009
14 theme_text_color -13027015
15 theme_primary -1

@ -1,13 +0,0 @@
base_theme,2
author,Fedilab
name,Breeze Dark - Yellow
theme_boost_header_color,-14012878
theme_statuses_color,-14473687
theme_link_color,-12734743
theme_icons_color,-4340793
pref_color_background,-15658735
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-148405
theme_text_color,-1052431
theme_primary,-13552069
1 base_theme 2
2 author Fedilab
3 name Breeze Dark - Yellow
4 theme_boost_header_color -14012878
5 theme_statuses_color -14473687
6 theme_link_color -12734743
7 theme_icons_color -4340793
8 pref_color_background -15658735
9 pref_color_navigation_bar true
10 pref_color_status_bar true
11 theme_accent -148405
12 theme_text_color -1052431
13 theme_primary -13552069

@ -1,15 +0,0 @@
base_theme,2
author,Roboron
name,Cyberpunk Neon
theme_boost_header_color,-16776697,
theme_text_header_1_line,-1441575,
theme_text_header_2_line,-5242717,
theme_statuses_color,-16181197,
theme_link_color,-1441575,
theme_icons_color,-16138810,
pref_color_background,-16774370,
pref_color_navigation_bar,true,
pref_color_status_bar,true,
theme_accent,-1441575,
theme_text_color,-16138810,
theme_primary,-16774370,
1 base_theme,2
2 author,Roboron
3 name,Cyberpunk Neon
4 theme_boost_header_color,-16776697,
5 theme_text_header_1_line,-1441575,
6 theme_text_header_2_line,-5242717,
7 theme_statuses_color,-16181197,
8 theme_link_color,-1441575,
9 theme_icons_color,-16138810,
10 pref_color_background,-16774370,
11 pref_color_navigation_bar,true,
12 pref_color_status_bar,true,
13 theme_accent,-1441575,
14 theme_text_color,-16138810,
15 theme_primary,-16774370,

@ -1,15 +0,0 @@
base_theme,0
author,S1m
name,Dark Elephant
theme_boost_header_color,-13552317
theme_text_header_1_line,-3479297
theme_text_header_2_line,-7287815
theme_statuses_color,-13552317
theme_link_color,-11098143
theme_icons_color,-789517
pref_color_background,-14144456
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-13922086
theme_text_color,-789517
theme_primary,-14144456
1 base_theme 0
2 author S1m
3 name Dark Elephant
4 theme_boost_header_color -13552317
5 theme_text_header_1_line -3479297
6 theme_text_header_2_line -7287815
7 theme_statuses_color -13552317
8 theme_link_color -11098143
9 theme_icons_color -789517
10 pref_color_background -14144456
11 pref_color_navigation_bar true
12 pref_color_status_bar true
13 theme_accent -13922086
14 theme_text_color -789517
15 theme_primary -14144456

@ -1,15 +0,0 @@
base_theme,2
author,Jøta Seth
name,Grey Orange
theme_boost_header_color,-14869219
theme_text_header_1_line,-1
theme_text_header_2_line,-1
theme_statuses_color,-14145496
theme_link_color,-26624
theme_icons_color,-26624
pref_color_background,-13092808
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-26624
theme_text_color,-1
theme_primary,-14408668
1 base_theme 2
2 author Jøta Seth
3 name Grey Orange
4 theme_boost_header_color -14869219
5 theme_text_header_1_line -1
6 theme_text_header_2_line -1
7 theme_statuses_color -14145496
8 theme_link_color -26624
9 theme_icons_color -26624
10 pref_color_background -13092808
11 pref_color_navigation_bar true
12 pref_color_status_bar true
13 theme_accent -26624
14 theme_text_color -1
15 theme_primary -14408668

@ -1,15 +0,0 @@
base_theme,2
author,@AntoineD@h.kher.nl
name,Gruvbox OLED
theme_boost_header_color,-16777216
theme_text_header_1_line,-265785
theme_text_header_2_line,-6777062
theme_statuses_color,-16777216
theme_link_color,-2647775
theme_icons_color,-7175308
pref_color_background,-16777216
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-9921174
theme_text_color,-265785
theme_primary,-16777216
1 base_theme 2
2 author @AntoineD@h.kher.nl
3 name Gruvbox OLED
4 theme_boost_header_color -16777216
5 theme_text_header_1_line -265785
6 theme_text_header_2_line -6777062
7 theme_statuses_color -16777216
8 theme_link_color -2647775
9 theme_icons_color -7175308
10 pref_color_background -16777216
11 pref_color_navigation_bar true
12 pref_color_status_bar true
13 theme_accent -9921174
14 theme_text_color -265785
15 theme_primary -16777216

@ -1,15 +0,0 @@
base_theme,2
author,AngryTux
name,Less Angry Orange
theme_boost_header_color,-15855063
theme_text_header_1_line,-2128640
theme_text_header_2_line,-5329234
theme_statuses_color,-1
theme_link_color,-12146699
theme_icons_color,-2128640
pref_color_background,-15987700
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-3968000
theme_text_color,-197380
theme_primary,-14408668
1 base_theme 2
2 author AngryTux
3 name Less Angry Orange
4 theme_boost_header_color -15855063
5 theme_text_header_1_line -2128640
6 theme_text_header_2_line -5329234
7 theme_statuses_color -1
8 theme_link_color -12146699
9 theme_icons_color -2128640
10 pref_color_background -15987700
11 pref_color_navigation_bar true
12 pref_color_status_bar true
13 theme_accent -3968000
14 theme_text_color -197380
15 theme_primary -14408668

@ -1,15 +0,0 @@
base_theme,2
author,Mondstern
name,Mondstern Fedilab
theme_boost_header_color,-1,
theme_text_header_1_line,-13855804,
theme_text_header_2_line,-16227945,
theme_statuses_color,-14935012,
theme_link_color,-15542685,
theme_icons_color,-10723999,
pref_color_background,-15921907,
pref_color_navigation_bar,false,
pref_color_status_bar,false,
theme_accent,-15542685,
theme_text_color,-1,
theme_primary,-14474461,
1 base_theme,2
2 author,Mondstern
3 name,Mondstern Fedilab
4 theme_boost_header_color,-1,
5 theme_text_header_1_line,-13855804,
6 theme_text_header_2_line,-16227945,
7 theme_statuses_color,-14935012,
8 theme_link_color,-15542685,
9 theme_icons_color,-10723999,
10 pref_color_background,-15921907,
11 pref_color_navigation_bar,false,
12 pref_color_status_bar,false,
13 theme_accent,-15542685,
14 theme_text_color,-1,
15 theme_primary,-14474461,

@ -1,13 +0,0 @@
base_theme,2
author,Fedilab
name,Nocturnal
theme_boost_header_color,-12895429
theme_statuses_color,-13553359
theme_link_color,-16747570
theme_icons_color,-10158118
pref_color_background,-14606047
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-13136013
theme_text_color,-2236963
theme_primary,-14013910
1 base_theme 2
2 author Fedilab
3 name Nocturnal
4 theme_boost_header_color -12895429
5 theme_statuses_color -13553359
6 theme_link_color -16747570
7 theme_icons_color -10158118
8 pref_color_background -14606047
9 pref_color_navigation_bar true
10 pref_color_status_bar true
11 theme_accent -13136013
12 theme_text_color -2236963
13 theme_primary -14013910

@ -1,15 +0,0 @@
base_theme,2
author,Jøta Seth
name,Photon Dark
theme_boost_header_color,-14145496
theme_text_header_1_line,-1
theme_text_header_2_line,-1
theme_statuses_color,-14935012
theme_link_color,-14059009
theme_icons_color,-9474193
pref_color_background,-15921907
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-14059009
theme_text_color,-1
theme_primary,-14474461
1 base_theme 2
2 author Jøta Seth
3 name Photon Dark
4 theme_boost_header_color -14145496
5 theme_text_header_1_line -1
6 theme_text_header_2_line -1
7 theme_statuses_color -14935012
8 theme_link_color -14059009
9 theme_icons_color -9474193
10 pref_color_background -15921907
11 pref_color_navigation_bar true
12 pref_color_status_bar true
13 theme_accent -14059009
14 theme_text_color -1
15 theme_primary -14474461

@ -1,15 +0,0 @@
base_theme,1
author,Animaly
name,Solarized - Cyan Accent
theme_boost_header_color,-69167
theme_text_header_1_line,-4880128
theme_text_header_2_line,-7102047
theme_statuses_color,-133405
theme_link_color,-14251054
theme_icons_color,-10106727
pref_color_background,-1120043
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-8021760
theme_text_color,-16766154
theme_primary,-1120043
1 base_theme 1
2 author Animaly
3 name Solarized - Cyan Accent
4 theme_boost_header_color -69167
5 theme_text_header_1_line -4880128
6 theme_text_header_2_line -7102047
7 theme_statuses_color -133405
8 theme_link_color -14251054
9 theme_icons_color -10106727
10 pref_color_background -1120043
11 pref_color_navigation_bar true
12 pref_color_status_bar true
13 theme_accent -8021760
14 theme_text_color -16766154
15 theme_primary -1120043

@ -1,15 +0,0 @@
base_theme,2
author,Fedilab
name,Solarized Dark - Purple
theme_boost_header_color,-16506327
theme_text_header_1_line,-1120043
theme_text_header_2_line,-1120043
theme_statuses_color,-16304574
theme_link_color,-14251054
theme_icons_color,-7102047
pref_color_background,-16766154
pref_color_navigation_bar,true
pref_color_status_bar,true
theme_accent,-9670204
theme_text_color,-133405
theme_primary,-16304574
1 base_theme 2
2 author Fedilab
3 name Solarized Dark - Purple
4 theme_boost_header_color -16506327
5 theme_text_header_1_line -1120043
6 theme_text_header_2_line -1120043
7 theme_statuses_color -16304574
8 theme_link_color -14251054
9 theme_icons_color -7102047
10 pref_color_background -16766154
11 pref_color_navigation_bar true
12 pref_color_status_bar true
13 theme_accent -9670204
14 theme_text_color -133405
15 theme_primary -16304574

@ -1,47 +0,0 @@
[
{
"theme_name": "Dark",
"base_theme": "DARK",
"primary": "#FF272727",
"primary_dark": "#FF272727",
"primary_light": "#FFd9e1e8",
"accent": "#FF2b90d9",
"accent_dark": "#FF1b80c9",
"accent_light": "#FF772b90d9",
"background": "#FF272727",
"background_dark": "#FF282c37",
"background_light": "#FF282c37",
"should_tint_statusbar": true,
"should_tint_navbar": true
},
{
"theme_name": "Light",
"base_theme": "LIGHT",
"primary": "#FFFFFF",
"primary_dark": "#FFFFFFFF",
"primary_light": "#FFd9e1e8",
"accent": "#FF2b90d9",
"accent_dark": "#FF1b80c9",
"accent_light": "#FF772b90d9",
"background": "#FFFFFFFF",
"background_dark": "#FFFFFFFF",
"background_light": "#FFFFFFFF",
"should_tint_statusbar": true,
"should_tint_navbar": true
},
{
"theme_name": "Black",
"base_theme": "DARK",
"primary": "#FF000000",
"primary_dark": "#FF000000",
"primary_light": "#FF000000",
"accent": "#FF606984",
"accent_dark": "#FF606984",
"accent_light": "#FF606984",
"background": "#FF000000",
"background_dark": "#FF000000",
"background_light": "#FF000000",
"should_tint_statusbar": true,
"should_tint_navbar": true
}
]

@ -0,0 +1,34 @@
package app.fedilab.android.client.entities.app;
/* Copyright 2022 Thomas Schneider
*
* This file is a part of Fedilab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
public class Quotes implements Serializable {
@SerializedName("quotes")
public List<Quote> quotes;
public static class Quote implements Serializable {
@SerializedName("author")
public String author;
@SerializedName("content")
public String content;
}
}

@ -71,12 +71,17 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.vanniktech.emoji.EmojiManager; import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.EmojiPopup; import com.vanniktech.emoji.EmojiPopup;
import com.vanniktech.emoji.one.EmojiOneProvider; import com.vanniktech.emoji.one.EmojiOneProvider;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.nio.charset.StandardCharsets;
import java.text.Normalizer; import java.text.Normalizer;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -86,6 +91,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -102,6 +108,7 @@ import app.fedilab.android.client.entities.api.Status;
import app.fedilab.android.client.entities.api.Tag; import app.fedilab.android.client.entities.api.Tag;
import app.fedilab.android.client.entities.app.BaseAccount; import app.fedilab.android.client.entities.app.BaseAccount;
import app.fedilab.android.client.entities.app.Languages; import app.fedilab.android.client.entities.app.Languages;
import app.fedilab.android.client.entities.app.Quotes;
import app.fedilab.android.client.entities.app.StatusDraft; import app.fedilab.android.client.entities.app.StatusDraft;
import app.fedilab.android.databinding.ComposeAttachmentItemBinding; import app.fedilab.android.databinding.ComposeAttachmentItemBinding;
import app.fedilab.android.databinding.ComposePollBinding; import app.fedilab.android.databinding.ComposePollBinding;
@ -545,6 +552,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
public void run() { public void run() {
String fedilabHugsTrigger = ":fedilab_hugs:"; String fedilabHugsTrigger = ":fedilab_hugs:";
String fedilabMorseTrigger = ":fedilab_morse:"; String fedilabMorseTrigger = ":fedilab_morse:";
String fedilabQuoteTrigger = ":fedilab_quote:";
if (s.toString().contains(fedilabHugsTrigger)) { if (s.toString().contains(fedilabHugsTrigger)) {
newContent[0] = s.toString().replaceAll(Pattern.quote(fedilabHugsTrigger), "").trim(); newContent[0] = s.toString().replaceAll(Pattern.quote(fedilabHugsTrigger), "").trim();
int toFill = 500 - newContent[0].length(); int toFill = 500 - newContent[0].length();
@ -604,6 +612,57 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
newContent[0] = newContent[0].replaceAll("null", ""); newContent[0] = newContent[0].replaceAll("null", "");
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
holder.binding.content.setText(newContent[0]);
statusList.get(holder.getBindingAdapterPosition()).text = newContent[0];
holder.binding.content.setSelection(holder.binding.content.getText().length());
autocomplete = false;
updateCharacterCount(holder);
};
mainHandler.post(myRunnable);
} else if (s.toString().contains(fedilabQuoteTrigger)) {
newContent[0] = s.toString().replaceAll(fedilabQuoteTrigger, "").trim();
List<String> mentions = new ArrayList<>();
String mentionPattern = "@[a-z0-9_]+(@[a-z0-9.\\-]+[a-z0-9]+)?";
final Pattern mPattern = Pattern.compile(mentionPattern, Pattern.CASE_INSENSITIVE);
Matcher matcherMentions = mPattern.matcher(newContent[0]);
while (matcherMentions.find()) {
mentions.add(matcherMentions.group());
}
for (String mention : mentions) {
newContent[0] = newContent[0].replace(mention, "");
}
InputStream is;
newContent[0] = "";
if (mentions.size() > 0) {
for (String mention : mentions) {
newContent[0] += mention + " ";
}
}
try {
is = context.getAssets().open("quotes/famous.json");
int size;
size = is.available();
byte[] buffer = new byte[size];
//noinspection ResultOfMethodCallIgnored
is.read(buffer);
is.close();
String json = new String(buffer, StandardCharsets.UTF_8);
Gson gson = new Gson();
List<Quotes.Quote> quotes = gson.fromJson(json, new TypeToken<List<Quotes.Quote>>() {
}.getType());
if (quotes != null && quotes.size() > 0) {
final int random = new Random().nextInt(quotes.size());
Quotes.Quote quote = quotes.get(random);
newContent[0] += quote.content + "\n- " + quote.author;
}
} catch (IOException e) {
e.printStackTrace();
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> { Runnable myRunnable = () -> {
holder.binding.content.setText(newContent[0]); holder.binding.content.setText(newContent[0]);
statusList.get(holder.getBindingAdapterPosition()).text = newContent[0]; statusList.get(holder.getBindingAdapterPosition()).text = newContent[0];
@ -649,6 +708,15 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
autocomplete = true; autocomplete = true;
return; return;
} }
String patternQ = "^(.|\\s)*(:fedilab_quote:)";
final Pattern qPattern = Pattern.compile(patternQ);
Matcher mq = qPattern.matcher((s.toString().substring(currentCursorPosition[0] - searchLength[0], currentCursorPosition[0])));
if (mq.matches()) {
autocomplete = true;
return;
}
String[] searchInArray = (s.toString().substring(currentCursorPosition[0] - searchLength[0], currentCursorPosition[0])).split("\\s"); String[] searchInArray = (s.toString().substring(currentCursorPosition[0] - searchLength[0], currentCursorPosition[0])).split("\\s");
if (searchInArray.length < 1) { if (searchInArray.length < 1) {
updateCharacterCount(holder); updateCharacterCount(holder);

Loading…
Cancel
Save