Ejemplo n.º 1
0
 def __init__(self):
     Ui.DroidUi.__init__(self)
     self.layout = Ui.LinearLayout(
         Ui.ScrollView(self),
         background='@android:drawable/screen_background_dark_transparent',
     )
     for name in NAMES:
         self.image(self.layout, name)
	def on_but_save_click(self):
		valuetext = self.add_txt_value.cget('text', '')

		if valuetext and valuetext.isdigit():
			self.result = '%s:00 - %s' % (self.curdatetime.isoformat(' ')[:16], valuetext)
			self.layout.quit()
		else:
			Ui.info("You must enter a valid number for calories")
Ejemplo n.º 3
0
 def image(self, master, name):
     layout = Ui.LinearLayout(
         master,
         orientation=Ui.HORIZONTAL,
     )
     Ui.ImageView(layout, src='@android:drawable/' + name)
     Ui.TextView(layout, text=name)
     return layout
Ejemplo n.º 4
0
def Killer():
	while True:
		all = Ui.Package.running()
		one = Ui.choose('Choose to kill', all)
		if one is None:
			break
		for name in one:
			print('kill', name)
			Ui.Package(name).stop()
    def on_but_save_click(self):
        valuetext = self.add_txt_value.cget('text', '')

        if valuetext and valuetext.isdigit():
            self.result = '%s:00 - %s' % (self.curdatetime.isoformat(' ')[:16],
                                          valuetext)
            self.layout.quit()
        else:
            Ui.info("You must enter a valid number for calories")
Ejemplo n.º 6
0
def main():
	global view
	get_keycodes()
	gui = Ui.DroidUi()
	view = Ui.TextView(gui,
		text = 'Press any key',
		textSize = '40sp',
		layout_width = Ui.FILL_PARENT,
		gravity = Ui.CENTER,
	)
	Ui.Button(gui, text = 'Quit', command = gui.quit)
	gui.reg_event('key', display_event)
	gui.mainloop()
Ejemplo n.º 7
0
 def __init__(self):
     Ui.DroidUi.__init__(self)
     self.layout = Ui.LinearLayout(Ui.ScrollView(self), )
     for name in sorted(HTMLColor):
         color = HTMLColor[name]
         Ui.TextView(
             self.layout,
             layout_width=Ui.MATCH_PARENT,
             gravity=Ui.CENTER,
             text='%s: %s' % (name, color),
             textColor='#%06x' % (0xffffff - int(color[1:], 16), ),
             background=color,
         )
    def __init__(self):
        Ui.DroidUi.__init__(self)

        self.layout = Ui.LinearLayout(
            self,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.FILL_PARENT,
            background="#ff314859",
            orientation=Ui.VERTICAL,
        )
        Ui.TextView(
            self.layout,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.WRAP_CONTENT,
            text="Wrapper Demo",
            textSize="20dp",
            gravity=Ui.CENTER,
            textColor=color_yellow,
        )
        self.lst_list = Ui.ListView(
            self.layout,
            layout_width=Ui.FILL_PARENT,
            layout_height="300dp",
        )
        self.buttonBox = Ui.LinearLayout(
            self.layout,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.WRAP_CONTENT,
            orientation=Ui.HORIZONTAL,
        )
        self._button(
            self.buttonBox,
            text="Add",
            background=color_light,
            command=self.on_but_add_click,
        )
        self._button(
            self.buttonBox,
            text="Lookup",
            background=color_deep,
            command=self.on_but_lookup,
        )
        self._button(
            self.buttonBox,
            text="Exit",
            background=color_light,
            command=self.layout.quit,
        )
 def on_but_datechange_click(self):
     newdate = Ui.askdate(self.curdatetime.date())
     if newdate:
         self.curdatetime = datetime.combine(newdate,
                                             self.curdatetime.timetz())
         self.add_txt_date.configure(
             text=self.curdatetime.date().isoformat())
 def on_but_timechange_click(self):
     newtime = Ui.asktime(self.curdatetime.time())
     if newtime:
         self.curdatetime = datetime.combine(self.curdatetime.date(),
                                             newtime)
         self.add_txt_time.configure(
             text=self.curdatetime.time().isoformat()[:5])
