Hacker News new | past | comments | ask | show | jobs | submit | on_and_off's comments login

"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.

[0] https://cs.android.com/android/platform/superproject/main/+/...


> I have actually made my own TextView using just layout so I don't think this comment is warranted.

Make sure you handle the following attributes and how they affect each other!

> text, bufferType, hint, textColor, textColorHighlight, textColorHint, textAppearance, textColorLink, textFontWeight, textSize, textScaleX, fontFamily, typeface, textStyle, cursorVisible, maxLines, maxHeight, lines, height, minLines, minHeight, maxEms, maxWidth, ems, width, minEms, minWidth, gravity, scrollHorizontally, password, singleLine, selectAllOnFocus, includeFontPadding, maxLength, shadowColor, shadowDx, shadowDy, shadowRadius, autoLink, linksClickable, numeric, digits, phoneNumber, inputMethod, capitalize, autoText, editable, freezesText, ellipsize, drawableTop, drawableBottom, drawableRight, drawableLeft, drawableStart, drawableEnd, drawablePadding, drawableTint, drawableTintMode, lineSpacingExtra, lineSpacingMultiplier, justificationMode, marqueeRepeatLimit, inputType, imeOptions, privateImeOptions, imeActionLabel, imeActionId, editorExtras, elegantTextHeight, fallbackLineSpacing, letterSpacing, fontFeatureSettings, fontVariationSettings, breakStrategy, hyphenationFrequency, lineBreakStyle, lineBreakWordStyle, autoSizeTextType, autoSizeMinTextSize, autoSizeMaxTextSize, autoSizeStepGranularity, autoSizePresetSizes, textCursorDrawable, textSelectHandle, textSelectHandleLeft, textSelectHandleRight, allowUndo, enabled


>textSelectHandleLeft, textSelectHandleRight

Done

>textColor, typeface, textColorLink, textFontWeight, textStyle

handled by TextPaint in StaticLayout/DynamicLayout. For example textColorLink is just `linkColor` from TextPaint.[0]

>text, textSize, maxLines, justificationMode, breakStrategy, hyphenationFrequency, lineBreakStyle

handled by StaticLayout/DynamicLayout

>shadowColor, shadowDx, shadowDy, shadowRadius

mTextPaint.setShadowLayer(radius, dx, dy, color);

Wow, that was so difficult. Only those that "know about UI" must be capable of such a feat?

>numeric, digits, phoneNumber, inputMethod, editable, cursorVisible, textCursorDrawable, allowUndo, inputType, imeOptions, privateImeOptions, imeActionLabel, imeActionId, editorExtras,

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.

[0] https://developer.android.com/reference/android/text/TextPai...


> 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.


>you expect your case to be the only one used

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://developer.apple.com/documentation/swiftui/text

[1] https://doc.qt.io/qt-6/qlabel.html#details

[2] https://api.flutter.dev/flutter/widgets/RichText-class.html


or just paying for youtube premium ...


With uBO on desktop and YouTube Vanced on mobile, you get the exact same experience AND save $12/month.


and you also don't contribute to the creators incomes.

I can understand people vouching for using youtube premium or nebula instead, but not this.


Small creators who need income will get barely anything, while the ones the youtube algorithm prefers will get all. So yeah support them directly if you want but not google so I think vanced and the like is perfectly fine solution.


meh, still feel very hypocritical.

You have found a way not to pay for something, good for you, but brandishing it as some kind of "perfectly fine solution" is just laughable.


Youtube exploits creators’ work to make viewers at a cost of hosting said videos. It would be a pretty symbiotic thing but with the recent direction Google took I would rather not partake. Also, I barely use youtube. And I used to pay for for example google play music but as usual, google killed it.


People who care about that support them using (for instance) Patreon, and that makes them a LOT more than youtube will, especially with the demonetisation bonanza as of late.


I don't feel responsible for creators' incomes. It's their own choice and their own risks — no one's forcing them to quit their jobs and rely on YouTube for their only income. Or, simply put, "implicit contracts" aren't a thing for me.

Anyway, many, if not most, youtubers have pateron now in case you want to contribute to their incomes without feeding surveillance capitalism.


I'd sooner stop using YouTube altogether.

If paying for Google's services acted as an opt-out from their surveillance then I might consider it; but they'd never give users the opportunity to not have Google looking over their shoulder.


stopping using youtube altogether I would actually understand


I would if more non-commercial and non-monetized content were uploaded to Archive.org.


I am always stunned that many (most/all) of these high tech gadgets lack a LOT of safety features.

I would pay extra for a drone with such safeguards. just the prospect of less chances of ruining it would be enough.

Similarly, eskates often have a regenerative battery charging while braking which is a great idea. but it also cannot handle charging while already full. So if you go down a slope while the board is full, it can decide to shut down and let you bomb down that hill. Which sounds like an insane pitfall.

Or what happens if the board loses its connection to the remote ? I would hope that it brakes progressively but similarly it just does nothing .. so up to you to find a way to stop.

It is such a weird blind spot to have. I don't think a car manufacturer would ship a product with this kind of blind spot, is that a culture thing ? regulation ?

Anyway, fingers crossed that somebody seizes these opportunities.


>I am always stunned that many (most/all) of these high tech gadgets lack a LOT of safety features.

I’m not... no safety is what the free market will deliver in the absence of regulations or liability or both.


then why were seatbelts and safety glass delivered by the free market? why are tesla's significantly safer than other manufacturers of their own free will? Why do they push updates that improve braking to customers that have already paid? Why does volvo specifically advertise their safety as a differentiator?

Do you really think if a company could prove it provides double the survivability of accidents compared to others, the free market wouldn't reward it?

Your claim simply doesn't match reality.


You're actually proving yourself wrong here.

Regulation and regulation alone provided us with seatbelts and safety glass. Car companies even ran a massive lobbying and advertising campaign to convince America seatbelts weren't necessary with slogans calling drivers in car accidents "the nut behind the wheel" https://99percentinvisible.org/episode/nut-behind-wheel/


No, Volvo gave us seatbelts and the Tucker gave us safety glass. 9 years after the free market created seatbelts, the government mandated it. Mandates have never and will never manifest technological/scientific advancements out of nowhere.


> Mandates have never and will never manifest technological/scientific advancements out of nowhere.

I don't think that anyone is arguing that. I think the point is that the free market doesn't deliver these kind of safety features w/o the "incentive" of government mandates. Whether that is b/c the market doesn't demand those safety features in the absence of a mandate is another issue.


The free market didn't deliver seat belts. Regulation had to step in and Ralph Nader lobbied the US govt to get it passed.


Volvo sold the three point seatbelt for nine years before the US government required it.


Most automakers had them, they were just optional and so people didn't spend extra money on them and kept getting flung out of their cars.

Volvo had them standard, but Volvo has also never been above 1% market share in the US [1]. If a tree falls in a forest and nobody is there to hear it, does it make a sound?

[1] https://knoema.com/infographics/floslle/top-vehicle-manufact...


Volvo is European too.

The part we should be worried about is that it took 9 years for the govt to require it. 50 years from now, we'll be talking about how stupid it was that drones didn't have safety features.


That’s a little different, seatbelts save the lives of your customers


> why are tesla's significantly safer than other manufacturers of their own free will?

Safer than who? Model T fords? How many Tesla's are on the road anyway? In which countries? What about Ferrari? Mercedes?


Teslas turn off regenerative breaking if you charge too far, but the car tells you that pretty prominently: however, the car handles very differently without Regen brakes.


This was the dumbest thing I experienced with my Model 3. I was expecting my regen brakes to work after I pulled out and I had to brake super hard after.

Why can’t Tesla just give us an option to keep it consistent? I guess adding video games is more important.


Tesla has been religious about never blending regen and mechanical braking. The accelerator only controls the motors, the brake pedal only controls the brakes. They’ve broken that somewhat now with one-pedal driving mode. The only way they could make regen feel consistent with a cold or full battery would be to blend in friction braking to make up the difference, which is just not something Tesla is into doing.

