In Chromebook, apps can be full-screen, "small" or minimised. How can we change the app display between full-screen and "small"?

535 views
Skip to first unread message

davefinney

unread,
Jul 5, 2023, 7:54:32 AM7/5/23
to DroidScript
On Chromebook, apps look correct on full-screen, but show either black or a portion of the display when "small".

How can "small" be detected, and then how can we adjust the apps display?

ps. we can detect that the app is on Chromebook with app.IsChrome(), but is there an app.IsFullscreen() or similar?
ps. OnPause() and OnResume() only run when app is minimised or not (not whether full-screen or "small").

Thanks,
Dave.

Steve Garman

unread,
Jul 9, 2023, 12:34:12 PM7/9/23
to DroidScript
/*
This is some code I had on a very old chromebook
Every time an app was resized (e.g.minimized restored or dragged) the app restarted

You may be able to experiment with it a bit
*/
 
"use strict"

//Called when application is created.
function OnStart()
{
    var lay = app.CreateLayout("linear", "VCenter,FillXY");

    //Create a text label and add it to layout.
    var txt = app.CreateText("Touch to exit");
    txt.SetTextSize(32);
    txt.SetOnTouch(function(){app.Quit("Bye")})
    lay.AddChild(txt);

    //Add layout to app.
    app.AddLayout(lay);

    //Check for Chromebook window resize
    if(isWindowResized( lay ))
    {
        alert("Warning this app has been restarted from the" +
            " beginning because the window was resized");
    }
}

function isWindowResized(lay)
{
    // lay should be full display size using FillXY
   
    var resized = false;
    if(app.IsChrome())
    {
        console.log( "Starting in "+app.GetOrientation() );
        if(app.IsNewVersion())
        {
            app.ShowPopup("Window must not be resized")
            return resized
        }
        var appname=app.GetAppName();
        var wh = lay.GetAbsWidth()+":"+lay.GetAbsHeight();
        var lastWh=app.LoadText("lastWh","", appname);
   
        if(lastWh != wh)
        {
            app.SaveText("lastWh", wh, appname);
            resized = true;
            console.log("WARNING: App Window resized - restarted");
            var sz="width="+lay.GetAbsWidth()+" - height="+lay.GetAbsHeight()
            console.log(sz)
        }
    }
    return resized;
}

Steve Garman

unread,
Jul 9, 2023, 12:42:44 PM7/9/23
to DroidScript
In case it's not obvious by having a full size layout and detecting its size to change the size of anything you need to change
The details of how it was before are stored by app.SaveText()

davefinney

unread,
Jul 9, 2023, 4:42:19 PM7/9/23
to DroidScript
Seems like lay.GetAbsWidth() gives the width available for controls, then use that to size the controls?
I'll try it out,

Yes, the app restarting when switching between full-screen and "small" explains what is seen, need to test that too!

Thanks Steve.

Reply all
Reply to author
Forward
0 new messages