Compare commits

...

225 Commits
v1.3 ... master

Author SHA1 Message Date
Corewala 326c20f5ff Removed "fix" for images because it breaks things. 2023-02-20 16:54:27 -05:00
Corewala 867688a075 Fixed bug where current uri would be changed by resolving long-taps and image dialogs 2023-02-20 16:46:04 -05:00
Corewala bedbc9fb98 Made preferences less vulnerable to accidentally changing certificates 2023-02-20 16:14:17 -05:00
Corewala df6c159c2c Removed unused string 2023-02-20 15:31:37 -05:00
Corewala 93ef22a4f8 Removed unnecessary reference to proxy in redirect fix 2023-02-20 15:28:57 -05:00
Corewala 0a47f391e5 Fixed issue with local redirects from links on another host 2023-02-04 20:38:57 -05:00
Corewala 73afc7c684 Fixed redirect drop bug 2023-02-04 19:46:26 -05:00
Corewala 0fdffee966 v1.12 2022-11-09 23:21:34 -05:00
Corewala da4375b832 Merge remote-tracking branch 'origin/master' 2022-11-09 23:02:32 -05:00
Corewala 9f4d1c8027 Fixed bugged back button
Been a while eh?
2022-11-09 23:02:15 -05:00
Corewala 0df1501fd4
Merge pull request #30 from arielcostas/master
Delete local.properties,which shouldn't be on VCS

Thanks @arielcostas :)
2022-09-02 14:44:00 -04:00
Ariel Costas 2bd546d7ed Delete local.properties,which shouldn't be on VCS
Signed-off-by: Ariel Costas <arielcostas@mailbox.org>
2022-09-01 15:02:19 +02:00
Corewala 2c3c1db96b
Merge pull request #29 from rudmannn/master
fix android:lineHeight
2022-08-11 09:39:53 -04:00
strooonger 9038f49d40 fix android:lineHeight 2022-08-06 22:42:08 +08:00
Corewala eac1adb0cb Removed unused transverse function 2022-08-04 12:18:47 -04:00
Corewala eee109bb28 Made relative query strings work in accordance with the URL spec 2022-08-04 12:17:20 -04:00
Corewala f89f41ae14 Removed broken null check on http proxy 2022-08-01 18:38:09 -04:00
Corewala 26093144dd Fixed apostrophes in French fastlane description 2022-07-31 14:08:46 -04:00
Corewala 47dd2722e1 v1.11 2022-07-29 19:11:45 -04:00
Corewala b85de17c88 v1.10 changelog fix 2022-07-29 18:55:55 -04:00
Corewala 53c1980fa6 Updated todo 2022-07-29 16:23:24 -04:00
Corewala 0ae42a214d Removed redundant ouri and fixed local redirects (again) 2022-07-29 16:21:00 -04:00
Corewala 319b0b4d14 Fixed sharing of relative links 2022-07-29 15:47:33 -04:00
Corewala 13f21bc09b Fixed relative link handling with proxy 2022-07-29 15:09:26 -04:00
Corewala 79a3564569 Fixed snackbar on proxied content 2022-07-26 12:31:04 -04:00
Corewala 4a451ef5ca Fixed attention guide crash with long non-alphanumeric words 2022-07-26 12:09:00 -04:00
Corewala 467e3fc0b7 Added HTTP proxy
It's a beautiful half-broken mess
2022-07-25 23:07:55 -04:00
Corewala affa99e8f2 Added HTTP proxy to settings
It doesn't do anything yet. Great feature I know.
2022-07-09 18:38:31 -04:00
Corewala 4c94bd97e4 Fixed previousPosition when not through onLink 2022-07-09 13:27:27 -04:00
Corewala 679c3bd0be Replaced screenshots 2022-07-08 13:11:49 -04:00
Corewala aa6dcdad91 Previous scroll position is cached to reduce unnecessary re-scrolling 2022-07-08 12:28:17 -04:00
Corewala 9d4386939a Added HTTPS gateway support to todo 2022-07-08 11:08:12 -04:00
Corewala 001e7d3ffe Fixed type in screenshots folder name
That's a bit embarrassing
2022-07-02 11:09:06 -04:00
Corewala 882617df29 Added correct link to f-droid button 2022-07-02 11:02:34 -04:00
Corewala ba901e49ba Added f-droid button 2022-07-02 10:58:51 -04:00
Corewala cf8efbc625 Addressbar is cleared when loading about page 2022-07-01 15:53:06 -04:00
Corewala 09fc2a480a Improved handling of broken addresses in settings 2022-06-30 18:54:06 -04:00
Corewala a47d003f59 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	metadata/android/en-US/changelogs/11.txt
2022-06-23 13:55:40 -04:00
Corewala f79d0bf5ff Changelog v1.10 2022-06-23 13:33:14 -04:00
Licaon_Kter 011eb7487c
Add changelog 2022-06-22 10:51:00 +00:00
Corewala bae12d17a8 v1.10 2022-06-21 17:28:48 -04:00
Corewala f98756bebb Made local home into about page 2022-06-21 15:06:19 -04:00
Corewala e4cc13bb03 Made local page default 2022-06-21 14:37:04 -04:00
Corewala 3dee099dcf Added search to default homepage 2022-06-21 14:35:30 -04:00
Corewala 132749016a Made home capsule setting look better when empty/invalid 2022-06-21 14:23:44 -04:00
Corewala a791521565 Fixed infinite refresh on default homepage 2022-06-20 18:03:35 -04:00
Corewala 8258c48bb0 Updated strings on no internet page 2022-06-20 18:02:22 -04:00
Corewala c12702ef2f Fixed broken check for valid URI 2022-06-20 17:53:26 -04:00
Corewala 28fa72f59e Made refresh stop on empty homepage 2022-06-20 17:44:09 -04:00
Corewala 13af2089d8 Added fastlane icon 2022-06-20 14:22:35 -04:00
Corewala 2c24fa0c77 Does not load a URI on first launch
And fixed bugs
2022-06-20 12:45:20 -04:00
Corewala 0a59ac08cb Fixed crash if whitespace present in addressbar 2022-06-20 12:07:40 -04:00
Corewala c23b3efb70 Only show self-update option if sideloaded 2022-06-20 11:37:33 -04:00
Corewala 6d4dbbda94 Made self-updating false by default 2022-06-18 12:45:00 -04:00
Corewala 95ed0b815b Removed statement about Ariane source
Things have stayed pretty quiet for a while now, so it feels a bit unnecessary to have such a big statement anymore.
2022-06-16 15:28:07 -04:00
Corewala 125c34c6d0 Replace Egsam gemini link with repo
Apparently Github doesn't like non-http links in the README
2022-06-16 15:03:09 -04:00
Corewala 1c3905b197 Added goal of passing the Egsam client test 2022-06-16 15:00:51 -04:00
Corewala ee8ff30210 Changed images 2022-06-09 15:00:45 -04:00
Corewala 45b50afd47 Remove unnecessary plural French 2022-06-09 14:25:54 -04:00
Corewala dd95af5e5b Made French spelling consistent 2022-06-09 14:24:06 -04:00
Corewala fbdb04bf31 Fixed punctuation 2022-06-09 13:22:17 -04:00
Corewala 98d9af2871 Fixed plural accordance issue 2022-06-09 13:21:36 -04:00
Corewala 79a0d32bf1 Made capitalisation consistent 2022-06-09 13:21:01 -04:00
Corewala 5ccdaeb816 Added screenshots 2022-06-09 13:19:09 -04:00
Corewala f2d633e7e2 Added fastlane metadata 2022-06-09 13:18:54 -04:00
Corewala 05e2f64ebd Updated about body text 2022-06-09 12:41:15 -04:00
Corewala 2db5aa74ca Removed canGoBack check on request cancellation 2022-06-09 11:37:27 -04:00
Corewala 7828f3ea7f Deleted unused variable 2022-06-09 11:22:15 -04:00
Corewala bd8bbbc903 Made clear runtime cache button actually do something 2022-06-09 11:21:41 -04:00
Corewala 8f8bb15455 Added page switching to todo 2022-06-09 10:52:45 -04:00
Corewala 918deb4cdf Forgot to disable loading when request is canceled 2022-06-07 16:38:36 -04:00
Corewala cdcbdcdb2c Only latest gemini request is handled
Also back button cancels current requests if used while loading
2022-06-07 15:36:16 -04:00
Corewala 35352fa6f3 Only latest gemini request is handled 2022-06-07 15:06:54 -04:00
Corewala 0505e5d5bf Fixed redirects without leading slash 2022-06-03 10:42:42 -04:00
Corewala 764cee3042 Fixed addressbar for right-to-left languages 2022-05-31 16:21:45 -04:00
Corewala c0be77ef41 Improved internet connection handling 2022-05-30 19:53:44 -04:00
Corewala 60673c2fb3 Fixed attention guide crash on non-alphanumeric words 2022-05-30 11:38:45 -04:00
Corewala d247b17999 v1.9 2022-05-28 16:13:02 -04:00
Corewala eef63cd2e7 Made header rendering compliant with gemini spec 2022-05-28 14:42:44 -04:00
Corewala 8bb8c4f8f1 Removed mystery error fix
The fix would've broken legitimate response errors if opened with intents. Also for some reason the bug isn't happening on any of my devices anymore, even though I still have v1.8 installed on my phone. Very mysterious.
2022-05-27 12:21:15 -04:00
Corewala 30dcb45661 Fixed mystery connection error (for real this time)
Again, kind of an ugly fix, but at least it works I think
2022-05-26 14:05:58 -04:00
Corewala 589ab24a7e Removed useless fix 2022-05-26 13:36:05 -04:00
Corewala 1d2be092f1 Fixed a bunch of warnings
Spring cleaning I guess
2022-05-26 12:49:30 -04:00
Corewala d504df9cd3 Enabled more optimisation
The APK is so tiny and runs even faster now. How did I not do this earlier?
2022-05-26 12:42:16 -04:00
Corewala 1ec24a38a5 Fixed connection error before initialised
The fix isn't the cleanest, but it stopped throwing a mystery error.
2022-05-26 12:12:06 -04:00
Corewala d5ccf72ccf Removed unused import 2022-05-25 17:28:56 -04:00
Corewala 3d32bc95d5 Improved "no internet" screen 2022-05-25 17:00:56 -04:00
Corewala 5bb5fa7dcb Attention guides can handle hyphens 2022-05-25 11:34:55 -04:00
Corewala 8cde96c971 Made element names consistent with their titles 2022-05-24 15:47:44 -04:00
Corewala 0b7e24e764 Attention guides for gemtext 2022-05-24 15:38:47 -04:00
Corewala a7877cfc41 Removed unused variables and imports in GemtextAdapter 2022-05-22 16:49:11 -04:00
Corewala 684239c066 Removed unused code blocks parameter 2022-05-22 12:35:46 -04:00
Corewala e10e78b9f5 Added toasts for certificate loading 2022-05-22 11:43:48 -04:00
Corewala 3df657d4d4 Fixed white flash on startup 2022-05-22 11:22:00 -04:00
Corewala da37d8d684 Client certificate works with redirects 2022-05-22 10:55:52 -04:00
Corewala 04e8cfc2c7 Fixed hard crash on home button 2022-05-22 10:46:21 -04:00
Corewala 84af7e4588 Removed redundant internet check 2022-05-21 19:41:35 -04:00
Corewala 980a1ac4d5 Fixed localisation for update checks 2022-05-21 13:29:38 -04:00
Corewala 0b97d239c4 Hide update checks if installed from repository 2022-05-21 13:28:41 -04:00
Corewala 76145f80d5 v1.8 2022-05-19 14:11:45 -04:00
Corewala 0d30671b4b Fixed link buttons being enabled on first install despite being disabled in settings 2022-05-19 14:08:58 -04:00
Corewala c2cedab881 combined createBiometricPrompt function versions 2022-05-19 13:39:10 -04:00
Corewala 815c6bdccf Cleaned up unused imports and such 2022-05-19 13:25:58 -04:00
Corewala 5387f6635f Update cert icon in request function 2022-05-19 13:24:14 -04:00
Corewala 5e1e580f68 Shrunk signature icon to prevent rescaling of addressbar 2022-05-19 13:15:09 -04:00
Corewala cf3402e91f Overflow menu option changes title when cert is (un)loaded 2022-05-19 13:13:17 -04:00
Corewala 506976b25e Certificate button in overflow menu works better
Also the client cert icon isn't broken and doesn't cause the address bar to do weird scaling stuff anymore
2022-05-18 19:13:29 -04:00
Corewala b2f10454db Fixed null pointer error 2022-05-18 18:50:56 -04:00
Corewala da4702b1a0 Added signature system for sites which do not require certs
Also broke a bunch of things, but we'll get there I swear.
2022-05-18 12:18:59 -04:00
Corewala 29fe06ba54 Fixed inconsistent client cert weirdness 2022-05-17 20:45:40 -04:00
Corewala 5210d8484e Removed broken PREF_KEY_CLIENT_CERT_ACTIVE value 2022-05-17 20:02:39 -04:00
Corewala b954e94d3b Removed debug print 2022-05-17 19:46:29 -04:00
Corewala 2007e64550 Fixed recursion error 2022-05-17 19:45:31 -04:00
Corewala 4808620743 Simplified request function 2022-05-17 19:12:42 -04:00
Corewala 20846dad47 Only require verification for cert if changing host
Also removed all direct references to model.request
2022-05-17 19:00:47 -04:00
Corewala a519a522cf Make biometric unlock only required once per session 2022-05-17 18:37:11 -04:00
Corewala e46ea379c3 Fixed order of actions for biometrics 2022-05-17 15:34:44 -04:00
Corewala 55940914c0 Removed unused and broken useClientCertPreference 2022-05-17 15:14:31 -04:00
Corewala 36952de39f Fixed broken check for active client certificate 2022-05-17 13:49:18 -04:00
Corewala fe957eb581 Updated todo 2022-05-17 13:46:47 -04:00
Corewala 0c1cb3a309 Biometric verification for client certificates 2022-05-17 13:45:54 -04:00
Corewala 55db823420 Removed unnecessary values in BiometricManager 2022-05-17 13:25:49 -04:00
Corewala 93191e67c4 Touched up client cert settings 2022-05-17 13:19:04 -04:00
Corewala 64f3308e1b Added biometric cert password encryption to settings
Does nothing useful right now and just makes your client cert unusable while enabled. Obviously I plan to change that in the near-ish future.
2022-05-16 20:37:15 -04:00
Corewala 88583d1f49 Reverted changes to GemActivity and OmniTerm which broke image rendering 2022-05-16 12:19:41 -04:00
Corewala 02e27c7868 Fixed issue with local redirect responses 2022-05-15 12:26:06 -04:00
Corewala 15cc2d9a31 Removed debug strings lmao 2022-05-10 18:49:59 -04:00
Corewala 75f42173c9 External non-http URLs are handled correctly 2022-05-10 12:14:17 -04:00
Corewala bfd2572cec Removed %2F substitution in onLink 2022-05-10 11:32:28 -04:00
Corewala 1542ec5539 Checks theme in preferences on startup 2022-05-10 10:34:04 -04:00
Corewala fbf6c80282 Localised missing host error message 2022-05-08 17:50:00 -04:00
Corewala 94074e4689 Removed unused transverse function in OmniTerm 2022-05-07 12:50:27 -04:00
Corewala 82688f02b6 Fixed error with navigation to URLs containing "%2F" 2022-05-07 12:49:28 -04:00
Corewala 494997c0ea Fixed inline images with query strings 2022-05-07 12:47:07 -04:00
Corewala 913bf12686 Fixed update system
Pretty embarrassed that I put this in a release without proper testing lol
2022-05-05 14:22:57 -04:00
Corewala 95d6e92a04 Made dialog buttons uppercase in line with Material Design 2022-05-05 10:19:03 -04:00
Corewala 1275136433 v1.7 2022-05-03 21:34:26 -04:00
Corewala 0981c23e37 Check for certificate before offering continue button 2022-05-03 21:24:01 -04:00
Corewala ee664058bc Localised "ok" in dialogs 2022-05-03 18:54:12 -04:00
Corewala e27526deaa Fixed missing buttons in input dialog 2022-05-03 18:50:27 -04:00
Corewala d60c1a3b20 Added dialog when client certificate is required
The biometric unlock feature is on the way, if you couldn't tell
2022-05-03 18:29:44 -04:00
Corewala b2ef138402 Rearranged client cert section in settings
Also removed unnecessary "if true" statement
2022-05-03 12:25:57 -04:00
Corewala 79056fe060 Relaunches if internet is found after unsuccessful launch 2022-05-02 14:49:35 -04:00
Corewala 01df294462 Made internet checks consistent, reduced spaghetticode 2022-05-02 12:04:29 -04:00
Corewala 8c7546f095 Check if internet is available before opening a history entry 2022-05-01 12:25:35 -04:00
Corewala f54add615a Check if internet is available before opening a bookmark 2022-05-01 12:21:22 -04:00
Corewala 539f17e9be Check if internet is available before refreshing 2022-05-01 12:17:28 -04:00
Corewala 676d64e4bc Check if internet is available before loading previous page 2022-05-01 11:59:08 -04:00
Corewala 508d1f39e6 Check if internet is available before attempting to load new capsule 2022-05-01 11:48:56 -04:00
Corewala 972ff95ecd Lock addressbar if launched with no internet 2022-05-01 11:44:42 -04:00
Corewala 791fabca74 Fixed instant crash when internet is unavailable 2022-05-01 11:31:45 -04:00
Corewala 3661c134c4 Search engine select 2022-04-20 15:28:11 -04:00
Corewala f0c85315a1 Updated todo 2022-03-14 09:23:49 -04:00
Corewala d999c683f0 Merge remote-tracking branch 'origin/master' 2022-03-13 17:04:09 -04:00
Corewala 6dab6918c6 v1.6 2022-03-13 17:03:58 -04:00
Corewala 70734e33d9 v1.7 2022-03-13 17:03:05 -04:00
Corewala d7a2cdeb9f Updater 2022-03-13 16:58:10 -04:00
Corewala 8d70218d23 Added update install function 2022-03-12 14:40:01 -05:00
Corewala 48c7339d57 Update checking function 2022-03-07 15:51:07 -05:00
Corewala 4cd0e1977b Set max lines in input query 2022-02-17 18:27:34 -05:00
Corewala a5ec6624c4 Made input dialog margins consistent 2022-02-16 20:28:41 -05:00
Corewala 8c0bfd04db Replaced full-screen query dialog with AlertDialog 2022-02-16 20:02:27 -05:00
Corewala a78d11bf5a Fixed keyboard glitching in address bar 2022-02-08 13:06:30 -05:00
Corewala 324d947330 Fixed bug where the intended page is replaced by homepage when opened with link 2022-02-08 11:04:34 -05:00
Corewala f6f7997c69 Changed homepage to tlgs.one 2022-02-08 10:22:57 -05:00
Corewala 102377d8d3 Localised app name
Realised too late for v1.5, guess it'll be in v1.6.
2022-01-30 13:51:23 -05:00
Corewala c550a37581 Updated link 2022-01-30 13:40:32 -05:00
Corewala 0f09464654 v1.5 2022-01-30 13:21:25 -05:00
Corewala 0c034a7a43 Removed code block toggle
Might re-implement later, but the current implementation was somewhat cluttered
2022-01-30 11:26:11 -05:00
Corewala 1dcf3423a5 Update todo 2022-01-30 10:22:25 -05:00
Corewala f89af6e673 Fixed link long press handler (again) 2022-01-30 10:16:26 -05:00
Corewala 2b93265dbc Fixed string in settings 2022-01-26 20:28:33 -05:00
Corewala 2ee80fadd9 Link buttons 2022-01-26 20:23:40 -05:00
Corewala 9ed4c057b1 Added statement on Ariane 2022-01-26 13:12:44 -05:00
Corewala 4c1f21ab97 Removed code block scrollbar 2022-01-25 17:05:14 -05:00
Corewala 3c26af68c3 Updated badges 2022-01-24 15:25:38 -05:00
Corewala 47e08ba727 Relicensed to GPL 3
Not much to this decision beyond the GPL being the EUPL-compatible license I am most comfortable with.
2022-01-23 19:49:04 -05:00
Corewala f628c2d361 Updated copyright year 2022-01-22 16:29:21 -05:00
Corewala 88d8075a45 Streamlined inline images rendering 2022-01-18 14:47:43 -05:00
Corewala 441aff3c98 Reverted link buttons. They broke too many things. 2022-01-18 14:35:24 -05:00
Corewala 52f8dfcc72 Updated todo 2022-01-17 18:57:42 -05:00
Corewala 2024f88bb2 Removed code block toggle 2022-01-17 18:56:42 -05:00
Corewala 227d745f5c Link button strings 2022-01-17 18:47:12 -05:00
Corewala 28c72ce29c Added link buttons 2022-01-17 18:45:45 -05:00
Corewala 1b829279b9 Actually let's do the thing Ariane does for quotes 2022-01-15 17:36:36 -05:00
Corewala fe37541701 Increased margins quote block 2022-01-15 17:30:41 -05:00
Corewala 883e6e4de6 Rounded quote boxes 2022-01-15 17:25:42 -05:00
Corewala bbd613a13b Increased header font size 2022-01-15 12:09:52 -05:00
Corewala fac85fe8a9 Fixed inline images for local links 2022-01-15 09:47:20 -05:00
Corewala c535861c1e Configuring full-width buttons 2022-01-14 22:31:08 -05:00
Corewala 8e6ca8461a Removed protocol-breaking inline rendering of non-local links 2022-01-14 19:56:28 -05:00
Corewala 576e47be4b Fixed reference to gemtext_inline_image 2022-01-13 17:09:57 -05:00
Corewala f5f3a47e36 Changed radius of code block 2022-01-13 11:18:53 -05:00
Corewala b0f674f369 Local link share handler double slash workaround 2022-01-13 09:48:02 -05:00
Corewala 299061ef99 Higher contrast stroke and removed vibrant_stroke 2022-01-12 22:35:17 -05:00
Corewala 0854375c54 Added update notifier to todo 2022-01-12 21:20:52 -05:00
Corewala 5b94fd48e6 Increased rounded corner radius 2022-01-12 21:06:18 -05:00
Corewala 0572976be6 Inline images now have rounded corners 2022-01-12 20:42:36 -05:00
Corewala 84de93fedb Image dialog imageview is below toolbar 2022-01-10 15:07:13 -05:00
Corewala f7deb674c5 Hide previously rendered images when inline images is disabled 2022-01-10 14:27:51 -05:00
Corewala 6fb947cbdd Added link listeners to inline images 2022-01-09 19:36:53 -05:00
Corewala 9ac10f13fd Change inline images default to false 2022-01-09 12:27:24 -05:00
Corewala 6e22bf3218 Updated todo list 2022-01-09 12:23:51 -05:00
Corewala 85af5ff3a8 Added inline image rendering option 2022-01-09 12:22:36 -05:00
Corewala 20623fc4aa Added handler for sharing local links 2022-01-08 21:18:23 -05:00
Corewala 959d42e335 v1.4 2022-01-08 17:47:14 -05:00
Corewala 6f6ef9426b Replace gemini search with TLGS 2022-01-08 17:38:19 -05:00
Corewala da56080399 Added page navigation to todo list 2022-01-08 17:30:30 -05:00
Corewala b4f963bf93 Deleted unused link popup 2022-01-08 17:16:37 -05:00
Corewala a4ecd82004 All dialogs now use proper toolbars 2022-01-08 17:10:58 -05:00
Corewala 42ad53708d Titles are shown in dialogs 2022-01-08 13:35:20 -05:00
Corewala fbf13728eb Bookmarks dialog behaves like other dialogs 2022-01-08 13:34:17 -05:00
Corewala 60597a0b1c Added share dialog on long tap 2022-01-08 11:17:20 -05:00
Corewala fdafb7c395 Removed unused import 2022-01-07 18:52:54 -05:00
Corewala 5520e4e02e Fixed error in onResume() and removed unnecessary fix in OmniTerm.kt 2022-01-07 18:52:19 -05:00
Corewala 6d44717ef6 Removed large gemtext 2022-01-07 16:26:18 -05:00
Corewala 36e2151c9f Fixed empty history list crash 2022-01-07 16:22:35 -05:00
Corewala 9ed34ece8f Revert "Removed kapt"
This reverts commit b9e2c98699.
2022-01-07 16:00:12 -05:00
Corewala b9e2c98699 Removed kapt 2022-01-07 15:49:20 -05:00
Corewala 69900eccb7 Removed ProcessTextActivity 2022-01-07 10:06:32 -05:00
Corewala 380b36b3b2 Kapt fix 2022-01-07 10:02:05 -05:00
Corewala 9f81e66cac Fixed address bar focus bug 2022-01-06 17:36:18 -05:00
Corewala 0e12e8a276 Fixed keyboard scrolling bug 2022-01-06 17:26:32 -05:00
Corewala 4f4f6a3304 Slightly darker addressbar 2022-01-05 20:34:29 -05:00
Corewala 597f192995 Less padding in toolbar 2022-01-05 20:26:11 -05:00
87 changed files with 2705 additions and 2086 deletions

