Merge branch 'develop' into develop
This commit is contained in:
commit
4d92dc1f42
|
@ -13,8 +13,8 @@ android {
|
|||
defaultConfig {
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 477
|
||||
versionName "3.17.0"
|
||||
versionCode 478
|
||||
versionName "3.18.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
flavorDimensions "default"
|
||||
|
@ -68,13 +68,17 @@ android {
|
|||
'src/main/res/layouts/mastodon',
|
||||
'src/main/res/layouts/peertube',
|
||||
'src/main/res/layouts',
|
||||
'src/main/layout',
|
||||
|
||||
'src/main/res/drawables/mastodon',
|
||||
'src/main/res/drawables/peertube',
|
||||
'src/main/res/drawables',
|
||||
|
||||
'src/main/res/menus/mastodon',
|
||||
'src/main/res/menus/peertube',
|
||||
'src/main/res/menus',
|
||||
|
||||
'src/main/res/values',
|
||||
|
||||
'src/main/res'
|
||||
]
|
||||
}
|
||||
|
|
|
@ -196,6 +196,9 @@
|
|||
<activity
|
||||
android:name=".mastodon.activities.ContextActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".mastodon.activities.DirectMessageActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".mastodon.activities.DraftActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
|
|
|
@ -381,7 +381,7 @@
|
|||
},
|
||||
{
|
||||
"code": "lo",
|
||||
"language": "ພາສາ"
|
||||
"language": "ລາວ"
|
||||
},
|
||||
{
|
||||
"code": "lt",
|
||||
|
@ -726,5 +726,109 @@
|
|||
{
|
||||
"code": "zu",
|
||||
"language": "isiZulu"
|
||||
},
|
||||
{
|
||||
"code": "ast",
|
||||
"language": "Asturianu"
|
||||
},
|
||||
{
|
||||
"code": "ckb",
|
||||
"language": "سۆرانی"
|
||||
},
|
||||
{
|
||||
"code": "cnr",
|
||||
"language": "crnogorski"
|
||||
},
|
||||
{
|
||||
"code": "jbo",
|
||||
"language": "la .lojban."
|
||||
},
|
||||
{
|
||||
"code": "kab",
|
||||
"language": "Taqbaylit"
|
||||
},
|
||||
{
|
||||
"code": "kmr",
|
||||
"language": "Kurmancî"
|
||||
},
|
||||
{
|
||||
"code": "ldn",
|
||||
"language": "Láadan"
|
||||
},
|
||||
{
|
||||
"code": "lfn",
|
||||
"language": "lingua franca nova"
|
||||
},
|
||||
{
|
||||
"code": "sco",
|
||||
"language": "Scots"
|
||||
},
|
||||
{
|
||||
"code": "sma",
|
||||
"language": "Åarjelsaemien Gïele"
|
||||
},
|
||||
{
|
||||
"code": "smj",
|
||||
"language": "Julevsámegiella"
|
||||
},
|
||||
{
|
||||
"code": "szl",
|
||||
"language": "ślůnsko godka"
|
||||
},
|
||||
{
|
||||
"code": "tai",
|
||||
"language": "ภาษาไท or ภาษาไต"
|
||||
},
|
||||
{
|
||||
"code": "tok",
|
||||
"language": "toki pona"
|
||||
},
|
||||
{
|
||||
"code": "zba",
|
||||
"language": "باليبلن"
|
||||
},
|
||||
{
|
||||
"code": "zgh",
|
||||
"language": "ⵜⴰⵎⴰⵣⵉⵖⵜ"
|
||||
},
|
||||
{
|
||||
"code": "en-GB",
|
||||
"language": "English (British)"
|
||||
},
|
||||
{
|
||||
"code": "es-AR",
|
||||
"language": "Español (Argentina)"
|
||||
},
|
||||
{
|
||||
"code": "es-MX",
|
||||
"language": "Español (México)"
|
||||
},
|
||||
{
|
||||
"code": "fr-QC",
|
||||
"language": "Français (Canadien)"
|
||||
},
|
||||
{
|
||||
"code": "pt-BR",
|
||||
"language": "Português (Brasil)"
|
||||
},
|
||||
{
|
||||
"code": "pt-PT",
|
||||
"language": "Português (Portugal)"
|
||||
},
|
||||
{
|
||||
"code": "sr-Latn",
|
||||
"language": "Srpski (latinica)"
|
||||
},
|
||||
{
|
||||
"code": "zh-CN",
|
||||
"language": "简体中文"
|
||||
},
|
||||
{
|
||||
"code": "zh-HK",
|
||||
"language": "繁體中文(香港)"
|
||||
},
|
||||
{
|
||||
"code": "zh-TW",
|
||||
"language": "繁體中文(臺灣)"
|
||||
}
|
||||
]
|
|
@ -1,4 +1,9 @@
|
|||
[
|
||||
{
|
||||
"version": "3.18.0",
|
||||
"code": "478",
|
||||
"note": "Added:\n- Support camel case tags (automatically recorded when composing)\n- Manage tags when composing (top right menu)\n- Custom tabs (default: enabled)\n\nChanged:\n- Media heights now use the screen size\n- Remove horizontal scroll for media\n- Reduce size of emoji when text size is increased\n- Update available languages in picker\n\nFixed:\n- Forwarded tags are added back after being deleted\n- TalkBack issues\n- Some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.17.0",
|
||||
"code": "477",
|
||||
|
@ -88,305 +93,5 @@
|
|||
"version": "3.13.6",
|
||||
"code": "460",
|
||||
"note": "Fixed:\n- Cross-compose: Wrong instance emojis\n- Custom emojis not displayed in notifications\n- Fav/Boost markers with shared messages\n- Empty notifications\n- Fix cw removed when replying\n- Fix expand media with fit preview images when sensitive\n- Fix an issue with fetch more displayed too often (cache clear will help or wait new messages)"
|
||||
},
|
||||
{
|
||||
"version": "3.13.5",
|
||||
"code": "459",
|
||||
"note": "Added:\n- Glitch: Allow to post messages locally (Can be turned off in Settings)\n\nFixed:\n- Crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.13.4",
|
||||
"code": "458",
|
||||
"note": "Added:\n- Add Bubble timeline support in extra-features with filters\n- Allow to display public profiles by default to get all messages (Settings > Interface)\n\nChanged:\n- Full rework on links in messages (also mentions and tags)\n\nFixed:\n- Spoiler text when editing\n- Fix watermarks"
|
||||
},
|
||||
{
|
||||
"version": "3.13.3",
|
||||
"code": "457",
|
||||
"note": "Added:\n- Allow to enable extra features in Settings\n- Customizable settings for extra features\n- Support quotes, reactions with messages\n- Support text format (html, markdown, etc.) when composing\n\nFixed:\n- CW not working with media\n- Media not displayed for older instances\n- Some crashes\n"
|
||||
},
|
||||
{
|
||||
"version": "3.13.2",
|
||||
"code": "456",
|
||||
"note": "Changed:\n- Hidden media smaller with preview images\n\nFixed:\n- Issue with Media for Android 11+\n- Crash when not setting a translation key\n- Fix DeepL for API pro\n- Crash when visiting a profile with a lot of media\n- Home muted accounts not working without filters\n- Animated custom emoji not displayed"
|
||||
},
|
||||
{
|
||||
"version": "3.13.1",
|
||||
"code": "455",
|
||||
"note": "Added:\n- DeepL translation support free/pro keys\n\nChanged:\n- Hide buttons for media when editing\n\nFixed:\n- GIF loaded as static images\n- Suggested accounts cannot be followed"
|
||||
},
|
||||
{
|
||||
"version": "3.13.0",
|
||||
"code": "454",
|
||||
"note": "Added:\n- Post random quotes\n- Group reblogs in home timeline\n- Rename Nitter timelines\n- Android 13 support\n- Pagination with search / trending\n- Allow to remove left margin in messages (default: disabled)\n\nChanged:\n- Display translate button only when language is different\n- Respect blank spaces between words in messages\n- Focus button more accessible when editing media\n- Visual feedback for block on account list\n- Visual changes with compose / top bar\n- Use custom Nitter timeline name in manage timelines\n\nFixed:\n- Behavior with cw toggle\n- Truncated gimini links\n- Nav buttons not visible with media (Light theme)\n- Status bar with Android 5\n- Fix links not clickable\n- Fix deep links\n- Fix remote threads not fetched for some instances\n- Adding description to shared media\n- Open with another accounts\n- Chars size not respected for Android 5-6\n- Wrong instance fetched for instances.social\n- Bouncing Timeline on refresh\n- Links to mentions, tags, urls, not visible.\n- Custom channel sounds not applied\n- users with short username are not linked\n- Fix crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.12.3",
|
||||
"code": "453",
|
||||
"note": "Added:\n- Pagination with search / trending\n\nFixed:\n- Long press on Nitter tabs\n- Open with another accounts\n- Chars size not respected for Android 5-6\n- Wrong instance fetched for instances.social"
|
||||
},
|
||||
{
|
||||
"version": "3.12.2",
|
||||
"code": "452",
|
||||
"note": "Added:\n- Rename Nitter timelines\n- Android 13 support\n\nChanged:\n- Visual feedback for block on account list\n- Visual changes with compose / top bar\n\nFixed:\n- Nav buttons not visible with media (Light theme)\n- Status bar with Android 5\n- Fix links not clickable\n- Fix deep links\n- Fix remote threads not fetched for some instances\n- Adding description to shared media\n- Fix crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.12.1",
|
||||
"code": "451",
|
||||
"note": "Added:\n- Post random quotes\n- Group reblogs in home timeline\n\nChanged:\n- Display translate button only when language is different\n- Respect blank spaces between words in messages\n- Focus button more accessible when editing media\n\nFixed:\n- Behavior with cw toggle\n- Truncated gimini links"
|
||||
},
|
||||
{
|
||||
"version": "3.12.0",
|
||||
"code": "450",
|
||||
"note": "Added:\n- Full data import/export feature\n- Android 13 themed icon support\n\nFixed:\n- Fix a regression with filters\n- Fix dark solarized theme\n- Fix hide link previews for CW\n- Fix status bar color for all themes\n- Fix language in compose \"...\"\n- Fix add all home muted accounts from lists\n- Fix top notification badges"
|
||||
},
|
||||
{
|
||||
"version": "3.11.3",
|
||||
"code": "449",
|
||||
"note": "Added:\n- Add more targeted languages in picker for translations\n- Add account name in push notifications\n\nFixed:\n- Fix a crash when changing language\n- Fix counter colors\n- Fix default link color\n- Fix a crash when clicking on mentions"
|
||||
},
|
||||
{
|
||||
"version": "3.11.2",
|
||||
"code": "448",
|
||||
"note": "Added:\n- Mute/Unmute accounts in the Home timeline from their messages or their profiles\n- Add all users from a list to \"Muted home\" in one click\n- Display/Manage users that are muted for home\n\nFixed:\n- Timeline crashes"
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"note": "Added:\n- Allow to unmute/unfollow/unpin a tag from tag timelines\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\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"
|
||||
},
|
||||
{
|
||||
"version": "3.10.1",
|
||||
"code": "444",
|
||||
"note": "Added:\n- Display all messages in threads from remote instances (when possible)\n* Only public messages for instances using the Mastodon API\n* A dedicated button is displayed at the top right when conditions are filled."
|
||||
},
|
||||
{
|
||||
"version": "3.10.0",
|
||||
"code": "443",
|
||||
"note": "Added:\n- Dracula theme\n- Customize message colors\n- Enable/Disable Card presentation\n\nChanged:\n- Colors for some themes\n- Space between buttons\n\nFixed:\n- Animated profile pictures not displayed\n- Mentions broken in profile bio and fields\n- Jumps with fit preview images when scrolling up\n- Fetch more button broken with cache\n- Tag patterns in URL break the link\n- Typo in followed tags"
|
||||
},
|
||||
{
|
||||
"version": "3.9.7",
|
||||
"code": "442",
|
||||
"note": "Added:\n- Dracula theme\n\nChanged:\n- Colors for Light/Dark/Black themes\n\nFixed:\n- Animated profile pictures not displayed\n- Mentions broken in profile bio and fields\n- Tag patterns in URL break the link\n- Typo in followed tags"
|
||||
},
|
||||
{
|
||||
"version": "3.9.6",
|
||||
"code": "441",
|
||||
"note": "Fixed:\n- Jumps with fit preview images when scrolling up\n- Fetch more button broken with cache"
|
||||
},
|
||||
{
|
||||
"version": "3.9.5",
|
||||
"code": "440",
|
||||
"note": "Fixed:\n- Custom emoji are not always displayed\n- Jumps in timeline when using \"fit preview images\"\n- Dark theme: timeline buttons without toggle"
|
||||
},
|
||||
{
|
||||
"version": "3.9.4",
|
||||
"code": "439",
|
||||
"note": "Changed:\n- Remove card presentation\n- Link color for black theme\n\nFixed:\n- Crash when changing the theme"
|
||||
},
|
||||
{
|
||||
"version": "3.9.3",
|
||||
"code": "438",
|
||||
"note": "Added:\n- New design with 5 themes\n\nChanged:\n- Remove built-in browser support\n- Fit preview image displays images vertically\n- Add counters next to images\n\nFixed:\n- Jumps in timelines\n- Replies to wrong messages with followed instances\n- Bug with delete&redraft with a media\n- List cannot be hidden\n- Some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.9.1",
|
||||
"code": "436",
|
||||
"note": "Changed:\n- Remove built-in browser support\n- More spaces between action buttons in messages\n\nFixed:\n- Text size issue\n- Text overlap\n- Wrong background for solarized black\n- Mix between light and dark theme\n- Save button hidden"
|
||||
},
|
||||
{
|
||||
"version": "3.9.0",
|
||||
"code": "435",
|
||||
"note": "Added:\n- Migrate to Material Design 3\n- 5 Themes (Light, Dark, Solarized Light/Dark, Black)\n- Automatically switch between Light/Dark\n- Light and Dark theme can be defined for time-based switch\n- Android 12+: Dynamic color\n\nFixed:\n- Jumps in timelines\n"
|
||||
},
|
||||
{
|
||||
"version": "3.8.1",
|
||||
"code": "434",
|
||||
"note": "Added:\n- Mute tags with long press in timelines\n\nChanged:\n- Muted account messages are now removed from cache\n\nFixed:\n- Open with another account\n- Fix jumps in profiles\n- Media not displayed in album -> force indexation\n- Built-in browser does not give admin scope\n- Some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.8.0",
|
||||
"code": "433",
|
||||
"note": "Added:\n- List of blocked domains (allow to unblock)\n- Support gemini links\n- Suggested followers\n- Mod/Adm: Manage instance blocked domains\n- Open messages with another account\n- Allow to disable notifications for admins\n- Sort lists\n\nChanged:\n- Allow search term to be edited\n\nFixed:\n- Drafts deleted with no warning\n- Remove lists from \"Manage timelines\"\n- App crashes when proxy is set\n- Filter not synced after being edited\n- Some crashes / improvements"
|
||||
},
|
||||
{
|
||||
"version": "3.7.5",
|
||||
"code": "432",
|
||||
"note": "Added:\n- List of blocked domains (allow to unblock)\n- Support gemini links\n- Suggested followers\n\nChanged:\n- Allow search term to be edited\n\nFixed:\n- Drafts deleted with no warning\n- App crashes when proxy is set\n- Filter not synced after being edited\n- Some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.7.4",
|
||||
"code": "431",
|
||||
"note": "Added:\n- Full support to new filters for Mastodon 4\n- Visit profiles without being authenticated / Allow to display all their messages\n\nChanged:\n- Compose view takes the whole width even in threads\n- Accounts can be timed-mute from their profile\n\nFixed:\n- Draft stored when replying \"no\" or dialog prompted without changes\n- Empty pages when starting the app\n- Saving and sharing media fails on some devices\n- Add support for admin notifications\n- Copying content of a message"
|
||||
},
|
||||
{
|
||||
"version": "3.7.3",
|
||||
"code": "430",
|
||||
"note": "Added:\n- Visit profiles without being authenticated / Allow to display all their messages\n\nFixed:\n- Saving media fails on some devices"
|
||||
},
|
||||
{
|
||||
"version": "3.7.2",
|
||||
"code": "429",
|
||||
"note": "Added:\n- Full support to new filters for Mastodon 4"
|
||||
},
|
||||
{
|
||||
"version": "3.7.1",
|
||||
"code": "428",
|
||||
"note": "Added:\n- Support to open links containing /@display_name/ in their path (works on older devices)\n- Display reply count when counters are enabled\n- Add support for filtering profile messages\n\nChanged:\n- Compose view takes the whole width even in threads\n- Reset push notification marker when clearing cache\n\nFixed:\n- Draft stored when replying \"no\" or dialog prompted without changes\n- Filters not working with tags\n- Add a specific error message for followed tags\n- Empty pages when starting the app"
|
||||
},
|
||||
{
|
||||
"version": "3.7.0",
|
||||
"code": "427",
|
||||
"note": "Added:\n- Follow tags (dedicated entry in menu)\n- Reduce the list of languages when composing (Settings > Compose)\n- Language indicator when composing\n- Replies are automatically set to first message language\n- Two new Light themes\n- More moderation features\n- List name can be edited\n\nFixed:\n- Filter not working\n- Crash with trends\n- Issue with themes\n- Some content lost when sending messages (mentions)\n- Fix freezes in timelines\n- Some other fixes"
|
||||
},
|
||||
{
|
||||
"version": "3.6.5",
|
||||
"code": "426",
|
||||
"note": "- Two new Light themes\n- More moderation features\n\nFixed:\n- Filter not working\n- Crash with trends\n- Some content lost when sending messages (mentions)\n- Some other fixes"
|
||||
},
|
||||
{
|
||||
"version": "3.6.4",
|
||||
"code": "425",
|
||||
"note": "Changed:\n- Tag search ordered by popularity\n\nFixed:\n- Unable to get client ID on some devices\n- Issue with messages/notifications not correctly displayed\n- Notifications not received\n- Friendica: issues with mentions and tags (open browser)\n- Improve sharing behaviour"
|
||||
},
|
||||
{
|
||||
"version": "3.6.3",
|
||||
"code": "424",
|
||||
"note": "Fixed:\n- Issue with messages/notifications not correctly displayed\n- Friendica: issues with mentions and tags (open browser)\n- Improve sharing behaviour\n"
|
||||
},
|
||||
{
|
||||
"version": "3.6.2",
|
||||
"code": "423",
|
||||
"note": "Fixed:\n- Order of notifications\n- URL when sharing boosted message\n- Blank pages when restarting\n- Fix some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.6.1",
|
||||
"code": "422",
|
||||
"note": "Added:\n- Display client in detailed messages\n- Visual support for quotes starting with \">\"\n- Increase indentations for threads (zero to 20, default 5)\n- Visibility for public replies set to unlisted (can be disabled)\n\nChanged:\n- Reduce title size when text size is increased\n\nFixed:\n- Filters are not applied\n- Blocking an account doesn't remove messages in cache\n- Fix some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.6.0",
|
||||
"code": "421",
|
||||
"note": "Added:\n- Edit messages (if your instance supports that feature)\n- Pin/Unpin messages\n- Set the default language for translations\n- Change app icon (Settings > Interface)\n- Allow to disable \"remember position\" in timelines\n- Allow to disable notification aggregation in settings\n- Icon on media previews if a description is available\n\nChanged:\n- Allow to disable/enable media for notifications\n\nFixed:\n- Post loses \"spoiler message\" when adding a media\n- Camera not working on Android 11\n- Notification aggregation\n- Vibrations when fetching new notifications\n- Fix an issue with media timelines\n- Fix some theme issues\n- Fix an issue with built-in browser & openId\n- Bad behaviours with Art Timelines\n- Some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.5.3",
|
||||
"code": "420",
|
||||
"note": "- Edit messages (if your instance support that feature)\n- Some fixes"
|
||||
},
|
||||
{
|
||||
"version": "3.5.2",
|
||||
"code": "419",
|
||||
"note": "Added:\n- Pin/Unpin messages\n- Set the default language for translations\n\nChanged:\n- Allow to disable/enable media for notifications\n\nFixed:\n- Wrong images in notification timeline\n- Double icon bug\n- Fix some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.5.1",
|
||||
"code": "418",
|
||||
"note": "Added:\n- Change app icon (Settings > Interface)\n- Allow to disable \"remember position\" in timelines\n- Allow to disable notification aggregation in settings\n\nChanged:\n- Allow to disable/enable media for notifications\n\nFixed:\n- Post loses \"spoiler message\" when adding a media\n- Camera not working on Android 11\n- Notification aggregation\n- Vibrations when fetching new notifications\n- Fix an issue with media timelines\n- Some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.5.0",
|
||||
"code": "417",
|
||||
"note": "Changed:\n- Swipe between timelines\n- Improve cache\n- Button sizes can be changed in settings\n- French translation\n\nFixed:\n- Pleroma: Emoji reactions\n- Sharing (several fixes)\n- Theme issues\n- Rendering issue for links\n- Notifications not removed from cache\n- Issue with watermarks\n- Pagination with bookmarks/favourites\n- Some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.4.2",
|
||||
"code": "415",
|
||||
"note": "Fixed:\n- Attach media to a reply"
|
||||
},
|
||||
{
|
||||
"version": "3.4.1",
|
||||
"code": "414",
|
||||
"note": "Added:\n- Disable counters in settings\nFixed:\n- Duplicated messages from cache\n- Notifications in double\n- Drafts not automatically removed\n- Messages not removed from cache after deletion"
|
||||
},
|
||||
{
|
||||
"version": "3.4.0",
|
||||
"code": "413",
|
||||
"note": "Added:\n- New cache mechanism (can be disabled in settings)\n- Set thumbnails load behavior Always/Wifi only /ask\n- Add counters for new messages in timelines\nFixed:\n- Contextual menu not working in threads\n- Tag search issue with Friendica\n- Notifications click open the wrong tab\n- Encoding issue with media descriptions\n- Some other fixes."
|
||||
},
|
||||
{
|
||||
"version": "3.3.2",
|
||||
"code": "409",
|
||||
"note": "- Fix an issue with cache and home timeline\n- Nitter timelines use the custom instance from settings\n- Fix Nitter issues (only RT)\n- No longer accepts invalid certificate for onion URLs(Google)\n- Fix some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.3.1",
|
||||
"code": "408",
|
||||
"note": "- Improve speed for Nitter instances\n- Allow to edit Nitter accounts with a long press on tabs\n- Fix pagination issue with pinned timelines\n- Fix some crashes\n- Fix visibility when displaying counters"
|
||||
},
|
||||
{
|
||||
"version": "3.3.0",
|
||||
"code": "407",
|
||||
"note": "Added:\n- Settings to set all timelines at the top (default disabled)\n- Settings to display timelines in a list (default disabled)\n- Display counters for fav/reblog in timelines (default disabled)\n\nFixed:\n- Visibility issue when replying\n- Some theme issues when composing\n- Some crashes"
|
||||
},
|
||||
{
|
||||
"version": "3.2.0",
|
||||
"code": "405",
|
||||
"note": "Added:\n- Export Settings\n- Propagate manual reordering of lists in timeline to \"Lists\" submenu\n- Allow to change the push distributor in settings\n\nChanged:\n- Improve fit preview images\n- Improve notifications\n- Profile media displayed in a grid\n\nFixed:\n- Some Peertube videos not working\n- Respect the default visibility account when replying\n- Discriminate gif from images\n- App crashes when opening external instance timeline\n- Remove button in thread composer crashes the app\n- Back button opens a lot of old activities before closing the app\n- Problems with sharing\n- Reorder Lists with UI issue on change the visibility\n- Link is not shown correctly in posts from Friendica"
|
||||
},
|
||||
{
|
||||
"version": "3.1.0",
|
||||
"code": "402",
|
||||
"note": "Added:\n- New theme: Dark Elephant from S1m\n- Error messages from server side when posting fails\n\nChanged:\n- Fetch more buttons more visible\n\nFixed:\n- Issue when fetching missing messages\n- Some issues with themes\n- Too much lost space with reaction (Pleroma)\n- Delete and redraft crashes\n- Crash when playing a video\n- Other crash fixes"
|
||||
},
|
||||
{
|
||||
"version": "3.0.11",
|
||||
"code": "401",
|
||||
"note": "Added:\n- New theme: Dark Elephant from S1m\n- Error messages from server side when posting fails\n- Allow to set the fetch time for delayed notifications\n\nChanged:\n- Fetch more buttons more visible\n\nFixed:\n- Issue when fetching missing messages\n- Some issues with themes\n- Too much lost space with reaction (Pleroma)\n- Delete and redraft crashes\n- Crash when playing a video\n- Other crash fixes"
|
||||
},
|
||||
{
|
||||
"version": "3.0.10",
|
||||
"code": "400",
|
||||
"note": "Added:\n- Allow to define the max chars count when not detected (In about the instance)\n- Add emoji one picker when composing (must be enabled in settings)\n- Add release notes with the ability to translate them\n\nFixed:\n- Friendica custom emojis not displayed\n- Long press to store media\n- Some bug fixes"
|
||||
},
|
||||
{
|
||||
"version": "3.0.9",
|
||||
"code": "399",
|
||||
"note": "Added:\n- Set compose language (from compose menu -> three vertical dots)\n- Add reactions support for Pleroma\n- Add privacy indicator at the top right\n\nChanged\n- Improve the scrolling behaviour\n- Scroll to top (tab reselection) will fetch new messages and then scroll to top\n\nFixed:\n- Empty tag timelines\n- Remove focus point for fit media preview\n- Fix cannot share with one account\n- Fix black theme\n- Theme cannot be selected\n- Fix some button colors"
|
||||
},
|
||||
{
|
||||
"version": "3.0.8",
|
||||
"code": "398",
|
||||
"note": "- Keep improving the scroll behaviour\n- Scroll to top (tab reselection) will fetch new messages and then scroll to top\n- Remove focus point for fit media preview\n- Fix cannot share with one account\n- Fix black theme\n- Fix some button colors"
|
||||
},
|
||||
{
|
||||
"version": "3.0.7",
|
||||
"code": "397",
|
||||
"note": "- Fix some bugs reported."
|
||||
},
|
||||
{
|
||||
"version": "3.0.6",
|
||||
"code": "396",
|
||||
"note": "Added:\n- Allow to set a focus point on previews (media editor)\n- Respect the focus point with previews\n- Pagination with the fetch more button support reading up or down\n- Add trends\n\nFixed:\n- Only last push notification is displayed (not grouped)\n- Bad behavior with the right/left scroll\n- Fix long profiles not fully displayed\n- Issues with some polls\n- Some crashes\n- Some bad behaviors"
|
||||
},
|
||||
{
|
||||
"version": "3.0.5",
|
||||
"code": "395",
|
||||
"note": "- Fix some bugs\n- Allow to share with the app"
|
||||
},
|
||||
{
|
||||
"version": "3.0.4",
|
||||
"code": "394",
|
||||
"note": "- Fix crashes for some Pleroma instances"
|
||||
},
|
||||
{
|
||||
"version": "3.0.2",
|
||||
"code": "393",
|
||||
"note": "- Some bug fixes\n- Improve pinned timelines"
|
||||
},
|
||||
{
|
||||
"version": "3.0.1",
|
||||
"code": "391",
|
||||
"note": "Some quick fixes"
|
||||
},
|
||||
{
|
||||
"version": "3.0.0",
|
||||
"code": "390",
|
||||
"note": "New version of Fedilab with new feature.\n- You can now compose threads\n- See the whole thread when replying\n- Cache support\n- New design"
|
||||
}
|
||||
]
|
|
@ -478,7 +478,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
if (!activity.isDestroyed() && !activity.isFinishing() && url != null) {
|
||||
if (url.trim().isEmpty()) {
|
||||
BitmapDrawable avatar = new AvatarGenerator.AvatarBuilder(activity)
|
||||
.setLabel(account.peertube_account.getAcct())
|
||||
.setLabel(acct)
|
||||
.setAvatarSize(120)
|
||||
.setTextSize(30)
|
||||
.toSquare()
|
||||
|
|
|
@ -399,6 +399,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
} else {
|
||||
Toasty.info(ComposeActivity.this, getString(R.string.toot_error_no_content), Toasty.LENGTH_SHORT).show();
|
||||
}
|
||||
} else if (item.getItemId() == R.id.action_tags) {
|
||||
TagCacheActivity tagCacheActivity = new TagCacheActivity();
|
||||
tagCacheActivity.show(getSupportFragmentManager(), null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
package app.fedilab.android.mastodon.activities;
|
||||
/* Copyright 2023 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 static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||
import static app.fedilab.android.mastodon.activities.ComposeActivity.PICK_MEDIA;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityDirectMessageBinding;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||
import app.fedilab.android.mastodon.client.entities.app.StatusCache;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
||||
import app.fedilab.android.mastodon.ui.drawer.StatusAdapter;
|
||||
import app.fedilab.android.mastodon.ui.fragment.timeline.FragmentMastodonDirectMessage;
|
||||
import app.fedilab.android.mastodon.viewmodel.mastodon.StatusesVM;
|
||||
|
||||
public class DirectMessageActivity extends BaseActivity implements FragmentMastodonDirectMessage.FirstMessage {
|
||||
|
||||
public static boolean expand;
|
||||
public static boolean displayCW;
|
||||
|
||||
FragmentMastodonDirectMessage currentFragment;
|
||||
private Status firstMessage;
|
||||
private String remote_instance;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityDirectMessageBinding binding = ActivityDirectMessageBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
setSupportActionBar(binding.toolbar);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
//Remove title
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayShowTitleEnabled(false);
|
||||
}
|
||||
binding.title.setText(R.string.context_conversation);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
|
||||
binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
Bundle b = getIntent().getExtras();
|
||||
displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false);
|
||||
Status focusedStatus = null; // or other values
|
||||
if (b != null) {
|
||||
focusedStatus = (Status) b.getSerializable(Helper.ARG_STATUS);
|
||||
remote_instance = b.getString(Helper.ARG_REMOTE_INSTANCE, null);
|
||||
}
|
||||
if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_STATUS, focusedStatus);
|
||||
bundle.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance);
|
||||
FragmentMastodonDirectMessage FragmentMastodonDirectMessage = new FragmentMastodonDirectMessage();
|
||||
FragmentMastodonDirectMessage.firstMessage = this;
|
||||
currentFragment = (FragmentMastodonDirectMessage) Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, FragmentMastodonDirectMessage, bundle, null, null);
|
||||
StatusesVM timelinesVM = new ViewModelProvider(DirectMessageActivity.this).get(StatusesVM.class);
|
||||
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(DirectMessageActivity.this, status -> {
|
||||
if (status != null) {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = status;
|
||||
statusCache.status_id = status.id;
|
||||
//Update cache
|
||||
new Thread(() -> {
|
||||
try {
|
||||
new StatusCache(getApplication()).updateIfExists(statusCache);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
//Update UI
|
||||
Runnable myRunnable = () -> StatusAdapter.sendAction(DirectMessageActivity.this, Helper.ARG_STATUS_ACTION, status, null);
|
||||
mainHandler.post(myRunnable);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
List<Uri> uris = new ArrayList<>();
|
||||
if (requestCode >= PICK_MEDIA && resultCode == RESULT_OK) {
|
||||
ClipData clipData = data.getClipData();
|
||||
if (clipData != null) {
|
||||
for (int i = 0; i < clipData.getItemCount(); i++) {
|
||||
ClipData.Item item = clipData.getItemAt(i);
|
||||
uris.add(item.getUri());
|
||||
}
|
||||
} else {
|
||||
uris.add(data.getData());
|
||||
}
|
||||
currentFragment.addAttachment(uris);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void get(Status status) {
|
||||
firstMessage = status;
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
|
@ -126,8 +126,10 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
|||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
if (attachments == null || attachments.size() == 0)
|
||||
if (attachments == null || attachments.size() == 0) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
setTitle("");
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
package app.fedilab.android.mastodon.activities;
|
||||
/* Copyright 2023 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 android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityCamelTagBinding;
|
||||
import app.fedilab.android.mastodon.client.entities.app.CamelTag;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
import app.fedilab.android.mastodon.ui.drawer.TagsEditAdapter;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
public class TagCacheActivity extends DialogFragment {
|
||||
|
||||
private List<String> tags;
|
||||
private TagsEditAdapter tagsEditAdapter;
|
||||
|
||||
private ActivityCamelTagBinding binding;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
binding = ActivityCamelTagBinding.inflate(getLayoutInflater());
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(requireContext());
|
||||
materialAlertDialogBuilder.setView(binding.getRoot());
|
||||
|
||||
Dialog dialog = materialAlertDialogBuilder.create();
|
||||
tags = new ArrayList<>();
|
||||
|
||||
binding.saveTag.setOnClickListener(v -> {
|
||||
if (binding.tagAdd.getText() != null && (binding.tagAdd.getText().toString().trim().replaceAll("#", "").length() > 0)) {
|
||||
String tagToInsert = binding.tagAdd.getText().toString().trim().replaceAll("#", "");
|
||||
try {
|
||||
boolean isPresent = new CamelTag(requireActivity()).tagExists(tagToInsert);
|
||||
if (isPresent)
|
||||
Toasty.warning(requireActivity(), getString(R.string.tags_already_stored), Toast.LENGTH_LONG).show();
|
||||
else {
|
||||
new CamelTag(requireActivity()).insert(tagToInsert);
|
||||
int position = tags.size();
|
||||
tags.add(tagToInsert);
|
||||
Toasty.success(requireActivity(), getString(R.string.tags_stored), Toast.LENGTH_LONG).show();
|
||||
binding.tagAdd.setText("");
|
||||
tagsEditAdapter.notifyItemInserted(position);
|
||||
}
|
||||
} catch (DBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
dialog.setTitle(R.string.manage_tags);
|
||||
|
||||
new Thread(() -> {
|
||||
List<String> tagsTemp = new CamelTag(requireActivity()).getAll();
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
if (tagsTemp != null)
|
||||
tags = tagsTemp;
|
||||
if (tags != null) {
|
||||
tagsEditAdapter = new TagsEditAdapter(tags);
|
||||
binding.tagList.setAdapter(tagsEditAdapter);
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(requireActivity());
|
||||
binding.tagList.setLayoutManager(mLayoutManager);
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
|
||||
binding.close.setOnClickListener(v -> requireDialog().dismiss());
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -118,6 +118,8 @@ public class Status implements Serializable, Cloneable {
|
|||
public transient boolean isFetchMore = false;
|
||||
public transient PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
|
||||
public boolean isChecked = false;
|
||||
//When forwarding tags
|
||||
public boolean tagAdded = false;
|
||||
public String translationContent;
|
||||
public boolean translationShown;
|
||||
public boolean mathsShown = false;
|
||||
|
|
|
@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.client.entities.api;
|
|||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -42,4 +44,13 @@ public class Tag implements Serializable {
|
|||
}
|
||||
return weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
boolean same = false;
|
||||
if (obj instanceof Tag) {
|
||||
same = this.name.equals(((Tag) obj).name);
|
||||
}
|
||||
return same;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
package app.fedilab.android.mastodon.client.entities.app;
|
||||
/* Copyright 2023 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 android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
|
||||
public class CamelTag {
|
||||
|
||||
private final SQLiteDatabase db;
|
||||
@SerializedName("name")
|
||||
public String name;
|
||||
|
||||
public CamelTag(Context context) {
|
||||
this.db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert or update a status
|
||||
*
|
||||
* @param name {@link String}
|
||||
* @return long - -1 if exists or id
|
||||
* @throws DBException exception with database
|
||||
*/
|
||||
public synchronized long insert(String name) throws DBException {
|
||||
if (db == null) {
|
||||
throw new DBException("db is null. Wrong initialization.");
|
||||
}
|
||||
boolean exists = tagExists(name);
|
||||
if (!exists) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Sqlite.COL_TAG, name);
|
||||
try {
|
||||
return db.insertOrThrow(Sqlite.TABLE_CACHE_TAGS, null, values);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tags List of {@String} containing "search"
|
||||
*
|
||||
* @param search - String the word to search
|
||||
* @return List<String>
|
||||
*/
|
||||
public List<String> getBy(String search) {
|
||||
Cursor c = db.query(Sqlite.TABLE_CACHE_TAGS, null, Sqlite.COL_TAG + " LIKE \"%" + search + "%\"", null, null, null, null, null);
|
||||
return cursorToTag(c);
|
||||
}
|
||||
|
||||
public boolean tagExists(String name) throws DBException {
|
||||
Cursor c = db.query(Sqlite.TABLE_CACHE_TAGS, null, Sqlite.COL_TAG + " = \"" + name + "\"", null, null, null, null, null);
|
||||
boolean isPresent = (c != null && c.getCount() > 0);
|
||||
assert c != null;
|
||||
c.close();
|
||||
return isPresent;
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
db.delete(Sqlite.TABLE_CACHE_TAGS, null, null);
|
||||
}
|
||||
|
||||
public void removeTag(String tag) {
|
||||
db.delete(Sqlite.TABLE_CACHE_TAGS, Sqlite.COL_TAG + " = ?", new String[]{tag});
|
||||
}
|
||||
|
||||
public void update(String oldTag, String newTag) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Sqlite.COL_TAG, newTag);
|
||||
try {
|
||||
db.update(Sqlite.TABLE_CACHE_TAGS, values, Sqlite.COL_TAG + " = ?", new String[]{oldTag});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all tags in db
|
||||
*
|
||||
* @return string tags List<String>
|
||||
*/
|
||||
public List<String> getAll() {
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_CACHE_TAGS, null, null, null, null, null, Sqlite.COL_TAG + " ASC", null);
|
||||
return cursorToTag(c);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> cursorToTag(Cursor c) {
|
||||
//No element found
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<String> tags = new ArrayList<>();
|
||||
while (c.moveToNext()) {
|
||||
tags.add(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_TAG)));
|
||||
}
|
||||
//Close the cursor
|
||||
c.close();
|
||||
//Tag list is returned
|
||||
return tags;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import app.fedilab.android.mastodon.client.entities.api.Status;
|
|||
|
||||
|
||||
public class CustomEmoji extends ReplacementSpan {
|
||||
private final float scale;
|
||||
private float scale;
|
||||
private final WeakReference<View> viewWeakReference;
|
||||
private Drawable imageDrawable;
|
||||
private boolean callbackCalled;
|
||||
|
@ -40,6 +40,9 @@ public class CustomEmoji extends ReplacementSpan {
|
|||
this.viewWeakReference = viewWeakReference;
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
scale = sharedpreferences.getFloat(mContext.getString(R.string.SET_FONT_SCALE), 1.1f);
|
||||
if (scale > 1.3f) {
|
||||
scale = 1.3f;
|
||||
}
|
||||
callbackCalled = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ import androidx.annotation.IdRes;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.browser.customtabs.CustomTabColorSchemeParams;
|
||||
import androidx.browser.customtabs.CustomTabsIntent;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
@ -646,16 +648,29 @@ public class Helper {
|
|||
if (url == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://") && !url.toLowerCase().startsWith("gemini://")) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
intent.setData(Uri.parse(url));
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean customTab = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOM_TABS), true);
|
||||
if (customTab) {
|
||||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
||||
int colorInt = ThemeHelper.getAttColor(context, R.attr.statusBar);
|
||||
CustomTabColorSchemeParams defaultColors = new CustomTabColorSchemeParams.Builder()
|
||||
.setToolbarColor(colorInt)
|
||||
.build();
|
||||
builder.setDefaultColorSchemeParams(defaultColors);
|
||||
CustomTabsIntent customTabsIntent = builder.build();
|
||||
customTabsIntent.launchUrl(context, Uri.parse(url));
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://") && !url.toLowerCase().startsWith("gemini://")) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
intent.setData(Uri.parse(url));
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ public class TranslateHelper {
|
|||
MyTransL.translatorEngine et;
|
||||
if (translator.compareToIgnoreCase("FEDILAB") == 0) {
|
||||
et = MyTransL.translatorEngine.LIBRETRANSLATE;
|
||||
} else if (translator.compareToIgnoreCase("LINGVA") == 0) {
|
||||
et = MyTransL.translatorEngine.LINGVA;
|
||||
} else {
|
||||
et = MyTransL.translatorEngine.DEEPL;
|
||||
}
|
||||
|
@ -60,6 +62,12 @@ public class TranslateHelper {
|
|||
params.setSource_lang("auto");
|
||||
if (translator.compareToIgnoreCase("FEDILAB") == 0) {
|
||||
myTransL.setLibretranslateDomain("translate.fedilab.app");
|
||||
} else if (translator.compareToIgnoreCase("LINGVA") == 0) {
|
||||
String host = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR_DOMAIN), context.getString(R.string.SET_TRANSLATOR_HOST_LINGVA));
|
||||
if (host == null || host.trim().isEmpty()) {
|
||||
host = context.getString(R.string.SET_TRANSLATOR_HOST_LINGVA);
|
||||
}
|
||||
myTransL.setLingvaDomain(host);
|
||||
} else {
|
||||
String translatorVersion = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR_VERSION), "PRO");
|
||||
params.setPro(translatorVersion.equals("PRO"));
|
||||
|
|
|
@ -47,6 +47,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
|
@ -57,6 +58,7 @@ import app.fedilab.android.mastodon.client.entities.api.ScheduledStatus;
|
|||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||
import app.fedilab.android.mastodon.client.entities.app.Account;
|
||||
import app.fedilab.android.mastodon.client.entities.app.BaseAccount;
|
||||
import app.fedilab.android.mastodon.client.entities.app.CamelTag;
|
||||
import app.fedilab.android.mastodon.client.entities.app.PostState;
|
||||
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
|
@ -228,19 +230,38 @@ public class ComposeWorker extends Worker {
|
|||
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBD);
|
||||
return;
|
||||
}
|
||||
String language = sharedPreferences.getString(context.getString(R.string.SET_COMPOSE_LANGUAGE) + dataPost.userId + dataPost.instance, null);
|
||||
if (statuses.get(i).local_only) {
|
||||
statuses.get(i).text += " \uD83D\uDC41";
|
||||
}
|
||||
//Record tags
|
||||
if (statuses.get(i).text != null && statuses.get(i).text.length() > 0) {
|
||||
Matcher matcher = Helper.hashtagPattern.matcher(statuses.get(i).text);
|
||||
while (matcher.find()) {
|
||||
int matchStart = matcher.start(1);
|
||||
int matchEnd = matcher.end();
|
||||
//Get cached tags
|
||||
if (matchStart >= 0 && matchEnd < statuses.get(i).text.length()) {
|
||||
String tag = statuses.get(i).text.substring(matchStart, matchEnd);
|
||||
tag = tag.replace("#", "");
|
||||
if (tag.length() > 0) {
|
||||
try {
|
||||
new CamelTag(context).insert(tag);
|
||||
} catch (DBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dataPost.scheduledDate == null) {
|
||||
if (dataPost.statusEditId == null) {
|
||||
statusCall = mastodonStatusesService.createStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
|
||||
poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language, statuses.get(i).quote_id, statuses.get(i).content_type);
|
||||
poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), statuses.get(i).language, statuses.get(i).quote_id, statuses.get(i).content_type);
|
||||
} else { //Status is edited
|
||||
statusCall = mastodonStatusesService.updateStatus(null, dataPost.token, dataPost.statusEditId, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
|
||||
poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive,
|
||||
statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language,
|
||||
statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), statuses.get(i).language,
|
||||
media_edit_id, media_edit_description, media_edit_focus);
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -119,6 +119,7 @@ import app.fedilab.android.mastodon.client.entities.api.Poll;
|
|||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Tag;
|
||||
import app.fedilab.android.mastodon.client.entities.app.BaseAccount;
|
||||
import app.fedilab.android.mastodon.client.entities.app.CamelTag;
|
||||
import app.fedilab.android.mastodon.client.entities.app.Languages;
|
||||
import app.fedilab.android.mastodon.client.entities.app.Quotes;
|
||||
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
|
||||
|
@ -136,7 +137,7 @@ import es.dmoral.toasty.Toasty;
|
|||
|
||||
public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private static final int searchDeep = 15;
|
||||
private static final int TYPE_COMPOSE = 1;
|
||||
public static final int TYPE_COMPOSE = 1;
|
||||
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", "!", ",", "?",
|
||||
|
@ -818,13 +819,24 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
} else if (matcherTag.matches()) {
|
||||
String searchGroup = matcherTag.group(3);
|
||||
if (searchGroup != null) {
|
||||
List<String> camelTags = new CamelTag(context).getBy(searchGroup);
|
||||
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, searchGroup, null,
|
||||
"hashtags", false, true, false, 0,
|
||||
null, null, 10).observe((LifecycleOwner) context,
|
||||
results -> {
|
||||
if (results == null) {
|
||||
if (results == null || results.hashtags == null || results.hashtags.size() == 0) {
|
||||
return;
|
||||
}
|
||||
if (camelTags != null && camelTags.size() > 0) {
|
||||
for (String camelTag : camelTags) {
|
||||
Tag tag = new Tag();
|
||||
tag.name = camelTag;
|
||||
if (!results.hashtags.contains(tag)) {
|
||||
results.hashtags.add(0, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int currentCursorPosition = holder.binding.content.getSelectionStart();
|
||||
TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(context, results.hashtags);
|
||||
holder.binding.content.setThreshold(1);
|
||||
|
@ -1312,7 +1324,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
ComposeViewHolder holder = (ComposeViewHolder) viewHolder;
|
||||
boolean extraFeatures = sharedpreferences.getBoolean(context.getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
||||
boolean mathsComposer = sharedpreferences.getBoolean(context.getString(R.string.SET_MATHS_COMPOSER), true);
|
||||
boolean forwardTag = sharedpreferences.getBoolean(context.getString(R.string.SET_FORWARD_TAGS_IN_REPLY), true);
|
||||
boolean forwardTag = sharedpreferences.getBoolean(context.getString(R.string.SET_FORWARD_TAGS_IN_REPLY), false);
|
||||
|
||||
|
||||
if (mathsComposer) {
|
||||
|
@ -1600,7 +1612,8 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
statusDraft.setCursorToEnd = false;
|
||||
holder.binding.content.setSelection(holder.binding.content.getText().length());
|
||||
}
|
||||
if (forwardTag && position > 0 && statusDraft.text != null && !statusDraft.text.contains("#")) {
|
||||
if (forwardTag && position > 0 && statusDraft.text != null && !statusDraft.text.contains("#") && !statusList.get(position).tagAdded) {
|
||||
statusList.get(position).tagAdded = true;
|
||||
Status status = statusList.get(position - 1).reblog == null ? statusList.get(position - 1) : statusList.get(position - 1).reblog;
|
||||
if (status.tags != null && status.tags.size() > 0) {
|
||||
statusDraft.text += "\n\n";
|
||||
|
@ -1614,8 +1627,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
statusDraft.setCursorToEnd = false;
|
||||
holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3);
|
||||
}
|
||||
} else if (forwardTag && position > 0 && statusDraft.text != null && statusDraft.text.contains("#")) {
|
||||
} else if (forwardTag && position > 0 && statusDraft.text != null && statusDraft.text.contains("#") && !statusList.get(position).tagAdded) {
|
||||
Status status = statusList.get(position - 1).reblog == null ? statusList.get(position - 1) : statusList.get(position - 1).reblog;
|
||||
statusList.get(position).tagAdded = true;
|
||||
int lenght = 0;
|
||||
for (Tag tag : status.tags) {
|
||||
lenght += ("#" + tag.name + " ").length();
|
||||
|
@ -1634,7 +1648,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
holder.binding.sensitiveMedia.setChecked(statusDraft.sensitive);
|
||||
holder.binding.content.addTextChangedListener(initializeTextWatcher(holder));
|
||||
holder.binding.buttonPoll.setOnClickListener(v -> displayPollPopup(holder, statusDraft, position));
|
||||
holder.binding.buttonPoll.setOnClickListener(v -> displayPollPopup(holder, statusDraft, position));
|
||||
if (instanceInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1681,7 +1694,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
|
||||
if (statusDraft.language == null || statusDraft.language.isEmpty()) {
|
||||
String currentCode = sharedpreferences.getString(context.getString(R.string.SET_COMPOSE_LANGUAGE) + account.user_id + account.instance, Locale.getDefault().getLanguage());
|
||||
if (currentCode == null || currentCode.isEmpty()) {
|
||||
if (currentCode.isEmpty()) {
|
||||
currentCode = "EN";
|
||||
}
|
||||
statusDraft.language = currentCode;
|
||||
|
|
|
@ -47,6 +47,7 @@ import app.fedilab.android.R;
|
|||
import app.fedilab.android.databinding.DrawerConversationBinding;
|
||||
import app.fedilab.android.databinding.ThumbnailBinding;
|
||||
import app.fedilab.android.mastodon.activities.ContextActivity;
|
||||
import app.fedilab.android.mastodon.activities.DirectMessageActivity;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Account;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Conversation;
|
||||
|
@ -210,15 +211,26 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
//--- DATE ---
|
||||
holder.binding.lastMessageDate.setText(Helper.dateDiff(context, conversation.last_status.created_at));
|
||||
|
||||
boolean chatMode = sharedpreferences.getBoolean(context.getString(R.string.SET_CHAT_FOR_CONVERSATION), true);
|
||||
holder.binding.statusContent.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
Intent intent;
|
||||
if (chatMode) {
|
||||
intent = new Intent(context, DirectMessageActivity.class);
|
||||
} else {
|
||||
intent = new Intent(context, ContextActivity.class);
|
||||
}
|
||||
intent.putExtra(Helper.ARG_STATUS, conversation.last_status);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
holder.binding.attachmentsListContainer.setOnTouchListener((v, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
Intent intent;
|
||||
if (chatMode) {
|
||||
intent = new Intent(context, DirectMessageActivity.class);
|
||||
} else {
|
||||
intent = new Intent(context, ContextActivity.class);
|
||||
}
|
||||
intent.putExtra(Helper.ARG_STATUS, conversation.last_status);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
holderStatus.bindingNotification.status.mainContainer.setAlpha(.7f);
|
||||
boolean displayMedia = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_MEDIA_NOTIFICATION), true);
|
||||
if (!displayMedia) {
|
||||
holderStatus.bindingNotification.status.attachmentsListContainer.setVisibility(View.GONE);
|
||||
holderStatus.bindingNotification.status.media.mediaContainer.setVisibility(View.GONE);
|
||||
holderStatus.bindingNotification.status.mediaContainer.setVisibility(View.GONE);
|
||||
}
|
||||
String title = "";
|
||||
|
|
|
@ -446,9 +446,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
LinearLayoutCompat.MarginLayoutParams pmc = (LinearLayoutCompat.MarginLayoutParams) holder.binding.mediaContainer.getLayoutParams();
|
||||
pmc.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
||||
holder.binding.mediaContainer.setLayoutParams(pmc);
|
||||
LinearLayoutCompat.MarginLayoutParams pal = (LinearLayoutCompat.MarginLayoutParams) holder.binding.attachmentsListContainer.getLayoutParams();
|
||||
LinearLayoutCompat.MarginLayoutParams pal = (LinearLayoutCompat.MarginLayoutParams) holder.binding.media.mediaContainer.getLayoutParams();
|
||||
pal.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
||||
holder.binding.attachmentsListContainer.setLayoutParams(pal);
|
||||
holder.binding.media.mediaContainer.setLayoutParams(pal);
|
||||
LinearLayoutCompat.MarginLayoutParams pp = (LinearLayoutCompat.MarginLayoutParams) holder.binding.poll.pollContainer.getLayoutParams();
|
||||
pp.setMarginStart((int) Helper.convertDpToPixel(6, context));
|
||||
holder.binding.poll.pollContainer.setLayoutParams(pp);
|
||||
|
@ -1432,7 +1432,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
boolean cardDisplayed = (statusToDeal.card != null && (display_card || statusToDeal.isFocused) && statusToDeal.quote_id == null);
|
||||
if (statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0 && (!hideSingleMediaWithCard || !cardDisplayed || statusToDeal.media_attachments.size() > 1)) {
|
||||
|
||||
holder.binding.attachmentsList.removeAllViews();
|
||||
|
||||
holder.binding.mediaContainer.removeAllViews();
|
||||
if ((loadMediaType.equals("ASK") || (loadMediaType.equals("WIFI") && !TimelineHelper.isOnWIFI(context))) && !statusToDeal.canLoadMedia) {
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
|
@ -1445,10 +1445,73 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
});
|
||||
} else {
|
||||
int mediaPosition = 1;
|
||||
boolean singleMedia = statusToDeal.media_attachments.size() == 1;
|
||||
if (!fullAttachement) {
|
||||
int defaultHeight = (int) Helper.convertDpToPixel(300, context);
|
||||
if (measuredWidth > 0) {
|
||||
defaultHeight = (int) (measuredWidth * 3) / 4;
|
||||
}
|
||||
LinearLayoutCompat.LayoutParams lp = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, defaultHeight);
|
||||
holder.binding.media.mediaContainer.setLayoutParams(lp);
|
||||
if (statusToDeal.media_attachments.size() == 1) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (statusToDeal.media_attachments.size() == 2) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (statusToDeal.media_attachments.size() == 3) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (statusToDeal.media_attachments.size() == 4) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (statusToDeal.media_attachments.size() > 4) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
for (Attachment attachment : statusToDeal.media_attachments) {
|
||||
LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context));
|
||||
|
||||
if (fullAttachement) {
|
||||
|
||||
}
|
||||
LayoutMediaBinding layoutMediaBinding = null;
|
||||
|
||||
|
||||
if ((fullAttachement && (!statusToDeal.sensitive || expand_media))) {
|
||||
layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context));
|
||||
holder.binding.mediaContainer.addView(layoutMediaBinding.getRoot());
|
||||
} else {
|
||||
if (mediaPosition == 1) {
|
||||
layoutMediaBinding = holder.binding.media.media1Container;
|
||||
} else if (mediaPosition == 2 && statusToDeal.media_attachments.size() == 3) {
|
||||
layoutMediaBinding = holder.binding.media.media3Container;
|
||||
} else if (mediaPosition == 2) {
|
||||
layoutMediaBinding = holder.binding.media.media2Container;
|
||||
} else if (mediaPosition == 3 && statusToDeal.media_attachments.size() == 3) {
|
||||
layoutMediaBinding = holder.binding.media.media4Container;
|
||||
} else if (mediaPosition == 3) {
|
||||
layoutMediaBinding = holder.binding.media.media3Container;
|
||||
} else if (mediaPosition == 4) {
|
||||
layoutMediaBinding = holder.binding.media.media4Container;
|
||||
}
|
||||
}
|
||||
if (fullAttachement && (!statusToDeal.sensitive || expand_media)) {
|
||||
|
||||
float ratio = 1.0f;
|
||||
float mediaH = -1.0f;
|
||||
float mediaW = -1.0f;
|
||||
|
@ -1459,30 +1522,29 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
ratio = measuredWidth > 0 ? measuredWidth / mediaW : 1.0f;
|
||||
}
|
||||
}
|
||||
loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, mediaW, mediaH, ratio, statusToDeal, attachment, singleMedia);
|
||||
loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, mediaW, mediaH, ratio, statusToDeal, attachment);
|
||||
|
||||
} else {
|
||||
loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, -1.f, -1.f, -1.f, statusToDeal, attachment, singleMedia);
|
||||
if (layoutMediaBinding != null) {
|
||||
loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, -1.f, -1.f, -1.f, statusToDeal, attachment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mediaPosition++;
|
||||
if ((fullAttachement && (!statusToDeal.sensitive || expand_media)) || singleMedia) {
|
||||
holder.binding.mediaContainer.addView(layoutMediaBinding.getRoot());
|
||||
} else {
|
||||
holder.binding.attachmentsList.addView(layoutMediaBinding.getRoot());
|
||||
}
|
||||
}
|
||||
if ((!fullAttachement || statusToDeal.sensitive) && !singleMedia) {
|
||||
if (!fullAttachement || statusToDeal.sensitive) {
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.mediaContainer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.binding.mediaContainer.setVisibility(View.VISIBLE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.GONE);
|
||||
holder.binding.media.mediaContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
holder.binding.displayMedia.setVisibility(View.GONE);
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.GONE);
|
||||
holder.binding.media.mediaContainer.setVisibility(View.GONE);
|
||||
}
|
||||
holder.binding.statusContent.setMovementMethod(LongClickLinkMovementMethod.getInstance());
|
||||
holder.binding.reblogInfo.setOnClickListener(v -> {
|
||||
|
@ -2262,9 +2324,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
}
|
||||
}
|
||||
|
||||
private static RequestBuilder<Drawable> prepareRequestBuilder(Context context, Attachment attachment,
|
||||
float mediaW, float mediaH,
|
||||
float focusX, float focusY, boolean isSensitive, boolean isArt) {
|
||||
public static RequestBuilder<Drawable> prepareRequestBuilder(Context context, Attachment attachment,
|
||||
float mediaW, float mediaH,
|
||||
float focusX, float focusY, boolean isSensitive, boolean isArt) {
|
||||
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean fullAttachement = sharedpreferences.getBoolean(context.getString(R.string.SET_FULL_PREVIEW), false);
|
||||
|
@ -2309,7 +2371,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
StatusViewHolder holder,
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
|
||||
int mediaPosition, float mediaW, float mediaH, float ratio,
|
||||
Status statusToDeal, Attachment attachment, boolean singleImage) {
|
||||
Status statusToDeal, Attachment attachment) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
|
||||
boolean fullAttachement = sharedpreferences.getBoolean(context.getString(R.string.SET_FULL_PREVIEW), false);
|
||||
|
@ -2317,24 +2379,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
boolean expand_media = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_MEDIA), false);
|
||||
|
||||
LinearLayout.LayoutParams lp;
|
||||
int defaultHeight = (int) Helper.convertDpToPixel(200, context);
|
||||
if (measuredWidth > 0) {
|
||||
defaultHeight = (int) (measuredWidth * 3) / 4;
|
||||
}
|
||||
|
||||
if (fullAttachement && mediaH > 0 && (!statusToDeal.sensitive || expand_media)) {
|
||||
lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
} else {
|
||||
if (singleImage) {
|
||||
lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, defaultHeight);
|
||||
} else {
|
||||
//noinspection SuspiciousNameCombination
|
||||
lp = new LinearLayout.LayoutParams(defaultHeight, defaultHeight);
|
||||
}
|
||||
lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
}
|
||||
|
||||
|
||||
layoutMediaBinding.media.setLayoutParams(lp);
|
||||
|
||||
float focusX = 0.f;
|
||||
|
@ -2343,10 +2396,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
||||
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
||||
}
|
||||
layoutMediaBinding.count.setVisibility(View.VISIBLE);
|
||||
if ((!fullAttachement || statusToDeal.sensitive) && !singleImage) {
|
||||
layoutMediaBinding.count.setText(String.format(Locale.getDefault(), "%d/%d", mediaPosition, statusToDeal.media_attachments.size()));
|
||||
}
|
||||
|
||||
if (attachment.description != null && attachment.description.trim().length() > 0) {
|
||||
layoutMediaBinding.media.setContentDescription(attachment.description.trim());
|
||||
}
|
||||
|
@ -2426,7 +2476,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
});
|
||||
|
||||
if ((!statusToDeal.sensitive || expand_media) && (fullAttachement || singleImage)) {
|
||||
if ((!statusToDeal.sensitive || expand_media) && (fullAttachement)) {
|
||||
layoutMediaBinding.getRoot().setPadding(0, 0, 0, 10);
|
||||
} else {
|
||||
layoutMediaBinding.getRoot().setPadding(0, 0, 10, 0);
|
||||
|
|
|
@ -0,0 +1,501 @@
|
|||
package app.fedilab.android.mastodon.ui.drawer;
|
||||
/* Copyright 2023 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 static app.fedilab.android.mastodon.ui.drawer.StatusAdapter.prepareRequestBuilder;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.LinearLayoutCompat;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.lifecycle.ViewModelStoreOwner;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.databinding.DrawerStatusChatBinding;
|
||||
import app.fedilab.android.databinding.LayoutMediaBinding;
|
||||
import app.fedilab.android.databinding.LayoutPollItemBinding;
|
||||
import app.fedilab.android.mastodon.activities.MediaActivity;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Poll;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
import app.fedilab.android.mastodon.helper.LongClickLinkMovementMethod;
|
||||
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
||||
import app.fedilab.android.mastodon.helper.MediaHelper;
|
||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||
import app.fedilab.android.mastodon.viewmodel.mastodon.StatusesVM;
|
||||
|
||||
public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final List<Status> statusList;
|
||||
private Context context;
|
||||
private RecyclerView mRecyclerView;
|
||||
private static float measuredWidth = -1;
|
||||
public StatusDirectMessageAdapter(List<Status> data) {
|
||||
this.statusList = data;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
|
||||
context = parent.getContext();
|
||||
DrawerStatusChatBinding itemBinding = DrawerStatusChatBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new StatusChatViewHolder(itemBinding);
|
||||
}
|
||||
|
||||
public static void loadAndAddAttachment(Context context, LayoutMediaBinding layoutMediaBinding,
|
||||
StatusChatViewHolder holder,
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
|
||||
int mediaPosition, float mediaW, float mediaH, float ratio,
|
||||
Status status, Attachment attachment) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
|
||||
boolean long_press_media = sharedpreferences.getBoolean(context.getString(R.string.SET_LONG_PRESS_STORE_MEDIA), false);
|
||||
boolean expand_media = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_MEDIA), false);
|
||||
|
||||
LinearLayout.LayoutParams lp;
|
||||
|
||||
lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
|
||||
layoutMediaBinding.media.setLayoutParams(lp);
|
||||
|
||||
float focusX = 0.f;
|
||||
float focusY = 0.f;
|
||||
if (status.media_attachments.get(0).meta != null && status.media_attachments.get(0).meta.focus != null) {
|
||||
focusX = status.media_attachments.get(0).meta.focus.x;
|
||||
focusY = status.media_attachments.get(0).meta.focus.y;
|
||||
}
|
||||
if (attachment.description != null && attachment.description.trim().length() > 0) {
|
||||
layoutMediaBinding.media.setContentDescription(attachment.description.trim());
|
||||
}
|
||||
String finalUrl;
|
||||
if (attachment.url == null) {
|
||||
finalUrl = attachment.remote_url;
|
||||
} else {
|
||||
finalUrl = attachment.url;
|
||||
}
|
||||
layoutMediaBinding.media.setOnLongClickListener(v -> {
|
||||
if (long_press_media) {
|
||||
MediaHelper.manageMove(context, finalUrl, false);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if (attachment.type != null && (attachment.type.equalsIgnoreCase("video") || attachment.type.equalsIgnoreCase("gifv"))) {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playVideo.setVisibility(View.GONE);
|
||||
}
|
||||
if (attachment.type != null && attachment.type.equalsIgnoreCase("audio")) {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.playMusic.setVisibility(View.GONE);
|
||||
}
|
||||
if (attachment.description != null && !attachment.description.isEmpty()) {
|
||||
layoutMediaBinding.viewDescription.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
layoutMediaBinding.viewDescription.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
RequestBuilder<Drawable> requestBuilder = prepareRequestBuilder(context, attachment, mediaW * ratio, mediaH * ratio, focusX, focusY, status.sensitive, false);
|
||||
if (!status.sensitive || expand_media) {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_24);
|
||||
} else {
|
||||
layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_off_24);
|
||||
}
|
||||
requestBuilder.load(attachment.preview_url).into(layoutMediaBinding.media);
|
||||
if (status.sensitive) {
|
||||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, ThemeHelper.getAttColor(context, R.attr.colorError));
|
||||
} else {
|
||||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.white);
|
||||
}
|
||||
|
||||
layoutMediaBinding.media.setOnClickListener(v -> {
|
||||
if (status.sensitive && !expand_media) {
|
||||
status.sensitive = false;
|
||||
int position = holder.getBindingAdapterPosition();
|
||||
adapter.notifyItemChanged(position);
|
||||
|
||||
if (timeout > 0) {
|
||||
new CountDownTimer((timeout * 1000L), 1000) {
|
||||
public void onTick(long millisUntilFinished) {
|
||||
}
|
||||
|
||||
public void onFinish() {
|
||||
status.sensitive = true;
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putInt(Helper.ARG_MEDIA_POSITION, mediaPosition);
|
||||
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(status.media_attachments));
|
||||
mediaIntent.putExtras(b);
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, status.media_attachments.get(0).url);
|
||||
// start the new activity
|
||||
context.startActivity(mediaIntent, options.toBundle());
|
||||
});
|
||||
layoutMediaBinding.viewHide.setOnClickListener(v -> {
|
||||
status.sensitive = !status.sensitive;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
|
||||
mRecyclerView = recyclerView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return statusList.size();
|
||||
}
|
||||
|
||||
public static class StatusChatViewHolder extends RecyclerView.ViewHolder {
|
||||
DrawerStatusChatBinding binding;
|
||||
|
||||
StatusChatViewHolder(DrawerStatusChatBinding itemView) {
|
||||
super(itemView.getRoot());
|
||||
binding = itemView;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||
|
||||
StatusChatViewHolder holder = (StatusChatViewHolder) viewHolder;
|
||||
Status status = statusList.get(position);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
holder.binding.messageContent.setText(
|
||||
status.getSpanContent(context,
|
||||
new WeakReference<>(holder.binding.messageContent),
|
||||
() -> mRecyclerView.post(() -> notifyItemChanged(holder.getBindingAdapterPosition()))),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holder.binding.messageContent.setMovementMethod(LongClickLinkMovementMethod.getInstance());
|
||||
if (measuredWidth <= 0 && status.media_attachments != null && status.media_attachments.size() > 0) {
|
||||
holder.binding.media.mediaContainer.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
holder.binding.media.mediaContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
measuredWidth = holder.binding.media.mediaContainer.getWidth();
|
||||
notifyItemChanged(0, statusList.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
MastodonHelper.loadPPMastodon(holder.binding.userPp, status.account);
|
||||
holder.binding.date.setText(Helper.longDateToString(status.created_at));
|
||||
//Owner account
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
if (status.account.id.equals(MainActivity.currentUserID)) {
|
||||
holder.binding.mainContainer.setBackgroundResource(R.drawable.bubble_right_tail);
|
||||
|
||||
layoutParams.setMargins((int) Helper.convertDpToPixel(50, context), (int) Helper.convertDpToPixel(12, context), 0, 0);
|
||||
holder.binding.date.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
holder.binding.messageContent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
holder.binding.userName.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
} else {
|
||||
holder.binding.mainContainer.setBackgroundResource(R.drawable.bubble_left_tail);
|
||||
layoutParams.setMargins(0, (int) Helper.convertDpToPixel(12, context), (int) Helper.convertDpToPixel(50, context), 0);
|
||||
holder.binding.date.setTextColor(ContextCompat.getColor(context, R.color.black));
|
||||
holder.binding.messageContent.setTextColor(ContextCompat.getColor(context, R.color.black));
|
||||
holder.binding.userName.setTextColor(ContextCompat.getColor(context, R.color.black));
|
||||
}
|
||||
holder.binding.mainContainer.setLayoutParams(layoutParams);
|
||||
|
||||
final float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.1f);
|
||||
if (status.poll != null && status.poll.options != null) {
|
||||
|
||||
holder.binding.poll.pollInfo.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
holder.binding.poll.refresh.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class);
|
||||
if (status.poll.voted || status.poll.expired) {
|
||||
holder.binding.poll.submitVote.setVisibility(View.GONE);
|
||||
holder.binding.poll.rated.setVisibility(View.VISIBLE);
|
||||
holder.binding.poll.multipleChoice.setVisibility(View.GONE);
|
||||
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.GONE);
|
||||
int greaterValue = 0;
|
||||
for (Poll.PollItem pollItem : status.poll.options) {
|
||||
if (pollItem.votes_count > greaterValue)
|
||||
greaterValue = pollItem.votes_count;
|
||||
}
|
||||
holder.binding.poll.rated.removeAllViews();
|
||||
List<Integer> ownvotes = status.poll.own_votes;
|
||||
int j = 0;
|
||||
if (status.poll.voters_count == 0 && status.poll.votes_count > 0) {
|
||||
status.poll.voters_count = status.poll.votes_count;
|
||||
}
|
||||
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
||||
for (Poll.PollItem pollItem : status.poll.options) {
|
||||
@NonNull LayoutPollItemBinding pollItemBinding = LayoutPollItemBinding.inflate(inflater, holder.binding.poll.rated, true);
|
||||
double value = ((double) (pollItem.votes_count * 100) / (double) status.poll.voters_count);
|
||||
pollItemBinding.pollItemPercent.setText(String.format("%s %%", (int) value));
|
||||
pollItemBinding.pollItemText.setText(
|
||||
pollItem.getSpanTitle(context, status,
|
||||
new WeakReference<>(pollItemBinding.pollItemText)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
pollItemBinding.pollItemPercent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
pollItemBinding.pollItemText.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
pollItemBinding.pollItemValue.setProgress((int) value);
|
||||
if (pollItem.votes_count == greaterValue) {
|
||||
pollItemBinding.pollItemPercent.setTypeface(null, Typeface.BOLD);
|
||||
pollItemBinding.pollItemText.setTypeface(null, Typeface.BOLD);
|
||||
}
|
||||
if (ownvotes != null && ownvotes.contains(j)) {
|
||||
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_check_24);
|
||||
assert img != null;
|
||||
img.setColorFilter(ThemeHelper.getAttColor(context, R.attr.colorPrimary), PorterDuff.Mode.SRC_IN);
|
||||
img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (20 * scale + 0.5f));
|
||||
pollItemBinding.pollItemText.setCompoundDrawables(null, null, img, null);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (status.poll.voters_count == 0 && status.poll.votes_count > 0) {
|
||||
status.poll.voters_count = status.poll.votes_count;
|
||||
}
|
||||
holder.binding.poll.rated.setVisibility(View.GONE);
|
||||
holder.binding.poll.submitVote.setVisibility(View.VISIBLE);
|
||||
if (status.poll.multiple) {
|
||||
if ((holder.binding.poll.multipleChoice).getChildCount() > 0)
|
||||
(holder.binding.poll.multipleChoice).removeAllViews();
|
||||
for (Poll.PollItem pollOption : status.poll.options) {
|
||||
CheckBox cb = new CheckBox(context);
|
||||
cb.setText(
|
||||
pollOption.getSpanTitle(context, status,
|
||||
new WeakReference<>(cb)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
holder.binding.poll.multipleChoice.addView(cb);
|
||||
cb.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
}
|
||||
holder.binding.poll.multipleChoice.setVisibility(View.VISIBLE);
|
||||
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.GONE);
|
||||
} else {
|
||||
if ((holder.binding.poll.singleChoiceRadioGroup).getChildCount() > 0)
|
||||
(holder.binding.poll.singleChoiceRadioGroup).removeAllViews();
|
||||
for (Poll.PollItem pollOption : status.poll.options) {
|
||||
RadioButton rb = new RadioButton(context);
|
||||
rb.setText(
|
||||
pollOption.getSpanTitle(context, status,
|
||||
new WeakReference<>(rb)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
rb.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
|
||||
holder.binding.poll.singleChoiceRadioGroup.addView(rb);
|
||||
}
|
||||
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.VISIBLE);
|
||||
holder.binding.poll.multipleChoice.setVisibility(View.GONE);
|
||||
}
|
||||
holder.binding.poll.submitVote.setVisibility(View.VISIBLE);
|
||||
holder.binding.poll.submitVote.setOnClickListener(v -> {
|
||||
int[] choice;
|
||||
if (status.poll.multiple) {
|
||||
ArrayList<Integer> choices = new ArrayList<>();
|
||||
int choicesCount = holder.binding.poll.multipleChoice.getChildCount();
|
||||
for (int i1 = 0; i1 < choicesCount; i1++) {
|
||||
if (holder.binding.poll.multipleChoice.getChildAt(i1) != null && holder.binding.poll.multipleChoice.getChildAt(i1) instanceof CheckBox) {
|
||||
if (((CheckBox) holder.binding.poll.multipleChoice.getChildAt(i1)).isChecked()) {
|
||||
choices.add(i1);
|
||||
}
|
||||
}
|
||||
}
|
||||
choice = new int[choices.size()];
|
||||
Iterator<Integer> iterator = choices.iterator();
|
||||
for (int i1 = 0; i1 < choice.length; i1++) {
|
||||
choice[i1] = iterator.next();
|
||||
}
|
||||
if (choice.length == 0)
|
||||
return;
|
||||
} else {
|
||||
choice = new int[1];
|
||||
choice[0] = -1;
|
||||
int choicesCount = holder.binding.poll.singleChoiceRadioGroup.getChildCount();
|
||||
for (int i1 = 0; i1 < choicesCount; i1++) {
|
||||
if (holder.binding.poll.singleChoiceRadioGroup.getChildAt(i1) != null && holder.binding.poll.singleChoiceRadioGroup.getChildAt(i1) instanceof RadioButton) {
|
||||
if (((RadioButton) holder.binding.poll.singleChoiceRadioGroup.getChildAt(i1)).isChecked()) {
|
||||
choice[0] = i1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice[0] == -1)
|
||||
return;
|
||||
}
|
||||
//Vote on the poll
|
||||
|
||||
statusesVM.votePoll(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.poll.id, choice)
|
||||
.observe((LifecycleOwner) context, poll -> {
|
||||
if (poll != null) {
|
||||
int i = 0;
|
||||
for (Poll.PollItem item : status.poll.options) {
|
||||
if (item.span_title != null) {
|
||||
poll.options.get(i).span_title = item.span_title;
|
||||
} else {
|
||||
poll.options.get(i).span_title = new SpannableString(item.title);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
status.poll = poll;
|
||||
notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
holder.binding.poll.refreshPoll.setOnClickListener(v -> statusesVM.getPoll(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.poll.id)
|
||||
.observe((LifecycleOwner) context, poll -> {
|
||||
if (poll != null) {
|
||||
//Store span elements
|
||||
int i = 0;
|
||||
for (Poll.PollItem item : status.poll.options) {
|
||||
if (item.span_title != null) {
|
||||
poll.options.get(i).span_title = item.span_title;
|
||||
} else {
|
||||
poll.options.get(i).span_title = new SpannableString(item.title);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
status.poll = poll;
|
||||
notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
}
|
||||
}));
|
||||
holder.binding.poll.pollContainer.setVisibility(View.VISIBLE);
|
||||
String pollInfo = context.getResources().getQuantityString(R.plurals.number_of_voters, status.poll.voters_count, status.poll.voters_count);
|
||||
if (status.poll.expired) {
|
||||
pollInfo += " - " + context.getString(R.string.poll_finish_at, MastodonHelper.dateToStringPoll(status.poll.expires_at));
|
||||
} else {
|
||||
pollInfo += " - " + context.getString(R.string.poll_finish_in, MastodonHelper.dateDiffPoll(context, status.poll.expires_at));
|
||||
}
|
||||
holder.binding.poll.pollInfo.setText(pollInfo);
|
||||
} else {
|
||||
holder.binding.poll.pollContainer.setVisibility(View.GONE);
|
||||
}
|
||||
holder.binding.userName.setText(
|
||||
status.account.getSpanDisplayName(context,
|
||||
new WeakReference<>(holder.binding.userName)),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
|
||||
if (status.media_attachments != null && status.media_attachments.size() > 0) {
|
||||
holder.binding.media.mediaContainer.setVisibility(View.VISIBLE);
|
||||
int mediaPosition = 1;
|
||||
|
||||
int defaultHeight = (int) Helper.convertDpToPixel(300, context);
|
||||
if (measuredWidth > 0) {
|
||||
defaultHeight = (int) (measuredWidth * 3) / 4;
|
||||
}
|
||||
LinearLayoutCompat.LayoutParams lp = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, defaultHeight);
|
||||
holder.binding.media.mediaContainer.setLayoutParams(lp);
|
||||
if (status.media_attachments.size() == 1) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (status.media_attachments.size() == 2) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (status.media_attachments.size() == 3) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.GONE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (status.media_attachments.size() == 4) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (status.media_attachments.size() > 4) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media2Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media3Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.media4Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
holder.binding.media.moreMedia.setVisibility(View.VISIBLE);
|
||||
}
|
||||
for (Attachment attachment : status.media_attachments) {
|
||||
LayoutMediaBinding layoutMediaBinding = null;
|
||||
if (mediaPosition == 1) {
|
||||
layoutMediaBinding = holder.binding.media.media1Container;
|
||||
} else if (mediaPosition == 2 && status.media_attachments.size() == 3) {
|
||||
layoutMediaBinding = holder.binding.media.media3Container;
|
||||
} else if (mediaPosition == 2) {
|
||||
layoutMediaBinding = holder.binding.media.media2Container;
|
||||
} else if (mediaPosition == 3 && status.media_attachments.size() == 3) {
|
||||
layoutMediaBinding = holder.binding.media.media4Container;
|
||||
} else if (mediaPosition == 3) {
|
||||
layoutMediaBinding = holder.binding.media.media3Container;
|
||||
} else if (mediaPosition == 4) {
|
||||
layoutMediaBinding = holder.binding.media.media4Container;
|
||||
}
|
||||
if (layoutMediaBinding != null) {
|
||||
loadAndAddAttachment(context, layoutMediaBinding, holder, this, mediaPosition, -1.f, -1.f, -1.f, status, attachment);
|
||||
}
|
||||
|
||||
|
||||
mediaPosition++;
|
||||
}
|
||||
} else {
|
||||
holder.binding.media.mediaContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package app.fedilab.android.mastodon.ui.drawer;
|
||||
/* Copyright 2023 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 android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.DrawerTagEditBinding;
|
||||
import app.fedilab.android.mastodon.client.entities.app.CamelTag;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
public class TagsEditAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final List<String> tags;
|
||||
private final TagsEditAdapter tagsEditAdapter;
|
||||
private Context context;
|
||||
|
||||
public TagsEditAdapter(List<String> tags) {
|
||||
this.tags = tags;
|
||||
tagsEditAdapter = this;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int position) {
|
||||
context = parent.getContext();
|
||||
DrawerTagEditBinding itemBinding = DrawerTagEditBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new TagCaheViewHolder(itemBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||
final String[] tag = {tags.get(viewHolder.getLayoutPosition())};
|
||||
TagCaheViewHolder holder = (TagCaheViewHolder) viewHolder;
|
||||
holder.binding.tagName.setText(String.format("#%s", tag[0]));
|
||||
holder.binding.saveTag.setOnClickListener(v -> {
|
||||
if (holder.binding.tagName.getText() != null && holder.binding.tagName.getText().toString().trim().replaceAll("#", "").length() > 0) {
|
||||
String tagToInsert = holder.binding.tagName.getText().toString().trim().replaceAll("#", "");
|
||||
try {
|
||||
boolean isPresent = new CamelTag(context).tagExists(tagToInsert);
|
||||
if (isPresent)
|
||||
Toasty.warning(context, context.getString(R.string.tags_already_stored), Toast.LENGTH_LONG).show();
|
||||
else {
|
||||
new CamelTag(context).update(tag[0], tagToInsert);
|
||||
Toasty.success(context, context.getString(R.string.tags_renamed), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} catch (DBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
holder.binding.deleteTag.setOnClickListener(v -> {
|
||||
holder.binding.tagName.clearFocus();
|
||||
new CamelTag(context).removeTag(tag[0]);
|
||||
tags.remove(tag[0]);
|
||||
tagsEditAdapter.notifyItemRemoved(viewHolder.getLayoutPosition());
|
||||
Toasty.success(context, context.getString(R.string.tags_deleted), Toast.LENGTH_LONG).show();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tags.size();
|
||||
}
|
||||
|
||||
|
||||
static class TagCaheViewHolder extends RecyclerView.ViewHolder {
|
||||
DrawerTagEditBinding binding;
|
||||
|
||||
public TagCaheViewHolder(@NonNull DrawerTagEditBinding drawerTagEditBinding) {
|
||||
super(drawerTagEditBinding.getRoot());
|
||||
binding = drawerTagEditBinding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -18,11 +18,16 @@ import android.content.SharedPreferences;
|
|||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.MultiSelectListPreference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.client.entities.app.Languages;
|
||||
|
||||
public class FragmentComposeSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
|
@ -40,6 +45,40 @@ public class FragmentComposeSettings extends PreferenceFragmentCompat implements
|
|||
String val = sharedPreferences.getString(getString(R.string.SET_WATERMARK_TEXT) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance, sharedPreferences.getString(getString(R.string.SET_WATERMARK_TEXT), null));
|
||||
SET_WATERMARK_TEXT.setText(val);
|
||||
}
|
||||
|
||||
MultiSelectListPreference SET_SELECTED_LANGUAGE = findPreference(getString(R.string.SET_SELECTED_LANGUAGE));
|
||||
if (SET_SELECTED_LANGUAGE != null) {
|
||||
|
||||
Set<String> storedLanguages = sharedPreferences.getStringSet(getString(R.string.SET_SELECTED_LANGUAGE), null);
|
||||
|
||||
String[] selectedValue = new String[0];
|
||||
if (storedLanguages != null && storedLanguages.size() > 0) {
|
||||
if (storedLanguages.size() == 1 && storedLanguages.toArray()[0] == null) {
|
||||
sharedPreferences.edit().remove(getString(R.string.SET_SELECTED_LANGUAGE)).commit();
|
||||
} else {
|
||||
selectedValue = storedLanguages.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
List<Languages.Language> languages = Languages.get(requireActivity());
|
||||
if (languages != null) {
|
||||
String[] codesArr = new String[languages.size()];
|
||||
String[] languagesArr = new String[languages.size()];
|
||||
int i = 0;
|
||||
for (Languages.Language language : languages) {
|
||||
codesArr[i] = language.code;
|
||||
languagesArr[i] = language.language;
|
||||
i++;
|
||||
}
|
||||
SET_SELECTED_LANGUAGE.setEntries(languagesArr);
|
||||
SET_SELECTED_LANGUAGE.setEntryValues(codesArr);
|
||||
if (selectedValue.length > 0) {
|
||||
SET_SELECTED_LANGUAGE.setDefaultValue(selectedValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,7 +47,8 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
|||
ListPreference SET_TRANSLATOR_VERSION = findPreference(getString(R.string.SET_TRANSLATOR_VERSION));
|
||||
|
||||
EditTextPreference SET_TRANSLATOR_API_KEY = findPreference(getString(R.string.SET_TRANSLATOR_API_KEY));
|
||||
if (SET_TRANSLATOR != null && SET_TRANSLATOR.getValue().equals("FEDILAB")) {
|
||||
EditTextPreference SET_TRANSLATOR_DOMAIN = findPreference(getString(R.string.SET_TRANSLATOR_DOMAIN));
|
||||
if (SET_TRANSLATOR != null && !SET_TRANSLATOR.getValue().equals("DEEPL")) {
|
||||
if (SET_TRANSLATOR_API_KEY != null) {
|
||||
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_API_KEY");
|
||||
}
|
||||
|
@ -55,6 +56,11 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
|||
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_VERSION");
|
||||
}
|
||||
}
|
||||
if (SET_TRANSLATOR != null && !SET_TRANSLATOR.getValue().equals("LINGVA")) {
|
||||
if (SET_TRANSLATOR_DOMAIN != null) {
|
||||
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_DOMAIN");
|
||||
}
|
||||
}
|
||||
SwitchPreferenceCompat SET_DISPLAY_BOOKMARK = findPreference(getString(R.string.SET_DISPLAY_BOOKMARK));
|
||||
if (SET_DISPLAY_BOOKMARK != null) {
|
||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_BOOKMARK) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
||||
|
|
|
@ -0,0 +1,942 @@
|
|||
package app.fedilab.android.mastodon.ui.fragment.timeline;
|
||||
/* Copyright 2023 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 static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||
import static app.fedilab.android.BaseMainActivity.currentInstance;
|
||||
import static app.fedilab.android.BaseMainActivity.currentToken;
|
||||
import static app.fedilab.android.BaseMainActivity.currentUserID;
|
||||
import static app.fedilab.android.BaseMainActivity.instanceInfo;
|
||||
import static app.fedilab.android.mastodon.activities.ComposeActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputFilter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatEditText;
|
||||
import androidx.appcompat.widget.LinearLayoutCompat;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.work.Data;
|
||||
import androidx.work.OneTimeWorkRequest;
|
||||
import androidx.work.OutOfQuotaPolicy;
|
||||
import androidx.work.WorkManager;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.databinding.ComposeAttachmentItemBinding;
|
||||
import app.fedilab.android.databinding.ComposePollBinding;
|
||||
import app.fedilab.android.databinding.ComposePollItemBinding;
|
||||
import app.fedilab.android.databinding.FragmentDirectMessageBinding;
|
||||
import app.fedilab.android.databinding.PopupMediaDescriptionBinding;
|
||||
import app.fedilab.android.mastodon.activities.ComposeActivity;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Attachment;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Context;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Mention;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Poll;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||
import app.fedilab.android.mastodon.imageeditor.EditImageActivity;
|
||||
import app.fedilab.android.mastodon.jobs.ComposeWorker;
|
||||
import app.fedilab.android.mastodon.services.ThreadMessageService;
|
||||
import app.fedilab.android.mastodon.ui.drawer.StatusDirectMessageAdapter;
|
||||
import app.fedilab.android.mastodon.viewmodel.mastodon.StatusesVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class FragmentMastodonDirectMessage extends Fragment {
|
||||
|
||||
|
||||
public FirstMessage firstMessage;
|
||||
private FragmentDirectMessageBinding binding;
|
||||
private StatusesVM statusesVM;
|
||||
private List<Status> statuses;
|
||||
private StatusDirectMessageAdapter statusDirectMessageAdapter;
|
||||
//Handle actions that can be done in other fragments
|
||||
private Status focusedStatus;
|
||||
private Status firstStatus;
|
||||
private boolean pullToRefresh;
|
||||
private String user_token, user_instance;
|
||||
|
||||
private final BroadcastReceiver broadcast_data = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(android.content.Context context, Intent intent) {
|
||||
Bundle b = intent.getExtras();
|
||||
if (b != null) {
|
||||
|
||||
if (b.getBoolean(Helper.RECEIVE_NEW_MESSAGE, false)) {
|
||||
Status statusReceived = (Status) b.getSerializable(Helper.RECEIVE_STATUS_ACTION);
|
||||
if (statusReceived != null) {
|
||||
statuses.add(statusReceived);
|
||||
statusDirectMessageAdapter.notifyItemInserted(statuses.size() - 1);
|
||||
initiliazeStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private Status statusCompose;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
focusedStatus = null;
|
||||
pullToRefresh = false;
|
||||
if (getArguments() != null) {
|
||||
focusedStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS);
|
||||
}
|
||||
user_instance = MainActivity.currentInstance;
|
||||
user_token = MainActivity.currentToken;
|
||||
|
||||
if (focusedStatus == null) {
|
||||
getChildFragmentManager().beginTransaction().remove(this).commit();
|
||||
}
|
||||
binding = FragmentDirectMessageBinding.inflate(inflater, container, false);
|
||||
statusesVM = new ViewModelProvider(FragmentMastodonDirectMessage.this).get(StatusesVM.class);
|
||||
binding.recyclerView.setNestedScrollingEnabled(true);
|
||||
this.statuses = new ArrayList<>();
|
||||
this.statuses.add(focusedStatus);
|
||||
statusDirectMessageAdapter = new StatusDirectMessageAdapter(this.statuses);
|
||||
binding.swipeContainer.setRefreshing(false);
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(requireActivity());
|
||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||
binding.recyclerView.setAdapter(statusDirectMessageAdapter);
|
||||
binding.swipeContainer.setOnRefreshListener(() -> {
|
||||
if (this.statuses.size() > 0) {
|
||||
binding.swipeContainer.setRefreshing(true);
|
||||
pullToRefresh = true;
|
||||
statusesVM.getContext(user_instance, user_token, focusedStatus.id)
|
||||
.observe(getViewLifecycleOwner(), this::initializeContextView);
|
||||
}
|
||||
});
|
||||
if (focusedStatus != null) {
|
||||
statusesVM.getContext(user_instance, user_token, focusedStatus.id)
|
||||
.observe(getViewLifecycleOwner(), this::initializeContextView);
|
||||
}
|
||||
binding.buttonCloseAttachmentPanel.setOnClickListener(v -> binding.attachmentChoicesPanel.setVisibility(View.GONE));
|
||||
statusCompose = new Status();
|
||||
binding.buttonAttach.setOnClickListener(v -> {
|
||||
|
||||
if (instanceInfo.configuration.media_attachments.supported_mime_types != null) {
|
||||
if (instanceInfo.getMimeTypeAudio().size() == 0) {
|
||||
binding.buttonAttachAudio.setEnabled(false);
|
||||
}
|
||||
if (instanceInfo.getMimeTypeImage().size() == 0) {
|
||||
binding.buttonAttachImage.setEnabled(false);
|
||||
}
|
||||
if (instanceInfo.getMimeTypeVideo().size() == 0) {
|
||||
binding.buttonAttachVideo.setEnabled(false);
|
||||
}
|
||||
if (instanceInfo.getMimeTypeOther().size() == 0) {
|
||||
binding.buttonAttachManual.setEnabled(false);
|
||||
}
|
||||
}
|
||||
binding.attachmentChoicesPanel.setVisibility(View.VISIBLE);
|
||||
binding.buttonAttach.setChecked(false);
|
||||
});
|
||||
binding.buttonPoll.setOnClickListener(v -> displayPollPopup());
|
||||
binding.buttonAttachAudio.setOnClickListener(v -> {
|
||||
binding.attachmentChoicesPanel.setVisibility(View.GONE);
|
||||
pickupMedia(ComposeActivity.mediaType.AUDIO);
|
||||
});
|
||||
binding.buttonAttachImage.setOnClickListener(v -> {
|
||||
binding.attachmentChoicesPanel.setVisibility(View.GONE);
|
||||
pickupMedia(ComposeActivity.mediaType.PHOTO);
|
||||
});
|
||||
binding.buttonAttachVideo.setOnClickListener(v -> {
|
||||
binding.attachmentChoicesPanel.setVisibility(View.GONE);
|
||||
pickupMedia(ComposeActivity.mediaType.VIDEO);
|
||||
});
|
||||
binding.buttonAttachManual.setOnClickListener(v -> {
|
||||
binding.attachmentChoicesPanel.setVisibility(View.GONE);
|
||||
pickupMedia(ComposeActivity.mediaType.ALL);
|
||||
});
|
||||
|
||||
binding.sendButton.setOnClickListener(v -> {
|
||||
statusCompose.submitted = true;
|
||||
statusCompose.text = binding.text.getText().toString();
|
||||
onSubmit(prepareDraft(statusCompose, MainActivity.currentInstance, MainActivity.currentUserID));
|
||||
});
|
||||
LocalBroadcastManager.getInstance(requireActivity()).registerReceiver(broadcast_data, new IntentFilter(Helper.BROADCAST_DATA));
|
||||
|
||||
binding.text.setKeyBoardInputCallbackListener((inputContentInfo, flags, opts) -> {
|
||||
if (inputContentInfo != null) {
|
||||
Uri uri = inputContentInfo.getContentUri();
|
||||
List<Uri> uris = new ArrayList<>();
|
||||
uris.add(uri);
|
||||
addAttachment(uris);
|
||||
}
|
||||
});
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
private void onSubmit(StatusDraft statusDraft) {
|
||||
new Thread(() -> {
|
||||
if (statusDraft.instance == null) {
|
||||
statusDraft.instance = currentInstance;
|
||||
}
|
||||
if (statusDraft.user_id == null) {
|
||||
statusDraft.user_id = currentUserID;
|
||||
}
|
||||
|
||||
if (!canBeSent(statusDraft)) {
|
||||
return;
|
||||
}
|
||||
if (statusDraft.id > 0) {
|
||||
try {
|
||||
new StatusDraft(requireActivity()).updateStatusDraft(statusDraft);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
statusDraft.id = new StatusDraft(requireActivity()).insertStatusDraft(statusDraft);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
int mediaCount = 0;
|
||||
for (Status status : statusDraft.statusDraftList) {
|
||||
mediaCount += status.media_attachments != null ? status.media_attachments.size() : 0;
|
||||
}
|
||||
if (mediaCount > 0) {
|
||||
Data inputData = new Data.Builder()
|
||||
.putString(Helper.ARG_STATUS_DRAFT_ID, String.valueOf(statusDraft.id))
|
||||
.putString(Helper.ARG_INSTANCE, currentInstance)
|
||||
.putString(Helper.ARG_TOKEN, currentToken)
|
||||
.putString(Helper.ARG_USER_ID, currentUserID)
|
||||
.build();
|
||||
OneTimeWorkRequest request = new OneTimeWorkRequest.Builder(ComposeWorker.class)
|
||||
.setInputData(inputData)
|
||||
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
|
||||
.build();
|
||||
WorkManager.getInstance(requireActivity()).enqueue(request);
|
||||
|
||||
} else {
|
||||
new ThreadMessageService(requireActivity(), currentInstance, currentUserID, currentToken, statusDraft, null, null);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
LocalBroadcastManager.getInstance(requireActivity()).unregisterReceiver(broadcast_data);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
|
||||
private boolean canBeSent(StatusDraft statusDraft) {
|
||||
if (statusDraft == null) {
|
||||
return false;
|
||||
}
|
||||
List<Status> statuses = statusDraft.statusDraftList;
|
||||
if (statuses == null || statuses.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
Status statusCheck = statuses.get(0);
|
||||
if (statusCheck == null) {
|
||||
return false;
|
||||
}
|
||||
return (statusCheck.text != null && statusCheck.text.trim().length() != 0)
|
||||
|| (statusCheck.media_attachments != null && statusCheck.media_attachments.size() != 0)
|
||||
|| statusCheck.poll != null
|
||||
|| (statusCheck.spoiler_text != null && statusCheck.spoiler_text.trim().length() != 0);
|
||||
}
|
||||
|
||||
public StatusDraft prepareDraft(Status status, String instance, String user_id) {
|
||||
//Collect all statusCompose
|
||||
List<Status> statusDrafts = new ArrayList<>();
|
||||
statusDrafts.add(status);
|
||||
StatusDraft statusDraftDB = new StatusDraft();
|
||||
statusDraftDB.statusReplyList = new ArrayList<>();
|
||||
statusDraftDB.statusReplyList.addAll(statuses);
|
||||
statusDraftDB.statusDraftList = new ArrayList<>();
|
||||
statusDraftDB.statusDraftList.addAll(statusDrafts);
|
||||
statusDraftDB.instance = instance;
|
||||
statusDraftDB.user_id = user_id;
|
||||
return statusDraftDB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the popup to attach a poll to message
|
||||
*/
|
||||
private void displayPollPopup() {
|
||||
AlertDialog.Builder alertPoll = new MaterialAlertDialogBuilder(requireActivity());
|
||||
alertPoll.setTitle(R.string.create_poll);
|
||||
ComposePollBinding composePollBinding = ComposePollBinding.inflate(LayoutInflater.from(requireActivity()), new LinearLayout(requireActivity()), false);
|
||||
alertPoll.setView(composePollBinding.getRoot());
|
||||
int max_entry = 4;
|
||||
int max_length = 25;
|
||||
final int[] pollCountItem = {2};
|
||||
|
||||
if (instanceInfo != null && instanceInfo.configuration != null && instanceInfo.configuration.pollsConf != null) {
|
||||
max_entry = instanceInfo.configuration.pollsConf.max_options;
|
||||
max_length = instanceInfo.configuration.pollsConf.max_option_chars;
|
||||
} else if (instanceInfo != null && instanceInfo.poll_limits != null) {
|
||||
max_entry = instanceInfo.poll_limits.max_options;
|
||||
max_length = instanceInfo.poll_limits.max_option_chars;
|
||||
}
|
||||
InputFilter[] fArray = new InputFilter[1];
|
||||
fArray[0] = new InputFilter.LengthFilter(max_length);
|
||||
composePollBinding.option1.text.setFilters(fArray);
|
||||
composePollBinding.option1.textLayout.setHint(getString(R.string.poll_choice_s, 1));
|
||||
composePollBinding.option2.text.setFilters(fArray);
|
||||
composePollBinding.option2.textLayout.setHint(getString(R.string.poll_choice_s, 2));
|
||||
composePollBinding.option1.buttonRemove.setVisibility(View.GONE);
|
||||
composePollBinding.option2.buttonRemove.setVisibility(View.GONE);
|
||||
int finalMax_entry = max_entry;
|
||||
composePollBinding.buttonAddOption.setOnClickListener(v -> {
|
||||
if (pollCountItem[0] < finalMax_entry) {
|
||||
ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(composePollBinding.optionsList.getContext()), composePollBinding.optionsList, false);
|
||||
if (composePollBinding.pollType.getCheckedButtonId() == R.id.poll_type_multiple)
|
||||
composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple);
|
||||
composePollItemBinding.text.setFilters(fArray);
|
||||
composePollItemBinding.textLayout.setHint(getString(R.string.poll_choice_s, (pollCountItem[0] + 1)));
|
||||
LinearLayoutCompat viewItem = composePollItemBinding.getRoot();
|
||||
composePollBinding.optionsList.addView(composePollItemBinding.getRoot());
|
||||
composePollItemBinding.buttonRemove.setOnClickListener(view -> {
|
||||
composePollBinding.optionsList.removeView(viewItem);
|
||||
pollCountItem[0]--;
|
||||
if (pollCountItem[0] >= finalMax_entry) {
|
||||
composePollBinding.buttonAddOption.setVisibility(View.GONE);
|
||||
} else {
|
||||
composePollBinding.buttonAddOption.setVisibility(View.VISIBLE);
|
||||
}
|
||||
int childCount = composePollBinding.optionsList.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
AppCompatEditText title = (composePollBinding.optionsList.getChildAt(i)).findViewById(R.id.text);
|
||||
title.setHint(getString(R.string.poll_choice_s, i + 1));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
pollCountItem[0]++;
|
||||
if (pollCountItem[0] >= finalMax_entry) {
|
||||
composePollBinding.buttonAddOption.setVisibility(View.GONE);
|
||||
} else {
|
||||
composePollBinding.buttonAddOption.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
ArrayAdapter<CharSequence> pollduration = ArrayAdapter.createFromResource(requireActivity(),
|
||||
R.array.poll_duration, android.R.layout.simple_spinner_dropdown_item);
|
||||
composePollBinding.pollDuration.setAdapter(pollduration);
|
||||
composePollBinding.pollDuration.setSelection(4);
|
||||
if (statusCompose != null && statusCompose.poll != null && statusCompose.poll.options != null) {
|
||||
int i = 1;
|
||||
for (Poll.PollItem pollItem : statusCompose.poll.options) {
|
||||
if (i == 1) {
|
||||
if (statusCompose.poll.multiple)
|
||||
composePollBinding.option1.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple);
|
||||
if (pollItem.title != null)
|
||||
composePollBinding.option1.text.setText(pollItem.title);
|
||||
} else if (i == 2) {
|
||||
if (statusCompose.poll.multiple)
|
||||
composePollBinding.option2.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple);
|
||||
if (pollItem.title != null)
|
||||
composePollBinding.option2.text.setText(pollItem.title);
|
||||
} else {
|
||||
|
||||
ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(requireActivity()), new LinearLayout(requireActivity()), false);
|
||||
if (composePollBinding.pollType.getCheckedButtonId() == R.id.poll_type_multiple)
|
||||
composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple);
|
||||
else
|
||||
composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_single);
|
||||
|
||||
composePollItemBinding.text.setFilters(fArray);
|
||||
composePollItemBinding.textLayout.setHint(getString(R.string.poll_choice_s, (pollCountItem[0] + 1)));
|
||||
composePollItemBinding.text.setText(pollItem.title);
|
||||
composePollBinding.optionsList.addView(composePollItemBinding.getRoot());
|
||||
composePollItemBinding.buttonRemove.setOnClickListener(view -> {
|
||||
composePollBinding.optionsList.removeView(view);
|
||||
pollCountItem[0]--;
|
||||
});
|
||||
pollCountItem[0]++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (statusCompose.poll.options.size() >= max_entry) {
|
||||
composePollBinding.buttonAddOption.setVisibility(View.GONE);
|
||||
}
|
||||
switch (statusCompose.poll.expire_in) {
|
||||
case 300:
|
||||
composePollBinding.pollDuration.setSelection(0);
|
||||
break;
|
||||
case 1800:
|
||||
composePollBinding.pollDuration.setSelection(1);
|
||||
break;
|
||||
case 3600:
|
||||
composePollBinding.pollDuration.setSelection(2);
|
||||
break;
|
||||
case 21600:
|
||||
composePollBinding.pollDuration.setSelection(3);
|
||||
break;
|
||||
case 86400:
|
||||
composePollBinding.pollDuration.setSelection(4);
|
||||
break;
|
||||
case 259200:
|
||||
composePollBinding.pollDuration.setSelection(5);
|
||||
break;
|
||||
case 604800:
|
||||
composePollBinding.pollDuration.setSelection(6);
|
||||
break;
|
||||
}
|
||||
if (statusCompose.poll.multiple)
|
||||
composePollBinding.pollType.check(R.id.poll_type_multiple);
|
||||
else
|
||||
composePollBinding.pollType.check(R.id.poll_type_single);
|
||||
|
||||
|
||||
}
|
||||
alertPoll.setNegativeButton(R.string.delete, (dialog, whichButton) -> {
|
||||
if (statusCompose != null && statusCompose.poll != null) statusCompose.poll = null;
|
||||
buttonState();
|
||||
dialog.dismiss();
|
||||
});
|
||||
alertPoll.setPositiveButton(R.string.save, null);
|
||||
final AlertDialog alertPollDiaslog = alertPoll.create();
|
||||
alertPollDiaslog.setOnShowListener(dialog -> {
|
||||
composePollBinding.pollType.addOnButtonCheckedListener((group, checkedId, isChecked) -> {
|
||||
if (isChecked) {
|
||||
if (checkedId == R.id.poll_type_single) {
|
||||
if (statusCompose != null && statusCompose.poll != null)
|
||||
statusCompose.poll.multiple = false;
|
||||
for (int i = 0; i < composePollBinding.optionsList.getChildCount(); i++) {
|
||||
ComposePollItemBinding child = ComposePollItemBinding.bind(composePollBinding.optionsList.getChildAt(i));
|
||||
child.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_single);
|
||||
}
|
||||
} else if (checkedId == R.id.poll_type_multiple) {
|
||||
if (statusCompose != null && statusCompose.poll != null)
|
||||
statusCompose.poll.multiple = true;
|
||||
for (int i = 0; i < composePollBinding.optionsList.getChildCount(); i++) {
|
||||
ComposePollItemBinding child = ComposePollItemBinding.bind(composePollBinding.optionsList.getChildAt(i));
|
||||
child.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Button b = alertPollDiaslog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
b.setOnClickListener(view1 -> {
|
||||
int poll_duration_pos = composePollBinding.pollDuration.getSelectedItemPosition();
|
||||
|
||||
int selected_poll_type_id = composePollBinding.pollType.getCheckedButtonId();
|
||||
String choice1 = composePollBinding.option1.text.getText().toString().trim();
|
||||
String choice2 = composePollBinding.option2.text.getText().toString().trim();
|
||||
|
||||
if (choice1.isEmpty() && choice2.isEmpty()) {
|
||||
Toasty.error(requireActivity(), getString(R.string.poll_invalid_choices), Toasty.LENGTH_SHORT).show();
|
||||
} else if (statusCompose != null) {
|
||||
statusCompose.poll = new Poll();
|
||||
statusCompose.poll.multiple = selected_poll_type_id == R.id.poll_type_multiple;
|
||||
int expire;
|
||||
switch (poll_duration_pos) {
|
||||
case 0:
|
||||
expire = 300;
|
||||
break;
|
||||
case 1:
|
||||
expire = 1800;
|
||||
break;
|
||||
case 2:
|
||||
expire = 3600;
|
||||
break;
|
||||
case 3:
|
||||
expire = 21600;
|
||||
break;
|
||||
case 4:
|
||||
expire = 86400;
|
||||
break;
|
||||
case 5:
|
||||
expire = 259200;
|
||||
break;
|
||||
case 6:
|
||||
expire = 604800;
|
||||
break;
|
||||
default:
|
||||
expire = 864000;
|
||||
}
|
||||
statusCompose.poll.expire_in = expire;
|
||||
List<Poll.PollItem> pollItems = new ArrayList<>();
|
||||
int childCount = composePollBinding.optionsList.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
Poll.PollItem pollItem = new Poll.PollItem();
|
||||
AppCompatEditText title = (composePollBinding.optionsList.getChildAt(i)).findViewById(R.id.text);
|
||||
pollItem.title = title.getText().toString();
|
||||
pollItems.add(pollItem);
|
||||
}
|
||||
List<String> options = new ArrayList<>();
|
||||
boolean doubleTitle = false;
|
||||
for (Poll.PollItem po : pollItems) {
|
||||
if (!options.contains(po.title.trim())) {
|
||||
options.add(po.title.trim());
|
||||
} else {
|
||||
doubleTitle = true;
|
||||
}
|
||||
}
|
||||
if (!doubleTitle) {
|
||||
statusCompose.poll.options = pollItems;
|
||||
dialog.dismiss();
|
||||
} else {
|
||||
Toasty.error(requireActivity(), getString(R.string.poll_duplicated_entry), Toasty.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
binding.buttonPoll.setVisibility(View.VISIBLE);
|
||||
buttonState();
|
||||
});
|
||||
});
|
||||
|
||||
alertPollDiaslog.show();
|
||||
}
|
||||
|
||||
|
||||
private void initiliazeStatus() {
|
||||
statusCompose = new Status();
|
||||
binding.text.setText("");
|
||||
binding.attachmentsListContainer.removeAllViews();
|
||||
if (statuses != null && statuses.size() > 0) {
|
||||
binding.recyclerView.scrollToPosition(statuses.size() - 1);
|
||||
Status lastStatus = statuses.get(statuses.size() - 1);
|
||||
statusCompose.in_reply_to_id = lastStatus.id;
|
||||
statusCompose.visibility = "direct";
|
||||
statusCompose.mentions = new ArrayList<>();
|
||||
if (lastStatus.account.acct != null && currentAccount.mastodon_account != null && !lastStatus.account.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) {
|
||||
Mention mention = new Mention();
|
||||
mention.acct = "@" + lastStatus.account.acct;
|
||||
mention.url = lastStatus.account.url;
|
||||
mention.username = lastStatus.account.username;
|
||||
statusCompose.mentions.add(mention);
|
||||
}
|
||||
//There are other mentions to
|
||||
if (lastStatus.mentions != null && lastStatus.mentions.size() > 0) {
|
||||
for (Mention mentionTmp : lastStatus.mentions) {
|
||||
if (currentAccount.mastodon_account != null && !mentionTmp.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) {
|
||||
statusCompose.mentions.add(mentionTmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
manageMentions(statusCompose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage mentions displayed when replying to a message
|
||||
*
|
||||
* @param statusCompose {@link Status} - Status that user is replying
|
||||
*/
|
||||
private void manageMentions(Status statusCompose) {
|
||||
|
||||
if (statusCompose.mentions != null && (statusCompose.text == null || statusCompose.text.length() == 0) && statusCompose.mentions.size() > 0) {
|
||||
//Retrieves mentioned accounts + OP and adds them at the beginin of the toot
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
Mention inReplyToUser;
|
||||
inReplyToUser = statusCompose.mentions.get(0);
|
||||
if (statusCompose.text == null) {
|
||||
statusCompose.text = "";
|
||||
}
|
||||
//Put other accounts mentioned at the bottom
|
||||
boolean capitalize = sharedpreferences.getBoolean(getString(R.string.SET_CAPITALIZE), true);
|
||||
boolean mentionsAtTop = sharedpreferences.getBoolean(getString(R.string.SET_MENTIONS_AT_TOP), false);
|
||||
|
||||
if (inReplyToUser != null) {
|
||||
if (capitalize && !mentionsAtTop) {
|
||||
statusCompose.text = inReplyToUser.acct.startsWith("@") ? inReplyToUser.acct + "\n" : "@" + inReplyToUser.acct + "\n";
|
||||
} else {
|
||||
statusCompose.text = inReplyToUser.acct.startsWith("@") ? inReplyToUser.acct + " " : "@" + inReplyToUser.acct + " ";
|
||||
}
|
||||
}
|
||||
binding.text.setText(statusCompose.text);
|
||||
if (statusCompose.mentions.size() > 1) {
|
||||
if (!mentionsAtTop) {
|
||||
statusCompose.text += "\n";
|
||||
}
|
||||
for (int i = 1; i < statusCompose.mentions.size(); i++) {
|
||||
String tootTemp = String.format("@%s ", statusCompose.mentions.get(i).acct);
|
||||
statusCompose.text = String.format("%s ", (statusCompose.text + tootTemp.trim()));
|
||||
}
|
||||
}
|
||||
binding.text.setText(statusCompose.text);
|
||||
binding.text.requestFocus();
|
||||
binding.text.post(() -> {
|
||||
binding.text.setSelection(statusCompose.text.length()); //Put cursor at the end
|
||||
});
|
||||
} else {
|
||||
binding.text.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage the actions when picking up a media
|
||||
*
|
||||
* @param type - type of media in the list of {@link ComposeActivity.mediaType}
|
||||
*/
|
||||
private void pickupMedia(ComposeActivity.mediaType type) {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
if (ContextCompat.checkSelfPermission(requireActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(requireActivity(),
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Intent intent;
|
||||
intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||
String[] mimetypes = new String[0];
|
||||
if (type == ComposeActivity.mediaType.PHOTO) {
|
||||
if (instanceInfo != null && instanceInfo.getMimeTypeImage() != null && instanceInfo.getMimeTypeImage().size() > 0) {
|
||||
mimetypes = instanceInfo.getMimeTypeImage().toArray(new String[0]);
|
||||
} else {
|
||||
mimetypes = new String[]{"image/*"};
|
||||
}
|
||||
} else if (type == ComposeActivity.mediaType.VIDEO) {
|
||||
if (instanceInfo != null && instanceInfo.getMimeTypeVideo() != null && instanceInfo.getMimeTypeVideo().size() > 0) {
|
||||
mimetypes = instanceInfo.getMimeTypeVideo().toArray(new String[0]);
|
||||
} else {
|
||||
mimetypes = new String[]{"video/*"};
|
||||
}
|
||||
} else if (type == ComposeActivity.mediaType.AUDIO) {
|
||||
if (instanceInfo != null && instanceInfo.getMimeTypeAudio() != null && instanceInfo.getMimeTypeAudio().size() > 0) {
|
||||
mimetypes = instanceInfo.getMimeTypeAudio().toArray(new String[0]);
|
||||
} else {
|
||||
mimetypes = new String[]{"audio/mpeg", "audio/opus", "audio/flac", "audio/wav", "audio/ogg"};
|
||||
}
|
||||
} else if (type == ComposeActivity.mediaType.ALL) {
|
||||
if (instanceInfo != null && instanceInfo.getMimeTypeOther() != null && instanceInfo.getMimeTypeOther().size() > 0) {
|
||||
mimetypes = instanceInfo.getMimeTypeOther().toArray(new String[0]);
|
||||
} else {
|
||||
mimetypes = new String[]{"*/*"};
|
||||
}
|
||||
}
|
||||
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
|
||||
requireActivity().startActivityForResult(intent, (ComposeActivity.PICK_MEDIA));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an attachment from ComposeActivity
|
||||
*
|
||||
* @param uris List<Uri> - uris of the media
|
||||
*/
|
||||
public void addAttachment(List<Uri> uris) {
|
||||
Helper.createAttachmentFromUri(requireActivity(), uris, attachments -> {
|
||||
if (statusCompose.media_attachments == null) {
|
||||
statusCompose.media_attachments = new ArrayList<>();
|
||||
}
|
||||
statusCompose.media_attachments.addAll(attachments);
|
||||
if (statusCompose.media_attachments.size() > 0) {
|
||||
displayAttachments(statusCompose.media_attachments.size() - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display attachment for a holder
|
||||
*/
|
||||
private void displayAttachments(int scrollToMediaPosition) {
|
||||
if (statusCompose != null && statusCompose.media_attachments != null) {
|
||||
binding.attachmentsList.removeAllViews();
|
||||
List<Attachment> attachmentList = statusCompose.media_attachments;
|
||||
if (attachmentList != null && attachmentList.size() > 0) {
|
||||
int mediaPosition = 0;
|
||||
for (Attachment attachment : attachmentList) {
|
||||
ComposeAttachmentItemBinding composeAttachmentItemBinding = ComposeAttachmentItemBinding.inflate(LayoutInflater.from(requireActivity()), binding.attachmentsList, false);
|
||||
composeAttachmentItemBinding.buttonPlay.setVisibility(View.GONE);
|
||||
/* if (editMessageId != null && attachment.url != null) {
|
||||
composeAttachmentItemBinding.editPreview.setVisibility(View.GONE);
|
||||
composeAttachmentItemBinding.buttonDescription.setVisibility(View.INVISIBLE);
|
||||
composeAttachmentItemBinding.buttonOrderDown.setVisibility(View.INVISIBLE);
|
||||
composeAttachmentItemBinding.buttonOrderUp.setVisibility(View.INVISIBLE);
|
||||
}*/
|
||||
String attachmentPath = attachment.local_path != null && !attachment.local_path.trim().isEmpty() ? attachment.local_path : attachment.preview_url;
|
||||
if (attachment.type != null || attachment.mimeType != null) {
|
||||
if ((attachment.type != null && attachment.type.toLowerCase().startsWith("image")) || (attachment.mimeType != null && attachment.mimeType.toLowerCase().startsWith("image"))) {
|
||||
Glide.with(composeAttachmentItemBinding.preview.getContext())
|
||||
.load(attachmentPath)
|
||||
//.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.into(composeAttachmentItemBinding.preview);
|
||||
} else if ((attachment.type != null && attachment.type.toLowerCase().startsWith("video")) || (attachment.mimeType != null && attachment.mimeType.toLowerCase().startsWith("video"))) {
|
||||
composeAttachmentItemBinding.buttonPlay.setVisibility(View.VISIBLE);
|
||||
long interval = 2000;
|
||||
RequestOptions options = new RequestOptions().frame(interval);
|
||||
Glide.with(composeAttachmentItemBinding.preview.getContext()).asBitmap()
|
||||
.load(attachmentPath)
|
||||
.apply(options)
|
||||
.into(composeAttachmentItemBinding.preview);
|
||||
} else if ((attachment.type != null && attachment.type.toLowerCase().startsWith("audio")) || (attachment.mimeType != null && attachment.mimeType.toLowerCase().startsWith("audio"))) {
|
||||
Glide.with(composeAttachmentItemBinding.preview.getContext())
|
||||
.load(R.drawable.ic_baseline_audio_file_24)
|
||||
.into(composeAttachmentItemBinding.preview);
|
||||
} else {
|
||||
Glide.with(composeAttachmentItemBinding.preview.getContext())
|
||||
.load(R.drawable.ic_baseline_insert_drive_file_24)
|
||||
.into(composeAttachmentItemBinding.preview);
|
||||
}
|
||||
} else {
|
||||
Glide.with(composeAttachmentItemBinding.preview.getContext())
|
||||
.load(R.drawable.ic_baseline_insert_drive_file_24)
|
||||
.into(composeAttachmentItemBinding.preview);
|
||||
}
|
||||
if (mediaPosition == 0) {
|
||||
composeAttachmentItemBinding.buttonOrderUp.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
composeAttachmentItemBinding.buttonOrderUp.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mediaPosition == attachmentList.size() - 1) {
|
||||
composeAttachmentItemBinding.buttonOrderDown.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
composeAttachmentItemBinding.buttonOrderDown.setVisibility(View.VISIBLE);
|
||||
}
|
||||
//Remote attachments when deleting/redrafting can't be ordered
|
||||
if (attachment.local_path == null) {
|
||||
composeAttachmentItemBinding.buttonOrderUp.setVisibility(View.INVISIBLE);
|
||||
composeAttachmentItemBinding.buttonOrderDown.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
int finalMediaPosition = mediaPosition;
|
||||
if (attachment.local_path != null && (attachment.local_path.endsWith("png") || attachment.local_path.endsWith("jpg") || attachment.local_path.endsWith("jpeg"))) {
|
||||
composeAttachmentItemBinding.editPreview.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
composeAttachmentItemBinding.editPreview.setVisibility(View.GONE);
|
||||
}
|
||||
composeAttachmentItemBinding.editPreview.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(requireActivity(), EditImageActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
intent.putExtra("imageUri", attachment.local_path);
|
||||
intent.putExtras(b);
|
||||
startActivity(intent);
|
||||
});
|
||||
composeAttachmentItemBinding.buttonDescription.setOnClickListener(v -> {
|
||||
AlertDialog.Builder builderInner = new MaterialAlertDialogBuilder(requireActivity());
|
||||
// builderInner.setTitle(R.string.upload_form_description);
|
||||
PopupMediaDescriptionBinding popupMediaDescriptionBinding = PopupMediaDescriptionBinding.inflate(LayoutInflater.from(requireActivity()), null, false);
|
||||
builderInner.setView(popupMediaDescriptionBinding.getRoot());
|
||||
|
||||
popupMediaDescriptionBinding.mediaDescription.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1500)});
|
||||
popupMediaDescriptionBinding.mediaDescription.requestFocus();
|
||||
Glide.with(popupMediaDescriptionBinding.mediaPicture.getContext())
|
||||
.asBitmap()
|
||||
.load(attachmentPath)
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
popupMediaDescriptionBinding.mediaPicture.setImageBitmap(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
super.onLoadFailed(errorDrawable);
|
||||
}
|
||||
});
|
||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
if (attachment.description != null) {
|
||||
popupMediaDescriptionBinding.mediaDescription.setText(attachment.description);
|
||||
popupMediaDescriptionBinding.mediaDescription.setSelection(popupMediaDescriptionBinding.mediaDescription.getText().length());
|
||||
}
|
||||
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
|
||||
attachment.description = popupMediaDescriptionBinding.mediaDescription.getText().toString();
|
||||
displayAttachments(finalMediaPosition);
|
||||
dialog.dismiss();
|
||||
});
|
||||
AlertDialog alertDialog = builderInner.create();
|
||||
Objects.requireNonNull(alertDialog.getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
alertDialog.show();
|
||||
popupMediaDescriptionBinding.mediaDescription.requestFocus();
|
||||
|
||||
});
|
||||
|
||||
composeAttachmentItemBinding.buttonOrderUp.setOnClickListener(v -> {
|
||||
if (finalMediaPosition > 0 && attachmentList.size() > 1) {
|
||||
Attachment at1 = attachmentList.get(finalMediaPosition);
|
||||
Attachment at2 = attachmentList.get(finalMediaPosition - 1);
|
||||
attachmentList.set(finalMediaPosition - 1, at1);
|
||||
attachmentList.set(finalMediaPosition, at2);
|
||||
displayAttachments(finalMediaPosition - 1);
|
||||
}
|
||||
});
|
||||
composeAttachmentItemBinding.buttonOrderDown.setOnClickListener(v -> {
|
||||
if (finalMediaPosition < (attachmentList.size() - 1) && attachmentList.size() > 1) {
|
||||
Attachment at1 = attachmentList.get(finalMediaPosition);
|
||||
Attachment at2 = attachmentList.get(finalMediaPosition + 1);
|
||||
attachmentList.set(finalMediaPosition, at2);
|
||||
attachmentList.set(finalMediaPosition + 1, at1);
|
||||
displayAttachments(finalMediaPosition + 1);
|
||||
}
|
||||
});
|
||||
composeAttachmentItemBinding.buttonRemove.setOnClickListener(v -> {
|
||||
AlertDialog.Builder builderInner = new MaterialAlertDialogBuilder(requireActivity());
|
||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
builderInner.setPositiveButton(R.string.delete, (dialog, which) -> {
|
||||
attachmentList.remove(attachment);
|
||||
displayAttachments(finalMediaPosition);
|
||||
new Thread(() -> {
|
||||
if (attachment.local_path != null) {
|
||||
File fileToDelete = new File(attachment.local_path);
|
||||
if (fileToDelete.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
fileToDelete.delete();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
});
|
||||
builderInner.setMessage(R.string.toot_delete_media);
|
||||
builderInner.show();
|
||||
});
|
||||
composeAttachmentItemBinding.preview.setOnClickListener(v -> displayAttachments(finalMediaPosition));
|
||||
if (attachment.description == null || attachment.description.trim().isEmpty()) {
|
||||
composeAttachmentItemBinding.buttonDescription.setChipIconResource(R.drawable.ic_baseline_warning_24);
|
||||
composeAttachmentItemBinding.buttonDescription.setTextColor(ContextCompat.getColor(requireActivity(), R.color.black));
|
||||
composeAttachmentItemBinding.buttonDescription.setChipIconTintResource(R.color.black);
|
||||
composeAttachmentItemBinding.buttonDescription.setChipBackgroundColor(ThemeHelper.getNoDescriptionColorStateList(requireActivity()));
|
||||
} else {
|
||||
composeAttachmentItemBinding.buttonDescription.setChipIconResource(R.drawable.ic_baseline_check_circle_24);
|
||||
composeAttachmentItemBinding.buttonDescription.setTextColor(ContextCompat.getColor(requireActivity(), R.color.white));
|
||||
composeAttachmentItemBinding.buttonDescription.setChipIconTintResource(R.color.white);
|
||||
composeAttachmentItemBinding.buttonDescription.setChipBackgroundColor(ThemeHelper.getHavingDescriptionColorStateList(requireActivity()));
|
||||
}
|
||||
binding.attachmentsList.addView(composeAttachmentItemBinding.getRoot());
|
||||
mediaPosition++;
|
||||
}
|
||||
binding.attachmentsList.setVisibility(View.VISIBLE);
|
||||
if (scrollToMediaPosition >= 0 && binding.attachmentsList.getChildCount() < scrollToMediaPosition) {
|
||||
binding.attachmentsList.requestChildFocus(binding.attachmentsList.getChildAt(scrollToMediaPosition), binding.attachmentsList.getChildAt(scrollToMediaPosition));
|
||||
}
|
||||
} else {
|
||||
binding.attachmentsList.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
binding.attachmentsList.setVisibility(View.GONE);
|
||||
}
|
||||
buttonState();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Manage state of media and poll button
|
||||
*/
|
||||
private void buttonState() {
|
||||
if (BaseMainActivity.software == null || BaseMainActivity.software.toUpperCase().compareTo("MASTODON") == 0) {
|
||||
if (statusCompose.poll == null) {
|
||||
binding.buttonAttachImage.setEnabled(true);
|
||||
binding.buttonAttachVideo.setEnabled(true);
|
||||
binding.buttonAttachAudio.setEnabled(true);
|
||||
binding.buttonAttachManual.setEnabled(true);
|
||||
} else {
|
||||
binding.buttonAttachImage.setEnabled(false);
|
||||
binding.buttonAttachVideo.setEnabled(false);
|
||||
binding.buttonAttachAudio.setEnabled(false);
|
||||
binding.buttonAttachManual.setEnabled(false);
|
||||
binding.buttonPoll.setEnabled(true);
|
||||
}
|
||||
binding.buttonPoll.setEnabled(statusCompose.media_attachments == null || statusCompose.media_attachments.size() <= 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Intialize the common view for the context
|
||||
*
|
||||
* @param context {@link Context}
|
||||
*/
|
||||
private void initializeContextView(final Context context) {
|
||||
|
||||
if (context == null) {
|
||||
Helper.sendToastMessage(requireActivity(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error));
|
||||
return;
|
||||
}
|
||||
if (binding == null || !isAdded() || getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (pullToRefresh) {
|
||||
pullToRefresh = false;
|
||||
int size = this.statuses.size();
|
||||
statuses.clear();
|
||||
statusDirectMessageAdapter.notifyItemRangeRemoved(0, size);
|
||||
statuses.add(focusedStatus);
|
||||
}
|
||||
if (context.ancestors.size() > 0) {
|
||||
firstStatus = context.ancestors.get(0);
|
||||
} else {
|
||||
firstStatus = statuses.get(0);
|
||||
}
|
||||
if (firstMessage != null) {
|
||||
firstMessage.get(firstStatus);
|
||||
}
|
||||
|
||||
int statusPosition = context.ancestors.size();
|
||||
//Build the array of statuses
|
||||
statuses.addAll(0, context.ancestors);
|
||||
statusDirectMessageAdapter.notifyItemRangeInserted(0, statusPosition);
|
||||
statuses.addAll(statusPosition + 1, context.descendants);
|
||||
statusDirectMessageAdapter.notifyItemRangeInserted(statusPosition + 1, context.descendants.size());
|
||||
binding.swipeContainer.setRefreshing(false);
|
||||
initiliazeStatus();
|
||||
}
|
||||
|
||||
public interface FirstMessage {
|
||||
void get(Status status);
|
||||
}
|
||||
}
|
|
@ -166,7 +166,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
badgeCount = 0;
|
||||
headerMenuOpen = false;
|
||||
binding.navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
||||
|
||||
startInForeground();
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
peertubeInformation.setPrivacies(new LinkedHashMap<>());
|
||||
peertubeInformation.setPlaylistPrivacies(new LinkedHashMap<>());
|
||||
peertubeInformation.setTranslations(new LinkedHashMap<>());
|
||||
startInForeground();
|
||||
|
||||
|
||||
//noinspection ConstantConditions
|
||||
if (BuildConfig.FLAVOR.compareTo("playstore") == 0) {
|
||||
|
@ -417,10 +417,13 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
|
||||
private void startInForeground() {
|
||||
Intent notificationIntent = new Intent(this, RetrieveInfoService.class);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(notificationIntent);
|
||||
} else {
|
||||
startService(notificationIntent);
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(notificationIntent);
|
||||
} else {
|
||||
startService(notificationIntent);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||
public class Sqlite extends SQLiteOpenHelper {
|
||||
|
||||
|
||||
public static final int DB_VERSION = 9;
|
||||
public static final int DB_VERSION = 10;
|
||||
public static final String DB_NAME = "fedilab_db";
|
||||
|
||||
//Table of owned accounts
|
||||
|
@ -94,13 +94,16 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
public static final String COL_USER_INSTANCE = "USER_INSTANCE";
|
||||
|
||||
//Home fetch logs
|
||||
public static final String TABLE_HOME_FETCH_LOGS = "TABLE_HOME_FETCH_LOGS";
|
||||
public static final String TABLE_HOME_FETCH_LOGS = "HOME_FETCH_LOGS";
|
||||
public static final String COL_INSERTED = "INSERTED";
|
||||
public static final String COL_UPDATED = "UPDATED";
|
||||
public static final String COL_FAILED = "FAILED";
|
||||
public static final String COL_FREQUENCY = "FREQUENCY";
|
||||
public static final String COL_FETCHED_COUNT = "FETCHED_COUNT";
|
||||
|
||||
public static final String TABLE_CACHE_TAGS = "CACHE_TAGS";
|
||||
public static final String COL_TAG = "TAG";
|
||||
|
||||
|
||||
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
|
||||
+ COL_USER_ID + " TEXT NOT NULL, "
|
||||
|
@ -211,6 +214,10 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
+ COL_ABOUT + " TEXT NOT NULL, "
|
||||
+ COL_USER_INSTANCE + " TEXT NOT NULL)";
|
||||
|
||||
private final String CREATE_TABLE_CACHE_TAGS = "CREATE TABLE "
|
||||
+ TABLE_CACHE_TAGS + "("
|
||||
+ COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||
+ COL_TAG + " TEXT NOT NULL)";
|
||||
|
||||
public static SQLiteDatabase db;
|
||||
private static Sqlite sInstance;
|
||||
|
@ -243,6 +250,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
db.execSQL(CREATE_DOMAINS_TRACKING);
|
||||
db.execSQL(CREATE_TABLE_MUTED);
|
||||
db.execSQL(CREATE_TABLE_STORED_INSTANCES);
|
||||
db.execSQL(CREATE_TABLE_CACHE_TAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -271,6 +279,8 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
db.execSQL(CREATE_TABLE_MUTED);
|
||||
case 8:
|
||||
db.execSQL(CREATE_TABLE_STORED_INSTANCES);
|
||||
case 9:
|
||||
db.execSQL(CREATE_TABLE_CACHE_TAGS);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import static app.fedilab.android.activities.LoginActivity.softwareLogin;
|
|||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
@ -43,9 +44,12 @@ import androidx.activity.result.ActivityResultLauncher;
|
|||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.browser.customtabs.CustomTabColorSchemeParams;
|
||||
import androidx.browser.customtabs.CustomTabsIntent;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -60,6 +64,7 @@ import app.fedilab.android.mastodon.client.entities.app.Account;
|
|||
import app.fedilab.android.mastodon.client.entities.app.InstanceSocial;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||
import app.fedilab.android.mastodon.helper.ZipHelper;
|
||||
import app.fedilab.android.mastodon.viewmodel.mastodon.AppsVM;
|
||||
import app.fedilab.android.mastodon.viewmodel.mastodon.InstanceSocialVM;
|
||||
|
@ -214,6 +219,10 @@ public class FragmentLoginMain extends Fragment {
|
|||
menuInflater.inflate(R.menu.main_login, popupMenu.getMenu());
|
||||
MenuItem adminTabItem = popupMenu.getMenu().findItem(R.id.action_request_admin);
|
||||
adminTabItem.setChecked(requestedAdmin);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
boolean customTab = sharedpreferences.getBoolean(getString(R.string.SET_CUSTOM_TABS), true);
|
||||
popupMenu.getMenu().findItem(R.id.action_custom_tabs).setChecked(customTab);
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(item -> {
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_proxy) {
|
||||
|
@ -242,6 +251,13 @@ public class FragmentLoginMain extends Fragment {
|
|||
} else {
|
||||
proceed();
|
||||
}
|
||||
} else if (itemId == R.id.action_custom_tabs) {
|
||||
boolean newValue = !item.isChecked();
|
||||
item.setChecked(newValue);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(getString(R.string.SET_CUSTOM_TABS), newValue);
|
||||
editor.apply();
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
@ -291,13 +307,26 @@ public class FragmentLoginMain extends Fragment {
|
|||
client_idLogin = app.client_id;
|
||||
client_secretLogin = app.client_secret;
|
||||
String redirectUrl = MastodonHelper.authorizeURL(currentInstanceLogin, client_idLogin, requestedAdmin);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setData(Uri.parse(redirectUrl));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Toasty.error(requireActivity(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
boolean customTab = sharedpreferences.getBoolean(getString(R.string.SET_CUSTOM_TABS), true);
|
||||
if (customTab) {
|
||||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
||||
int colorInt = ThemeHelper.getAttColor(requireActivity(), R.attr.statusBar);
|
||||
CustomTabColorSchemeParams defaultColors = new CustomTabColorSchemeParams.Builder()
|
||||
.setToolbarColor(colorInt)
|
||||
.build();
|
||||
builder.setDefaultColorSchemeParams(defaultColors);
|
||||
CustomTabsIntent customTabsIntent = builder.build();
|
||||
customTabsIntent.launchUrl(requireActivity(), Uri.parse(redirectUrl));
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setData(Uri.parse(redirectUrl));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Toasty.error(requireActivity(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toasty.error(requireActivity(), getString(R.string.client_error), Toasty.LENGTH_SHORT).show();
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:drawable="@drawable/ic_block_script"
|
||||
android:gravity="center" />
|
||||
|
||||
<item
|
||||
android:id="@+id/ic_block_count"
|
||||
android:drawable="@color/transparent" />
|
||||
|
||||
</layer-list>
|
|
@ -0,0 +1,8 @@
|
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:left="5dp">
|
||||
<shape>
|
||||
<solid android:color="?attr/colorSecondary" />
|
||||
<corners android:radius="5dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -0,0 +1,19 @@
|
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:right="20dp">
|
||||
<rotate
|
||||
android:fromDegrees="35"
|
||||
android:pivotX="0%"
|
||||
android:pivotY="100%"
|
||||
android:toDegrees="0">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/chat_other_background" />
|
||||
</shape>
|
||||
</rotate>
|
||||
</item>
|
||||
<item android:left="5dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/chat_other_background" />
|
||||
<corners android:radius="5dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -0,0 +1,8 @@
|
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:right="5dp">
|
||||
<shape>
|
||||
<solid android:color="?attr/colorPrimary" />
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -0,0 +1,19 @@
|
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:left="20dp">
|
||||
<rotate
|
||||
android:fromDegrees="-40"
|
||||
android:pivotX="100%"
|
||||
android:pivotY="100%"
|
||||
android:toDegrees="0">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="?attr/colorSecondary" />
|
||||
</shape>
|
||||
</rotate>
|
||||
</item>
|
||||
<item android:right="6dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="?attr/colorSecondary" />
|
||||
<corners android:radius="5dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/account_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/tag_add"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"
|
||||
android:inputType="text"
|
||||
android:padding="20dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/save_tag"
|
||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="5dp"
|
||||
android:text="@string/set_save_changes" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/tag_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/close"
|
||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:text="@string/close" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2023 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>
|
||||
-->
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/profile_picture"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:contentDescription="@string/profile_picture" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.AppCompat.Title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/nav_host_fragment_content_main"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue