mirror of
https://github.com/clockworkpi/launcher.git
synced 2026-03-19 02:12:38 +01:00
Toggle AirPlane Mode
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import pygame
|
||||
#import math
|
||||
import subprocess
|
||||
import commands
|
||||
|
||||
#from beeprint import pp
|
||||
from libs.roundrects import aa_round_rect
|
||||
@@ -74,8 +74,8 @@ class InfoPageListItem(object):
|
||||
|
||||
|
||||
|
||||
class HelloWorldPage(Page):
|
||||
_FootMsg = ["Nav.","","","Back",""]
|
||||
class AirplanePage(Page):
|
||||
_FootMsg = ["Nav.","","","Back","Toggle"]
|
||||
_MyList = []
|
||||
_ListFontObj = fonts["varela13"]
|
||||
|
||||
@@ -88,53 +88,18 @@ class HelloWorldPage(Page):
|
||||
|
||||
_DrawOnce = False
|
||||
_Scroller = None
|
||||
|
||||
_InAirPlaneMode = False
|
||||
|
||||
def __init__(self):
|
||||
Page.__init__(self)
|
||||
self._Icons = {}
|
||||
|
||||
def HelloWorld(self):
|
||||
|
||||
hello = {}
|
||||
hello["key"] = "helloworld"
|
||||
hello["label"] = "HelloWorld "
|
||||
hello["value"] = "GameShell"
|
||||
self._AList["hello"] = hello
|
||||
|
||||
def GenList(self):
|
||||
|
||||
self._MyList = []
|
||||
|
||||
start_x = 0
|
||||
start_y = 10
|
||||
last_height = 0
|
||||
|
||||
for i,u in enumerate( ["hello"] ):
|
||||
if u not in self._AList:
|
||||
continue
|
||||
|
||||
v = self._AList[u]
|
||||
|
||||
li = InfoPageListItem()
|
||||
li._Parent = self
|
||||
li._PosX = start_x
|
||||
li._PosY = start_y + last_height
|
||||
li._Width = Width
|
||||
li._Fonts["normal"] = self._ListFontObj
|
||||
li._Fonts["small"] = fonts["varela12"]
|
||||
|
||||
if self._AList[u]["label"] != "":
|
||||
li.Init( self._AList[u]["label"] )
|
||||
else:
|
||||
li.Init( self._AList[u]["key"] )
|
||||
|
||||
li._Flag = self._AList[u]["key"]
|
||||
|
||||
li.SetSmallText( self._AList[u]["value"] )
|
||||
|
||||
last_height += li._Height
|
||||
|
||||
self._MyList.append(li)
|
||||
|
||||
|
||||
def Init(self):
|
||||
if self._Screen != None:
|
||||
@@ -155,7 +120,6 @@ class HelloWorldPage(Page):
|
||||
self._Icons["bg"] = bgpng
|
||||
"""
|
||||
|
||||
self.HelloWorld()
|
||||
|
||||
self.GenList()
|
||||
|
||||
@@ -178,12 +142,35 @@ class HelloWorldPage(Page):
|
||||
self._PosY += dis
|
||||
self._Scrolled += dis
|
||||
|
||||
def ToggleMode(self):
|
||||
print("ToggleMode")
|
||||
out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
|
||||
print out
|
||||
if out[1] == "yes":
|
||||
self._InAirPlaneMode = True
|
||||
|
||||
self._Screen._MsgBox.SetText("Turning On")
|
||||
self._Screen._MsgBox.Draw()
|
||||
commands.getstatusoutput("rfkill unblock all")
|
||||
|
||||
else:
|
||||
self._InAirPlaneMode = False
|
||||
self._Screen._MsgBox.SetText("Turning Off")
|
||||
self._Screen._MsgBox.Draw()
|
||||
commands.getstatusoutput("rfkill block all")
|
||||
|
||||
|
||||
def OnLoadCb(self):
|
||||
self._Scrolled = 0
|
||||
self._PosY = 0
|
||||
self._DrawOnce = False
|
||||
|
||||
out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
|
||||
if out[1] == "yes":
|
||||
self._InAirPlaneMode = True
|
||||
else:
|
||||
self._InAirPlaneMode = False
|
||||
|
||||
|
||||
def OnReturnBackCb(self):
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
@@ -194,7 +181,17 @@ class HelloWorldPage(Page):
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
|
||||
if event.key == CurKeys["B"]:
|
||||
self.ToggleMode()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
pygame.time.delay(1000)
|
||||
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
"""
|
||||
if event.key == CurKeys["Up"]:
|
||||
self.ScrollUp()
|
||||
self._Screen.Draw()
|
||||
@@ -203,29 +200,23 @@ class HelloWorldPage(Page):
|
||||
self.ScrollDown()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
"""
|
||||
|
||||
def Draw(self):
|
||||
|
||||
if self._DrawOnce == False:
|
||||
self.ClearCanvas()
|
||||
#self._Ps.Draw()
|
||||
if "bg" in self._Icons:
|
||||
self._Icons["bg"].NewCoord(self._Width/2,self._Height/2 + (self._BGheight - Height)/2 + self._Screen._TitleBar._Height)
|
||||
self._Icons["bg"].Draw()
|
||||
|
||||
for i in self._MyList:
|
||||
i.Draw()
|
||||
|
||||
self._DrawOnce = True
|
||||
self.ClearCanvas()
|
||||
|
||||
if "bg" in self._Icons:
|
||||
self._Icons["bg"].NewCoord(self._Width/2,self._Height/2 + (self._BGheight - Height)/2 + self._Screen._TitleBar._Height)
|
||||
self._Icons["bg"].Draw()
|
||||
|
||||
|
||||
if self._HWND != None:
|
||||
self._HWND.fill((255,255,255))
|
||||
|
||||
self._HWND.blit(self._CanvasHWND,(self._PosX,self._PosY,self._Width, self._Height ) )
|
||||
|
||||
self._Scroller.UpdateSize(self._BGheight,abs(self._Scrolled)*3)
|
||||
self._Scroller.Draw()
|
||||
# self._Scroller.UpdateSize(self._BGheight,abs(self._Scrolled)*3)
|
||||
# self._Scroller.Draw()
|
||||
|
||||
|
||||
|
||||
@@ -236,9 +227,9 @@ class APIOBJ(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
def Init(self,main_screen):
|
||||
self._Page = HelloWorldPage()
|
||||
self._Page = AirplanePage()
|
||||
self._Page._Screen = main_screen
|
||||
self._Page._Name ="HelloWorld"
|
||||
self._Page._Name ="Airplane Mode"
|
||||
self._Page.Init()
|
||||
|
||||
def API(self,main_screen):
|
||||
@@ -76,14 +76,14 @@ class ListPage(Page):
|
||||
self._PsIndex = 0
|
||||
|
||||
# "" pkgname, label
|
||||
alist = [["","Wifi","Wi-Fi"],
|
||||
alist = [["","Airplane","Airplane Mode"],
|
||||
["","Wifi","Wi-Fi"],
|
||||
["","Sound","Sound Volume"],
|
||||
["","Brightness","BackLight Brightness"],
|
||||
["","Storage",""],
|
||||
["","Update", ""],
|
||||
["","About", "About"],
|
||||
["","PowerOFF","Power off"],
|
||||
["","HelloWorld","HelloWorld"],]
|
||||
["","PowerOFF","Power off"],]
|
||||
|
||||
start_x = 0
|
||||
start_y = 0
|
||||
|
||||
Reference in New Issue
Block a user