DrewNaylor / Retiled

An attempt at creating a "desktop" environment mainly for Linux phones and tablets that's similar in function to some parts of Microsoft's Windows Phone 8.x, primarily the Start screen, Search app, navigation bar, Action Center, and the status bar. Development is mainly being done using the PinePhone, so that'll be the main supported device.
https://codeberg.org/DrewNaylor/Retiled
Apache License 2.0
66 stars 3 forks source link

Live Tiles will get their data through supported scripting languages (or even executables), but data will be displayed with QML. #70

Open DrewNaylor opened 2 years ago

DrewNaylor commented 2 years ago

You might read that title and go, "Yeah, of course they'll use QML, it's what the Start screen is built with," but the interesting thing is that this could be set up in a way that an app would specify how the data would be shown on the tile. The Live Tile developer would (recommended) base their Live Tile off one of the templates, just like they would on Windows Phone (except it's like LiveTiles.FlipTile or something), or (if this makes sense) they could completely change their Live Tile to be more like an Android widget (if the button doesn't override everything) with a bunch of buttons and stuff to use. It'll probably just be based on the templates, though.

I don't exactly know how I'd store the customized Live Tile QML code inside the regular Tile QML code, but I'm sure there's a way to do it.

I'd have to figure out how to connect all the properties in the Live Tile's QML file so it displays properly. Might have to have an If statement that uses something in the .desktop file that says what kind of Live Tile is being used, since I might not know what everything is supposed to connect to. Actually, I probably wouldn't know, so it would be a super complicated problem to figure out. Maybe there's some way to connect all the properties without having to know what they are, for stuff like weather (unless the weather apps just used pictures on flipping around, which would be a lot simpler; stuff like emails and events could be lists of dictionaries).

I need to both look for open-source WP apps that are license-compatible and have Live Tiles to see how to implement my own ones. I also need to read Microsoft's documentation on Live Tiles to know what kinds there are, but that's a given.

DrewNaylor commented 2 years ago

If this doesn't work, a simpler idea would be to just store the properties in a Python script that has all the data flow through it. That way a picture can still be set and so can whether it flips or not. Would still have to figure out how it would update and get new content.

Updating would be done every 30 minutes by default of course, but the user should be able to choose different values for different tiles. For example, someone may want a weather app to update every 10 minutes, but a tech news app can update every hour. The default should also be changeable, to a minimum of one minute (one minute would also be the minimum in general, even if the user manually sets something lower for an app).

DrewNaylor commented 2 years ago

I've realized that probably the easiest/simplest/most reliable way to get and load the data would be by using JSON and a config file that says what to run and which Live Tile layout to use for each supported size. For example, a weather app might have three items on its tile, which we'll say are the highs, lows, weather conditions in words ("cloudy", for example), and an image for the weather conditions for the next three days to make things simple. The JSON string would have three items as described in this pseudocode:

{
    item1: {
        image: "https:// (cloudy weather icon address)
        largetext: "monday"
        smalltext1: "78°F/68°F"
        smalltext2: "cloudy"
            }
     item2: {
        image: "https:// (thunderstorm weather icon address)
        largetext: "tuesday"
        smalltext1: "70°F/63°F"
        smalltext2: "thunderstorm"
           }
       item3: {
        image: "https:// (sunny weather icon address)
        largetext: "wednesday"
        smalltext1: "82°F/75°F"
        smalltext2: "sunny"
           }
}