Ejemplo n.º 11
0
def intent():
    def write(file, dict, keys=None):
        if keys is None:
            keys = sorted(dict)
        for k in keys:
            try:
                v = dict[k]
            except KeyError:
                print('no such key:', k)
                continue
            try:
                v = int(v)
                if v > 10: v = hex(v)
                file.write('%s = %s\n' % (k, v))
            except:
                file.write('%s = \'%s\'\n' % (k, v))
            del dict[k]
        file.write('\n')

    f = open('intent.txt', 'w+')
    consts = Ui.Class('android.content.Intent').consts()
    for i in (ACTION, BROADCAST, CATEGORY, EXTRA, FLAG):
        write(f, consts, i)
    write(f, consts)
    f.close()
Ejemplo n.º 12
0
def get_keycodes():
	global keys
	keys = [None] * 512
	for k, v in Ui.Class('android.view.KeyEvent').consts().items():
		if k.startswith('KEYCODE'):
			keys[v] = k
	return keys
Ejemplo n.º 13
0
 def _boxLayout(self, master):
     return Ui.LinearLayout(
         master,
         layout_width=Ui.FILL_PARENT,
         layout_height="0px",
         orientation=Ui.HORIZONTAL,
         layout_weight=27,
     )
 def _buttonLayout(self, master):
     return Ui.LinearLayout(
         master,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.WRAP_CONTENT,
         orientation=Ui.HORIZONTAL,
         layout_weight=15,
     )
Ejemplo n.º 15
0
 def _block(self, master, color):
     return Ui.TextView(
         master,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.FILL_PARENT,
         layout_weight=1,
         gravity=Ui.CENTER,
         background=color,
     )
 def _button(self, master, **kw):
     Ui.Button(master,
               layout_width=Ui.FILL_PARENT,
               layout_height="80dp",
               textSize="14dp",
               textColor=color_white,
               layout_weight=1,
               gravity=Ui.CENTER,
               **kw)
Ejemplo n.º 17
0
def FlashLight():
    phone = Ui.Phone()
    lock = Ui.WakeLock()

    try:
        # no screen dim
        lock.bright()

        # set max screen brightness, but has no effect
        old_bright = phone.brightness(255)

        # show a white black screen
        gui = Ui.TextView(background='#ffffffff')
        gui.mainloop('FlashLight')

        # restore screen brightness
        phone.brightness(old_bright)
    finally:
        lock.release()
Ejemplo n.º 18
0
    def __init__(self):
        Ui.DroidUi.__init__(self)
        self.layout = Ui.LinearLayout(
            self,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.FILL_PARENT,
            background=color_bg,
            orientation=Ui.VERTICAL,
        )

        Ui.TextView(
            self.layout,
            layout_width=Ui.FILL_PARENT,
            layout_height="0px",
            textSize="20dp",
            text="Gyro Test",
            textColor=color_white,
            layout_weight=19,
            gravity=Ui.CENTER,
        )

        box1 = self._boxLayout(self.layout)
        self._block(box1, color_bg)
        self.txt_top = self._block(box1, color_default)
        self._block(box1, color_bg)

        box2 = self._boxLayout(self.layout)
        self.txt_left = self._block(box2, color_default)
        self._block(box2, color_bg)
        self.txt_right = self._block(box2, color_default)

        box3 = self._boxLayout(self.layout)
        self._block(box3, color_bg)
        self.txt_bottom = self._block(box3, color_default)
        self._block(box3, color_bg)

        self.reg_event('sensors', self.gyro)

        # start sensing
        self.sensing = Ui.Sensing()
 def _valueButton(self, master, value, background):
     return Ui.Button(
         master,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.FILL_PARENT,
         text=value,
         textSize="14dp",
         background=background,
         textColor=color_white,
         layout_weight=1,
         gravity=Ui.CENTER,
         command=lambda value=value: self.on_but_value_handler(value),
     )