4
.gitignore vendored
View File

@ -1,4 +1,6 @@
.gradle
.idea
build
release
release
local.properties
app/local.properties

978
LICENSE
View File

@ -1,305 +1,675 @@
European Union Public Licence v. 1.2
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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.
This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
EUPL © the European Union 2007, 2016
This European Union Public Licence (the 'EUPL') applies to the Work (as defined
below) which is provided under the terms of this Licence. Any use of the Work,
other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as
defined below) has placed the following notice immediately following the copyright
notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1. Definitions
In this Licence, the following terms have the following meaning:
— 'The Licence': this Licence.
— 'The Original Work': the work or software distributed or communicated by
the Licensor under this Licence, available as Source Code and also as Executable
Code as the case may be.
— 'Derivative Works': the works or software that could be created by the Licensee,
based upon the Original Work or modifications thereof. This Licence does not
define the extent of modification or dependence on the Original Work required
in order to classify a work as a Derivative Work; this extent is determined
by copyright law applicable in the country mentioned in Article 15.
— 'The Work': the Original Work or its Derivative Works.
— 'The Source Code': the human-readable form of the Work which is the most
convenient for people to study and modify.
— 'The Executable Code': any code which has generally been compiled and which
is meant to be interpreted by a computer as a program.
— 'The Licensor': the natural or legal person that distributes or communicates
the Work under the Licence.
— 'Contributor(s)': any natural or legal person who modifies the Work under
the Licence, or otherwise contributes to the creation of a Derivative Work.
— 'The Licensee' or 'You': any natural or legal person who makes any usage
of the Work under the terms of the Licence.
— 'Distribution' or 'Communication': any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making available,
online or offline, copies of the Work or providing access to its essential
functionalities at the disposal of any other natural or legal person.
2. Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable
licence to do the following, for the duration of copyright vested in the Original
Work:
— use the Work in any circumstance and for all usage,
— reproduce the Work,
— modify the Work, and make Derivative Works based upon the Work,
— communicate to the public, including the right to make available or display
the Work or copies thereof to the public and perform publicly, as the case
may be, the Work,
— distribute the Work or copies thereof,
— lend and rent the Work or copies thereof,
— sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether
now known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make effective
the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights
to any patents held by the Licensor, to the extent necessary to make use of
the rights granted on the Work under this Licence.
3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as Executable
Code. If the Work is provided as Executable Code, the Licensor provides in
addition a machine-readable copy of the Source Code of the Work along with
each copy of the Work that the Licensor distributes or indicates, in a notice
following the copyright notice attached to the Work, a repository where the
Source Code is easily and freely accessible for as long as the Licensor continues
to distribute or communicate the Work.
4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits
from any exception or limitation to the exclusive rights of the rights owners
in the Work, of the exhaustion of those rights or of other applicable limitations
thereto.
5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the disclaimer
of warranties. The Licensee must include a copy of such notices and a copy
of the Licence with every copy of the Work he/she distributes or communicates.
The Licensee must cause any Derivative Work to carry prominent notices stating
that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the
Original Works or Derivative Works, this Distribution or Communication will
be done under the terms of this Licence or of a later version of this Licence
unless the Original Work is expressly distributed only under this version
of the Licence — for example by communicating 'EUPL v. 1.2 only'. The Licensee
(becoming Licensor) cannot offer or impose any additional terms or conditions
on the Work or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative
Works or copies thereof based upon both the Work and another work licensed
under a Compatible Licence, this Distribution or Communication can be done
under the terms of this Compatible Licence. For the sake of this clause, 'Compatible
Licence' refers to the licences listed in the appendix attached to this Licence.
Should the Licensee's obligations under the Compatible Licence conflict with
his/her obligations under this Licence, the obligations of the Compatible
Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the
Work, the Licensee will provide a machine-readable copy of the Source Code
or indicate a repository where this Source will be easily and freely available
for as long as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade
names, trademarks, service marks, or names of the Licensor, except as required
for reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings
to the Work are owned by him/her or licensed to him/her and that he/she has
the power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent Contributors
grant You a licence to their contributions to the Work, under the terms of
this Licence.
7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
Contributors. It is not a finished work and may therefore contain defects
or 'bugs' inherent to this type of development.
For the above reason, the Work is provided under the Licence on an 'as is'
basis and without warranties of any kind concerning the Work, including without
limitation merchantability, fitness for a particular purpose, absence of defects
or errors, accuracy, non-infringement of intellectual property rights other
than copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a condition
for the grant of any rights to the Work.
8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the
use of the Work, including without limitation, damages for loss of goodwill,
work stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such damage.
However, the Licensor will be liable under statutory product liability laws
as far such laws apply to the Work.
9. Additional agreements
While distributing the Work, You may choose to conclude an additional agreement,
defining obligations or services consistent with this Licence. However, if
accepting obligations, You may act only on your own behalf and on your sole
responsibility, not on behalf of the original Licensor or any other Contributor,
and only if You agree to indemnify, defend, and hold each Contributor harmless
for any liability incurred by, or claims asserted against such Contributor
by the fact You have accepted any warranty or additional liability.
10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon 'I agree'
placed under the bottom of a window displaying the text of this Licence or
by affirming consent in any other similar way, in accordance with the rules
of applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and conditions
by exercising any rights granted to You by Article 2 of this Licence, such
as the use of the Work, the creation by You of a Derivative Work or the Distribution
or Communication by You of the Work or copies thereof.
11. Information to the public
In case of any Distribution or Communication of the Work by means of electronic
communication by You (for example, by offering to download the Work from a
remote location) the distribution channel or media (for example, a website)
must at least provide to the public the information requested by the applicable
law regarding the Licensor, the Licence and the way it may be accessible,
concluded, stored and reproduced by the Licensee.
12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically
upon any breach by the Licensee of the terms of the Licence.
Such a termination will not terminate the licences of any person who has received
the Work from the Licensee under the Licence, provided such persons remain
in full compliance with the Licence.
13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as
a whole. Such provision will be construed or reformed so as necessary to make
it valid and enforceable.
The European Commission may publish other linguistic versions or new versions
of this Licence or updated versions of the Appendix, so far this is required
and reasonable, without reducing the scope of the rights granted by the Licence.
New versions of the Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version
of their choice.
14. Jurisdiction
Without prejudice to specific agreement between parties,
— any litigation resulting from the interpretation of this License, arising
between the European Union institutions, bodies, offices or agencies, as a
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
of Justice of the European Union, as laid down in article 272 of the Treaty
on the Functioning of the European Union,
— any litigation arising between other parties and resulting from the interpretation
of this License, will be subject to the exclusive jurisdiction of the competent
court where the Licensor resides or conducts its primary business.
15. Applicable Law
Without prejudice to specific agreement between parties,
— this Licence shall be governed by the law of the European Union Member State
where the Licensor has his seat, resides or has his registered office,
— this licence shall be governed by Belgian law if the Licensor has no seat,
residence or registered office inside a European Union Member State.
Appendix
'Compatible Licences' according to Article 5 EUPL are:
— GNU General Public License (GPL) v. 2, v. 3
— GNU Affero General Public License (AGPL) v. 3
— Open Software License (OSL) v. 2.1, v. 3.0
— Eclipse Public License (EPL) v. 1.0
— CeCILL v. 2.0, v. 2.1
— Mozilla Public Licence (MPL) v. 2
— GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
— Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
works other than software
— European Union Public Licence (EUPL) v. 1.1, v. 1.2
— Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity
(LiLiQ-R+).
The European Commission may update this Appendix to later versions of the
above licences without producing a new version of the EUPL, as long as they
provide the rights granted in Article 2 of this Licence and protect the covered
Source Code from exclusive appropriation.
All other changes or additions to this Appendix require the production of
a new EUPL version.

View File