My BMW i3 did this really well, FWIW.


I mean, the solution is not to charge past 90%: for most practical purposes there’s no reason to go past 90% anyways.


Because that's not how batteries work.

Regen works because the batteries are being charged by the induction of the motors taking energy from the moving car. If the batteries are full they cannot take any more change and hence cannot draw power from the motion of the car.

What do you expect them to do? Dump the current on a giant resistor and hope it doesn't melt?


> Dump the current on a giant resistor and hope it doesn't melt?

That's called an induction brake and it's already widely used in trains and semi trucks. That said, you still need a friction brake at low speeds, since the induction braking force is proportional to velocity.


Simulate the same braking curve with the physical brakes as when regen is functioning?


I suppose that's one approach. Mechanical brakes work by converting the kinetic energy of the vehicle into heat via friction, it seems fitting that inductive brakes would dump energy to heat by running current over a resistor. Though under normal braking circumstances I don't know what percentage of the vehicle's energy is lost to the brakes themselves and what percentage is lost to the friction of the tire with the road.


Can anyone do the math and tell me how big that resistor would need to be? I’ve always wondered how many watts are being dissipated by my brake pads and rotors when I stop.


Assuming your Tesla is around 2000 kg and traveling at 30 meters/s, it's got about 900,000 J of kinetic energy. Stopping in 10s is some serious power that you'd need to throw off.


All of yhe 90 kW doesn't need to be radiated in real time though as it's ok for the brake elements to heat up.


> What do you expect them to do? Dump the current on a giant resistor and hope it doesn't melt?

You know...they could use it to boil water for a built in coffee/green tea maker.

Just a thought...


Can’t you also set the car to never charge to actual max, giving regen breaking some leeway? (If this is somehow a problem you run into often)


Yes, and that is the default. But people do charge to 100% occasionally for road trips (or for escaping a hurricane path, etc).


Annoyingly, newer Leafs don't let you limit how much you charge anymore, and the regenerative braking curve changes based on how much battery you have…


I guess that's easier and cheaper than adding a circuit to keep regenerative braking on, but dump the energy into a big resistor...


Aka rheostatic braking. Trains do this, but they have pretty large radiators for it.


that would be an unnecessarily complicated way of reimplementing friction brakes.


Most of the hardware is already there for the regenerative brakes, and it allows the driver's muscle memory with respect to braking pressure to still apply in that edge case. I'd be surprised if it were simpler to make the friction brake fallback behave identically to the regenerative system when the battery is full.

Maybe it's not worth the cost/complexity anyway, but the idea has merit somewhere in the design space.


If a Tesla would use rheostatic braking, I think it would require more cooling capacity than the cars are currently designed for. If the resistor couldn't be kept cool, then the car would have to revert back to friction brakes anyway. More cooling probably means bigger air intakes, which I think would run contrary to their aesthetic goals.


Rheostatic and friction brakes both basically convert kinetic energy into heat. Is there some fundamental reason why a resistor would be harder to cool appropriately (low thermal conductivity comes to mind, though I'm pretty sure there are high performance ceramics used for both brakes and resistors -- my heuristics aren't really good enough to make a good guess for this one)?


Well, friction brakes are cooled by the airflow in the wheel wells. Perhaps you could aircool the resistors in the same place. The friction brakes would probably still be there though; would there be space for both?


Shouldn't the resistor having to end up dissipating exactly as much heat as the friction brakes do, by conservation of energy? Is there a reason that it's inherently mechanically harder for the resistor to dissipate that heat?


not really, but you have to have the friction brakes anyway, so why add more parts?


Disks and pads wear out. I haven't done the math, but I assume you could put in a big (wine bottle sized?) power resistor that can take the thermal cycling more or less indefinitely.

You'd have to cool it, as other commenters have pointed out (you're putting a car's worth of kinetic energy into the thing, after all). I'm not suggesting that it's a good idea, just possible.


and then you need extra engineering and production costs to cool those resistors :)