Ejemplo n.º 20
0
 def __init__(self):
     self.about = Ui.TextView(
         Ui.ScrollView(padding='20dp', background='#ff000000'),
         text=self.about_text,
     )
     self.game = Game()
     self.outer = Ui.LinearLayout(
         Ui.LinearLayout(background='#ff000000'),
         padding='30dp',
         background='#3500ffff',
         layout_height=Ui.FILL_PARENT,
     )
     self.inner = Ui.LinearLayout(self.outer, gravity=Ui.CENTER)
     Ui.TextView(
         self.inner,
         text='Android Sudoku',
         textSize='20dip',
         layout_marginBottom='25dip',
     )
     Ui.Button(self.inner, text='Continue', command=self.resume)
     Ui.Button(self.inner, text='New Game', command=self.play)
     Ui.Button(self.inner, text='About', command=self.about.mainloop)
     Ui.Button(self.inner, text='Exit', command=self.inner.quit)
 def __init__(self):
     self.layout = Ui.LinearLayout(
         background="#ff314859",
         orientation=Ui.VERTICAL,
     )
     Ui.TextView(
         self.layout,
         layout_width=Ui.FILL_PARENT,
         layout_height="0px",
         textSize="16dp",
         text="FullScreenWrapper2 Demo",
         textColor="#ffffffff",
         layout_weight=20,
         gravity=Ui.CENTER,
     )
     self.txt_colorbox = Ui.TextView(
         self.layout,
         layout_width=Ui.FILL_PARENT,
         layout_height="0px",
         background="#ff000000",
         layout_weight="60",
         gravity=Ui.CENTER,
     )
     self.buttonBox = Ui.LinearLayout(
         self.layout,
         layout_width=Ui.FILL_PARENT,
         layout_height="0px",
         orientation=Ui.HORIZONTAL,
         layout_weight="20",
     )
     Ui.Button(
         self.buttonBox,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.FILL_PARENT,
         background="#ff66a3d2",
         text="Random Color",
         layout_weight=1,
         textSize="14dp",
         gravity=Ui.CENTER,
         # HERE: click callback, auto registered
         command=self.change_color,
     )
     Ui.Button(
         self.buttonBox,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.FILL_PARENT,
         background="#ff25567b",
         layout_weight=1,
         text="Exit",
         textSize="14dp",
         gravity=Ui.CENTER,
         # HERE: call quit() on ui element will quit the current layout
         command=self.layout.quit,
     )
	def _datetimeLayout(self, master, name, text, command):
		layout = Ui.LinearLayout(master,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.WRAP_CONTENT,
			orientation = Ui.HORIZONTAL,
			layout_weight = 11,
		)
		Ui.TextView(layout,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.FILL_PARENT,
			text = text,
			textColor = color_yellow,
			textSize = "14dp",
			layout_weight = 1,
			gravity = Ui.CENTER,
			textStyle = 1,
		)
		setattr(self, name, Ui.TextView(layout,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.FILL_PARENT,
			textColor = color_white,
			textSize = "14dp",
			layout_weight = 1,
			gravity = Ui.joinattr(Ui.LEFT, Ui.CENTER_VERTICAL),
		))
		Ui.Button(layout,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.FILL_PARENT,
			textColor = color_white,
			textSize = "14dp",
			layout_weight = 1,
			background = color_light,
			text = "Change",
			gravity = Ui.CENTER,
			command = command,
		)
		Ui.LinearLayout(master,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.WRAP_CONTENT,
			layout_weight = 1,
		)
 def _datetimeLayout(self, master, name, text, command):
     layout = Ui.LinearLayout(
         master,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.WRAP_CONTENT,
         orientation=Ui.HORIZONTAL,
         layout_weight=11,
     )
     Ui.TextView(
         layout,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.FILL_PARENT,
         text=text,
         textColor=color_yellow,
         textSize="14dp",
         layout_weight=1,
         gravity=Ui.CENTER,
         textStyle=1,
     )
     setattr(
         self, name,
         Ui.TextView(
             layout,
             layout_width=Ui.FILL_PARENT,
             layout_height=Ui.FILL_PARENT,
             textColor=color_white,
             textSize="14dp",
             layout_weight=1,
             gravity=Ui.joinattr(Ui.LEFT, Ui.CENTER_VERTICAL),
         ))
     Ui.Button(
         layout,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.FILL_PARENT,
         textColor=color_white,
         textSize="14dp",
         layout_weight=1,
         background=color_light,
         text="Change",
         gravity=Ui.CENTER,
         command=command,
     )
     Ui.LinearLayout(
         master,
         layout_width=Ui.FILL_PARENT,
         layout_height=Ui.WRAP_CONTENT,
         layout_weight=1,
     )
	def on_but_timechange_click(self):
		newtime = Ui.asktime(self.curdatetime.time())
		if newtime:
			self.curdatetime = datetime.combine(self.curdatetime.date(), newtime)
			self.add_txt_time.configure(text = self.curdatetime.time().isoformat()[:5])
 def on_but_lookup(self):
     Ui.info("no functionality built yet :-)")
Ejemplo n.º 26
0
 def getkey(valid):
     if 0 == len(valid):
         Ui.info('no moves')
         return None
     return Ui.pick('select', valid)