(Edit: Badges in the corner like severe weather alert ones will have to be figured out, and some Live Tiles like email in medium slides the icon over to the left to give area to big numbers that display the number of notifications in that app. I also need to allow apps to have two sides, which for weather apps would be current conditions on one side and the forecast on the other. Tiles also need to allow having the background image set, which is often used for weather apps. All these things will require more JSON that I'll have to figure out. I think setting the number to 0 [zero] for the tile clears the tile if I remember the docs right, so I'll do that, too. Clearing the corner badge can be to have it set it to Badge.None or something. Edit 2: The big numbers on the tiles are usually for the number of notifications that app has, but I think sometimes the badge in the corner can also count as being from the notifications. I'll have to figure out a way to link the notifications together with the tiles. This may use JSON, but somehow I have to send it to the relevant tile as well as the Action Center's entry for that app. The important thing is the Action Center-related parts of tiles have to update when a notification comes in rather than every 30 minutes [for example], however it's designed to do so.)

Developers would have to remember to add an extra line (\n) to the start of the "smalltext2" text if they have the "smalltext1" also be multi-line, just to keep things from overlapping. There might be a better way to do that, but that's my first idea that came to mind.

The benefit of using JSON like this is that the developers would just have to provide a config file (or even specify it in the .desktop file, preferably, likely in a specified [LiveTile] section; not sure if I have to add the X-Retiled- to the front of the section name), then we can just see which tile type that the program wants and which program/script it wants to run to get the data, and we can just parse the JSON and show it.

One thing I think Windows Phone had was that if you open an app when something was on the tile, it'd go to that page, but I don't remember it ever doing that, so I just... won't do that. It doesn't make sense, anyway. Maybe I'm just imagining things or misremembering a dream as something real.

It's important to note that not all tiles are Live Tiles, as some are just deep links. However, I do wonder if it would be possible to allow Live Tiles on deep link tiles, such as for contact tiles so that recent emails, calls, and text messages can be shown from a specific contact on their tile. I'll have to make a program/script that returns recent stuff from a contact that's passed to it for that to work, then put the program path and stuff into the .desktop file's [LiveTile] section when it's pinned.

We should allow custom images to be created though, as some apps with deep links like TubeCast I think would put text on the tile, with the video's thumbnail below it. Not sure how that was done, but maybe it saved an image that was set on the tile and had the tile text hidden. That reminds me, there needs to be a way for tiles to hide their text if I haven't written this yet.

On the subject of links, webpage tiles were just screenshots of the page when it was pinned. Not sure how that would be implemented, but actually I thought about this before, and maybe we could let the user take a screenshot and crop it to what they want, considering the only way to have it well-integrated where it takes a screenshot on pinning would be to make a browser or fork one to add that functionality.

Edit: Perhaps it would be a good idea to allow multiple large text elements like the Data Sense Live Tile? Or maybe not, and just give an example of forcing that with line returns.

DrewNaylor commented 2 years ago

Can't remember if I mentioned this yet here, but the JSON response will have to be cached so the script/program that gets the data doesn't run every time the start screen is opened, and there needs to be a brief delay before tiles are updated when they're created and added to the start screen so that things don't get too slow with everything updating at once. Perhaps a random delay between 1 and 5 seconds (inclusive, so it can be a 1 second delay, 5 second delay, or anything in between) could help with that. Unfortunately, that means sometimes an app will take longer to update its tile than it usually does, but I think that's a worthwhile tradeoff. This will be important because people aren't always on the start screen, and wouldn't be using their phone when they're sleeping. I'd have to add a feature where tiles don't update when the screen is off, to save battery.

Earlier I mentioned caching the JSON response. I'll also have to cache the "last requested" time and date in UTC so that I can check if it's been greater than the amount of time the user configured for that Live Tile to update. I'll probably have it check to see if it needs to be updated once a minute, considering that'll be the minimum amount of time the user can set for tile data to be invalidated. Important: If a tile can't refresh its data for whatever reason, it should continue to show the cached JSON response, but in some cases, an app may need to show it couldn't update, such as a weather app, so maybe there should be "outdated" somewhere, or something.

DrewNaylor commented 2 years ago

Here's the tile schema for notifications, which could help to figure this out. Particularly useful is the thing to override the app's display name, which would be used for the Phone app when there's a carrier or no signal available. Multiple dialer apps exist, though, so I don't know if I should just set that for all of them or not. https://docs.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/tile-schema

DrewNaylor commented 2 years ago

Here are some ways Live Tiles were done for the flip, iconic, and cyclic templates. http://windowsapptutorials.com/windows-phone/different-tile-templates-properties-windows-phone/

Edit: that page is down now, but Microsoft has a ton of examples of Live Tile templates for Windows Phone (and also desktop) 8.x here: https://learn.microsoft.com/en-us/previous-versions/windows/apps/hh761491(v=win.10) Importantly, the People Hub app's Live Tile was an "image collection tile" (using the contact images, I guess) based on the following note I copied from the page just to draw attention to it:

"Note When displayed on Windows Phone 8.1, certain template types do not act as they do when displayed on Windows. Peek templates on the phone flip from front to back rather than scrolling up and down and image collection tiles have an animated checkerboard pattern." (italics added for emphasis)

It's important to note that the mini-tiles with pictures on the People Hub Live Tile would flip forward like regular Live Tiles except without "over flipping" like real ones do (the mini-tiles smoothly stop their flip exactly at the full rotation, rather than "overshooting" like, say, the Bing News tile [but wait, the Storage Sense Live Tile also does the smooth flip rather than "overshooting", so I don't know what's going on there; should there be an option to allow Live Tiles to "overshoot" when flipping if the .desktop file specifies that it should "overshoot"? Maybe, to add more personality to the UI and let different apps do slightly different things to make it more lively.]), and it would have a few different colors that each mini-tile would use as its background when there are no images to place there. It appears to use the Accent color, then a lighter version, then an even-lighter version. So for "Light Cobalt" as I call it, that would be #3E65FF, then a lighter version would be #6E8BFF, then an even-lighter version would be #9EB2FF. I think this is just calculated from the Accent color rather than hardcoded, because that wouldn't make sense. One way this can be implemented is by having RetiledStart grab the new Accent color whenever it's updated, then calculating the two variants and storing them both in two separate variables. At runtime, we'll then randomly select whether to use the Accent color, the lighter variant, or the extra-light variant whenever the mini-tiles flip if they end up having no image. I'd also like to have a way to possibly display mini-tiles even when the tile is small if the user wants that to happen, as tile folders still do display a preview of the first four tiles in them when they're small, but they're static at that point. Might be neat, but also might not be a good idea.

Also, these mini-tiles are not the same as what's used for tile folders, so those always seem to use the Accent color and slide around to occasionally show previews of a randomly-selected Live Tile contained within them, such as the Photos app. Another important thing to mention is that there are small lines between each cell in the folder preview, and a set of those cells are picked to move out of the way to show the Live Tile preview as previously mentioned, while some cells stay behind to show the icons of a few other tiles. I just did a test, and it does show previews of tiles even if they're not Live, so it'll be a much-smaller version of the Medium tile compared to when it would appear outside a folder. Maybe there may be a way to occasionally update which tiles are being displayed on small tile folders rather than statically displaying the first four. This could be more reasonable than displaying stuff in the mini-tiles for, say, the People Hub app. Of course, I doubt that it would be a good idea to still do the "tile-previewing" thing when the folder is small, so maybe just shift them around randomly to display other tiles within them? I do know that the Calendar app still displays the day in the middle of it, even at the smallest real tile size (when it's one of the first four tiles inside a small tile folder), so technically it could be given slight things like that. Or maybe the different behavior would be too weird for users when they make the tile small and they won't like it. Could add options in the Settings app under start+theme that would be like, "randomly shift tile previews around within small tile folders", and a note that states that this is different to how medium and wide folders work, where that will be a "peek", and this will keep the updated tile folder preview until the next random shift.

DrewNaylor commented 2 years ago

I was going to say that calendar apps that show the current day and date can just be set to update every 24 hours at midnight, but then I saw a screenshot that included calendar events, so I don't know how to handle that. At least the small one can show just the date, so I can do the 24-hour thing with the small tile.