0

I'm trying to set the lightmode of status bar and navigation bar on and off in delphi 11.3 for android. The first problem is that i can't find the "getinsetscontroller". I fix that with the below code that works (not sure if it is the right approach because google says it's deprecated).

The second problem is that when the app starts or looses focus the statusbar icon color is white (not sure if lightmode is on or off) and the app isn't in full screen mode. I have to set the lightmode and full screen on manually with a button for example. Is there any way to start the app in fullscreen and lightmode on and maintain that until i decide to turn it off?

procedure SetLightMode(AToggle: Boolean);
var
  LWindow: JWindow;
  LParams: JWindowManager_LayoutParams;
begin
  LWindow := TAndroidHelper.Activity.getWindow;
  LParams := LWindow.getAttributes();

  if AToggle then
  begin
    LParams.flags := LParams.flags or TJWindowManager_LayoutParams.JavaClass.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
    LWindow.setStatusBarColor(TJColor.JavaClass.WHITE);
    LWindow.setNavigationBarColor(TJColor.JavaClass.WHITE);
    LWindow.getDecorView().setSystemUiVisibility(TJView.JavaClass.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or TJView.JavaClass.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or TJView.JavaClass.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or TJView.JavaClass.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
  end
  else
  begin
    LParams.flags := LParams.flags or TJWindowManager_LayoutParams.JavaClass.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
    LWindow.setStatusBarColor(TJColor.JavaClass.BLACK);
    LWindow.setNavigationBarColor(TJColor.JavaClass.BLACK);
    LWindow.getDecorView().setSystemUiVisibility(TJView.JavaClass.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or TJView.JavaClass.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or TJView.JavaClass.SYSTEM_UI_FLAG_LAYOUT_STABLE);
  end;

  LWindow.setAttributes(LParams);
end;
xa_la_ra
  • 1
  • 1

0 Answers0