Yes, the Android SDK has to be one of the worst software packages to ever have been written. Just look at the sourcecode for TextView[0] if you want to see for yourself. 8,700 lines of code to show text on the screen? Well actually, TextView is actually a full blown text editor with the editing functionality turned off as a flag. EditText just wraps TextView and sets the `ediable` field to true. What genius software design! Ever wonder how those selection handles appear when you long press on text in a TextView? I wonder what component that is? Trick question – its built right in to TextView as well! It uses a popup window the displays the handles in global coordinates which it gets using a mixture of `getLocationInWindow` and `getLocationOnScreen`.[1] Another stroke of genius form the Android SDK! Want to change any of this functionality slightly? Now you have to make your own TextView starting from StaticLayout.
Lmao, tbh all this is coming across as "Jr Engineer knows everything" syndrome.
The fact your [1] link is a class that's not even used in the TextView class isn't lost on me to start. They share an interface though, scary!1!!
The fact your [0] link is to a copy of the TextView from 2017 is even funnier.
> Just look at the sourcecode for TextView[0] if you want to see for yourself. 8,700 lines of code to show text on the screen? Well actually, TextView is actually a full blown text editor with the editing functionality turned off as a flag.
Hmm yes, 8,700 lines to "just show text". No hyperbole detected there. Who cares about fonts, shadows, or any other visuals on or around the text, all we're showing is "just text".
> Well actually, TextView is actually a full blown text editor with the editing functionality turned off as a flag.
And? It's called code de-duplication. While realistically I think the better approach would have been to have TextEdit be the barebones display only and Editor add the editing functionality, sometimes code is so tightly coupled for reasons that you can't do that easily. This approach is much better than hitting cmd+c/cmd+v and copying the code into a new class.
The funniest part to me is that your rant is about TextViews though. When that's been soft deprecated for 5 years already (replaced by Compose Text element).
>The fact your [1] link is a class that's not even used in the TextView class
The [1] link is only used by TextView. It is completely reliant on TextView and can't be used by other components. And yes, it is used, right here: https://android.googlesource.com/platform/frameworks/base/+/...
mEditor is used over 400 times in TextView.java. Did you even read it before commenting?
>The fact your [0] link is to a copy of the TextView from 2017 is even funnier.
Why is that funny? Most of it has not changed. I linked to the up to date one in the second link. I searched "TextView source code" on Google to get the first one. It gets the point across and doesn't matter how old it is.
>Hmm yes, 8,700 lines to "just show text". No hyperbole detected there. Who cares about fonts, shadows, or any other visuals on or around the text, all we're showing is "just text".
I'm pretty sure a lot of that is handled by DynamicLayout, not TextView, although correct me if I'm wrong here. If if it isn't, it should be, and is indicative of poor software design. Shadows certainly should not be handled by TextView, I have no idea why anyone would think that.
Take a look at Flutter's implementation. Text is just 1,400 lines, a large portion of which is documentation (another thing the Adnroid SDK sorely lacks,) and it just shows text to the user.[0] Somehow all the "tight coupling" issues have gone away here, and there is no need to throw a text editor into the code. How does Flutter edit text? It has a base EditableText class[1] that is then exposed by simpler widgets like TextField[2]. Now if I want to make my own custom editable text I can without having to recreate the whole thing.
>And? It's called code de-duplication
No. You don't get rid of separation of concerns to save a few bytes. If TextView cannot be made into a separate component that EditText uses then it should implement the functionality of TextView on its own. This is called the single-responsibility principle. A TextView should not be a texteditor. It can't get any simpler than that. Either refactor the text viewing components into something that can be shared by TextView and EditText, or separate them completely.
>The funniest part to me is that your rant is about TextViews though. When that's been soft deprecated for 5 years already (replaced by Compose Text element).
I wonder why this great piece of code was deprecated if it's so great? And yes, that's another great thing about the Andorid SDK. Everything is deprecated while its replacements are only supported on new devices. Then you end up having to do:
> I wonder why this great piece of code was deprecated if it's so great? And yes, that's another great thing about the Andorid SDK. Everything is deprecated while its replacements are only supported on new devices.
Again, same vibes.
The reason you are seeing anything like this, is because you are looking at foundation code and expecting app code. This code is going to be used by apps to run on ALL devices. Best way I can try to describe it is just library code sits between the kernel and software, it has to support everything. Company X's latest XR/AI app doesn't.
Software is constantly evolving for whatever the latest trend is be it VR, AI, or whatever, and eventually you move on from devices that don't get updated. But, so do users. Users by and far want the latest and greatest, shiniest thing. That means every company wants to support `thing`, even if it means dropping `oldThing`.
Funnily enough I had to have a discussion at my job today about dropping support for FireOS 6 devices because of OS specific bugs that happen with Compose that cause a buggy UI. We can't make it work exactly as we want while providing a good experience, so we won't be providing an experience at all. The reason that's okay? Those devices have usage percentage that's practically nil, as they are older devices and not the "latest and greatest".
Are you serious? The Android devs have been working to fix the deprecation and update issue for the last decade and a half. I think you are actually the junior dev here if you are defending it. They have been slowly moving from their custom fork of Linux back to mainline, separating device-level components (eg. Bluetooth) as separate modules, trying to force device vendors to support a baseline of features via GKI, trying to separate kernel updates from higher level system updates, and trying to increase SoC support duration from vendors like Qualcomm. The minuscule device support length on Android is a real issue that Google has spent tens of millions of dollars trying to fix (and only now are they even close to being able to start fixing it). A lot of it is due to political decisions that began at the beginning of Android's lifetime, when device vendors had much more control over the operating system. The fact that pointing that out as a flaw gives you "junior programmer vibes" is seriously concerning.
Also, you failed to address even a single point I made in my post about TextView.
>It's the fact that you hand wave away Text rendering as "just showing text" while claiming you've made your own.
I didn't wave away "text rendering" at all. TextView as nothing to do with text rendering. Have you tried reading the code? Also, even if it did, that would not make it any better. Your claim that TextView is good code because it implements everything from text layout and rendering to text editing is actually much much worse that it simply doing what it really does, which you would know if you would just read and understand the code. Why you have not done so by now is puzzling. Think of it this way: if you were looking at the source code of a text editor, would you expect the whole program to consist of just two classes? That is always going to be bad code.
>Then claim that platform code is terrible because it...uses flags to determine what platform it's on and use the appropriate commands...
Windows has backward compatibility going multiple decades. It even used to ship with a DOS emulator to ensure you can run programs from 30 years ago on it. Linux too has never broken ABI compatibility (although the same cannot be said for user space). Yet you seem to think it is fine for Android to break its API every update. Have you developed for any other systems? I get the feeling that all you know is Android and its awful SDK so you feel you have to defend it.
>Yeah, when talking about components A-Z and the structure around them you don't typically need to point out that X will be included, but here we are.
No. There were two points I made in the post you responded to. One was a very specific point about TextView where I gave my arguments as why it is bad code and in which I pointed out that you never even read the code we were talking about. The other was a side point about deprecating APIs in Android. You decided to ignore the entire main points of my post and only respond to the side point.
"to just show text" is such a tell that you know nothing about UI.
Displaying text is extremely complex. This is only 8000 lines because skiaa does the brunt of the job.
Also, who gives a shit about TextView? Just use BasicText, we aren't in 2017 anymore.
The actual layout algorithm is handled by DynamicLayout, not the textView. It really is just supposed to show some text. You can see it here.[0] Almost all the difficult aspects of showing the text, such as alignment, text direction, line spacing, line breaking, ect. as well as the actual rendering of the text are handled by StaticLayout/DynamicLayout. All TextView should be doing is basically just allowing you to add text programmatically and handling the selection handles. That should not entail having a text editor.
>"to just show text" is such a tell that you know nothing about UI
I have actually made my own TextView using just layout so I don't think this comment is warranted.
Only needed if you add a text editor into your text view, which I did not do.
I'm not going to go through all of these because I'm not sure exactly which side implements them (for example elegantTextHeight sound like something TextView does, but I'm not sure.) I suggest you actually sit down to read TextView before you make comments about it.
> Only needed if you add a text editor into your text view, which I did not do.
> I'm not going to go through all of these because I'm not sure exactly which side implements them (for example elegantTextHeight sound like something TextView does, but I'm not sure.) I suggest you actually sit down to read TextView before you make comments about it.
Which is exactly my damn point, you expect your case to be the only one used. They have to think about EVERYONE and their use cases and how everything interacts.
Have you handled LTR text correctly, custom unicode in fonts, weird alignment issues due to accent marks?
My guess would be no, simply because you never thought of them.
I expect the text editor to be a different component. Take a look at any other UI toolkit's text view like Swift for example:
>A view that displays one or more lines of read-only text.[0]
or QT:
>QLabel is used for displaying text or an image. No user interaction functionality is provided.[1]
In fact, even for just displaying text, I still expect rich text to be handled by a separate component. In Flutter you have RichText for example.[2] I don't know why are are confusing separating components with the components existing at all. Yes, "just displaying text" should be a simple component, because any
reasonable UI toolkit will have already abstracted out all the layout code into a level bellow the user facing widgets, and the simple text component will just call into that.
>Have you handled LTR text correctly
That is handled by Layout via setTextDirection, not TextView. This is what I meant by saying you should read the code. Also I already mentioned text direction in my previous comment in this chain which I see you have not bothered to read.
>custom unicode in fonts, weird alignment issues due to accent marks?
Huh? Just read the code. TextView is not doing any of that.
>My guess would be no
All you have to do si wire up these fields from the XML input (another awful ASDK technology). That's really what TextView is meant to do: send its values to the underlying Layout and handle text selection like copy-paste. I didn't want to wire up XML that I don't need so I didn't. None of it is particularly hard.
[0] https://android.googlesource.com/platform/frameworks/base/+/...
[1] https://cs.android.com/android/platform/superproject/main/+/...