Ejemplo n.º 27
0
 def play(self):
     ret = Ui.pick('New Game', ['easy', 'normal', 'hard'])
     if not ret:
         return
     self.game.setvalue(self.Puzzle[ret])
     self.game.main()
Ejemplo n.º 28
0
 def __init__(self, size=9):
     self.value = [None] * (size * size)
     self.size = size
     self.haverun = False
     self.table = Ui.RelativeLayout(
         background=self.back_color,
         gravity=Ui.CENTER,
     )
     self.array = []
     row = [
         Ui.TextView(
             self.table,
             clickable=Ui.TRUE,
             command=lambda x=0, y=0: self.click(x, y),
             layout_width='34dp',
             layout_height='34dp',
             background=self.puzzle_back,
             layout_marginRight='2dp',
             gravity=Ui.CENTER,
         )
     ]
     for j in range(1, size):
         row.append(
             Ui.TextView(
                 self.table,
                 clickable=Ui.TRUE,
                 command=lambda x=0, y=j: self.click(x, y),
                 layout_width='34dp',
                 layout_height='34dp',
                 background=self.puzzle_back,
                 layout_toRightOf='@id/' + row[j - 1].id,
                 layout_marginRight='2dp',
                 gravity=Ui.CENTER,
             ))
     self.array.append(row)
     for i in range(1, size):
         row = [
             Ui.TextView(
                 self.table,
                 clickable=Ui.TRUE,
                 command=lambda x=i, y=0: self.click(x, y),
                 layout_width='34dp',
                 layout_height='34dp',
                 background=self.puzzle_back,
                 layout_below='@id/' + self.array[i - 1][0].id,
                 layout_marginTop='2dp',
                 gravity=Ui.CENTER,
             )
         ]
         for j in range(1, size):
             row.append(
                 Ui.TextView(
                     self.table,
                     clickable=Ui.TRUE,
                     command=lambda x=i, y=j: self.click(x, y),
                     layout_width='34dp',
                     layout_height='34dp',
                     background=self.puzzle_back,
                     layout_alignLeft='@id/' + self.array[0][j].id,
                     layout_alignTop='@id/' + row[0].id,
                     gravity=Ui.CENTER,
                 ))
         self.array.append(row)
    def __init__(self):
        Ui.DroidUi.__init__(self)
        self.result = None
        self.curdatetime = datetime.today()

        self.layout = Ui.LinearLayout(
            self,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.FILL_PARENT,
            background="#ff314859",
            orientation=Ui.VERTICAL,
        )

        Ui.TextView(
            self.layout,
            layout_width=Ui.FILL_PARENT,
            textSize="20dp",
            text="Add Screen",
            textColor=color_white,
            gravity=Ui.CENTER,
            layout_weight=15,
        )

        self._datetimeLayout(self.layout, 'add_txt_date', 'Date',
                             self.on_but_datechange_click)
        self._datetimeLayout(self.layout, 'add_txt_time', 'Time',
                             self.on_but_timechange_click)

        valueLayout = Ui.LinearLayout(
            self.layout,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.WRAP_CONTENT,
            orientation=Ui.HORIZONTAL,
            layout_weight=11,
        )
        Ui.TextView(
            valueLayout,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.FILL_PARENT,
            text='Value',
            textColor=color_yellow,
            textSize="14dp",
            layout_weight=1,
            gravity=Ui.CENTER,
            textStyle=1,
        )
        self.add_txt_value = Ui.EditText(
            valueLayout,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.FILL_PARENT,
            digits="0123456789",
            textSize="12dp",
            layout_weight=1,
            background=color_white,
            gravity=Ui.joinattr(Ui.LEFT, Ui.CENTER_VERTICAL),
        )
        Ui.Button(
            valueLayout,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.FILL_PARENT,
            textColor=color_yellow,
            textSize="14dp",
            layout_weight=1,
            background=color_light,
            text="Save",
            gravity=Ui.CENTER,
            command=self.on_but_save_click,
        )

        Ui.TextView(
            self.layout,
            layout_width=Ui.FILL_PARENT,
            layout_height=Ui.WRAP_CONTENT,
            textSize="10dp",
            text="Type value or choose below",
            textColor=color_white,
            gravity=Ui.CENTER,
            layout_weight=5,
        )

        buttonBox1 = self._buttonLayout(self.layout)
        self._valueButton(buttonBox1, 40, color_light)
        self._valueButton(buttonBox1, 70, color_deep)
        self._valueButton(buttonBox1, 100, color_light)
        self._valueButton(buttonBox1, 120, color_deep)

        buttonBox2 = self._buttonLayout(self.layout)
        self._valueButton(buttonBox2, 150, color_deep)
        self._valueButton(buttonBox2, 180, color_light)
        self._valueButton(buttonBox2, 200, color_deep)
        self._valueButton(buttonBox2, 250, color_light)

        buttonBox3 = self._buttonLayout(self.layout)
        self._valueButton(buttonBox3, 300, color_light)
        self._valueButton(buttonBox3, 350, color_deep)
        self._valueButton(buttonBox3, 400, color_light)
        self._valueButton(buttonBox3, 450, color_deep)
