- Главная
- Форум
- Программирование
- Программирование под Android
- SL4A - Scripting Layer For Android » Страница 32
SL4A - Scripting Layer For Android » Страница 32
-Программирование под Android
Мужики, протестируйте библиотеку интерфейса для sl4a, пожалуйста.. Пока она не полная, но уже интересно, как ведет себя на разных размерах экранов. Кому не сложно, заскриньте проблемные места, если найдете. Примеры использования в конце каждого модуля библиотеки, если запускать из консоли. Буду благодарен.
Прикрепленный файл #1:
У меня все корректно. Подозреваю, что у Жеки с данными дефолтными размерами шрифтов буквы будут огромных размеров, судя по его тестам моих скриптов. Я бы посоветовал разметке напрямую не указывать параметр textSize, а писать что-то вроде {textSizeTitle}, а потом форматировать droid.fullShow(layout.format(textSizeTitle=('', 'android:textSize={0}'.format(text_size_title))[bool(text_size_title)])), и по-умолчанию выставлять text_size_title = None (при None там будет пустая строка), т.е. дать возможность юзать дефолтный размер. Блин, путанно написал). И еще, в диалоговых окнах не лишнем будет задействовать на предмет возврата None кнопку меню (82) и пространство вокруг окна. Разумеется, это лишь мое субъективное мнение)
Так и вышло. Размер текста огромен.
(117,67 Kb)
(135,87 Kb)
(85,49 Kb)
-------------
добавлено в 14.25: по поводу блютуз вот нарыл пример реализации чата по данному протоколу:
Показать / Скрыть текст
from android import Android
import time,sys
# Prepare the python for android API
droid = Android()
# Instruct Py4A which HTML file to use for the webview (we’ll explore this later)
droid.webViewShow('file:///sdcard/sl4a/scripts/daveTest/index.html')
# SL4A uses the concept of events, like javascript does.
# To use them, you need to “register” to events, and take action whenever you detect an event.
# Events are passed with various attributes to your script.
# So for example the “name” attribute allows you to distinguish between different events, while the “data” attribute contains the # data passed by the event
# You create your own event names and data via the webview as we’ll soon see
while True:
# Wait for an event
event = droid.eventWait().result
#If / else statement to determine what action to take depending on the event name
if event['name'] == 'kill':
#exit if webview sends and event named “kill”
sys.exit()
elif event['name'] == 'bluetooth':
#switch bluetooth on
droid.toggleBluetoothState(True)
# this is a bluetooth client, so we just need to ask the user
# which bluetooth server to connect to, and connect
droid.bluetoothConnect()
# wait for a bluetooth message
while True:
# We got a bluetooth message, so emit an event to the webview (using eventPost)
# named “bluetoothOut” and pass the message along with the #event.
message = droid.bluetoothReadLine().result
droid.eventPost('bluetoothOut', message)
#If the message is “quit”, display a native android alert (not a web one) and #exit
if message =='quit':
title = 'dvas0004'
text = 'Server told me to turn bluetooth off'
droid.dialogCreateAlert(title, text)
droid.dialogSetNeutralButtonText('Ok')
droid.dialogShow()
droid.dialogGetResponse().result
droid.dialogDismiss()
break
elif event['name'] == 'sayHi':
# If the event the script receives is called “sayHi” vibrate, create a notification
# in the notification bar, and an alert to boot…
droid.notify('dvas0004',event['data'])
droid.vibrate()
title = 'dvas0004'
text = 'Look at your notifications bar!'
droid.dialogCreateAlert(title, text)
droid.dialogSetNeutralButtonText('Ok')
droid.dialogShow()
droid.dialogGetResponse().result
droid.dialogDismiss()
Вот такую библиотеку нашел для py4a
Прикрепленный файл #1: 4cc_droidui-master.zip (57,9 Kb)
Существует возможность программе на питон дать права SU? Для файлменеджера надо. В манифесте надо чего прописать, или там не так все просто?
-------------
добавлено в 08.54: И еще вопрос, кто знает, где эти графические ресурсы @android/drawable находятся, не могу найти, в какой папке?
Не получается нихрена. И в res нету этих ресурсов, какие-то 3 картинки левые и все. Фиг с ним. Я не могу понять эту файловую систему. Вот например файл /storage/sdcard0/file.txt. И тот же файл /sdcard/file.txt. Нафига тогда эта /sdcard, если есть /storage/sdcard0 ? Т.е. я делаю скан всех файлов, и у меня выводятся одни и те-же файлы и через первое, и через второе, да еще и через /mnt... Какой в этом смысл? Погуглил, там все линух описывают, что где находится, на свой вопрос так пока ответа и не нашел((. И еще где у андроида временная папка, которая очищается после перезагрузки, есть такая?
- «
- 1
- 2
- --
- 31
- 32
- 33
- --
- 36
- 37
- »