I worked with a DJI matrice for some research projects so it is a larger one than most consumers but man those things are crazy dangerous. The propellors can cut off your fingers or cause serious damage if it hits someone. Not to mention a piece of metal falling out of the sky onto someone. I agree heavily they need more safety mechanisms


> I am always stunned that many (most/all) of these high tech gadgets lack a LOT of safety features.

Exactly. I would also expect a drone to have triple redundundancy of all sensors but they seem to have only one copy of each.


As long as they are carrying less people than 737-MAX, I think they will be fine with less redundancy.

They should be safe, so they don't fall on people etc, but that is a separate issue.


All it takes is for a single IMU failure to fall on people. Two IMUs doesn't help because you don't know which one is right. With three you can vote out the 1/3 failing IMU and issue a warning to land immediately.

Same for GPS and everything else.


Yet even MAX didn't have triple redundancy of all sensors, and I don't think it is customary to have triple redundancy for all sensors in pretty much any plane.

Some things are more or less important, and even insignificant for safe landing. Triple redundant sensors won't save you from programming errors, birds or cables in rotors, batteries bursting into flames which is still more likely to cause a crash than your only camera or microphone failing - probably even a GPS failure, as long as you have a working IMU.


Geese is shunting a resistor across the motor so hard?


my hot take on RTS : I like the genre (or rather used to like, the last one I loved was SupCom) but I wish somebody would make an RTS with no/minimal macro. Controlling the builder/peons units is a chore at best and I would love to see it streamlined a lot. For example just ask for a building to be built instead of finding/assigning builders to the task and micromanaging what they will do next.

Dungeon Keeper comes to mind as a game that starts to go in that direction but it can be argued it is more a (very) fun management game than an RTS.

Probably not doable, we would lose a lot of expressivity in such a change. However, if there is a new RTS coming, I personally would love to see an innovative take on the genre, closer to Brutal Legends 2 / Sacrifice 2 (or as another commented posted, something emulating logistics would be another interesting avenue) than to the inevitable Warcraft 4 (for ios ;)).


SupCom's still active, through Forged Alliance Forever. I got back into it a couple of months back and was pleasantly suprised by how easy it was to find a game.


happy to hear that this is still going on !

I lost interest in FA around the time when FAF was in its first betas.

Planetary Annihilation is more or less a successor but I could not get into it.

I like its idea but in practice the micro was insane in order to keep an eye on several different planets.


This is why I've always liked C&C over SC.

Side note, openra is still addictive.


Consider trying http://www.toothandtailgame.com/

It's designed to be playable with a controller, and uses a player character who commands the army and builds buildings. (Units autoproduce to a limit per building.) It removes APM from the equation, and also adds a new resource as a result: Position and focus of your commander.


AOE2 Deathmatch mode? Thanks for bringing up Brutal Legend and Sacrifice - genuinely fun, interesting games.


They had some sweet ideas.

I just watched a retrospective on 20 years of Double Fine. Tim had some interesting comments in there about how BL came to be. They were avoiding very hard to make or market the game as an RTS because the genre already had a big stigma at the time.

It might kinda explain the weird state of the game. It was definitely a fun and interesting experience but it was also flawed .. way too many games packed into one for its own good.


https://globulation2.org might fit your bill except that it is Open-Source-crappy and dead. Its core idea is good though.


Did you mean no micro?


oups indeed I meant micro not macro

RTS without macro would make no sense


> RTS without macro would make no sense

actually, the game "world in conflict" has no macro - you get free units (in limited quantities), and you micro the set of units to take control of points in the terrain (which leads to more reinforcements/units).

Quite an interesting RTS, i would say. It's completely about tactics and micro, no macro at all.


interesting, I will have to give it a look at one of these days ?

I heard about it but haven't played it. Looks like it was made from the same team as Ground Control, so this would be a tactics game (maybe a bit of a pedantic point to make though .. the 2 genres are closely related) ?

Indeed, it was not what I had in mind but removing the strategic layer would also serve as making these games more focused and hopefully less frantic.


I live without a car in SF, partly because I used to do the same in European cities :

- it is amazing to be able to walk / use public transport to go everywhere you need to

- I just don't like driving in cities. It is just a chore monopolizing my attention.