Ejemplo n.º 30
0
	def getkey(valid):
		if 0 == len(valid):
			Ui.info('no moves')
			return None
		return Ui.pick('select', valid)
Ejemplo n.º 31
0
	def play(self):
		ret = Ui.pick('New Game', ['easy', 'normal', 'hard'])
		if not ret:
			return
		self.game.setvalue(self.Puzzle[ret])
		self.game.main()
	def on_but_datechange_click(self):
		newdate = Ui.askdate(self.curdatetime.date())
		if newdate:
			self.curdatetime = datetime.combine(newdate, self.curdatetime.timetz())
			self.add_txt_date.configure(text = self.curdatetime.date().isoformat())
	def on_but_lookup(self):
		Ui.info("no functionality built yet :-)")
	def __init__(self):
		Ui.DroidUi.__init__(self)
		self.result = None
		self.curdatetime = datetime.today()

		self.layout = Ui.LinearLayout(self,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.FILL_PARENT,
			background = "#ff314859",
			orientation = Ui.VERTICAL,
		)

		Ui.TextView(self.layout,
			layout_width = Ui.FILL_PARENT,
			textSize = "20dp",
			text = "Add Screen",
			textColor = color_white,
			gravity = Ui.CENTER,
			layout_weight = 15,
		)

		self._datetimeLayout(self.layout, 'add_txt_date', 'Date', self.on_but_datechange_click)
		self._datetimeLayout(self.layout, 'add_txt_time', 'Time', self.on_but_timechange_click)

		valueLayout = Ui.LinearLayout(self.layout,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.WRAP_CONTENT,
			orientation = Ui.HORIZONTAL,
			layout_weight = 11,
		)
		Ui.TextView(valueLayout,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.FILL_PARENT,
			text = 'Value',
			textColor = color_yellow,
			textSize = "14dp",
			layout_weight = 1,
			gravity = Ui.CENTER,
			textStyle = 1,
		)
		self.add_txt_value = Ui.EditText(valueLayout,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.FILL_PARENT,
			digits = "0123456789",
			textSize = "12dp",
			layout_weight = 1,
			background = color_white,
			gravity = Ui.joinattr(Ui.LEFT, Ui.CENTER_VERTICAL),
		)
		Ui.Button(valueLayout,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.FILL_PARENT,
			textColor = color_yellow,
			textSize = "14dp",
			layout_weight = 1,
			background = color_light,
			text = "Save",
			gravity = Ui.CENTER,
			command = self.on_but_save_click,
		)

		Ui.TextView(self.layout,
			layout_width = Ui.FILL_PARENT,
			layout_height = Ui.WRAP_CONTENT,
			textSize = "10dp",
			text = "Type value or choose below",
			textColor = color_white,
			gravity = Ui.CENTER,
			layout_weight = 5,
		)

		buttonBox1 = self._buttonLayout(self.layout)
		self._valueButton(buttonBox1, 40, color_light)
		self._valueButton(buttonBox1, 70, color_deep)
		self._valueButton(buttonBox1, 100, color_light)
		self._valueButton(buttonBox1, 120, color_deep)

		buttonBox2 = self._buttonLayout(self.layout)
		self._valueButton(buttonBox2, 150, color_deep)
		self._valueButton(buttonBox2, 180, color_light)
		self._valueButton(buttonBox2, 200, color_deep)
		self._valueButton(buttonBox2, 250, color_light)

		buttonBox3 = self._buttonLayout(self.layout)
		self._valueButton(buttonBox3, 300, color_light)
		self._valueButton(buttonBox3, 350, color_deep)
		self._valueButton(buttonBox3, 400, color_light)
		self._valueButton(buttonBox3, 450, color_deep)