@ -5,7 +5,14 @@
[![forthebadge](https://forthebadge.com/images/badges/built-for-android.svg)](https://github.com/Corewala/Buran#buran)
[![forthebadge](https://forthebadge.com/images/badges/as-seen-on-tv.svg)](https://github.com/Corewala/Buran#buran)
[![shields](https://img.shields.io/badge/Download-Here-orange?style=for-the-badge&logo=github)](https://github.com/Corewala/Buran/releases/latest)
[![shields](https://img.shields.io/badge/Download-Here-orange?style=for-the-badge)](https://github.com/Corewala/Buran/releases/latest)
[![shields](https://img.shields.io/badge/license-GPL-blue?style=for-the-badge)](https://github.com/Corewala/Buran/blob/master/LICENSE)
<a href="https://f-droid.org/packages/corewala.gemini.buran">
<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">
</a>
Buran is a simple Gemini protocol browser for Android.
@ -13,14 +20,20 @@ Buran is a simple Gemini protocol browser for Android.
- [ ] Utility for creating and managing client certificates
- [ ] Keystore generator and catalog
- [ ] Option to require password or biometric authentication
- [X] Option to require password or biometric authentication
- [ ] Color palette interface for picking background and accent colors
- [ ] Option to render links as buttons
- [ ] Inline rendering of images
- [X] Option to render links as buttons
- [X] Inline rendering of images
- [ ] Page navigation feature
- [X] Update notifier
- [X] Attention guide mode
- [ ] Simple A/B page switching system
- [ ] Pass [Egsam test](https://github.com/pitr/egsam)
- [X] Option to define an HTTPS gateway
## Credits
Buran is based on the [Ariane source code](https://web.archive.org/web/20210920212507/https://codeberg.org/oppenlab/Ariane) (now [Seren](https://orllewin.uk/)), created by ÖLAB.
Buran is based on the [Ariane source code](https://web.archive.org/web/20210920212507/https://codeberg.org/oppenlab/Ariane) (now [Seren](https://orllewin.neocities.org/seren/)), created by ÖLAB.
The font used in code blocks is [JetBrains Mono](https://www.jetbrains.com/lp/mono/), created by JetBrains.

View File

@ -11,8 +11,8 @@ android {
applicationId "corewala.gemini.buran"
minSdkVersion 21
targetSdkVersion 30
versionCode 4
versionName "v1.3"
versionCode 13
versionName "v1.12"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -21,6 +21,7 @@ android {
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
@ -56,6 +57,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.google.android.material:material:1.3.0-rc01'
implementation "androidx.biometric:biometric:1.1.0"
//ROOM DB
def room_version = "2.2.6"

View File

@ -1,4 +0,0 @@
sdk.dir=/home/vagrant/android-sdk
sdk-location=/home/vagrant/android-sdk
ndk.dir=/home/vagrant/android-ndk/r12b
ndk-location=/home/vagrant/android-ndk/r12b

View File

@ -3,27 +3,19 @@
package="corewala.buran">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application
android:name="corewala.buran.Buran"
android:allowBackup="true"
android:icon="@drawable/launcher"
android:label="Buran"
android:label="@string/app_name"
android:roundIcon="@drawable/launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name="corewala.buran.ui.ProcessTextActivity"
android:label="Open in Buran"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />
<data android:mimeType="text/plain"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="corewala.buran.ui.GemActivity"
android:launchMode="singleTop">

View File

@ -5,14 +5,13 @@ import android.app.Application
class Buran: Application() {
companion object{
const val DEFAULT_HOME_CAPSULE = "gemini://rawtext.club/~sloum/spacewalk.gmi"
const val FEATURE_CLIENT_CERTS = true
const val DEFAULT_HOME_CAPSULE = ""
const val DEFAULT_SEARCH_BASE = "gemini://tlgs.one/search?"
const val PREF_KEY_CLIENT_CERT_URI = "client_cert_uri"
const val PREF_KEY_CLIENT_CERT_HUMAN_READABLE = "client_cert_uri_human_readable"
const val PREF_KEY_CLIENT_CERT_ACTIVE = "client_cert_active"
const val PREF_KEY_CLIENT_CERT_PASSWORD = "client_cert_password"
const val CLIENT_CERT_PASSWORD_SECRET_KEY_NAME = "client_cert_secret_key_name"
const val PREF_KEY_USE_CUSTOM_TAB = "use_custom_tabs"
}
}

View File

@ -4,7 +4,6 @@ import android.net.Uri
import java.util.*
const val GEM_SCHEME = "gemini://"
const val GUS_SEARCH_BASE = "gemini://geminispace.info/search?"
class OmniTerm(private val listener: Listener) {
val history = ArrayList<OppenURI>()
@ -15,8 +14,12 @@ class OmniTerm(private val listener: Listener) {
* User input to the 'omni bar' - could be an address or a search term
* @param term - User-inputted term
*/
fun input(term: String){
fun input(term: String, searchbase: String?){
when {
term.contains(" ") -> {
val encoded = Uri.encode(term)
listener.request("$searchbase$encoded")
}
term.startsWith(GEM_SCHEME) && term != GEM_SCHEME -> {
listener.request(term)
return
@ -26,14 +29,14 @@ class OmniTerm(private val listener: Listener) {
}
else -> {
val encoded = Uri.encode(term)
listener.request("$GUS_SEARCH_BASE$encoded")
listener.request("$searchbase$encoded")
}
}
}
fun search(term: String){
fun search(term: String, searchbase: String?){
val encoded = Uri.encode(term)
listener.request("$GUS_SEARCH_BASE$encoded")
listener.request("$searchbase$encoded")
}
@ -51,21 +54,27 @@ class OmniTerm(private val listener: Listener) {
*/
private fun navigation(link: String, invokeListener: Boolean) {
when {
link.startsWith("http") -> listener.openBrowser(link)
link.startsWith(GEM_SCHEME) -> uri.set(link)
link.startsWith("//") -> uri.set("gemini:$link")
link.startsWith("http://") or link.startsWith("https://") -> {
uri.set(link)
}
link.contains(":") -> listener.openExternal(link)
else -> uri.resolve(link)
}
//todo - fix this, the double slash fix breaks the scheme, so this hack puts it back... uggh
val address = uri.toString().replace("%2F", "/").replace("//", "/").replace("gemini:/", "gemini://")
println("OmniTerm resolved address: $address")
val address = uri.toString().replace("//", "/").replace(":/", "://")
if(invokeListener) listener.request(address)
println("OmniTerm resolved address: $address")
}
fun traverse(address: String): String {
return OppenURI(address).traverse().toString()
fun getGlobalUri(reference: String): String {
return when {
reference.contains(":") -> reference
reference.startsWith("//") -> "gemini:$reference"
else -> uri.resolve(reference, false)
}
}
fun reset(){
@ -81,7 +90,11 @@ class OmniTerm(private val listener: Listener) {
}
fun getCurrent(): String {
return history.last().toString()
return if(history.size > 0){
history.last().toString()
}else{
""
}
}
fun canGoBack(): Boolean {
@ -93,8 +106,12 @@ class OmniTerm(private val listener: Listener) {
return history.last().toString()
}
fun clearCache() {
history.clear()
}
interface Listener{
fun request(address: String)
fun openBrowser(address: String)
fun openExternal(address: String)
}
}

View File

@ -1,9 +1,12 @@
package corewala.buran
const val SCHEME = "gemini://"
import corewala.toURI
const val GEMSCHEME = "gemini://"
const val TRAVERSE = "../"
const val SOLIDUS = "/"
const val DIREND = "/"
const val QUERY = "?"
/**
*
@ -15,68 +18,65 @@ class OppenURI constructor(private var ouri: String) {
constructor(): this("")
var host: String = ""
var scheme: String = ""
init {
extractHost()
if(ouri.isNotEmpty()){
host = ouri.toURI().host
scheme = ouri.toURI().scheme
}
}
fun set(ouri: String){
this.ouri = ouri
extractHost()
if(ouri.isNotEmpty()){
host = ouri.toURI().host
scheme = ouri.toURI().scheme
}
}
fun resolve(reference: String) {
if(ouri == "$SCHEME$host") ouri = "$ouri/"
return when {
reference.startsWith(SCHEME) -> set(reference)
reference.startsWith(SOLIDUS) -> ouri = "$SCHEME$host$reference"
fun resolve(reference: String, persistent: Boolean): String{
if(ouri == "$GEMSCHEME$host") ouri = "$ouri/"
var resolvedUri = ""
when {
reference.startsWith(GEMSCHEME) -> set(reference)
reference.startsWith(SOLIDUS) -> resolvedUri = "$scheme://$host$reference"
reference.startsWith(TRAVERSE) -> {
if(!ouri.endsWith(DIREND)) ouri = ouri.removeFile()
if(!ouri.endsWith(DIREND)) resolvedUri = ouri.removeFile()
val traversalCount = reference.split(TRAVERSE).size - 1
ouri = traverse(traversalCount) + reference.replace(TRAVERSE, "")
resolvedUri = traverse(traversalCount) + reference.replace(TRAVERSE, "")
}
reference.startsWith(QUERY) -> {
resolvedUri = if(reference.contains(QUERY)){
ouri.substringBefore(QUERY) + reference
}else{
ouri + reference
}
}
else -> {
ouri = when {
ouri.endsWith(DIREND) -> "${ouri}$reference"
resolvedUri = when {
ouri.endsWith(DIREND) -> {
"${ouri}$reference"
}
else -> "${ouri.substring(0, ouri.lastIndexOf("/"))}/$reference"
}
}
}
if(persistent){
ouri = resolvedUri
}
return resolvedUri
}
fun traverse(): OppenURI{
val path = ouri.removePrefix("$SCHEME$host")
val segments = path.split(SOLIDUS).filter { it.isNotEmpty() }
var nouri = "$SCHEME$host"
when (ouri) {
"" -> {
}
SCHEME -> ouri = ""
"$nouri/" -> ouri = SCHEME
else -> {
when {
segments.isNotEmpty() -> {
val remaining = segments.dropLast(1)
remaining.forEach { segment ->
nouri += "/$segment"
}
ouri = "$nouri/"
}
else -> ouri = "$nouri/"
}
}
}
return this
fun resolve(reference: String): String{
return resolve(reference, true)
}
private fun traverse(count: Int): String{
val path = ouri.removePrefix("$SCHEME$host")
val path = ouri.removePrefix("$GEMSCHEME$host")
val segments = path.split(SOLIDUS).filter { it.isNotEmpty() }
val segmentCount = segments.size
var nouri = "$SCHEME$host"
var nouri = "$GEMSCHEME$host"
segments.forEachIndexed{ index, segment ->
if(index < segmentCount - count){
@ -88,15 +88,6 @@ class OppenURI constructor(private var ouri: String) {
}
private fun extractHost(){
if(ouri.isEmpty()) return
val urn = ouri.removePrefix(SCHEME)
host = when {
urn.contains(SOLIDUS) -> urn.substring(0, urn.indexOf(SOLIDUS))
else -> urn
}
}
fun copy(): OppenURI = OppenURI(ouri)
override fun toString(): String = ouri

View File

@ -8,17 +8,16 @@ sealed class GemState {
data class AppQuery(val uri: URI): GemState()
data class Requesting(val uri: URI): GemState()
data class NotGeminiRequest(val uri: URI) : GemState()
data class ResponseGemtext(val uri: URI, val header: GeminiResponse.Header, val lines: List<String>) : GemState()
data class ResponseInput(val uri: URI, val header: GeminiResponse.Header) : GemState()
data class Redirect(val uri: URI, val header: GeminiResponse.Header) : GemState()
data class ResponseText(val uri: URI, val header: GeminiResponse.Header, val content: String) : GemState()
data class ResponseImage(val uri: URI, val header: GeminiResponse.Header, val cacheUri: Uri) : GemState()
data class ResponseBinary(val uri: URI, val header: GeminiResponse.Header, val cacheUri: Uri) : GemState()
data class ResponseUnknownMime(val uri: URI, val header: GeminiResponse.Header) : GemState()
data class ResponseError(val header: GeminiResponse.Header): GemState()
data class ResponseUnknownHost(val uri: URI): GemState()
data class ClientCertRequired(val uri: URI, val header: GeminiResponse.Header): GemState()
data class ClientCertError(val header: GeminiResponse.Header): GemState()
object Blank: GemState()
}

View File

@ -40,7 +40,6 @@ class BuranHistory(private val db: BuranAbstractDatabase): HistoryDatasource {
override fun add(uri: Uri, onAdded: () -> Unit) {
if(!uri.toString().startsWith("gemini://")){
onAdded
return
}
GlobalScope.launch(Dispatchers.IO){

View File

@ -6,11 +6,10 @@ import corewala.buran.io.database.history.BuranHistory
import java.net.URI
interface Datasource {
fun request(address: String, onUpdate: (state: GemState) -> Unit)
fun request(address: String, forceDownload: Boolean, onUpdate: (state: GemState) -> Unit)
fun request(address: String, forceDownload: Boolean, clientCertPassword: String?, alternativeRequest: String?, onUpdate: (state: GemState) -> Unit)
fun isRequesting(): Boolean
fun cancel()
fun canGoBack(): Boolean
fun goBack(onUpdate: (state: GemState) -> Unit)
companion object{
fun factory(context: Context, history: BuranHistory): Datasource {
return GeminiDatasource(context, history)

View File

@ -2,16 +2,15 @@ package corewala.buran.io.gemini
import android.content.Context
import androidx.core.net.toUri
import androidx.preference.PreferenceManager
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import corewala.buran.Buran
import corewala.buran.OppenURI
import corewala.buran.io.GemState
import corewala.buran.io.database.history.BuranHistory
import corewala.buran.io.keymanager.BuranKeyManager
import corewala.toURI
import corewala.toUri
import java.io.*
import java.lang.IllegalStateException
import java.net.ConnectException
import java.net.URI
import java.net.UnknownHostException
@ -20,7 +19,6 @@ import javax.net.ssl.*
class GeminiDatasource(private val context: Context, val history: BuranHistory): Datasource {
private val prefs = PreferenceManager.getDefaultSharedPreferences(context)
private val runtimeHistory = mutableListOf<URI>()
private var forceDownload = false
@ -32,61 +30,78 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
private var socketFactory: SSLSocketFactory? = null
override fun request(address: String, forceDownload: Boolean, onUpdate: (state: GemState) -> Unit) {
this.forceDownload = forceDownload
request(address, onUpdate)
}
private var currentRequestAddress: String? = null
override fun request(address: String, forceDownload: Boolean, clientCertPassword: String?, alternativeRequest: String?, onUpdate: (state: GemState) -> Unit){
this.forceDownload = forceDownload
override fun request(address: String, onUpdate: (state: GemState) -> Unit) {
this.onUpdate = onUpdate
val uri = URI.create(address)
onUpdate(GemState.Requesting(uri))
if(address.startsWith("gemini://")){
currentRequestAddress = address
}
GlobalScope.launch {
geminiRequest(uri, onUpdate)
geminiRequest(uri, onUpdate, clientCertPassword, alternativeRequest)
}
}
private fun initSSLFactory(protocol: String){
override fun isRequesting(): Boolean{
return !currentRequestAddress.isNullOrEmpty()
}
override fun cancel(){
currentRequestAddress = null
}
private fun initSSLFactory(protocol: String, clientCertPassword: String?){
val sslContext = when (protocol) {
"TLS_ALL" -> SSLContext.getInstance("TLS")
else -> SSLContext.getInstance(protocol)
}
sslContext.init(buranKeyManager.getFactory()?.keyManagers, DummyTrustManager.get(), null)
sslContext.init(buranKeyManager.getFactory(clientCertPassword)?.keyManagers, DummyTrustManager.get(), null)
socketFactory = sslContext.socketFactory
}
private fun geminiRequest(uri: URI, onUpdate: (state: GemState) -> Unit){
private fun geminiRequest(uri: URI, onUpdate: (state: GemState) -> Unit, clientCertPassword: String?, alternativeRequest: String?){
val protocol = "TLS"
val useClientCert = prefs.getBoolean(Buran.PREF_KEY_CLIENT_CERT_ACTIVE, false)
//Update factory if operating mode has changed
when {
socketFactory == null -> initSSLFactory(protocol!!)
useClientCert && !buranKeyManager.lastCallUsedKey -> initSSLFactory(protocol!!)
!useClientCert && buranKeyManager.lastCallUsedKey -> initSSLFactory(protocol!!)
initSSLFactory(protocol, clientCertPassword)
val port = if(uri.port != -1){
uri.port
}else{
1965
}
val socket: SSLSocket?
try {
socket = socketFactory?.createSocket(uri.host, 1965) as SSLSocket
socket = socketFactory?.createSocket(uri.host, port) as SSLSocket
println("Buran socket handshake with ${uri.host}")
socket.startHandshake()
}catch (uhe: UnknownHostException){
println("Buran socket error, unknown host: $uhe")
onUpdate(GemState.ResponseUnknownHost(uri))
if(currentRequestAddress == uri.toString()) {
println("Buran socket error, unknown host: $uhe")
onUpdate(GemState.ResponseUnknownHost(uri))
}
return
}catch (ce: ConnectException){
println("Buran socket error, connect exception: $ce")
onUpdate(GemState.ResponseError(GeminiResponse.Header(-1, ce.message ?: ce.toString())))
if(currentRequestAddress == uri.toString()) {
println("Buran socket error, connect exception: $ce")
onUpdate(GemState.ResponseError(GeminiResponse.Header(-1, ce.message ?: ce.toString())))
}
return
}catch (she: SSLHandshakeException){
println("Buran socket error, ssl handshake exception: $she")
onUpdate(GemState.ResponseError(GeminiResponse.Header(-2, she.message ?: she.toString())))
if(currentRequestAddress == uri.toString()) {
println("Buran socket error, ssl handshake exception: $she")
onUpdate(GemState.ResponseError(GeminiResponse.Header(-2, she.message ?: she.toString())))
}
return
}
@ -95,7 +110,12 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
val bufferedWriter = BufferedWriter(outputStreamWriter)
val outWriter = PrintWriter(bufferedWriter)
val requestEntity = uri.toString() + "\r\n"
val requestEntity = if(alternativeRequest.isNullOrEmpty()){
uri.toString()
}else{
alternativeRequest
} + "\r\n"
println("Buran socket requesting $requestEntity")
outWriter.print(requestEntity)
outWriter.flush()
@ -113,30 +133,38 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
val bufferedReader = BufferedReader(headerInputReader)
val headerLine = bufferedReader.readLine()
println("Buran: response header: $headerLine")
println("Buran response header: $headerLine")
if(headerLine == null){
onUpdate(GemState.ResponseError(GeminiResponse.Header(-2, "Server did not respond with a Gemini header: $uri")))
if(currentRequestAddress == uri.toString()){
onUpdate(GemState.ResponseError(GeminiResponse.Header(-2, "Server did not respond with a Gemini header: $uri")))
}
return
}
val header = GeminiResponse.parseHeader(headerLine)
when {
header.code == GeminiResponse.INPUT -> onUpdate(GemState.ResponseInput(uri, header))
header.code == GeminiResponse.REDIRECT -> request(URI.create(header.meta).toString(), onUpdate)
header.code != GeminiResponse.SUCCESS -> onUpdate(GemState.ResponseError(header))
header.meta.startsWith("text/gemini") -> getGemtext(bufferedReader, uri, header, onUpdate)
header.meta.startsWith("text/") -> getString(socket, uri, header, onUpdate)
header.meta.startsWith("image/") -> getBinary(socket, uri, header, onUpdate)
else -> {
//File served over Gemini but not handled in-app, eg .pdf
if(forceDownload){
getBinary(socket, uri, header, onUpdate)
}else{
onUpdate(GemState.ResponseUnknownMime(uri, header))
if(currentRequestAddress == uri.toString()){
currentRequestAddress = null
when {
header.code == GeminiResponse.INPUT -> onUpdate(GemState.ResponseInput(uri, header))
header.code == GeminiResponse.REDIRECT -> onUpdate(GemState.Redirect(uri, header))
header.code == GeminiResponse.CLIENT_CERTIFICATE_REQUIRED -> onUpdate(GemState.ClientCertRequired(uri, header))
header.code != GeminiResponse.SUCCESS -> onUpdate(GemState.ResponseError(header))
header.meta.startsWith("text/gemini") -> getGemtext(bufferedReader, requestEntity.trim().toURI(), header, onUpdate)
header.meta.startsWith("text/") -> getString(socket, uri, header, onUpdate)
header.meta.startsWith("image/") -> getBinary(socket, uri, header, onUpdate)
else -> {
//File served over Gemini but not handled in-app, eg .pdf
if(forceDownload){
getBinary(socket, uri, header, onUpdate)
}else{
onUpdate(GemState.ResponseUnknownMime(uri, header))
}
}
}
}else{
println("Buran dropped response from $uri: request cancelled or superseded")
}
//Close input
@ -159,10 +187,6 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
val processed = GemtextHelper.findCodeBlocks(lines)
when {
!uri.toString().startsWith("gemini://") -> throw IllegalStateException("Not a Gemini Uri")
}
updateHistory(uri)
onUpdate(GemState.ResponseGemtext(uri, header, processed))
}
@ -186,12 +210,10 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
private fun getBinary(socket: SSLSocket?, uri: URI, header: GeminiResponse.Header, onUpdate: (state: GemState) -> Unit){
var filename: String? = null
val fileSegmentIndex: Int = uri.path.lastIndexOf('/')
when {
fileSegmentIndex != -1 -> filename = uri.path.substring(fileSegmentIndex + 1)
}
val charset = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz0123456789"
val filename = (1..12)
.map{charset.random()}
.joinToString("")
val host = uri.host.replace(".", "_")
val cacheName = "${host}_$filename"
@ -223,11 +245,6 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
override fun canGoBack(): Boolean = runtimeHistory.isEmpty() || runtimeHistory.size > 1
override fun goBack(onUpdate: (state: GemState) -> Unit) {
runtimeHistory.removeLast()
request(runtimeHistory.last().toString(), onUpdate)
}
//This just forces the factory to rebuild before the next request
fun invalidate() {
socketFactory = null

View File

@ -0,0 +1,107 @@
package corewala.buran.io.keymanager
import android.content.Context
import android.os.Build
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import androidx.annotation.RequiresApi
import androidx.biometric.BiometricPrompt
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import corewala.buran.Buran
import corewala.buran.R
import java.nio.charset.Charset
import java.security.KeyStore
import javax.crypto.Cipher
import javax.crypto.KeyGenerator
import javax.crypto.SecretKey
import javax.crypto.spec.GCMParameterSpec
data class EncryptedData(val ciphertext: ByteArray, val initializationVector: ByteArray)
@RequiresApi(Build.VERSION_CODES.P)
class BuranBiometricManager {
private lateinit var biometricPrompt: BiometricPrompt
private lateinit var promptInfo: BiometricPrompt.PromptInfo
fun createBiometricPrompt(context: Context, fragment: Fragment?, activity: FragmentActivity?, callback: BiometricPrompt.AuthenticationCallback){
val executor = ContextCompat.getMainExecutor(context)
if(fragment != null){
biometricPrompt = BiometricPrompt(fragment, executor, callback)
}else if(activity != null){
biometricPrompt = BiometricPrompt(activity, executor, callback)
}
promptInfo = BiometricPrompt.PromptInfo.Builder()
.setConfirmationRequired(false)
.setTitle(context.getString(R.string.confirm_your_identity))
.setSubtitle(context.getString(R.string.use_biometric_unlock))
.setNegativeButtonText(context.getString(R.string.cancel).toUpperCase())
.build()
}
fun authenticateToEncryptData() {
val cipher = getCipher()
val secretKey = getSecretKey(Buran.CLIENT_CERT_PASSWORD_SECRET_KEY_NAME)
cipher.init(Cipher.ENCRYPT_MODE, secretKey)
biometricPrompt.authenticate(promptInfo, BiometricPrompt.CryptoObject(cipher))
}
fun authenticateToDecryptData(initializationVector: ByteArray) {
val cipher = getCipher()
val secretKey = getSecretKey(Buran.CLIENT_CERT_PASSWORD_SECRET_KEY_NAME)
cipher.init(Cipher.DECRYPT_MODE, secretKey, GCMParameterSpec(128, initializationVector))
biometricPrompt.authenticate(promptInfo, BiometricPrompt.CryptoObject(cipher))
}
// Allows ByteArrays to be stored in prefs as strings. Possibly the most horrifying function I've ever written.
fun decodeByteArray(encodedByteArray: String): ByteArray{
val byteList = encodedByteArray.substring(1, encodedByteArray.length - 1).split(", ")
var decodedByteArray = byteArrayOf()
for(byte in byteList){
decodedByteArray += byte.toInt().toByte()
}
println(decodedByteArray.contentToString())
return decodedByteArray
}
fun encryptData(plaintext: String, cipher: Cipher): EncryptedData {
val ciphertext = cipher.doFinal(plaintext.toByteArray(Charset.forName("UTF-8")))
return EncryptedData(ciphertext,cipher.iv)
}
fun decryptData(ciphertext: ByteArray, cipher: Cipher): String {
val plaintext = cipher.doFinal(ciphertext)
return String(plaintext, Charset.forName("UTF-8"))
}
private fun getCipher(): Cipher {
val transformation = "${KeyProperties.KEY_ALGORITHM_AES}/${KeyProperties.BLOCK_MODE_GCM}/${KeyProperties.ENCRYPTION_PADDING_NONE}"
return Cipher.getInstance(transformation)
}
private fun getSecretKey(keyName: String): SecretKey {
val androidKeystore = "AndroidKeyStore"
val keyStore = KeyStore.getInstance(androidKeystore)
keyStore.load(null)
keyStore.getKey(keyName, null)?.let { return it as SecretKey }
val keyGenParams = KeyGenParameterSpec.Builder(
keyName,
KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT
).apply {
setBlockModes(KeyProperties.BLOCK_MODE_GCM)
setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
setKeySize(256)
setUserAuthenticationRequired(true)
}.build()
val keyGenerator = KeyGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_AES,
androidKeystore
)
keyGenerator.init(keyGenParams)
return keyGenerator.generateKey()
}
}

View File

@ -5,7 +5,6 @@ import android.content.SharedPreferences
import android.net.Uri
import androidx.preference.PreferenceManager
import corewala.buran.Buran
import corewala.buran.R
import java.io.FileNotFoundException
import java.io.IOException
import java.security.KeyStore
@ -19,23 +18,20 @@ class BuranKeyManager(val context: Context, val onKeyError: (error: String) -> U
var lastCallUsedKey = false
//If the user has a key loaded load it here - or else return null
fun getFactory(): KeyManagerFactory? {
val isClientCertActive = prefs.getBoolean(Buran.PREF_KEY_CLIENT_CERT_ACTIVE, false)
return when {
isClientCertActive -> {
fun getFactory(clientCertPassword: String?): KeyManagerFactory? {
return when { !clientCertPassword.isNullOrEmpty() -> {
lastCallUsedKey = true
val keyStore: KeyStore = KeyStore.getInstance("pkcs12")
val uriStr = prefs.getString(Buran.PREF_KEY_CLIENT_CERT_URI, "")
val password = prefs.getString(Buran.PREF_KEY_CLIENT_CERT_PASSWORD, "")
val uri = Uri.parse(uriStr)
try {
context.contentResolver?.openInputStream(uri)?.use {
try {
keyStore.load(it, password?.toCharArray())
keyStore.load(it, clientCertPassword.toCharArray())
val keyManagerFactory: KeyManagerFactory =
KeyManagerFactory.getInstance("X509")
keyManagerFactory.init(keyStore, password?.toCharArray())
keyManagerFactory.init(keyStore, clientCertPassword.toCharArray())
return@use keyManagerFactory
} catch (ioe: IOException) {
onKeyError("${ioe.message}")
@ -53,15 +49,4 @@ class BuranKeyManager(val context: Context, val onKeyError: (error: String) -> U
}
}
}
//Working example with cert packaged with app
fun getFactoryDemo(context: Context): KeyManagerFactory? {
val keyStore: KeyStore = KeyStore.getInstance("pkcs12")
keyStore.load(context.resources.openRawResource(R.raw.cert), "PASSWORD".toCharArray())
val keyManagerFactory: KeyManagerFactory = KeyManagerFactory.getInstance("X509")
keyManagerFactory.init(keyStore, "PASSWORD".toCharArray())
return keyManagerFactory
}
}

View File

@ -0,0 +1,91 @@
package corewala.buran.io.update
import android.app.DownloadManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Context.DOWNLOAD_SERVICE
import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.Build
import android.os.Environment
import androidx.core.content.FileProvider
import corewala.buran.BuildConfig
import corewala.buran.R
import java.io.File
import java.net.HttpURLConnection
import java.net.URL
class BuranUpdates {
fun getLatestVersion(): String {
var latestVersion = BuildConfig.VERSION_NAME
val updateCheckThread = Thread {
val url = "https://github.com/Corewala/Buran/releases/latest"
val con = URL(url).openConnection() as HttpURLConnection
con.connect()
con.getInputStream()
latestVersion = con.getURL().toString().drop(47)
}
updateCheckThread.start()
updateCheckThread.join()
println("Latest version: $latestVersion")
return latestVersion
}
fun installUpdate(context: Context, latestVersion: String){
val updateUrl = "https://github.com/Corewala/Buran/releases/download/$latestVersion/Buran-$latestVersion.apk"
var updateDestination = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).toString() + "/Buran.apk"
val fileUri = Uri.parse("file://$updateDestination")
val packageFile = File(updateDestination)
if(packageFile.exists()){
packageFile.delete()
}
val downloadManager = context.getSystemService(DOWNLOAD_SERVICE) as DownloadManager
val downloadUri = Uri.parse(updateUrl)
val request = DownloadManager.Request(downloadUri)
request.setTitle(context.getString(R.string.app_name))
request.setDescription("")
request.setDestinationUri(fileUri)
request.setMimeType("application/vnd.android.package-archive")
val contentUri = FileProvider.getUriForFile(
context,
BuildConfig.APPLICATION_ID + ".provider",
packageFile
)
val updateDownloadReceiver: BroadcastReceiver = object : BroadcastReceiver(){
override fun onReceive(context: Context, intent: Intent){
val intent = Intent(Intent.ACTION_VIEW)
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
intent.data = contentUri
} else {
val intent = Intent(Intent.ACTION_VIEW)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
intent.setDataAndType(
fileUri,
"application/vnd.android.package-archive"
)
}
println("Installing update")
context.startActivity(intent)
context.unregisterReceiver(this)
}
}
context.registerReceiver(updateDownloadReceiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
downloadManager.enqueue(request)
}
}

View File

@ -6,20 +6,30 @@ import android.content.Intent
import android.content.SharedPreferences
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.text.InputType
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.biometric.BiometricPrompt
import androidx.browser.customtabs.CustomTabsIntent
import androidx.databinding.DataBindingUtil
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar
import corewala.*
import kotlinx.android.synthetic.main.activity_gem.*
import corewala.buran.BuildConfig
import corewala.buran.Buran
import corewala.buran.OmniTerm
import corewala.buran.R
@ -29,14 +39,14 @@ import corewala.buran.io.database.BuranDatabase
import corewala.buran.io.database.bookmarks.BookmarksDatasource
import corewala.buran.io.gemini.Datasource
import corewala.buran.io.gemini.GeminiResponse
import corewala.buran.io.keymanager.BuranBiometricManager
import corewala.buran.io.update.BuranUpdates
import corewala.buran.ui.bookmarks.BookmarkDialog
import corewala.buran.ui.bookmarks.BookmarksDialog
import corewala.buran.ui.content_image.ImageDialog
import corewala.buran.ui.content_text.TextDialog
import corewala.buran.ui.gemtext_adapters.*
import corewala.buran.ui.modals_menus.about.AboutDialog
import corewala.buran.ui.gemtext_adapter.AbstractGemtextAdapter
import corewala.buran.ui.modals_menus.history.HistoryDialog
import corewala.buran.ui.modals_menus.input.InputDialog
import corewala.buran.ui.modals_menus.overflow.OverflowPopup
import corewala.buran.ui.settings.SettingsActivity
import java.io.File
@ -44,6 +54,7 @@ import java.io.FileInputStream
import java.io.FileOutputStream
import java.net.URI
const val CREATE_IMAGE_FILE_REQ = 628
const val CREATE_BINARY_FILE_REQ = 630
const val CREATE_BOOKMARK_EXPORT_FILE_REQ = 631
@ -54,6 +65,7 @@ class GemActivity : AppCompatActivity() {
lateinit var prefs: SharedPreferences
private var inSearch = false
private lateinit var bookmarkDatasource: BookmarksDatasource
private lateinit var db: BuranDatabase
private var bookmarksDialog: BookmarksDialog? = null
private val model by viewModels<GemViewModel>()
@ -61,31 +73,37 @@ class GemActivity : AppCompatActivity() {
private val omniTerm = OmniTerm(object : OmniTerm.Listener {
override fun request(address: String) {
loadingView(true)
model.request(address)
gemRequest(address)
}
override fun openBrowser(address: String) = openWebLink(address)
override fun openExternal(address: String) = openExternalLink(address)
})
lateinit var adapter: AbstractGemtextAdapter
private var certPassword: String? = null
private val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit = { uri, longTap, position: Int ->
private var proxiedAddress: String? = null
private var previousPosition: Int = 0
private var initialised: Boolean = false
private var goingBack: Boolean = false
private lateinit var adapter: AbstractGemtextAdapter
private lateinit var home: String
private lateinit var searchBase: String
private val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit = { uri, longTap, _: Int ->
if(longTap){
loadingView(true)
omniTerm.imageAddress(uri.toString())
omniTerm.uri.let{
model.requestInlineImage(URI.create(it.toString())){ imageUri ->
imageUri?.let{
runOnUiThread {
loadingView(false)
loadImage(position, imageUri)
}
}
}
val globalURI = omniTerm.getGlobalUri(uri.toString())
Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, globalURI)
type = "text/plain"
startActivity(Intent.createChooser(this, null))
}
}else{
//Reset input text hint after user has been searching
if(inSearch) {
@ -97,6 +115,27 @@ class GemActivity : AppCompatActivity() {
}
}
private val inlineImage: (link: URI, adapterPosition: Int) -> Unit = { uri, position: Int ->
if(getInternetStatus()){
omniTerm.imageAddress(uri.toString())
val clientCertPassword = if(isHostSigned(uri)){
certPassword
}else{
null
}
omniTerm.uri.let{
model.requestInlineImage(URI.create(it.toString()), clientCertPassword){ imageUri ->
imageUri?.let{
runOnUiThread {
loadImage(position, imageUri)
loadingView(false)
}
}
}
}
}
}
private fun loadImage(position: Int, uri: Uri) {
adapter.loadImage(position, uri)
}
@ -104,9 +143,6 @@ class GemActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val db = BuranDatabase(applicationContext)
bookmarkDatasource = db.bookmarks()
binding = DataBindingUtil.setContentView(this, R.layout.activity_gem)
binding.viewmodel = model
binding.lifecycleOwner = this
@ -117,28 +153,62 @@ class GemActivity : AppCompatActivity() {
prefs = PreferenceManager.getDefaultSharedPreferences(this)
adapter = when {
prefs.getBoolean("use_large_gemtext_adapter", false) -> AbstractGemtextAdapter.getLargeGmi(onLink)
else -> AbstractGemtextAdapter.getDefault(onLink)
when (prefs.getString("theme", "theme_FollowSystem")) {
"theme_FollowSystem" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
"theme_Light" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
"theme_Dark" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
}
adapter = AbstractGemtextAdapter.getAdapter(onLink, inlineImage)
binding.gemtextRecycler.adapter = adapter
model.initialise(
home = prefs.getString(
home = prefs.getString(
"home_capsule",
Buran.DEFAULT_HOME_CAPSULE
) ?: Buran.DEFAULT_HOME_CAPSULE
if(
!home.startsWith("gemini://")
or home.contains(" ")
or !home.contains(".")
){
home = ""
}
searchBase = prefs.getString(
"search_base",
Buran.DEFAULT_SEARCH_BASE
) ?: Buran.DEFAULT_SEARCH_BASE
if(
!searchBase.startsWith("gemini://")
or searchBase.contains(" ")
or !searchBase.contains(".")
or !searchBase.endsWith("?")
){
searchBase = Buran.DEFAULT_SEARCH_BASE
}
if(getInternetStatus()){
initialise()
}else{
loadingView(false)
val home = PreferenceManager.getDefaultSharedPreferences(this).getString(
"home_capsule",
Buran.DEFAULT_HOME_CAPSULE
) ?: Buran.DEFAULT_HOME_CAPSULE,
gemini = Datasource.factory(this, db.history()),
db = db,
onState = this::handleState
)
)
val title = "# ${this.getString(R.string.no_internet)}"
val text = this.getString(R.string.retry)
omniTerm.set(home!!)
adapter.render(listOf(title, text))
binding.addressEdit.inputType = InputType.TYPE_NULL
}
binding.addressEdit.setOnEditorActionListener { _, actionId, _ ->
when (actionId) {
EditorInfo.IME_ACTION_GO -> {
omniTerm.input(binding.addressEdit.text.toString().trim())
binding.addressEdit.hideKeyboard()
omniTerm.input(binding.addressEdit.text.toString().trim(), searchBase)
binding.addressEdit.clearFocus()
return@setOnEditorActionListener true
}
@ -146,14 +216,15 @@ class GemActivity : AppCompatActivity() {
}
}
binding.addressEdit.setOnFocusChangeListener { v, hasFocus ->
binding.addressEdit.setOnClickListener {
binding.addressEdit.requestFocus()
}
var addressPaddingRight = resources.getDimensionPixelSize(R.dimen.def_address_right_margin)
binding.addressEdit.setOnFocusChangeListener { _, hasFocus ->
if(hasFocus) {
binding.addressEdit.showKeyboard()
focusEnd()
}else{
val addressPaddingRight = resources.getDimensionPixelSize(R.dimen.def_address_right_margin)
if(!hasFocus) {
binding.addressEdit.hideKeyboard()
}
@ -174,6 +245,25 @@ class GemActivity : AppCompatActivity() {
binding.addressEdit.requestFocus()
inSearch = true
}
R.id.overflow_menu_sign -> {
if (prefs.getBoolean("use_biometrics", false) and certPassword.isNullOrEmpty()) {
biometricSecureRequest(binding.addressEdit.text.toString())
}else if(certPassword.isNullOrEmpty()){
if (certPassword.isNullOrEmpty()) {
certPassword = prefs.getString(
Buran.PREF_KEY_CLIENT_CERT_PASSWORD,
null
)
}
refresh()
Toast.makeText(this, this.getString(R.string.cert_loaded), Toast.LENGTH_SHORT).show()
}else{
certPassword = null
refresh()
Toast.makeText(this, this.getString(R.string.cert_unloaded), Toast.LENGTH_SHORT).show()
}
}
R.id.overflow_menu_bookmark -> {
val name = adapter.inferTitle()
BookmarkDialog(
@ -187,7 +277,7 @@ class GemActivity : AppCompatActivity() {
}
R.id.overflow_menu_bookmarks -> {
bookmarksDialog = BookmarksDialog(this, bookmarkDatasource) { bookmark ->
model.request(bookmark.uri.toString())
gemRequest(bookmark.uri.toString())
}
bookmarksDialog?.show()
}
@ -201,29 +291,41 @@ class GemActivity : AppCompatActivity() {
}
R.id.overflow_menu_history -> HistoryDialog.show(
this,
db.history()
db.history(),
omniTerm
) { historyAddress ->
model.request(historyAddress)
gemRequest(historyAddress)
}
R.id.overflow_menu_about -> AboutDialog.show(this)
R.id.overflow_menu_about -> gemRequest("")
R.id.overflow_menu_settings -> {
startActivity(Intent(this, SettingsActivity::class.java))
}
}
}
if(!prefs.getString(Buran.PREF_KEY_CLIENT_CERT_URI, null).isNullOrEmpty()){
OverflowPopup.setItemVisibility(R.id.overflow_menu_sign, true)
if(certPassword.isNullOrEmpty()){
OverflowPopup.setItemTitle(R.id.overflow_menu_sign, getString(R.string.load_cert))
}else{
OverflowPopup.setItemTitle(R.id.overflow_menu_sign, getString(R.string.unload_cert))
}
}else{
OverflowPopup.setItemVisibility(R.id.overflow_menu_sign, false)
}
}
binding.home.setOnClickListener {
val home = PreferenceManager.getDefaultSharedPreferences(this).getString(
"home_capsule",
Buran.DEFAULT_HOME_CAPSULE
)
omniTerm.history.clear()
model.request(home!!)
gemRequest(home, false)
}
binding.pullToRefresh.setOnRefreshListener {
refresh()
if(getInternetStatus()){
refresh()
}else{
binding.pullToRefresh.isRefreshing = false
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
}
}
checkIntentExtras(intent)
@ -233,13 +335,40 @@ class GemActivity : AppCompatActivity() {
omniTerm.getCurrent().run{
binding.addressEdit.setText(this)
focusEnd()
model.request(this)
gemRequest(this)
}
}
override fun onResume() {
super.onResume()
home = prefs.getString(
"home_capsule",
Buran.DEFAULT_HOME_CAPSULE
) ?: Buran.DEFAULT_HOME_CAPSULE
if(
!home.startsWith("gemini://")
or home.contains(" ")
or !home.contains(".")
){
home = ""
}
searchBase = prefs.getString(
"search_base",
Buran.DEFAULT_SEARCH_BASE
) ?: Buran.DEFAULT_SEARCH_BASE
if(
!searchBase.startsWith("gemini://")
or searchBase.contains(" ")
or !searchBase.contains(".")
or !searchBase.endsWith("?")
){
searchBase = Buran.DEFAULT_SEARCH_BASE
}
when {
prefs.contains("background_colour") -> {
when (val backgroundColor = prefs.getString("background_colour", "#XXXXXX")) {
@ -249,60 +378,57 @@ class GemActivity : AppCompatActivity() {
}
}
when {
prefs.getBoolean(
Buran.PREF_KEY_CLIENT_CERT_ACTIVE,
false
) -> {
binding.addressEdit.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.vector_client_cert,
0,
0,
0
)
binding.addressEdit.compoundDrawablePadding = 6.toPx().toInt()
}
else -> hideClientCertShield()
}
val useLargeGmiAdapter = prefs.getBoolean("use_large_gemtext_adapter", false)
when {
useLargeGmiAdapter -> {
if(adapter.typeId != GEMTEXT_ADAPTER_LARGE){
gemtext_recycler.adapter = null
adapter = AbstractGemtextAdapter.getLargeGmi(onLink)
gemtext_recycler.adapter = adapter
refresh()
}
}
else -> {
if(adapter.typeId != GEMTEXT_ADAPTER_DEFAULT) {
gemtext_recycler.adapter = null
adapter = AbstractGemtextAdapter.getDefault(onLink)
gemtext_recycler.adapter = adapter
refresh()
}
}
}
val hideCodeBlocks = prefs.getBoolean(
"collapse_code_blocks",
false
)
adapter.hideCodeBlocks(hideCodeBlocks)
val showInlineIcons = prefs.getBoolean(
"show_inline_icons",
true
)
adapter.inlineIcons(showInlineIcons)
val showLinkButtons = prefs.getBoolean(
"show_link_buttons",
false
)
adapter.linkButtons(showLinkButtons)
model.invalidateDatasource()
val useAttentionGuides = prefs.getBoolean(
"use_attention_guides",
false
)
adapter.attentionGuides(useAttentionGuides)
val showInlineImages = prefs.getBoolean(
"show_inline_images",
true
)
adapter.inlineImages(showInlineImages)
if(getInternetStatus()){
model.invalidateDatasource()
}
}
private fun hideClientCertShield(){
binding.addressEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
private fun updateClientCertIcon(){
if (!prefs.getString(
Buran.PREF_KEY_CLIENT_CERT_URI,
null
).isNullOrEmpty()){
if(certPassword.isNullOrEmpty()){
binding.addressEdit.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
0,
0
)
}else{
binding.addressEdit.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.vector_client_cert,
0,
0,
0
)
}
}
}
private fun handleState(state: GemState) {
@ -310,23 +436,88 @@ class GemActivity : AppCompatActivity() {
when (state) {
is GemState.AppQuery -> runOnUiThread { showAlert("App backdoor/query not implemented yet") }
is GemState.ResponseInput -> runOnUiThread {
val builder = AlertDialog.Builder(this, R.style.AppDialogTheme)
val inflater: LayoutInflater = layoutInflater
val dialogLayout: View = inflater.inflate(R.layout.dialog_input_query, null)
val editText: EditText = dialogLayout.findViewById(R.id.query_input)
editText.requestFocus()
editText.showKeyboard()
loadingView(false)
InputDialog.show(this, state) { queryAddress ->
model.request(queryAddress)
builder
.setTitle(state.header.meta)
.setPositiveButton(getString(R.string.confirm).toUpperCase()){ _, _ ->
gemRequest("${state.uri}?${Uri.encode(editText.text.toString())}")
editText.hideKeyboard()
}
.setNegativeButton(getString(R.string.cancel).toUpperCase()){ _, _ ->
editText.hideKeyboard()
}
.setView(dialogLayout)
.show()
}
is GemState.Redirect -> {
omniTerm.set(state.uri.toString())
gemRequest(omniTerm.getGlobalUri(state.header.meta))
}
is GemState.ClientCertRequired -> runOnUiThread {
loadingView(false)
val builder = AlertDialog.Builder(this, R.style.AppDialogTheme)
builder
.setTitle(getString(R.string.client_certificate_required))
.setMessage(state.header.meta)
if(!prefs.getString(Buran.PREF_KEY_CLIENT_CERT_URI, null).isNullOrEmpty()){
builder
.setPositiveButton(getString(R.string.use_client_certificate).toUpperCase()) { _, _ ->
if(prefs.getBoolean("use_biometrics", false) and certPassword.isNullOrEmpty()){
biometricSecureRequest(state.uri.toString())
}else{
if(certPassword.isNullOrEmpty()){
certPassword = prefs.getString(
Buran.PREF_KEY_CLIENT_CERT_PASSWORD,
null
)
}
gemRequest(state.uri.toString(), true)
Toast.makeText(this, this.getString(R.string.cert_loaded), Toast.LENGTH_SHORT).show()
}
}
.setNegativeButton(getString(R.string.cancel).toUpperCase()) { _, _ -> }
.show()
}else{
builder
.setNegativeButton(getString(R.string.close).toUpperCase()) { _, _ -> }
.show()
}
}
is GemState.Requesting -> loadingView(true)
is GemState.NotGeminiRequest -> externalProtocol(state)
is GemState.Requesting -> {
loadingView(true)
}
is GemState.NotGeminiRequest -> {
externalProtocol(state.uri)
}
is GemState.ResponseError -> {
omniTerm.reset()
showAlert("${GeminiResponse.getCodeString(state.header.code)}:\n\n${state.header.meta}")
}
is GemState.ClientCertError -> {
hideClientCertShield()
certPassword = null
updateClientCertIcon()
showAlert("${GeminiResponse.getCodeString(state.header.code)}:\n\n${state.header.meta}")
}
is GemState.ResponseGemtext -> renderGemtext(state)
is GemState.ResponseGemtext -> {
if(state.uri.scheme != "gemini"){
Snackbar.make(binding.root, getString(R.string.proxied_content), Snackbar.LENGTH_LONG).setAction(getString(R.string.open_original)) {
externalProtocol(state.uri)
}.show()
}
renderGemtext(state)
}
is GemState.ResponseText -> renderText(state)
is GemState.ResponseImage -> renderImage(state)
is GemState.ResponseBinary -> renderBinary(state)
@ -340,28 +531,38 @@ class GemActivity : AppCompatActivity() {
val download = getString(R.string.download)
AlertDialog.Builder(this, R.style.AppDialogTheme)
.setTitle("$download: ${state.header.meta}")
.setMessage("${state.uri}")
.setPositiveButton(getString(R.string.download)) { _, _ ->
loadingView(true)
model.requestBinaryDownload(state.uri)
if(getInternetStatus()) {
val clientCertPassword = if(isHostSigned(state.uri)){
certPassword
}else{
null
}
.setNegativeButton(getString(R.string.cancel)) { _, _ -> }
.show()
AlertDialog.Builder(this, R.style.AppDialogTheme)
.setTitle("$download: ${state.header.meta}")
.setMessage("${state.uri}")
.setPositiveButton(getString(R.string.download).toUpperCase()) { _, _ ->
loadingView(true)
model.requestBinaryDownload(state.uri, clientCertPassword, null)
}
.setNegativeButton(getString(R.string.cancel).toUpperCase()) { _, _ -> }
.show()
}else{
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
}
}
}
is GemState.ResponseUnknownHost -> {
omniTerm.reset()
runOnUiThread {
loadingView(false)
AlertDialog.Builder(this, R.style.AppDialogTheme)
.setTitle(R.string.unknown_host_dialog_title)
.setMessage("Host not found: ${state.uri}\n\nSearch with GUS instead?")
.setPositiveButton(getString(R.string.search)) { _, _ ->
.setTitle(getString(R.string.unknown_host))
.setMessage("${getString(R.string.unknown_host)}: ${state.uri}\n\n${getString(R.string.search_instead)}")
.setPositiveButton(getString(R.string.search).toUpperCase()) { _, _ ->
loadingView(true)
omniTerm.search(state.uri.toString())
omniTerm.search(state.uri.toString(), searchBase)
}
.setNegativeButton(getString(R.string.cancel)) { _, _ -> }
.setNegativeButton(getString(R.string.cancel).toUpperCase()) { _, _ -> }
.show()
}
}
@ -383,23 +584,55 @@ class GemActivity : AppCompatActivity() {
*/
private fun checkIntentExtras(intent: Intent) {
//Via ProcessTextActivity from selected text in another app
if(intent.hasExtra("process_text")){
val processText = intent.getStringExtra("process_text")
binding.addressEdit.setText(processText)
model.request(processText ?: "")
return
}
//From clicking a gemini:// address
val uri = intent.data
if(uri != null){
binding.addressEdit.setText(uri.toString())
model.request(uri.toString())
gemRequest(uri.toString())
return
}
}
private fun biometricSecureRequest(address: String){
val biometricManager = BuranBiometricManager()
val callback = object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
println("Authentication error: $errorCode: $errString")
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
println("Authentication failed")
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
println("Authentication succeeded")
val ciphertext = biometricManager.decodeByteArray(
prefs.getString(
"password_ciphertext",
null
)!!
)
certPassword = biometricManager.decryptData(ciphertext, result.cryptoObject?.cipher!!)
gemRequest(address, true)
Toast.makeText(applicationContext, applicationContext.getString(R.string.cert_loaded), Toast.LENGTH_SHORT).show()
}
}
val initializationVector = biometricManager.decodeByteArray(
prefs.getString(
"password_init_vector",
null
)!!
)
biometricManager.createBiometricPrompt(this, null, this, callback)
biometricManager.authenticateToDecryptData(initializationVector)
}
private fun showAlert(message: String) = runOnUiThread{
loadingView(false)
@ -407,7 +640,7 @@ class GemActivity : AppCompatActivity() {
AlertDialog.Builder(this)
.setTitle(getString(R.string.error))
.setMessage(message)
.setPositiveButton("OK"){ _, _ ->
.setPositiveButton(getString(R.string.close).toUpperCase()){ _, _ ->
}
.show()
@ -416,15 +649,15 @@ class GemActivity : AppCompatActivity() {
}
}
private fun externalProtocol(state: GemState.NotGeminiRequest) = runOnUiThread {
private fun externalProtocol(uri: URI) = runOnUiThread {
loadingView(false)
val uri = state.uri.toString()
val uri = uri.toString()
when {
(uri.startsWith("http://") || uri.startsWith("https://")) -> openWebLink(uri)
(uri.startsWith("http://") || uri.startsWith("https://")) -> openExternalLink(uri)
else -> {
val viewIntent = Intent(Intent.ACTION_VIEW)
viewIntent.data = Uri.parse(state.uri.toString())
viewIntent.data = Uri.parse(uri.toString())
try {
startActivity(viewIntent)
@ -432,7 +665,7 @@ class GemActivity : AppCompatActivity() {
showAlert(
String.format(
getString(R.string.no_app_installed_that_can_open),
state.uri
uri
)
)
}
@ -440,14 +673,24 @@ class GemActivity : AppCompatActivity() {
}
}
private fun openWebLink(address: String){
private fun openExternalLink(address: String){
if(PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
Buran.PREF_KEY_USE_CUSTOM_TAB,
true
)) {
)or !address.startsWith("http")) {
val builder = CustomTabsIntent.Builder()
val intent = builder.build()
intent.launchUrl(this, Uri.parse(address))
try {
intent.launchUrl(this, Uri.parse(address))
}catch (e: ActivityNotFoundException){
showAlert(
String.format(
getString(R.string.no_app_installed_that_can_open),
address
)
)
}
}else{
val viewIntent = Intent(Intent.ACTION_VIEW)
viewIntent.data = Uri.parse(address)
@ -458,18 +701,29 @@ class GemActivity : AppCompatActivity() {
private fun renderGemtext(state: GemState.ResponseGemtext) = runOnUiThread {
loadingView(false)
omniTerm.set(state.uri.toString())
omniTerm.set(proxiedAddress ?: state.uri.toString())
//todo - colours didn't change when switching themes, so disabled for now
//val addressSpan = SpannableString(state.uri.toString())
//addressSpan.set(0, 9, ForegroundColorSpan(resources.getColor(R.color.protocol_address)))
binding.addressEdit.setText(state.uri.toString())
if(!goingBack){
previousPosition = (binding.gemtextRecycler.layoutManager as LinearLayoutManager).findLastVisibleItemPosition()
}
adapter.render(state.lines)
//Scroll to top
binding.gemtextRecycler.post {
binding.gemtextRecycler.scrollToPosition(0)
//Scroll to correct position
if(goingBack){
println("Returning to previous position: $previousPosition")
binding.gemtextRecycler.scrollToPosition(previousPosition)
previousPosition = 0
goingBack = false
}else{
binding.gemtextRecycler.post {
binding.gemtextRecycler.scrollToPosition(0)
}
}
focusEnd()
@ -510,7 +764,7 @@ class GemActivity : AppCompatActivity() {
if(resultCode == RESULT_OK && (requestCode == CREATE_IMAGE_FILE_REQ || requestCode == CREATE_BINARY_FILE_REQ)){
//todo - tidy this mess up... refactor - none of this should be here
if(imageState == null && binaryState == null) return
data?.data?.let{ uri ->
data?.data?.let{ uri ->
val cachedFile = when {
imageState != null -> File(imageState!!.cacheUri.path ?: "")
binaryState != null -> File(binaryState!!.cacheUri.path ?: "")
@ -564,9 +818,151 @@ class GemActivity : AppCompatActivity() {
if(visible) binding.appBar.setExpanded(true)
}
private fun getInternetStatus(): Boolean {
val connectivityManager = this.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
val capabilities = connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
if(capabilities != null){
when {
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> { return true }
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> { return true }
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> { return true }
}
}
}else{
val activeNetworkInfo = connectivityManager.activeNetworkInfo
if(activeNetworkInfo != null && activeNetworkInfo.isConnected){
return true
}
}
return false
}
private fun initialise(){
db = BuranDatabase(applicationContext)
bookmarkDatasource = db.bookmarks()
if(intent.data == null){
model.initialise(
home = home,
gemini = Datasource.factory(this, db.history()),
db = db,
onState = this::handleState
)
if(home.isEmpty()){
loadLocalHome()
}
}else{
model.initialise(
home = intent.data.toString(),
gemini = Datasource.factory(this, db.history()),
db = db,
onState = this::handleState
)
}
if(PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
"check_for_updates",
false
)){
val updates = BuranUpdates()
val latestVersion = updates.getLatestVersion()
if (latestVersion == BuildConfig.VERSION_NAME){
println("No new version available")
} else {
println("New version available")
Snackbar.make(binding.root, getString(R.string.new_version_available), Snackbar.LENGTH_LONG).setAction(getString(R.string.update)) {
updates.installUpdate(this, latestVersion)
}.show()
}
}
initialised = true
}
private fun loadLocalHome(){
loadingView(false)
binding.pullToRefresh.isRefreshing = false
binding.addressEdit.text?.clear()
val title = "# ${getString(R.string.app_name)}"
val sourceLink = "=> https://github.com/Corewala/Buran ${getString(R.string.source)}"
adapter.render(listOf(
title,
"",
getString(R.string.about_body),
"",
getString(R.string.about_ariane_source),
"",
getString(R.string.about_font),
"",
getString(R.string.about_glyphs),
"",
sourceLink,
getString(R.string.copyright)
))
omniTerm.set("")
}
private fun isHostSigned(uri: URI): Boolean{
if((uri.host != omniTerm.getCurrent().toURI().host) && !certPassword.isNullOrEmpty()) {
return false
}
return true
}
private fun gemRequest(address: String, sign: Boolean?){
if(sign == null){
if(!isHostSigned(address.toURI())) certPassword = null
}else if(!sign){
certPassword = null
}
updateClientCertIcon()
if(address.startsWith("http://") or address.startsWith("https://")){
val httpProxy = prefs.getString("http_proxy", null) ?: ""
if(
httpProxy.isNullOrEmpty()
or !httpProxy.startsWith("gemini://")
or httpProxy.contains(" ")
or !httpProxy.contains(".")
){
openExternalLink(address)
}else{
model.request(httpProxy, certPassword, address)
}
}
if(getInternetStatus()){
if(initialised){
if(address.isEmpty()){
loadLocalHome()
}else{
model.request(address, certPassword, null)
}
}else{
initialise()
}
}else{
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
loadingView(false)
}
}
private fun gemRequest(address: String){
gemRequest(address, null)
}
override fun onBackPressed() {
if (omniTerm.canGoBack()){
model.request(omniTerm.goBack())
if(model.isRequesting()){
model.cancel()
loadingView(false)
}else if(omniTerm.canGoBack()){
goingBack = true
gemRequest(omniTerm.goBack())
}else{
println("Buran history is empty - exiting")
super.onBackPressed()
@ -589,7 +985,7 @@ class GemActivity : AppCompatActivity() {
savedInstanceState.getString("uri")?.run {
omniTerm.set(this)
binding.addressEdit.setText(this)
model.request(this)
gemRequest(this)
}
}
}

View File

@ -19,24 +19,34 @@ class GemViewModel: ViewModel() {
this.db = db
this.onState = onState
request(home)
if(home.startsWith("gemini://") and !home.contains(" ")){
request(home, null, null)
}
}
fun request(address: String) {
gemini.request(address){ state ->
fun request(address: String, clientCertPassword: String?, alternativeRequest: String?) {
gemini.request(address, false, clientCertPassword, alternativeRequest){ state ->
onState(state)
}
}
fun requestBinaryDownload(uri: URI) {
gemini.request(uri.toString(), true){ state ->
fun isRequesting(): Boolean{
return gemini.isRequesting()
}
fun cancel(){
gemini.cancel()
}
fun requestBinaryDownload(uri: URI, clientCertPassword: String?, alternativeRequest: String?) {
gemini.request(uri.toString(), true, clientCertPassword, alternativeRequest){ state ->
onState(state)
}
}
//todo - same action as above... refactor
fun requestInlineImage(uri: URI, onImageReady: (cacheUri: Uri?) -> Unit){
gemini.request(uri.toString()){ state ->
fun requestInlineImage(uri: URI, clientCertPassword: String?, onImageReady: (cacheUri: Uri?) -> Unit){
gemini.request(uri.toString(), false, clientCertPassword, null){ state ->
when (state) {
is GemState.ResponseImage -> onImageReady(state.cacheUri)
else -> onState(state)

View File

@ -1,24 +0,0 @@
package corewala.buran.ui
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
class ProcessTextActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val processText = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && intent.hasExtra(Intent.EXTRA_PROCESS_TEXT) -> intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT).toString()
else -> null
}
Intent(this, GemActivity::class.java).run {
putExtra("process_text", processText)
startActivity(this)
finish()
}
}
}

View File

@ -1,20 +1,27 @@
package corewala.buran.ui.content_image
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.view.MenuInflater
import android.view.View
import androidx.appcompat.app.AppCompatDialog
import androidx.appcompat.widget.PopupMenu
import androidx.core.view.forEach
import kotlinx.android.synthetic.main.dialog_content_image.view.*
import corewala.buran.R
import corewala.buran.io.GemState
import corewala.buran.ui.CREATE_BOOKMARK_EXPORT_FILE_REQ
import corewala.buran.ui.CREATE_BOOKMARK_IMPORT_FILE_REQ
import kotlinx.android.synthetic.main.dialog_bookmarks.view.*
import kotlinx.android.synthetic.main.dialog_content_text.view.*
import java.io.FileOutputStream
object ImageDialog {
fun show(context: Context, state: GemState.ResponseImage, onDownloadRequest: (state: GemState.ResponseImage) -> Unit){
val dialog = AppCompatDialog(context, R.style.AppTheme)
val view = View.inflate(context, R.layout.dialog_content_image, null)
@ -22,24 +29,24 @@ object ImageDialog {
view.image_view.setImageURI(state.cacheUri)
view.close_image_content_dialog.setOnClickListener {
view.image_toolbar.setNavigationIcon(R.drawable.vector_close)
view.image_toolbar.setNavigationOnClickListener {
dialog.dismiss()
}
view.image_overflow.setOnClickListener {
val overflowMenu = PopupMenu(context, view.image_overflow)
val inflater: MenuInflater = overflowMenu.menuInflater
inflater.inflate(R.menu.image_overflow_menu, overflowMenu.menu)
overflowMenu.setOnMenuItemClickListener { menuItem ->
if(menuItem.itemId == R.id.image_overflow_save_image){
onDownloadRequest(state)
view.image_toolbar.menu.forEach { menu ->
menu.setOnMenuItemClickListener { item ->
when(item.itemId){
R.id.image_overflow_save_image -> {
onDownloadRequest(state)
}
else -> {
}
}
true
}
overflowMenu.show()
}
dialog.show()
}

View File

@ -6,6 +6,7 @@ import androidx.appcompat.app.AppCompatDialog
import kotlinx.android.synthetic.main.dialog_content_text.view.*
import corewala.buran.R
import corewala.buran.io.GemState
import kotlinx.android.synthetic.main.dialog_bookmarks.view.*
object TextDialog {
@ -17,11 +18,13 @@ object TextDialog {
view.text_content.text = state.content
view.close_text_content_dialog.setOnClickListener {
view.text_toolbar.setNavigationIcon(R.drawable.vector_close)
view.text_toolbar.setNavigationOnClickListener {
dialog.dismiss()
}
dialog.show()
}
}

View File

@ -0,0 +1,33 @@
package corewala.buran.ui.gemtext_adapter
import android.net.Uri
import androidx.recyclerview.widget.RecyclerView
import java.net.URI
abstract class AbstractGemtextAdapter(
val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit,
val inlineImage: (link: URI, adapterPosition: Int) -> Unit
): RecyclerView.Adapter<GmiViewHolder>() {
var showInlineIcons: Boolean = false
var showLinkButtons: Boolean = false
var useAttentionGuides: Boolean = false
var showInlineImages: Boolean = false
abstract fun render(lines: List<String>)
abstract fun loadImage(position: Int, cacheUri: Uri)
abstract fun inlineIcons(visible: Boolean)
abstract fun inlineImages(visible: Boolean)
abstract fun linkButtons(visible: Boolean)
abstract fun attentionGuides(enabled: Boolean)
abstract fun inferTitle(): String?
companion object{
fun getAdapter(
onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit,
inlineImage: (link: URI, adapterPosition: Int) -> Unit
): AbstractGemtextAdapter {
return GemtextAdapter(onLink, inlineImage)
}
}
}

View File

@ -0,0 +1,360 @@
package corewala.buran.ui.gemtext_adapter
import android.annotation.SuppressLint
import android.net.Uri
import android.text.SpannableStringBuilder
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.text.bold
import corewala.buran.R
import corewala.endsWithImage
import corewala.visible
import kotlinx.android.synthetic.main.gemtext_code_block.view.*
import kotlinx.android.synthetic.main.gemtext_image_link.view.*
import kotlinx.android.synthetic.main.gemtext_link.view.gemtext_text_link
import kotlinx.android.synthetic.main.gemtext_quote.view.*
import kotlinx.android.synthetic.main.gemtext_text.view.*
import java.net.URI
class GemtextAdapter(
onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit,
inlineImage: (link: URI, adapterPosition: Int) -> Unit
): AbstractGemtextAdapter(onLink, inlineImage) {
private var lines = mutableListOf<String>()
private var inlineImages = HashMap<Int, Uri>()
private val typeText = 0
private val typeH1 = 1
private val typeH2 = 2
private val typeH3 = 3
private val typeListItem = 4
private val typeImageLink = 5
private val typeLink = 6
private val typeCodeBlock = 7
private val typeQuote = 8
override fun render(lines: List<String>){
this.inlineImages.clear()
this.lines.clear()
this.lines.addAll(lines)
notifyDataSetChanged()
}
private fun inflate(parent: ViewGroup, layout: Int): View{
return LayoutInflater.from(parent.context).inflate(layout, parent, false)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GmiViewHolder {
return when(viewType){
typeText -> GmiViewHolder.Text(inflate(parent, R.layout.gemtext_text))
typeH1 -> GmiViewHolder.H1(inflate(parent, R.layout.gemtext_h1))
typeH2 -> GmiViewHolder.H2(inflate(parent, R.layout.gemtext_h2))
typeH3 -> GmiViewHolder.H3(inflate(parent, R.layout.gemtext_h3))
typeListItem -> GmiViewHolder.ListItem(inflate(parent, R.layout.gemtext_text))
typeImageLink -> GmiViewHolder.ImageLink(inflate(parent, R.layout.gemtext_image_link))
typeLink -> GmiViewHolder.Link(inflate(parent, R.layout.gemtext_link))
typeCodeBlock-> GmiViewHolder.Code(inflate(parent, R.layout.gemtext_code_block))
typeQuote -> GmiViewHolder.Quote(inflate(parent, R.layout.gemtext_quote))
else -> GmiViewHolder.Text(inflate(parent, R.layout.gemtext_text))
}
}
override fun getItemViewType(position: Int): Int {
val line = lines[position]
return when {
line.startsWith("```") -> typeCodeBlock
line.startsWith("###") -> typeH3
line.startsWith("##") -> typeH2
line.startsWith("#") -> typeH1
line.startsWith("*") -> typeListItem
line.startsWith("=>") && getLink(line).endsWithImage() -> typeImageLink
line.startsWith("=>") -> typeLink
line.startsWith(">") -> typeQuote
else -> typeText
}
}
override fun getItemCount(): Int = lines.size
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: GmiViewHolder, position: Int) {
val line = lines[position]
when(holder){
is GmiViewHolder.Text -> {
when {
useAttentionGuides -> holder.itemView.gemtext_text_textview.text = getAttentionGuideText(line)
else -> holder.itemView.gemtext_text_textview.text = line
}
}
is GmiViewHolder.Code -> {
if(line.startsWith("```<|ALT|>")){
holder.itemView.gemtext_text_monospace_textview.text = line.substring(line.indexOf("</|ALT>") + 7)
}else{
holder.itemView.gemtext_text_monospace_textview.text = line.substring(3)
}
}
is GmiViewHolder.Quote -> {
when {
useAttentionGuides -> holder.itemView.gemtext_quote_textview.text = getAttentionGuideText(line.substring(1).trim())
else -> holder.itemView.gemtext_quote_textview.text = line.substring(1).trim()
}
}
is GmiViewHolder.H1 -> {
when {
line.length > 2 -> holder.itemView.gemtext_text_textview.text = line.substring(1).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.H2 -> {
when {
line.length > 3 -> holder.itemView.gemtext_text_textview.text = line.substring(2).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.H3 -> {
when {
line.length > 4 -> holder.itemView.gemtext_text_textview.text = line.substring(3).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.ListItem -> {
when {
useAttentionGuides -> holder.itemView.gemtext_text_textview.text = getAttentionGuideText("${line.substring(1)}".trim())
else -> holder.itemView.gemtext_text_textview.text = "${line.substring(1)}".trim()
}
}
is GmiViewHolder.Link -> {
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
var linkName = linkParts[0]
if(linkParts.size > 1) linkName = linkParts[1]
val displayText = linkName
when {
showLinkButtons -> {
holder.itemView.gemtext_text_link.visible(false)
holder.itemView.gemtext_link_button.visible(true)
holder.itemView.gemtext_link_button.text = displayText
} else -> {
holder.itemView.gemtext_link_button.visible(false)
holder.itemView.gemtext_text_link.visible(true)
holder.itemView.gemtext_text_link.text = displayText
holder.itemView.gemtext_text_link.paint.isUnderlineText = true
}
}
when {
showInlineIcons && linkParts.first().startsWith("http") -> {
holder.itemView.gemtext_text_link.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.vector_open_browser, 0)
holder.itemView.gemtext_link_button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.vector_open_browser, 0)
}
else -> {
holder.itemView.gemtext_text_link.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
holder.itemView.gemtext_link_button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
}
}
when {
showInlineIcons && linkParts.first().startsWith("http") -> holder.itemView.gemtext_text_link.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.vector_open_browser, 0)
else -> holder.itemView.gemtext_text_link.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
}
holder.itemView.gemtext_text_link.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked link: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_text_link.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked link: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
holder.itemView.gemtext_link_button.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked link: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_link_button.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked link: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
}
is GmiViewHolder.ImageLink -> {
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
var linkName = linkParts[0]
if(linkParts.size > 1) linkName = linkParts[1]
val displayText = linkName
when {
showLinkButtons -> {
holder.itemView.gemtext_text_link.visible(false)
holder.itemView.gemtext_link_button.visible(true)
holder.itemView.gemtext_link_button.text = displayText
} else -> {
holder.itemView.gemtext_link_button.visible(false)
holder.itemView.gemtext_text_link.visible(true)
holder.itemView.gemtext_text_link.text = displayText
holder.itemView.gemtext_text_link.paint.isUnderlineText = true
}
}
holder.itemView.gemtext_text_link.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked link: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_text_link.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked link: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
holder.itemView.gemtext_link_button.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked link: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_link_button.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked link: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
holder.itemView.gemtext_inline_image.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked image: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_inline_image.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked image: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
if(("://" !in getLink(lines[holder.adapterPosition])) and showInlineImages){
when {
inlineImages.containsKey(position) -> {
holder.itemView.rounded_image_frame.visible(true)
holder.itemView.gemtext_inline_image.setImageURI(inlineImages[position])
}
else -> {
val uri = getUri(lines[holder.adapterPosition])
println("Inline image rendered: $uri")
inlineImage(uri, holder.adapterPosition)
}
}
}else{
holder.itemView.rounded_image_frame.visible(false)
}
when {
showInlineIcons -> {
holder.itemView.gemtext_text_link.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.vector_photo, 0)
holder.itemView.gemtext_link_button.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.vector_photo, 0)
}
else -> {
holder.itemView.gemtext_text_link.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
holder.itemView.gemtext_link_button.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
}
}
}
}
}
private fun getLink(line: String): String{
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
return linkParts[0]
}
private fun getUri(linkLine: String): URI{
val linkParts = linkLine.substring(2).trim().split("\\s+".toRegex(), 2)
return URI.create(linkParts.first())
}
private fun getAttentionGuideText(text: String): SpannableStringBuilder {
val wordList = text.split(" ")
val attentionGuideText = SpannableStringBuilder()
for(word in wordList){
val wordComponents = word.split("-")
for(component in wordComponents) {
val joiner = if((wordComponents.size > 1) and (wordComponents.indexOf(component) != wordComponents.size - 1)){
"-"
}else{
" "
}
if (component.length > 1) {
if (component.first().isLetterOrDigit()) {
val index = component.length / 2
attentionGuideText
.bold { append(component.substring(0, index)) }
.append("${component.substring(index)}$joiner")
} else {
var offset = 1
if (component.length - offset > 1) {
while ((component.length - offset > 1) and !component.substring(offset).first().isLetterOrDigit()) {
offset += 1
}
val index = (component.length - offset) / 2
attentionGuideText
.append(component.substring(0, offset))
.bold { append(component.substring(offset, index + offset)) }
.append("${component.substring(index + offset)}$joiner")
}else{
attentionGuideText.append("$component$joiner")
}
}
} else {
attentionGuideText.append("$component$joiner")
}
}
}
return attentionGuideText
}
override fun inferTitle(): String? {
lines.forEach { line ->
if(line.startsWith("#")) return line.replace("#", "").trim()
}
return null
}
override fun loadImage(position: Int, cacheUri: Uri){
inlineImages[position] = cacheUri
notifyItemChanged(position)
}
override fun inlineIcons(visible: Boolean){
this.showInlineIcons = visible
notifyDataSetChanged()
}
override fun linkButtons(visible: Boolean){
this.showLinkButtons = visible
notifyDataSetChanged()
}
override fun attentionGuides(enabled: Boolean){
this.useAttentionGuides = enabled
notifyDataSetChanged()
}
override fun inlineImages(visible: Boolean){
this.showInlineImages = visible
notifyDataSetChanged()
}
}

View File

@ -1,4 +1,4 @@
package corewala.buran.ui.gemtext_adapters
package corewala.buran.ui.gemtext_adapter
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,34 +0,0 @@
package corewala.buran.ui.gemtext_adapters
import android.net.Uri
import androidx.recyclerview.widget.RecyclerView
import java.net.URI
const val GEMTEXT_ADAPTER_DEFAULT = 0
const val GEMTEXT_ADAPTER_LARGE = 1
abstract class AbstractGemtextAdapter(
val typeId: Int,
val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit
): RecyclerView.Adapter<GmiViewHolder>() {
var showInlineIcons: Boolean = false
var hideCodeBlocks: Boolean = false
abstract fun render(lines: List<String>)
abstract fun loadImage(position: Int, cacheUri: Uri)
abstract fun inlineIcons(visible: Boolean)
abstract fun hideCodeBlocks(hideCodeBlocks: Boolean)
abstract fun inferTitle(): String?
companion object{
fun getDefault(onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit): AbstractGemtextAdapter {
return DefaultGemtextAdapter(GEMTEXT_ADAPTER_DEFAULT, onLink)
}
fun getLargeGmi(onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit): AbstractGemtextAdapter {
return LargeGemtextAdapter(GEMTEXT_ADAPTER_LARGE, onLink)
}
}
}

View File

@ -1,256 +0,0 @@
package corewala.buran.ui.gemtext_adapters
import android.annotation.SuppressLint
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import kotlinx.android.synthetic.main.gemtext_code_block.view.*
import kotlinx.android.synthetic.main.gemtext_image_link.view.*
import kotlinx.android.synthetic.main.gemtext_link.view.gemtext_text_link
import kotlinx.android.synthetic.main.gemtext_text.view.*
import corewala.buran.R
import corewala.endsWithImage
import corewala.visible
import java.net.URI
class DefaultGemtextAdapter(
typeId: Int,
onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit)
: AbstractGemtextAdapter(typeId, onLink) {
private var lines = mutableListOf<String>()
private var inlineImages = HashMap<Int, Uri>()
private val typeText = 0
private val typeH1 = 1
private val typeH2 = 2
private val typeH3 = 3
private val typeListItem = 4
private val typeImageLink = 5
private val typeLink = 6
private val typeCodeBlock = 7
private val typeQuote = 8
override fun render(lines: List<String>){
this.inlineImages.clear()
this.lines.clear()
this.lines.addAll(lines)
notifyDataSetChanged()
}
private fun inflate(parent: ViewGroup, layout: Int): View{
return LayoutInflater.from(parent.context).inflate(layout, parent, false)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GmiViewHolder {
return when(viewType){
typeText -> GmiViewHolder.Text(inflate(parent, R.layout.gemtext_text))
typeH1 -> GmiViewHolder.H1(inflate(parent, R.layout.gemtext_h1))
typeH2 -> GmiViewHolder.H2(inflate(parent, R.layout.gemtext_h2))
typeH3 -> GmiViewHolder.H3(inflate(parent, R.layout.gemtext_h3))
typeListItem -> GmiViewHolder.ListItem(inflate(parent, R.layout.gemtext_text))
typeImageLink -> GmiViewHolder.ImageLink(inflate(parent, R.layout.gemtext_image_link))
typeLink -> GmiViewHolder.Link(inflate(parent, R.layout.gemtext_link))
typeCodeBlock-> GmiViewHolder.Code(inflate(parent, R.layout.gemtext_code_block))
typeQuote -> GmiViewHolder.Quote(inflate(parent, R.layout.gemtext_quote))
else -> GmiViewHolder.Text(inflate(parent, R.layout.gemtext_text))
}
}
override fun getItemViewType(position: Int): Int {
val line = lines[position]
return when {
line.startsWith("```") -> typeCodeBlock
line.startsWith("###") -> typeH3
line.startsWith("##") -> typeH2
line.startsWith("#") -> typeH1
line.startsWith("*") -> typeListItem
line.startsWith("=>") && getLink(line).endsWithImage() -> typeImageLink
line.startsWith("=>") -> typeLink
line.startsWith(">") -> typeQuote
else -> typeText
}
}
override fun getItemCount(): Int = lines.size
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: GmiViewHolder, position: Int) {
val line = lines[position]
when(holder){
is GmiViewHolder.Text -> holder.itemView.gemtext_text_textview.text = line
is GmiViewHolder.Code -> {
var altText: String? = null
if(line.startsWith("```<|ALT|>")){
//there's alt text: "```<|ALT|>$alt</|ALT>"
altText = line.substring(10, line.indexOf("</|ALT>"))
holder.itemView.gemtext_text_monospace_textview.text = line.substring(line.indexOf("</|ALT>") + 7)
}else{
holder.itemView.gemtext_text_monospace_textview.text = line.substring(3)
}
if(hideCodeBlocks){
holder.itemView.show_code_block.setText(R.string.show_code)//reset for recycling
altText?.let{
holder.itemView.show_code_block.append(": $altText")
}
holder.itemView.show_code_block.visible(true)
holder.itemView.show_code_block.paint.isUnderlineText = true
holder.itemView.show_code_block.setOnClickListener {
setupCodeBlockToggle(holder, altText)
}
holder.itemView.gemtext_text_monospace_textview.visible(false)
when {
showInlineIcons -> holder.itemView.show_code_block.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.vector_code, 0)
else -> holder.itemView.show_code_block.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
}
}else{
holder.itemView.show_code_block.visible(false)
holder.itemView.gemtext_text_monospace_textview.visible(true)
}
}
is GmiViewHolder.Quote -> holder.itemView.gemtext_text_monospace_textview.text = line.substring(1).trim()
is GmiViewHolder.H1 -> {
when {
line.length > 2 -> holder.itemView.gemtext_text_textview.text = line.substring(2).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.H2 -> {
when {
line.length > 3 -> holder.itemView.gemtext_text_textview.text = line.substring(3).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.H3 -> {
when {
line.length > 4 -> holder.itemView.gemtext_text_textview.text = line.substring(4).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.ListItem -> holder.itemView.gemtext_text_textview.text = "${line.substring(1)}".trim()
is GmiViewHolder.Link -> {
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
var linkName = linkParts[0]
if(linkParts.size > 1) linkName = linkParts[1]
val displayText = linkName
holder.itemView.gemtext_text_link.text = displayText
holder.itemView.gemtext_text_link.paint.isUnderlineText = true
when {
showInlineIcons && linkParts.first().startsWith("http") -> holder.itemView.gemtext_text_link.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.vector_open_browser, 0)
else -> holder.itemView.gemtext_text_link.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
}
holder.itemView.gemtext_text_link.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked link: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_text_link.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked link: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
}
is GmiViewHolder.ImageLink -> {
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
var linkName = linkParts[0]
if(linkParts.size > 1) linkName = linkParts[1]
val displayText = linkName
holder.itemView.gemtext_text_link.text = displayText
holder.itemView.gemtext_text_link.paint.isUnderlineText = true
holder.itemView.gemtext_text_link.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked link: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_text_link.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked link: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
when {
inlineImages.containsKey(position) -> {
holder.itemView.gemtext_inline_image.visible(true)
holder.itemView.gemtext_inline_image.setImageURI(inlineImages[position])
}
else -> holder.itemView.gemtext_inline_image.visible(false)
}
when {
showInlineIcons -> holder.itemView.gemtext_text_link.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.vector_photo, 0)
else -> holder.itemView.gemtext_text_link.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
}
}
}
}
private fun setupCodeBlockToggle(holder: GmiViewHolder.Code, altText: String?) {
//val adapterPosition = holder.adapterPosition
when {
holder.itemView.gemtext_text_monospace_textview.isVisible -> {
holder.itemView.show_code_block.setText(R.string.show_code)
holder.itemView.gemtext_text_monospace_textview.visible(false)
altText?.let{
holder.itemView.show_code_block.append(": $altText")
}
}
else -> {
holder.itemView.show_code_block.setText(R.string.hide_code)
holder.itemView.gemtext_text_monospace_textview.visible(true)
altText?.let{
holder.itemView.show_code_block.append(": $altText")
}
}
}
}
private fun getLink(line: String): String{
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
return linkParts[0]
}
private fun getUri(linkLine: String): URI{
val linkParts = linkLine.substring(2).trim().split("\\s+".toRegex(), 2)
return URI.create(linkParts.first())
}
override fun inferTitle(): String? {
lines.forEach { line ->
if(line.startsWith("#")) return line.replace("#", "").trim()
}
return null
}
override fun loadImage(position: Int, cacheUri: Uri){
inlineImages[position] = cacheUri
notifyItemChanged(position)
}
override fun inlineIcons(visible: Boolean){
this.showInlineIcons = visible
notifyDataSetChanged()
}
override fun hideCodeBlocks(hideCodeBlocks: Boolean) {
this.hideCodeBlocks = hideCodeBlocks
notifyDataSetChanged()
}
}

View File

@ -1,253 +0,0 @@
package corewala.buran.ui.gemtext_adapters
import android.annotation.SuppressLint
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import kotlinx.android.synthetic.main.gemtext_large_code_block.view.*
import kotlinx.android.synthetic.main.gemtext_large_image_link.view.*
import kotlinx.android.synthetic.main.gemtext_large_link.view.gemtext_text_link
import kotlinx.android.synthetic.main.gemtext_large_text.view.*
import corewala.buran.R
import corewala.endsWithImage
import corewala.visible
import java.net.URI
class LargeGemtextAdapter(
typeId: Int,
onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit)
: AbstractGemtextAdapter(typeId, onLink) {
private var lines = mutableListOf<String>()
private var inlineImages = HashMap<Int, Uri>()
private val typeText = 0
private val typeH1 = 1
private val typeH2 = 2
private val typeH3 = 3
private val typeListItem = 4
private val typeImageLink = 5
private val typeLink = 6
private val typeCodeBlock = 7
private val typeQuote = 8
override fun render(lines: List<String>){
this.inlineImages.clear()
this.lines.clear()
this.lines.addAll(lines)
notifyDataSetChanged()
}
private fun inflate(parent: ViewGroup, layout: Int): View{
return LayoutInflater.from(parent.context).inflate(layout, parent, false)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GmiViewHolder {
return when(viewType){
typeText -> GmiViewHolder.Text(inflate(parent, R.layout.gemtext_large_text))
typeH1 -> GmiViewHolder.H1(inflate(parent, R.layout.gemtext_large_h1))
typeH2 -> GmiViewHolder.H2(inflate(parent, R.layout.gemtext_large_h2))
typeH3 -> GmiViewHolder.H3(inflate(parent, R.layout.gemtext_large_h3))
typeListItem -> GmiViewHolder.ListItem(inflate(parent, R.layout.gemtext_large_text))
typeImageLink -> GmiViewHolder.ImageLink(inflate(parent, R.layout.gemtext_large_image_link))
typeLink -> GmiViewHolder.Link(inflate(parent, R.layout.gemtext_large_link))
typeCodeBlock-> GmiViewHolder.Code(inflate(parent, R.layout.gemtext_large_code_block))
typeQuote -> GmiViewHolder.Quote(inflate(parent, R.layout.gemtext_large_quote))
else -> GmiViewHolder.Text(inflate(parent, R.layout.gemtext_large_text))
}
}
override fun getItemViewType(position: Int): Int {
val line = lines[position]
return when {
line.startsWith("```") -> typeCodeBlock
line.startsWith("###") -> typeH3
line.startsWith("##") -> typeH2
line.startsWith("#") -> typeH1
line.startsWith("*") -> typeListItem
line.startsWith("=>") && getLink(line).endsWithImage() -> typeImageLink
line.startsWith("=>") -> typeLink
line.startsWith(">") -> typeQuote
else -> typeText
}
}
override fun getItemCount(): Int = lines.size
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: GmiViewHolder, position: Int) {
val line = lines[position]
when(holder){
is GmiViewHolder.Text -> holder.itemView.gemtext_text_textview.text = line
is GmiViewHolder.Code -> {
var altText: String? = null
if(line.startsWith("```<|ALT|>")){
//there's alt text: "```<|ALT|>$alt</|ALT>"
altText = line.substring(10, line.indexOf("</|ALT>"))
holder.itemView.gemtext_text_monospace_textview.text = line.substring(line.indexOf("</|ALT>") + 7)
}else{
holder.itemView.gemtext_text_monospace_textview.text = line.substring(3)
}
if(hideCodeBlocks){
holder.itemView.show_code_block.setText(R.string.show_code)//reset for recycling
altText?.let{
holder.itemView.show_code_block.append(": $altText")
}
holder.itemView.show_code_block.visible(true)
holder.itemView.show_code_block.setOnClickListener {
setupCodeBlockToggle(holder, altText)
}
holder.itemView.gemtext_text_monospace_textview.visible(false)
when {
showInlineIcons -> holder.itemView.show_code_block.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.vector_code, 0)
else -> holder.itemView.show_code_block.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
}
}else{
holder.itemView.show_code_block.visible(false)
holder.itemView.gemtext_text_monospace_textview.visible(true)
}
}
is GmiViewHolder.Quote -> holder.itemView.gemtext_text_monospace_textview.text = line.substring(1).trim()
is GmiViewHolder.H1 -> {
when {
line.length > 2 -> holder.itemView.gemtext_text_textview.text = line.substring(2).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.H2 -> {
when {
line.length > 3 -> holder.itemView.gemtext_text_textview.text = line.substring(3).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.H3 -> {
when {
line.length > 4 -> holder.itemView.gemtext_text_textview.text = line.substring(4).trim()
else -> holder.itemView.gemtext_text_textview.text = ""
}
}
is GmiViewHolder.ListItem -> holder.itemView.gemtext_text_textview.text = "${line.substring(1)}".trim()
is GmiViewHolder.Link -> {
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
var linkName = linkParts[0]
if(linkParts.size > 1) linkName = linkParts[1]
val displayText = linkName
holder.itemView.gemtext_text_link.text = displayText
when {
showInlineIcons && linkParts.first().startsWith("http") -> holder.itemView.gemtext_text_link.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.vector_open_browser, 0)
else -> holder.itemView.gemtext_text_link.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
}
holder.itemView.gemtext_text_link.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked link: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_text_link.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked link: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
}
is GmiViewHolder.ImageLink -> {
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
var linkName = linkParts[0]
if(linkParts.size > 1) linkName = linkParts[1]
val displayText = linkName
holder.itemView.gemtext_text_link.text = displayText
holder.itemView.gemtext_text_link.setOnClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User clicked link: $uri")
onLink(uri, false, holder.adapterPosition)
}
holder.itemView.gemtext_text_link.setOnLongClickListener {
val uri = getUri(lines[holder.adapterPosition])
println("User long-clicked link: $uri")
onLink(uri, true, holder.adapterPosition)
true
}
when {
inlineImages.containsKey(position) -> {
holder.itemView.gemtext_inline_image.visible(true)
holder.itemView.gemtext_inline_image.setImageURI(inlineImages[position])
}
else -> holder.itemView.gemtext_inline_image.visible(false)
}
when {
showInlineIcons -> holder.itemView.gemtext_text_link.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.vector_photo, 0)
else -> holder.itemView.gemtext_text_link.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
}
}
}
}
private fun setupCodeBlockToggle(holder: GmiViewHolder.Code, altText: String?) {
//val adapterPosition = holder.adapterPosition
when {
holder.itemView.gemtext_text_monospace_textview.isVisible -> {
holder.itemView.show_code_block.setText(R.string.show_code)
holder.itemView.gemtext_text_monospace_textview.visible(false)
altText?.let{
holder.itemView.show_code_block.append(": $altText")
}
}
else -> {
holder.itemView.show_code_block.setText(R.string.hide_code)
holder.itemView.gemtext_text_monospace_textview.visible(true)
altText?.let{
holder.itemView.show_code_block.append(": $altText")
}
}
}
}
private fun getLink(line: String): String{
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
return linkParts[0]
}
private fun getUri(linkLine: String): URI{
val linkParts = linkLine.substring(2).trim().split("\\s+".toRegex(), 2)
return URI.create(linkParts.first())
}
override fun inferTitle(): String? {
lines.forEach { line ->
if(line.startsWith("#")) return line.replace("#", "").trim()
}
return null
}
override fun loadImage(position: Int, cacheUri: Uri){
inlineImages[position] = cacheUri
notifyItemChanged(position)
}
override fun inlineIcons(visible: Boolean){
this.showInlineIcons = visible
notifyDataSetChanged()
}
override fun hideCodeBlocks(hideCodeBlocks: Boolean) {
this.hideCodeBlocks = hideCodeBlocks
notifyDataSetChanged()
}
}

View File

@ -1,34 +0,0 @@
package corewala.buran.ui.modals_menus
import android.view.MenuInflater
import android.view.View
import androidx.appcompat.widget.PopupMenu
import corewala.buran.R
import corewala.endsWithImage
import corewala.isWeb
import java.net.URI
object LinkPopup {
fun show(view: View?, uri: URI, onMenuOption: (menuId: Int) -> Unit){
if(view != null) {
val popup = PopupMenu(view.context, view)
val inflater: MenuInflater = popup.menuInflater
val uriStr = uri.toString()
when {
uriStr.endsWithImage() && !uriStr.isWeb() -> inflater.inflate(R.menu.image_link_menu, popup.menu)
else -> inflater.inflate(R.menu.link_menu, popup.menu)
}
popup.setOnMenuItemClickListener { menuItem ->
onMenuOption(menuItem.itemId)
true
}
popup.show()
}
}
}

View File

@ -1,43 +0,0 @@
package corewala.buran.ui.modals_menus.about
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Handler
import android.os.Looper
import android.view.View
import androidx.appcompat.app.AppCompatDialog
import androidx.appcompat.widget.AppCompatTextView
import kotlinx.android.synthetic.main.dialog_about.view.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import corewala.buran.R
import java.lang.StringBuilder
import java.security.SecureRandom
import java.security.Security
import javax.net.ssl.SSLContext
import javax.net.ssl.SSLSocket
import javax.net.ssl.SSLSocketFactory
object AboutDialog {
fun show(context: Context){
val dialog = AppCompatDialog(context, R.style.AppTheme)
val view = View.inflate(context, R.layout.dialog_about, null)
dialog.setContentView(view)
view.close_tab_dialog.setOnClickListener {
dialog.dismiss()
}
view.source_button.setOnClickListener {
context.startActivity(Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse("https://github.com/Corewala/Buran")
})
}
dialog.show()
}
}

View File

@ -3,49 +3,53 @@ package corewala.buran.ui.modals_menus.history
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.view.MenuInflater
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatDialog
import androidx.appcompat.widget.PopupMenu
import androidx.core.view.MenuCompat
import androidx.core.view.forEach
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.dialog_about.view.close_tab_dialog
import corewala.buran.OmniTerm
import kotlinx.android.synthetic.main.dialog_history.view.*
import corewala.buran.R
import corewala.buran.io.database.history.BuranHistory
object HistoryDialog {
fun show(context: Context, history: BuranHistory, onHistoryItem: (address: String) -> Unit){
fun show(context: Context, history: BuranHistory, omniTerm: OmniTerm, onHistoryItem: (address: String) -> Unit){
val dialog = AppCompatDialog(context, R.style.AppTheme)
val view = View.inflate(context, R.layout.dialog_history, null)
dialog.setContentView(view)
view.close_tab_dialog.setOnClickListener {
view.history_toolbar.setNavigationIcon(R.drawable.vector_close)
view.history_toolbar.setNavigationOnClickListener {
dialog.dismiss()
}
view.history_overflow.setOnClickListener {
val popup = PopupMenu(view.context, view.history_overflow)
val inflater: MenuInflater = popup.menuInflater
inflater.inflate(R.menu.history_overflow_menu, popup.menu)
popup.setOnMenuItemClickListener { menuItem ->
if(menuItem.itemId == R.id.history_overflow_clear_history){
history.clear {
Handler(Looper.getMainLooper()).post {
dialog.dismiss()
Toast.makeText(context, context.getString(R.string.history_cleared), Toast.LENGTH_SHORT).show()
view.history_toolbar.menu.forEach { menu ->
menu.setOnMenuItemClickListener { item ->
when(item.itemId){
R.id.menu_action_clear_history -> {
history.clear {
Handler(Looper.getMainLooper()).post {
Toast.makeText(context, context.getString(R.string.history_cleared), Toast.LENGTH_SHORT).show()
}
}
}
}else if(menuItem.itemId == R.id.history_overflow_clear_runtime_cache){
dialog.dismiss()
Toast.makeText(context, context.getString(R.string.runtime_cache_cleared), Toast.LENGTH_SHORT).show()
R.id.menu_action_clear_runtime_cache -> {
omniTerm.clearCache()
Toast.makeText(context, context.getString(R.string.runtime_cache_cleared), Toast.LENGTH_SHORT).show()
}
else -> {
}
}
true
}
MenuCompat.setGroupDividerEnabled(popup.menu, true)
popup.show()
}
view.history_toolbar.setOnMenuItemClickListener { _ ->
true
}
view.history_recycler.layoutManager = LinearLayoutManager(context)

View File

@ -1,33 +0,0 @@
package corewala.buran.ui.modals_menus.input
import android.content.Context
import android.view.View
import androidx.appcompat.app.AppCompatDialog
import kotlinx.android.synthetic.main.dialog_input_query.view.*
import corewala.buran.R
import corewala.buran.io.GemState
import java.net.URLEncoder
object InputDialog {
fun show(context: Context, state: GemState.ResponseInput, onQuery: (queryAddress: String) -> Unit) {
val dialog = AppCompatDialog(context, R.style.AppTheme)
val view = View.inflate(context, R.layout.dialog_input_query, null)
dialog.setContentView(view)
view.close_input_query_dialog.setOnClickListener {
dialog.dismiss()
}
view.query_text.text = state.header.meta
view.query_submit_button.setOnClickListener {
val encoded = URLEncoder.encode(view.query_input.text.toString(), "UTF-8")
onQuery("${state.uri}?$encoded")
dialog.dismiss()
}
dialog.show()
}
}

View File

@ -16,9 +16,11 @@ import corewala.buran.R
object OverflowPopup {
lateinit var popup: PopupMenu
fun show(view: View?, onMenuOption: (menuId: Int) -> Unit){
if(view != null) {
val popup = PopupMenu(view.context, view)
popup = PopupMenu(view.context, view)
val inflater: MenuInflater = popup.menuInflater
inflater.inflate(R.menu.overflow_menu, popup.menu)
popup.setOnMenuItemClickListener { menuItem ->
@ -31,6 +33,14 @@ object OverflowPopup {
}
}
fun setItemTitle(id: Int, title: String){
popup.menu.findItem(id).title = title
}
fun setItemVisibility(id: Int, visible: Boolean){
popup.menu.findItem(id).isVisible = visible
}
fun insertMenuItemIcons(context: Context, popupMenu: PopupMenu) {
val menu: Menu = popupMenu.menu
if (hasIcon(menu)) {

View File

@ -4,17 +4,20 @@ import android.app.Activity.RESULT_OK
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.OpenableColumns
import android.view.inputmethod.EditorInfo
import androidx.appcompat.app.AppCompatDelegate
import androidx.biometric.BiometricPrompt
import androidx.preference.*
import corewala.buran.Buran
import corewala.buran.R
import corewala.buran.io.keymanager.BuranBiometricManager
const val PREFS_SET_CLIENT_CERT_REQ = 20
@ -23,7 +26,6 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
lateinit var prefs: SharedPreferences
private lateinit var clientCertPref: Preference
private lateinit var useClientCertPreference: SwitchPreferenceCompat
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
@ -49,14 +51,35 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
val homecapsule = preferenceManager.sharedPreferences.getString(
"home_capsule",
Buran.DEFAULT_HOME_CAPSULE
)
)?.trim()
homePreference.summary = if(homecapsule.isNullOrEmpty()){
context.getString(R.string.no_home_capsule_set)
}else if(
!homecapsule.startsWith("gemini://")
or homecapsule.contains(" ")
or !homecapsule.contains(".")
){
context.getString(R.string.not_valid_address)
}else{
homecapsule
}
homePreference.summary = homecapsule
homePreference.positiveButtonText = getString(R.string.update)
homePreference.negativeButtonText = getString(R.string.cancel)
homePreference.title = getString(R.string.home_capsule)
homePreference.setOnPreferenceChangeListener { _, newValue ->
homePreference.summary = newValue.toString()
val newHomecapsule = newValue.toString().trim()
homePreference.summary = if(newHomecapsule.isNullOrEmpty()){
context.getString(R.string.no_home_capsule_set)
}else if(
!newHomecapsule.startsWith("gemini://")
or newHomecapsule.contains(" ")
or !newHomecapsule.contains(".")
){
context.getString(R.string.not_valid_address)
}else{
newHomecapsule
}
true
}
homePreference.setOnBindEditTextListener{ editText ->
@ -65,8 +88,72 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
}
appCategory.addPreference(homePreference)
//Home - Certificates
buildClientCertificateSection(context, appCategory)
//Search ---------------------------------------------
val searchPreference = EditTextPreference(context)
searchPreference.title = getString(R.string.search_engine)
searchPreference.key = "search_base"
searchPreference.dialogTitle = getString(R.string.search_base)
val searchengine = preferenceManager.sharedPreferences.getString(
"search_base",
Buran.DEFAULT_SEARCH_BASE
)?.trim()
searchPreference.summary = if(searchengine.isNullOrEmpty()){
Buran.DEFAULT_SEARCH_BASE
}else if(
!searchengine.startsWith("gemini://")
or searchengine.contains(" ")
or !searchengine.contains(".")
){
context.getString(R.string.not_valid_address)
}else if(!searchengine.endsWith("?")){
context.getString(R.string.not_valid_search_string)
}else{
searchengine
}
searchPreference.positiveButtonText = getString(R.string.update)
searchPreference.negativeButtonText = getString(R.string.cancel)
searchPreference.setOnPreferenceChangeListener { _, newValue ->
val newSearchBase = newValue.toString().trim()
searchPreference.summary = if(newSearchBase.isNullOrEmpty()){
Buran.DEFAULT_SEARCH_BASE
}else if(
!newSearchBase.startsWith("gemini://")
or newSearchBase.contains(" ")
or !newSearchBase.contains(".")
){
context.getString(R.string.not_valid_address)
}else if(!newSearchBase.endsWith("?")){
context.getString(R.string.not_valid_search_string)
}else{
newSearchBase
}
true
}
searchPreference.setOnBindEditTextListener{ editText ->
editText.imeOptions = EditorInfo.IME_ACTION_DONE
editText.setSelection(editText.text.toString().length)//Set caret position to end
}
appCategory.addPreference(searchPreference)
//Updates ---------------------------------------------
val sideloadedHashCode = -899861527
val isSideloaded = context.packageManager.getPackageInfo(
context.packageName,
PackageManager.GET_SIGNATURES
).signatures[0].hashCode() == sideloadedHashCode
val checkForUpdates = SwitchPreferenceCompat(context)
checkForUpdates.setDefaultValue(false)
checkForUpdates.key = "check_for_updates"
checkForUpdates.title = getString(R.string.check_for_updates)
checkForUpdates.isVisible = isSideloaded
appCategory.addPreference(checkForUpdates)
//Certificates
buildClientCertificateSection(context, screen)
//Appearance --------------------------------------------
buildAppearanceSection(context, appCategory)
@ -98,6 +185,56 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
useCustomTabsPreference.title = getString(R.string.web_content_switch_label)
webCategory.addPreference(useCustomTabsPreference)
val showInlineImages = SwitchPreferenceCompat(context)
showInlineImages.setDefaultValue(false)
showInlineImages.key = "show_inline_images"
showInlineImages.title = getString(R.string.show_inline_images)
webCategory.addPreference(showInlineImages)
val httpGeminiProxy = EditTextPreference(context)
httpGeminiProxy.title = getString(R.string.http_proxy)
httpGeminiProxy.key = "http_proxy"
httpGeminiProxy.dialogTitle = getString(R.string.http_proxy)
val httpProxy = preferenceManager.sharedPreferences.getString(
"http_proxy",
null
)?.trim()
httpGeminiProxy.summary = if(httpProxy.isNullOrEmpty()){
getString(R.string.no_http_proxy_set)
}else if(
!httpProxy.startsWith("gemini://")
or httpProxy.contains(" ")
or !httpProxy.contains(".")
){
getString(R.string.not_valid_address)
}else{
httpProxy
}
httpGeminiProxy.positiveButtonText = getString(R.string.update)
httpGeminiProxy.negativeButtonText = getString(R.string.cancel)
httpGeminiProxy.setOnPreferenceChangeListener { _, newValue ->
val newHomecapsule = newValue.toString().trim()
httpGeminiProxy.summary = if(newHomecapsule.isNullOrEmpty()){
getString(R.string.no_http_proxy_set)
}else if(
!newHomecapsule.startsWith("gemini://")
or newHomecapsule.contains(" ")
or !newHomecapsule.contains(".")
){
getString(R.string.not_valid_address)
}else{
newHomecapsule
}
true
}
httpGeminiProxy.setOnBindEditTextListener{ editText ->
editText.imeOptions = EditorInfo.IME_ACTION_DONE
editText.setSelection(editText.text.toString().length)//Set caret position to end
}
webCategory.addPreference(httpGeminiProxy)
}
private fun buildAppearanceSection(context: Context?, appCategory: PreferenceCategory) {
@ -173,106 +310,167 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
accessibilityCategory.title = getString(R.string.accessibility)
screen.addPreference(accessibilityCategory)
//Accessibility - code blocks
val aboutCodeBlocksPref = Preference(context)
aboutCodeBlocksPref.summary = getString(R.string.collapse_code_blocks_about)
aboutCodeBlocksPref.isPersistent = false
aboutCodeBlocksPref.isSelectable = false
accessibilityCategory.addPreference(aboutCodeBlocksPref)
val collapseCodeBlocksPreference = SwitchPreferenceCompat(context)
collapseCodeBlocksPreference.key = "collapse_code_blocks"
collapseCodeBlocksPreference.title = getString(R.string.collapse_code_blocks)
accessibilityCategory.addPreference(collapseCodeBlocksPreference)
//Accessibility - large text and buttons
val largeGemtextPreference = SwitchPreferenceCompat(context)
largeGemtextPreference.key = "use_large_gemtext_adapter"
largeGemtextPreference.title = getString(R.string.large_gemtext_and_button)
accessibilityCategory.addPreference(largeGemtextPreference)
//Accessibility - inline icons
val showInlineIconsPreference = SwitchPreferenceCompat(context)
showInlineIconsPreference.setDefaultValue(true)
showInlineIconsPreference.key = "show_inline_icons"
showInlineIconsPreference.title = getString(R.string.show_inline_icons)
accessibilityCategory.addPreference(showInlineIconsPreference)
//Accessibility - full-width buttons
val showLinkButtonsPreference = SwitchPreferenceCompat(context)
showLinkButtonsPreference.setDefaultValue(false)
showLinkButtonsPreference.key = "show_link_buttons"
showLinkButtonsPreference.title = getString(R.string.show_link_buttons)
accessibilityCategory.addPreference(showLinkButtonsPreference)
//Accessibility - gemtext attention guides
val attentionGuidingText = SwitchPreferenceCompat(context)
attentionGuidingText.setDefaultValue(false)
attentionGuidingText.key = "use_attention_guides"
attentionGuidingText.title = getString(R.string.use_attention_guides)
accessibilityCategory.addPreference(attentionGuidingText)
}
private fun buildClientCertificateSection(context: Context?, appCategory: PreferenceCategory) {
if (Buran.FEATURE_CLIENT_CERTS) {
private fun buildClientCertificateSection(context: Context?, screen: PreferenceScreen) {
val aboutPref = Preference(context)
aboutPref.key = "unused_pref"
aboutPref.summary = getString(R.string.pkcs_notice)
aboutPref.isPersistent = false
aboutPref.isSelectable = false
appCategory.addPreference(aboutPref)
val certificateCategory = PreferenceCategory(context)
certificateCategory.key = "certificate_category"
certificateCategory.title = getString(R.string.client_certificate)
screen.addPreference(certificateCategory)
clientCertPref = Preference(context)
clientCertPref.title = getString(R.string.client_certificate)
clientCertPref.key = Buran.PREF_KEY_CLIENT_CERT_HUMAN_READABLE
val aboutPref = Preference(context)
aboutPref.summary = getString(R.string.pkcs_notice)
aboutPref.isPersistent = false
aboutPref.isSelectable = false
certificateCategory.addPreference(aboutPref)
val clientCertUriHumanReadable = preferenceManager.sharedPreferences.getString(
Buran.PREF_KEY_CLIENT_CERT_HUMAN_READABLE,
null
)
clientCertPref = Preference(context)
clientCertPref.title = getString(R.string.client_certificate)
clientCertPref.key = Buran.PREF_KEY_CLIENT_CERT_HUMAN_READABLE
val hasCert = clientCertUriHumanReadable != null
if (!hasCert) {
clientCertPref.summary = getString(R.string.tap_to_select_client_certificate)
} else {
clientCertPref.summary = clientCertUriHumanReadable
val clientCertUriHumanReadable = preferenceManager.sharedPreferences.getString(
Buran.PREF_KEY_CLIENT_CERT_HUMAN_READABLE,
null
)
val hasCert = clientCertUriHumanReadable != null
if (!hasCert) {
clientCertPref.summary = getString(R.string.tap_to_select_client_certificate)
} else {
clientCertPref.summary = clientCertUriHumanReadable
}
clientCertPref.setOnPreferenceClickListener {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
type = "application/x-pkcs12"
}
startActivityForResult(intent, PREFS_SET_CLIENT_CERT_REQ)
true
}
clientCertPref.setOnPreferenceClickListener {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
type = "*/*"
certificateCategory.addPreference(clientCertPref)
val clientCertPassword = EditTextPreference(context)
clientCertPassword.key = Buran.PREF_KEY_CLIENT_CERT_PASSWORD
clientCertPassword.title = getString(R.string.client_certificate_password)
var certPassword = preferenceManager.sharedPreferences.getString(
Buran.PREF_KEY_CLIENT_CERT_PASSWORD,
null
)
clientCertPassword.dialogTitle = getString(R.string.client_certificate_password)
if (certPassword != null && certPassword.isNotEmpty()) {
clientCertPassword.summary = getDots(certPassword)
} else {
clientCertPassword.summary = getString(R.string.no_password)
}
clientCertPassword.isVisible = !preferenceManager.sharedPreferences.getBoolean("use_biometrics", false)
certificateCategory.addPreference(clientCertPassword)
val useBiometrics = SwitchPreferenceCompat(context)
useBiometrics.setDefaultValue(false)
useBiometrics.key = "use_biometrics"
useBiometrics.title = getString(R.string.biometric_cert_verification)
useBiometrics.isVisible = false
certificateCategory.addPreference(useBiometrics)
val passwordCiphertext = EditTextPreference(context)
passwordCiphertext.key = "password_ciphertext"
passwordCiphertext.isVisible = false
certificateCategory.addPreference(passwordCiphertext)
val passwordInitVector = EditTextPreference(context)
passwordInitVector.key = "password_init_vector"
passwordInitVector.isVisible = false
certificateCategory.addPreference(passwordInitVector)
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
useBiometrics.isVisible = (certPassword?.isNotEmpty() ?: false) or useBiometrics.isChecked
useBiometrics.setOnPreferenceChangeListener { _, newValue ->
val biometricManager = BuranBiometricManager()
val callback = object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
println("Authentication error: $errorCode: $errString")
useBiometrics.isChecked = !(newValue as Boolean)
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
println("Authentication failed")
useBiometrics.isChecked = !(newValue as Boolean)
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
println("Authentication succeeded")
if(newValue as Boolean){
println(certPassword)
val encryptedData = biometricManager.encryptData(certPassword!!, result.cryptoObject?.cipher!!)
val ciphertext = encryptedData.ciphertext
val initializationVector = encryptedData.initializationVector
passwordInitVector.text = initializationVector.contentToString()
passwordCiphertext.text = ciphertext.contentToString()
clientCertPassword.text = null
}else{
val ciphertext = biometricManager.decodeByteArray(passwordCiphertext.text)
clientCertPassword.text = biometricManager.decryptData(ciphertext, result.cryptoObject?.cipher!!)
clientCertPassword.summary = getDots(clientCertPassword.text)
}
clientCertPassword.isVisible = !(newValue as Boolean)
clientCertPref.isEnabled = !(newValue as Boolean)
}
}
startActivityForResult(intent, PREFS_SET_CLIENT_CERT_REQ)
biometricManager.createBiometricPrompt(requireContext(), this, null, callback)
if(newValue as Boolean){
biometricManager.authenticateToEncryptData()
}else{
val initializationVector = biometricManager.decodeByteArray(passwordInitVector.text)
biometricManager.authenticateToDecryptData(initializationVector)
}
true
}
}
appCategory.addPreference(clientCertPref)
val clientCertPassword = EditTextPreference(context)
clientCertPassword.key = Buran.PREF_KEY_CLIENT_CERT_PASSWORD
clientCertPassword.title = getString(R.string.client_certificate_password)
val certPasword = preferenceManager.sharedPreferences.getString(
Buran.PREF_KEY_CLIENT_CERT_PASSWORD,
null
)
if (certPasword != null && certPasword.isNotEmpty()) {
clientCertPassword.summary = getDots(certPasword)
} else {
clientCertPassword.setOnPreferenceChangeListener { _, newValue ->
val passphrase = "$newValue"
if (passphrase.isEmpty()) {
clientCertPassword.summary = getString(R.string.no_password)
useBiometrics.isVisible = false
} else {
clientCertPassword.summary = getDots(passphrase)
useBiometrics.isVisible = true
}
clientCertPassword.dialogTitle = getString(R.string.client_certificate_password)
clientCertPassword.setOnPreferenceChangeListener { _, newValue ->
val passphrase = "$newValue"
if (passphrase.isEmpty()) {
clientCertPassword.summary = getString(R.string.no_password)
} else {
clientCertPassword.summary = getDots(passphrase)
}
true//update the value
}
appCategory.addPreference(clientCertPassword)
useClientCertPreference = SwitchPreferenceCompat(context)
useClientCertPreference.key = Buran.PREF_KEY_CLIENT_CERT_ACTIVE
useClientCertPreference.title = getString(R.string.use_client_certificate)
appCategory.addPreference(useClientCertPreference)
if (!hasCert) {
useClientCertPreference.isVisible = false
}
certPassword = passphrase
true//update the value
}
}
@ -298,7 +496,6 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
persistPermissions(uri)
findFilename(uri)
}
}
super.onActivityResult(requestCode, resultCode, data)
}
@ -326,6 +523,5 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
readableReference
).apply()
clientCertPref.summary = readableReference
useClientCertPreference.isChecked = true
}
}

View File

@ -2,5 +2,5 @@
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="1.0dip" android:color="#ffcccccc" />
<corners android:radius="12.0dip" />
<corners android:radius="@dimen/default_margin_big" />
</shape>

View File

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">

View File

@ -33,59 +33,59 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin">
android:layout_marginTop="0dp">
<RelativeLayout android:id="@+id/address_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/default_margin">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/default_margin">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/home"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_centerVertical="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_home" />
android:id="@+id/home"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_home"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/home"
android:layout_toStartOf="@+id/more">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/address_edit"
android:background="@drawable/drawable_filled_rounded_rect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:drawablePadding="4dp"
android:inputType="textNoSuggestions|textUri"
android:singleLine="true"
android:textSize="12sp"
android:imeOptions="actionGo"
android:hint="@string/main_input_hint" />
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/home"
android:layout_toStartOf="@+id/more">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/address_edit"
android:background="@drawable/drawable_filled_rounded_rect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:drawablePadding="4dp"
android:inputType="textNoSuggestions|textUri"
android:singleLine="true"
android:textSize="12sp"
android:imeOptions="actionGo"
android:hint="@string/main_input_hint"/>
</RelativeLayout>
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/more"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_overflow" />
android:id="@+id/more"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_overflow"/>
</RelativeLayout>

View File

@ -15,7 +15,7 @@
android:layout_height="wrap_content"
tools:text="My Homepage"
android:layout_toLeftOf="@+id/bookmark_overflow"
android:textColor="@color/vibrant_stroke"
android:textColor="@color/stroke"
android:textSize="@dimen/text_large" />
<androidx.appcompat.widget.AppCompatTextView

View File

@ -1,115 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/default_margin">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/close_tab_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_close" />
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/default_margin_big"
android:paddingRight="@dimen/default_margin_big"
android:paddingBottom="@dimen/default_margin_big"
android:orientation="vertical">
<!-- Description -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/default_margin_big"
android:textColor="@color/stroke"
android:text="@string/about_body"/>
<!-- Version -->
<TextView
android:id="@+id/version_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/stroke"
tools:text="1.0.0 alpha delta"/>
<!-- Copyright -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/default_margin"
android:textColor="@color/stroke"
android:text="@string/copyright"/>
<!-- Source button -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/source_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Source"/>
<!-- DIV -->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/default_margin"
android:layout_marginTop="@dimen/default_margin"
android:alpha="0.5"
android:background="?attr/colorOnSurface" />
<!-- Ariane source attribution-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/default_margin"
android:textColor="@color/stroke"
android:text="@string/about_ariane_source"/>
<!-- Font Attribution -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/default_margin"
android:textColor="@color/stroke"
android:text="@string/about_font"/>
<!-- Glyph Attribution -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/default_margin"
android:textColor="@color/stroke"
android:text="@string/about_glyphs"/>
<!-- DIV -->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/default_margin"
android:layout_marginTop="@dimen/default_margin"
android:alpha="0.5"
android:background="?attr/colorOnSurface" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>

View File

@ -1,54 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.Toolbar
android:id="@+id/bookmarks_toolbar"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_margin"
android:layout_height="@dimen/bar_height"
app:menu="@menu/bookmark_import_export"
app:menu="@menu/bookmark_overflow_menu"
app:title="@string/bookmarks"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/bookmarks_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bookmarks_toolbar"/>
<RelativeLayout
android:id="@+id/bookmarks_empty_layout"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/bookmarks_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true"
android:paddingBottom="60dp"
android:gravity="center_horizontal">
android:layout_below="@+id/bookmarks_toolbar"/>
<RelativeLayout
android:id="@+id/bookmarks_empty_layout"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true"
android:paddingBottom="60dp"
android:gravity="center_horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="100dp"
android:layout_height="100dp"
/>
android:layout_width="100dp"
android:layout_height="100dp"
/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bookmarks_empty"
android:paddingTop="@dimen/default_margin_big"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bookmarks_empty"
android:paddingTop="@dimen/default_margin_big"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>

View File

@ -1,43 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.Toolbar
android:id="@+id/image_toolbar"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_margin"
android:layout_height="@dimen/bar_height"
app:menu="@menu/image_overflow_menu"
app:title="@string/image"/>
<corewala.buran.ui.content_image.TouchImageView
android:id="@+id/image_view"
android:scaleType="centerInside"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
/>
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/default_margin">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/close_image_content_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_close" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/image_overflow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_overflow" />
</RelativeLayout>
android:id="@+id/image_view"
android:scaleType="centerInside"
android:layout_below="@id/image_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>

View File

@ -1,42 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/default_margin">
<androidx.appcompat.widget.Toolbar
android:id="@+id/text_toolbar"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_margin"
android:layout_height="@dimen/bar_height"
app:title="@string/text"/>
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/close_text_content_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_close" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/history_overflow"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_overflow" />
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/default_margin"
android:layout_below="@+id/header">
android:layout_below="@+id/text_toolbar">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/text_content"
@ -45,6 +24,6 @@
android:textSize="@dimen/default_text_size"
android:textIsSelectable="true"/>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>

View File

@ -1,40 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/default_margin">
<androidx.appcompat.widget.Toolbar
android:id="@+id/history_toolbar"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_margin"
android:layout_height="@dimen/bar_height"
app:menu="@menu/history_overflow_menu"
app:title="@string/history"/>
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/close_tab_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_close" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/history_overflow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_overflow" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/history_recycler"
android:layout_below="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:id="@+id/history_recycler"
android:layout_below="@+id/history_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>

View File

@ -2,61 +2,14 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/default_margin">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/close_input_query_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_margin="@dimen/button_margin"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/vector_close" />
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/default_margin_big"
android:paddingRight="@dimen/default_margin_big"
android:paddingBottom="@dimen/default_margin_big"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/query_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/default_margin"
tools:text="Type your query"/>
android:paddingHorizontal="@dimen/screen_margin">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/query_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/default_margin"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/query_submit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/submit"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
android:inputType="text"
android:lines="1"
android:maxLines="1"/>
</RelativeLayout>

View File

@ -9,39 +9,23 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.AppCompatTextView
android:textSize="@dimen/default_text_size"
android:textColor="@color/stroke"
android:id="@id/show_code_block"
android:background="?android:selectableItemBackground"
android:focusable="true" android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin_small"
android:layout_marginBottom="@dimen/default_margin_small"
android:text="@string/show_code"
android:drawablePadding="4.0dip"
/>
<HorizontalScrollView
android:scrollbars="none"
android:background="@drawable/block_background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/def_quarter"
android:layout_marginBottom="@dimen/def_quarter"
android:layout_below="@id/show_code_block">
android:layout_marginBottom="@dimen/def_quarter">
<androidx.appcompat.widget.AppCompatTextView
android:scrollbarStyle="insideOverlay"
android:textSize="@dimen/code_text_size"
android:typeface="monospace"
android:textColor="@color/stroke"
android:id="@id/gemtext_text_monospace_textview"
android:id="@+id/gemtext_text_monospace_textview"
android:paddingLeft="@dimen/default_margin_big"
android:paddingTop="@dimen/default_margin_big"
android:paddingRight="@dimen/default_margin_big"
android:paddingBottom="0.0dip"
android:scrollbars="horizontal|vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollHorizontally="true"

View File

@ -2,33 +2,66 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/gemtext_text_link"
android:textColor="@color/stroke"
android:textSize="@dimen/default_text_size"
android:clickable="true"
android:focusable="true"
android:drawableEnd="@drawable/vector_photo"
android:drawablePadding="4dp"
android:background="?android:attr/selectableItemBackground"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
tools:text="an image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/gemtext_inline_image"
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/link_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="@dimen/default_margin"
android:background="#ffffff"
android:visibility="gone"
android:adjustViewBounds="true"
android:layout_below="@+id/gemtext_text_link"/>
android:layout_height="match_parent">
<com.google.android.material.button.MaterialButton
android:id="@+id/gemtext_link_button"
android:textColor="@color/stroke"
android:textSize="@dimen/default_text_size"
android:clickable="true"
android:focusable="true"
android:drawableEnd="@drawable/vector_photo"
android:drawablePadding="4dp"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:padding="@dimen/accessibility_button_padding"
app:cornerRadius="@dimen/default_margin_big"
android:textAllCaps="false"
tools:text="an image"
android:backgroundTint="@color/accessibility_button_background"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/gemtext_text_link"
android:textColor="@color/stroke"
android:textSize="@dimen/default_text_size"
android:clickable="true"
android:focusable="true"
android:drawableEnd="@drawable/vector_photo"
android:drawablePadding="4dp"
android:background="?android:attr/selectableItemBackground"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
tools:text="an image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.cardview.widget.CardView
android:id="@+id/rounded_image_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="@dimen/default_margin_big"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="@dimen/default_margin"
android:visibility="gone"
android:layout_below="@+id/link_frame">
<ImageView
android:id="@+id/gemtext_inline_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"/>
</androidx.cardview.widget.CardView>
</RelativeLayout>

View File

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="@dimen/default_margin">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/show_code_block"
android:textColor="@color/stroke"
android:layout_marginTop="@dimen/default_margin_small"
android:layout_marginBottom="@dimen/default_margin_small"
android:textSize="@dimen/large_text_size"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/accessibility_button_padding"
android:textAllCaps="false"
android:backgroundTint="@color/accessibility_button_background"
android:textAlignment="viewStart"
android:drawablePadding="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_code"
tools:text="Show code: Ascii art banner: Spacewalk - Updates from around geminispace"
/>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/show_code_block">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/gemtext_text_monospace_textview"
android:textSize="@dimen/code_text_size"
app:lineHeight="@dimen/code_text_size"
app:fontFamily="@font/code_font"
android:fontFamily="@font/code_font"
android:typeface="monospace"
android:textColor="@color/stroke"
android:textIsSelectable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/default_margin"
android:paddingRight="@dimen/default_margin"
android:paddingTop="@dimen/default_margin"
android:paddingBottom="@dimen/default_margin"
android:isScrollContainer="true"
android:overScrollMode="ifContentScrolls"
android:scrollHorizontally="true"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical|horizontal"/>
</HorizontalScrollView>
</RelativeLayout>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gemtext_text_textview"
android:textSize="@dimen/large_h1_text_size"
android:textColor="@color/stroke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="@dimen/default_margin_tiny" />

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gemtext_text_textview"
android:textSize="@dimen/large_h2_text_size"
android:textColor="@color/stroke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="@dimen/default_margin_tiny" />

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gemtext_text_textview"
android:textSize="@dimen/large_h3_text_size"
android:textColor="@color/stroke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="@dimen/default_margin_tiny" />

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/gemtext_text_link"
android:textColor="@color/stroke"
android:textSize="@dimen/large_text_size"
android:clickable="true"
android:focusable="true"
android:drawableEnd="@drawable/vector_photo"
android:drawablePadding="4dp"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:padding="@dimen/accessibility_button_padding"
android:textAllCaps="false"
tools:text="an image"
android:backgroundTint="@color/accessibility_button_background"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/gemtext_inline_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginBottom="@dimen/default_margin"
android:background="#ffffff"
android:visibility="gone"
android:adjustViewBounds="true"
android:layout_below="@+id/gemtext_text_link"/>
</RelativeLayout>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/gemtext_text_link"
android:textColor="@color/stroke"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:layout_marginTop="@dimen/default_margin_small"
android:layout_marginBottom="@dimen/default_margin_small"
android:textSize="@dimen/large_text_size"
android:clickable="true"
android:focusable="true"
android:textAllCaps="false"
android:textAlignment="viewStart"
android:padding="@dimen/accessibility_button_padding"
android:backgroundTint="@color/accessibility_button_background"
android:drawablePadding="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gemtext_text_monospace_textview"
android:textSize="@dimen/large_text_size"
android:textColor="@color/stroke"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:paddingLeft="@dimen/default_margin"
android:paddingRight="@dimen/default_margin"
android:paddingTop="@dimen/default_margin"
android:paddingBottom="@dimen/default_margin"
android:textStyle="italic"
android:background="@color/code_background"
android:textIsSelectable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineHeight="@dimen/large_line_height"/>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gemtext_text_textview"
android:textSize="@dimen/large_text_size"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:textColor="@color/stroke"
android:textIsSelectable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineHeight="@dimen/large_line_height"/>

View File

@ -3,7 +3,27 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.button.MaterialButton
android:id="@+id/gemtext_link_button"
android:textColor="@color/stroke"
android:textSize="@dimen/default_text_size"
android:clickable="true"
android:focusable="true"
android:drawableEnd="@drawable/vector_photo"
android:drawablePadding="4dp"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:padding="@dimen/accessibility_button_padding"
app:cornerRadius="@dimen/default_margin_big"
android:textAllCaps="false"
tools:text="an image"
android:backgroundTint="@color/accessibility_button_background"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/gemtext_text_link"

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gemtext_text_monospace_textview"
<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/gemtext_quote_textview"
android:textSize="@dimen/default_text_size"
android:textColor="@color/stroke"
android:layout_marginLeft="@dimen/screen_margin"
android:layout_marginRight="@dimen/screen_margin"
android:paddingLeft="@dimen/default_margin"
android:paddingRight="@dimen/default_margin"
android:paddingTop="@dimen/default_margin"
android:paddingBottom="@dimen/default_margin"
android:paddingLeft="@dimen/default_margin_big"
android:paddingRight="@dimen/default_margin_big"
android:paddingTop="@dimen/default_margin_big"
android:paddingBottom="@dimen/default_margin_big"
android:textStyle="italic"
android:background="@color/code_background"
android:background="@drawable/block_background"
android:textIsSelectable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineHeight="@dimen/default_line_height"/>
app:lineHeight="@dimen/default_line_height" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/gemtext_text_textview"
android:textSize="@dimen/default_text_size"
android:layout_marginLeft="@dimen/screen_margin"
@ -9,4 +9,4 @@
android:textIsSelectable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineHeight="@dimen/default_line_height"/>
app:lineHeight="@dimen/default_line_height" />

View File

@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/history_overflow_clear_history"
android:title="@string/clear_history" />
<item android:id="@+id/history_overflow_clear_runtime_cache"
android:title="@string/clear_cache" />
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_action_clear_history"
android:title="@string/clear_history"
app:showAsAction="never"/>
<item android:id="@+id/menu_action_clear_runtime_cache"
android:title="@string/clear_cache"
app:showAsAction="never"/>
</menu>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/link_menu_load_image"
android:title="@string/load_image" />
<item android:id="@+id/link_menu_copy"
android:title="@string/copy_address" />
</menu>

View File

@ -4,6 +4,9 @@
<item
android:id="@+id/overflow_menu_search"
android:title="@string/search"/>
<item
android:id="@+id/overflow_menu_sign"
android:title="@string/load_cert"/>
<item
android:id="@+id/overflow_menu_bookmark"
android:title="@string/add_bookmark"/>

Binary file not shown.

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:shrinkMode="strict" />

View File

@ -1,21 +1,21 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name">Buran</string>
<string name="app_name">Bourane</string>
<string name="gemini_protocol">gemini://</string>
<string name="main_input_hint">Entrez l\'adresse gemini://</string>
<string name="main_input_search_hint">Entrez un terme de recherche</string>
<string name="copy_address">Partager l\'adresse</string>
<string name="load_image">Afficher en ligne</string>
<string name="about">À propos</string>
<string name="address_copied_to_clipboard">Adresse copiée dans le presse-papiers</string>
<string name="gemini_address">Adresse Gemini</string>
<string name="share">Partager</string>
<string name="set_home">Choisir comme Accueil</string>
<string name="settings">Paramètres</string>
<string name="about_body">Buran: Un client pour le protocole Gemini par Corewala</string>
<string name="copyright">Copyright © 2021 Corewala</string>
<string name="about_ariane_source">Buran est basé sur le navigateur Ariane d\'ÖLAB sous la Licence Publique de l\'Union Européenne</string>
<string name="about_body">Un navigateur minimaliste pour le protocole Gemini par Corewala</string>
<string name="copyright">Copyright © 2022 Corewala</string>
<string name="about_ariane_source">Bourane est basé sur le navigateur Ariane d\'ÖLAB sous la Licence Publique de l\'Union Européenne</string>
<string name="about_font">Les blocs de code sont rendus avec JetBrains Mono de JetBrains</string>
<string name="about_glyphs">Les glyphes utilisés proviennent de Material Icons par Google</string>
<string name="source">Source</string>
<string name="clear_cache">Vider le cache d\'exécution</string>
<string name="history">Historique</string>
<string name="clear_history">Vider l\'historique</string>
@ -28,6 +28,8 @@
<string name="page_backlinks">Liens de retour</string>
<string name="add_bookmark">Ajouter marque-page</string>
<string name="bookmarks">Marque-pages</string>
<string name="image">Image</string>
<string name="text">Texte</string>
<string name="name">Nom</string>
<string name="gemini_uri">URL Gemini</string>
<string name="edit">Éditer</string>
@ -35,15 +37,23 @@
<string name="move_down">Déplacer vers le bas</string>
<string name="move_up">Déplacer vers le haut</string>
<string name="unknown_mime_dialog_title">Type Mime inconnu</string>
<string name="unknown_host_dialog_title">Hôte inconnu</string>
<string name="unknown_host">Hôte inconnu</string>
<string name="search_instead">Rechercher au lieu?</string>
<string name="download">Télécharger</string>
<string name="cancel">Annuler</string>
<string name="close">Fermer</string>
<string name="confirm">Confirmer</string>
<string name="error">Erreur</string>
<string name="no_app_installed_that_can_open">Aucune app installée qui puisse ouvrir %s</string>
<string name="no_state_object_exists">Erreur de téléchargement de fichier - aucun état d\'objet n\'existe</string>
<string name="file_saved_to_device">Fichier sauvegardé dans l\'appareil</string>
<string name="configure_buran">Configurer Buran</string>
<string name="home_capsule">Capsule d\'accueil</string>
<string name="not_valid_search_string">Ceci n\'est pas une base de recherche valide</string>
<string name="not_valid_address">Ceci n\'est pas une adresse valide</string>
<string name="no_home_capsule_set">Pas de capsule d\'accueil</string>
<string name="search_engine">Moteur de recherche</string>
<string name="search_base">Base de recherche</string>
<string name="update">Mettre à jour</string>
<string name="appearance">Apparence</string>
<string name="theme">Thème</string>
@ -55,25 +65,39 @@
<string name="web_content">Contenu Web</string>
<string name="web_content_label">Ouvrir les sites web en interne en utilisant des \'Onglets Personnalisés\', plutôt que d\'utiliser le navigateur par défaut. Cela pourrait vous aider à rester dans le Geminispace plutôt que d\'être distrait·e par le vaste web. Cela requiert un navigateur par défaut compatible.</string>
<string name="web_content_switch_label">Ouvrir en interne</string>
<string name="pkcs_notice">Seuls les magasins de clés client PKCS12 sont actuellement supportés</string>
<string name="http_proxy">Mandataire HTTP</string>
<string name="no_http_proxy_set">Pas de mandataire HTTP</string>
<string name="proxied_content">Ce contenu est visualisé via un mandataire</string>
<string name="open_original">Ouvrir l\'original</string>
<string name="show_inline_images">Images locales en ligne</string>
<string name="pkcs_notice">Seuls les magasins de clés client PKCS12 sont actuellement supportés.</string>
<string name="client_certificate">Certificat Client</string>
<string name="tap_to_select_client_certificate">Cliquez pour sélectionner un certificat client</string>
<string name="client_certificate_password">Mot de passe du Certificat Client</string>
<string name="no_password">Pas de mot de passe</string>
<string name="use_client_certificate">Utiliser un Certificat Client</string>
<string name="use_client_certificate">Utiliser Certificat Client</string>
<string name="client_certificate_required">Certificat Client Requis</string>
<string name="confirm_your_identity">Confirmez votre identité</string>
<string name="use_biometric_unlock">Utilisez vos informations biométriques pour continuer</string>
<string name="biometric_cert_verification">Certificat Client biométrique</string>
<string name="load_cert">Chargez Certificat</string>
<string name="unload_cert">Déchargez Certificat</string>
<string name="cert_loaded">Certificat chargé</string>
<string name="cert_unloaded">Certificat dechargé</string>
<string name="set_home_capsule">Choisir comme capsule d\'accueil</string>
<string name="check_for_updates">Vérifier pour des mises à jour</string>
<string name="new_version_available">Nouvelle version disponible</string>
<string name="no_internet">Aucun accès internet</string>
<string name="retry">Rafraichissez cette page pour réessayer</string>
<string name="history_cleared">Historique vidé</string>
<string name="runtime_cache_cleared">Cache d\'exécution vidé</string>
<string name="show_inline_icons">Icônes de lien en ligne</string>
<string name="show_link_buttons">Boutons de lien</string>
<string name="use_attention_guides">Utiliser des guides d\'attention</string>
<string name="bookmarks_empty">Vous n\'avez encore aucun marque-pages</string>
<string name="import_bookmarks">Importer des marque-pages</string>
<string name="export_bookmarks">Exporter des marque-pages</string>
<string name="accessibility">Accessibilité</string>
<string name="collapse_code_blocks">Cacher les rectangles pleins</string>
<string name="show_code">Montrer le code</string>
<string name="hide_code">Cacher le code</string>
<string name="large_gemtext_and_button">Gemtexte large</string>
<string name="collapse_code_blocks_about">Les capsules Gemini utilisent malheureusement souvent des en-têtes en ascii-art rendus avec des rectangles pleins à largeur fixe. Quand les rectangles pleins sont cachés, ils nécessitent un clic pour être affichés, ce qui améliore l\'ergonomie en cas d\'utilisation d\'un lecteur d\'écran.</string>
<string name="prefs_override_page_background">Utiliser une couleur d\'arrière-plan personnalisée</string>
<string name="prefs_override_page_background_dialog_title">Couleur d\'arrière-plan</string>
<string name="prefs_override_page_background_title">Couleur d\'arrière-plan</string>

View File

@ -6,12 +6,11 @@
<color name="code_background">#000000</color>
<color name="player_background">#1d1d1d</color>
<color name="protocol_address">#ffdede</color>
<color name="address_background">#2e2e2e</color>
<color name="address_background">#ff222121</color>
<color name="vibrant_stroke">#ffffff</color>
<color name="themed_text">#ffffff</color>
<color name="header_background">#1d1d1d</color>
<color name="navigation_bar_background">#1d1d1d</color>
<color name="stroke">#d2d2d2</color>
<color name="accessibility_button_background">#3A3A3A</color>
<color name="stroke">#ffffff</color>
<color name="accessibility_button_background">#26A69A</color>
</resources>

View File

@ -8,10 +8,9 @@
<color name="protocol_address">#002121</color>
<color name="address_background">#dfdfdf</color>
<color name="vibrant_stroke">#000000</color>
<color name="themed_text">#000000</color>
<color name="header_background">#ffffff</color>
<color name="navigation_bar_background">#ffffff</color>
<color name="stroke">#1d1d1d</color>
<color name="accessibility_button_background">#f9dede</color>
<color name="stroke">#000000</color>
<color name="accessibility_button_background">#26A69A</color>
</resources>

View File

@ -7,23 +7,14 @@
<dimen name="screen_margin">20dp</dimen>
<dimen name="button_margin">12dp</dimen>
<!-- Default Adapter-->
<!-- Gemtext Adapter-->
<dimen name="default_text_size">16sp</dimen>
<dimen name="default_line_height">20sp</dimen>
<dimen name="code_text_size">14sp</dimen>
<dimen name="h1_text_size">32sp</dimen>
<dimen name="h1_text_size">36sp</dimen>
<dimen name="h2_text_size">26sp</dimen>
<dimen name="h3_text_size">22sp</dimen>
<!-- Large Adapter -->
<dimen name="large_text_size">22sp</dimen>
<dimen name="large_line_height">28sp</dimen>
<dimen name="large_code_text_size">18sp</dimen>
<dimen name="large_h1_text_size">40sp</dimen>
<dimen name="large_h2_text_size">34sp</dimen>
<dimen name="large_h3_text_size">30sp</dimen>
<dimen name="button_size">32dp</dimen>
<dimen name="bar_height">50dp</dimen>
<dimen name="menu_item_icon_size">20dp</dimen>

View File

@ -4,18 +4,18 @@
<string name="main_input_hint">Enter gemini:// address</string>
<string name="main_input_search_hint">Enter search term</string>
<string name="copy_address">Share address</string>
<string name="load_image">Display inline</string>
<string name="about">About</string>
<string name="address_copied_to_clipboard">Address copied to clipboard</string>
<string name="gemini_address">Gemini address</string>
<string name="share">Share</string>
<string name="set_home">Set Home</string>
<string name="settings">Settings</string>
<string name="about_body">Buran: A Gemini protocol browser from Corewala</string>
<string name="copyright">Copyright © 2021 Corewala</string>
<string name="about_body">A simple Gemini protocol browser from Corewala</string>
<string name="copyright">Copyright © 2022 Corewala</string>
<string name="about_ariane_source">Buran is based on the Ariane browser by ÖLAB under the European Union Public Licence</string>
<string name="about_font">Code blocks are rendered using JetBrains Mono by JetBrains</string>
<string name="about_glyphs">Glyphs used are from Material Icons by Google</string>
<string name="source">Source</string>
<string name="clear_cache">Clear runtime cache</string>
<string name="history">History</string>
<string name="clear_history">Clear history</string>
@ -28,6 +28,8 @@
<string name="page_backlinks">Backlinks</string>
<string name="add_bookmark">Add Bookmark</string>
<string name="bookmarks">Bookmarks</string>
<string name="image">Image</string>
<string name="text">Text</string>
<string name="name">Name</string>
<string name="gemini_uri">Gemini URL</string>
<string name="edit">Edit</string>
@ -35,15 +37,23 @@
<string name="move_down">Move down</string>
<string name="move_up">Move up</string>
<string name="unknown_mime_dialog_title">Unknown Mime Type</string>
<string name="unknown_host_dialog_title" tools:ignore="MissingTranslation">Unknown Host</string>
<string name="unknown_host">Unknown Host</string>
<string name="search_instead">Search instead?</string>
<string name="download">Download</string>
<string name="cancel">Cancel</string>
<string name="close">Close</string>
<string name="confirm">Ok</string>
<string name="error">Error</string>
<string name="no_app_installed_that_can_open">No app installed that can open %s</string>
<string name="no_state_object_exists">File download error - no state object exists</string>
<string name="file_saved_to_device">File saved to device</string>
<string name="configure_buran">Configure Buran</string>
<string name="home_capsule">Home Capsule</string>
<string name="not_valid_search_string">This is not a valid search base</string>
<string name="not_valid_address">This is not a valid address</string>
<string name="no_home_capsule_set">No home capsule set</string>
<string name="search_engine">Search Engine</string>
<string name="search_base">Search Base</string>
<string name="update">Update</string>
<string name="appearance">Appearance</string>
<string name="theme">Theme</string>
@ -55,25 +65,39 @@
<string name="web_content">Web Content</string>
<string name="web_content_label">Open websites internally using \'Custom Tabs\', instead of using the default browser. This might help you stay in Geminispace instead of being distracted by the wider web. Requires compatible default browser.</string>
<string name="web_content_switch_label">Open internally</string>
<string name="pkcs_notice">Only PKCS12 client keystores are currently supported</string>
<string name="http_proxy">HTTP proxy</string>
<string name="no_http_proxy_set">No HTTP proxy set</string>
<string name="proxied_content">This content is rendered through a proxy</string>
<string name="open_original">Open original</string>
<string name="show_inline_images">Inline local images</string>
<string name="pkcs_notice">Only PKCS12 client keystores are currently supported.</string>
<string name="client_certificate">Client Certificate</string>
<string name="tap_to_select_client_certificate">Tap to select client certificate</string>
<string name="client_certificate_password">Client Certificate Password</string>
<string name="no_password">No Password</string>
<string name="use_client_certificate">Use Client Certificate</string>
<string name="client_certificate_required">Client Certificate Required</string>
<string name="confirm_your_identity">Confirm your identity</string>
<string name="use_biometric_unlock">Verify your biometric credentials to continue</string>
<string name="biometric_cert_verification">Client Certificate biometrics</string>
<string name="load_cert">Load Certificate</string>
<string name="unload_cert">Unload Certificate</string>
<string name="cert_loaded">Certificate loaded</string>
<string name="cert_unloaded">Certificate unloaded</string>
<string name="set_home_capsule">Set home capsule</string>
<string name="check_for_updates">Check for updates</string>
<string name="new_version_available">New version available</string>
<string name="no_internet">No internet access</string>
<string name="retry">Refresh this page to try again</string>
<string name="history_cleared">History cleared</string>
<string name="runtime_cache_cleared">Runtime cache cleared</string>
<string name="show_inline_icons">Inline link icons</string>
<string name="show_link_buttons">Show link buttons</string>
<string name="use_attention_guides">Use attention guides</string>
<string name="bookmarks_empty">You don\'t have any bookmarks yet</string>
<string name="import_bookmarks">Import bookmarks</string>
<string name="export_bookmarks">Export bookmarks</string>
<string name="accessibility">Accessibility</string>
<string name="collapse_code_blocks">Hide code blocks</string>
<string name="show_code">Show code</string>
<string name="hide_code">Hide code</string>
<string name="large_gemtext_and_button">Large Gemtext</string>
<string name="collapse_code_blocks_about">Gemini capsules unfortunately often use ascii-art headers rendered in monospaced code blocks. When code blocks are hidden they require a tap to expand which improves usability when using a screen reader.</string>
<string name="prefs_override_page_background">Use custom page background colour</string>
<string name="prefs_override_page_background_dialog_title">Page Background Colour</string>
<string name="prefs_override_page_background_title">Page Background Colour</string>

View File

@ -10,6 +10,7 @@
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
<item name="android:navigationBarColor">@color/navigation_bar_background</item>
<item name="android:windowDisablePreview">true</item>
</style>
<style name="SettingsTheme" parent="@style/AppTheme">

View File

@ -18,4 +18,9 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.code.style=official
# Kapt workaround
kapt.use.worker.api=false
kapt.incremental.apt=false
# R8 optimisation
android.enableR8.fullMode=true

View File

@ -1,11 +0,0 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Nov 29 22:38:09 EST 2021
sdk.dir=/home/corewala/.android_sdk
sdk-location=/home/vagrant/android-sdk
ndk.dir=/home/vagrant/android-ndk/r12b
ndk-location=/home/vagrant/android-ndk/r12b

View File

@ -0,0 +1,9 @@
Changelog:
- Default homepage is stored locally
- Only the latest request is rendered
- Back button cancels current request
- Lots of bugfixes

View File

@ -0,0 +1,9 @@
Changelog:
- HTTP proxy support
- Previous scroll position is stored
- Local links and redirects are fixed
- Minor tweaks and bugfixes

View File

@ -0,0 +1,9 @@
Changelog:
- Fixed broken unproxied HTTP links
- Un-bugged the back button
- This is a really tiny release
- Actual features coming at some point in the nebulous future

View File

@ -0,0 +1,5 @@
Buran is a simple Gemini protocol browser for Android which allows users to explore geminispace in style.
This application has no external dependencies and does not require any nonfree services, using only default system libraries. It has been fully localized in English and French, and supports an array of accessibility and quality-of-life features.
Buran is a fork of Ariane by ÖLAB allowed under the terms of the European Union Public Licence.

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -0,0 +1 @@
Simple Gemini browser for Android

View File

@ -0,0 +1 @@
Buran

View File

@ -0,0 +1,5 @@
Bourane est un navigateur minimaliste du protocole Gemini sur Android pour explorer l'espace Gemini avec style.
Cette application n'a aucune dépendance externe et ne nécessite aucun service non gratuit, en utilisant uniquement les bibliothèques système.
Bourane est basé sur le navigateur Ariane d'ÖLAB autorisé conformément aux termes de la Licence Publique de l'Union Européenne.

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -0,0 +1 @@
Navigateur minimaliste pour le protocole Gemini

View File

@ -0,0 +1 @@
Bourane