Still this is way harder to pull of here than it is e.g. in Paris. No subway system serving all the city here.

I am using an eskate to pick up the slack. If the market street project was already completed and we did the same for some other key streets, it would be 100% viable but in the city's current state :

- many roads are in a pitiful state. I haven't hurt myself seriously yet but I saw or know of many people who did.

- car drivers are extremely dangerous

100% on acceptance, culture scene and let's add food scene as well.


ah the old "I don't know anything about this implementation and why things are made this way but I would have made it 10 times better with half the resources".

give me a break


that's a bit of a false dichotomy though.

it is not like these 2 products were identical except for sideloading.

They don't have the same hardware, Apple has an unlimited ad budget, if you want to chat with somebody using iMessages, you are pretty much limited to iOS, you can't transfer app purchases between platforms, etc


If you go into subscription settings on iOS devices, they show a "try out apple music" ad -- you think this position is available to Spotify/others? They don't pay 30% on top of sales to boot.

Same thing with Google, they cross promote their own new properties everywhere in Gmail (left pane) and Google.com but no one else has access to those locations, they can destroy thousands of small business through this practice.


Honestly it is almost funny how Google has been mostly unable to successfully launch new products while they have the capacity to promote them to virtually all of the global north.

In particular with Play Music .. not going to complain, I don't think that this market needs another FAANG product but wow, failing to promote that service is one epic blunder.


Google has an unlimited as budget too. Indeed it has access to advertise on properties that Apple can never purchase access too.


Well, I guess it is back to local storage for me. I tried youtube music but it is not for me.

You can leave it to google to fuck up the same product under 10 different names.

At some point, they had a great service with Play Music. That was ... 5 or 6 years ago ?

Then they basically abandoned it, with maybe one small update every year and it slowly dove into irrelevance :/


you do realize that you could (have?) import all google music files to youtube music. Then you have a tab saying "own content" or so and all mp3s are still there and you could listen to them via yt music the same as you could before


It does not look like you can edit your uploads unlike with Play Music. Admittedly that's very probably a feature used by few people (although I know that for all of the people that use it, it is because of some very obscure track they are very attached to and can only listen to if they upload it, making it a must have feature).

And more generally, while I don't necessarily mind a rebrand (although I have to admit that this being Google, I have my suspicions that this will be handled the same way they handle all their messaging services) and I can be forgiving for a v1, this is still so far below play music that I don't really see myself using it.


@geek_at: unless I'm mistaken, you can't listen if your screen is off or without ads unless you pay for a yt music subscription. I paid to purchase music on Google Music and now I am being forced to pay a monthly fee to access the content ad free.


stupid question : but is there any specific reason why swiftui is not open source ?

I am working with jetpack compose these days and it is both open source and documented. I am not sure how I would work with it without that, it is quite a big departure from the legacy ui api.


Probably because it’s a competitive advantage for Apple to keep to themselves.


I wonder how much of an advantage it is practice ? It is one such toolkit among others, like React or Compose. It is different from making the whole OS open source.

I guess that since the benefit would be to make third party devs job easier, the incentive is not that great for apple .. devs will write mobile apps even if they have to write them in assembly.


I distinctly remember a tweet from 4 years ago, "this presidency will be a test of our institutions and counter powers".

Well, this did not go _well_.

I wish a lot of luck to the Biden administration, there is a lot to rebuild. I might disagree on tons of policy topics with him but at the very least I can completely agree that he lives up to what should be the bare minimum for any president : respect the rule of law, be the president of all americans, not just the ones who voted for you, etc


Biden says the right things, as experienced politicians do. Let's withold judgment until we see what he does.


Your comments seem fine, but could you please stop creating accounts for every few comments you post? We ban accounts that do that. This is in the site guidelines: https://news.ycombinator.com/newsguidelines.html.

You needn't use your real name, of course, but for HN to be a community, users need some identity for other users to relate to. Otherwise we may as well have no usernames and no community, and that would be a different kind of forum. https://hn.algolia.com/?sort=byDate&dateRange=all&type=comme...


Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: