add sms detail view

git-svn-id: http://www.neo1973-germany.de/svn@218 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
fgau 2008-12-23 17:21:25 +00:00
parent da26c60997
commit abbb956fbf
7 changed files with 430 additions and 29 deletions

View file

@ -0,0 +1,200 @@
// sms_detail.edc
// this is a theme for epydial, a pyneo dialer
data {
item: "author" "thomasg [thomas (a) gstaedtner (.) net] , fgau (fgau@gau-net.de)";
item: "version" "prototype";
item: "name" "epydial_blackwhite";
}
fonts {
font: "Vera.ttf" "Vera";
font: "VeraBd.ttf" "VeraBd";
}
images {
image: "bg.png" COMP;
}
color_classes {
color_class {
name: "unvisible";
color: 0 0 0 0;
color2: 128 128 128 255;
color3: 128 128 128 255;
}
color_class {
name: "button_inactive";
color: 255 255 255 128;
color2: 128 128 128 255;
color3: 128 128 128 255;;
}
color_class {
name: "scale";
color: 255 255 255 56;
color2: 0 0 0 255;
color3: 0 0 0 255;
}
}
styles {
style {
name: "textblock_style";
base: "font=Vera font_size=28 align=left valign=top color=#fff wrap=word";
tag: "h1" "+ font_size=36";
tag: "/h1" "- \n";
tag: "p" "+";
tag: "/p" "- \n";
tag: "em" "+ style=underline underline_color=#000A underline2_color=#0005";
tag: "/em" "-";
tag: "br" "\n";
tag: "c1" "+ color=#fff";
tag: "/c1" "-";
tag: "c2" "+ color=#f3f";
tag: "/c2" "-";
}
}
#define BUTTON(button_number, rel1x, rel1y, rel2x, rel2y, button_caption) \
part { \
name: "button_"button_number; \
type: RECT; \
description { \
state: "default" 0; \
color_class: "unvisible"; \
rel1 { relative: rel1x rel1y; offset: 0 0; }; \
rel2 { relative: rel2x rel2y; offset: 0 0; }; \
} \
description { \
state: "default" 0.5; \
inherit: "default" 0; \
color_class: "unvisible"; \
rel1.offset: 0 -5; \
rel2.offset: 0 5; \
} \
description { \
state: "default" 1; \
inherit: "default" 0; \
} \
} \
part { \
name: "button_"button_number"_caption"; \
type: TEXT; \
mouse_events: 0; \
description { \
state: "default" 0; \
color_class: "button_inactive"; \
rel1 { \
to: "button_"button_number; \
relative: 0 0; \
} \
rel2 { \
to: "button_"button_number; \
relative: 1 1; \
} \
text { \
text: button_caption; \
size: 18; \
font: "Sans:style=Bold,Edje-Vera"; \
fit: 1 1; \
} \
} \
} \
program { \
name: "button_"button_number"_signal_emit"; \
signal: "mouse,down,*"; \
source: "button_"button_number; \
action: SIGNAL_EMIT "hon_send" button_caption; \
} \
program { \
name: "button_"button_number"_animation"; \
signal: "mouse,down,*"; \
source: "button_"button_number; \
action: STATE_SET "default" 0.5; \
target: "button_"button_number; \
} \
program { \
name: "button_"button_number"_animation_end"; \
signal: "mouse,up,*"; \
source: "button_"button_number; \
action: STATE_SET "default" 1; \
target: "button_"button_number; \
transition: DECELERATE 0.1; \
}
#define ITEM(item_number, rel1x, rel1y, rel2x, rel2y) \
part { \
name: item_number; \
type: RECT; \
description { \
state: "default" 0; \
color_class: "scale"; \
rel1 { relative: rel1x rel1y;}; \
rel2 { relative: rel2x rel2y;}; \
} \
} \
part { \
name: "sms_text_"item_number; \
type: TEXTBLOCK; \
mouse_events: 0; \
description { \
state: "default" 0; \
color_class: "button_inactive"; \
align: 0.5 0.5; \
fixed: 1 1; \
rel1 { \
to: item_number; \
relative: 1/20 0; \
} \
rel2 { \
to: item_number; \
relative: 19/20 1; \
} \
text { \
text: "muaaaah "; \
style: "textblock_style"; \
} \
} \
} \
collections {
group {
name: "pyneo/sms/detail";
min: 100 100;
max: 800 800;
parts {
part {
name: "background";
type: IMAGE;
mouse_events: 0;
description {
state: "default" 0;
rel1 { relative: 0 0; offset: 0 0; }
rel2 { relative: 1 1; offset: 0 0; }
image { normal: "bg.png"; }
}
}
part {
name: "headline";
type: TEXT;
description {
state: "default" 0;
color_class: "button_inactive";
rel1 { relative: 1/20 1/20; }
rel2 { relative: 19/20 3/20; }
text {
text: "sms detail";
size: 20;
font: "VeraBd";
fit: 1 1;
}
}
}
ITEM(1, 1/20, 9/40, 19/20, 28/40);
BUTTON(10, 0, 58/70 , 1/3, 68/70, "<");
BUTTON(11, 1/3, 58/70, 2/3, 68/70, "<");
BUTTON(12, 2/3, 58/70, 3/3, 68/70, ">");
}
}
}

View file

@ -134,7 +134,7 @@ part { \
} \
} \
part { \
name: "contact_"item_number; \
name: "sms_status_"item_number; \
type: TEXT; \
mouse_events: 0; \
description { \
@ -146,7 +146,7 @@ part { \
} \
rel2 { \
to: item_number; \
relative: 19/20 1; \
relative: 3/20 1; \
} \
text { \
text: ""; \
@ -157,6 +157,54 @@ part { \
} \
} \
} \
part { \
name: "sms_time_number_"item_number; \
type: TEXT; \
mouse_events: 0; \
description { \
state: "default" 0; \
color_class: "button_inactive"; \
rel1 { \
to: item_number; \
relative: 4/20 0; \
} \
rel2 { \
to: item_number; \
relative: 19/20 1/2; \
} \
text { \
text: ""; \
size: 16; \
font: "Sans:style=Bold,Edje-Vera"; \
/*fit: 1 1; */\
align: 0 0.5; \
} \
} \
} \
part { \
name: "sms_text_"item_number; \
type: TEXT; \
mouse_events: 0; \
description { \
state: "default" 0; \
color_class: "button_inactive"; \
rel1 { \
to: item_number; \
relative: 4/20 1/2; \
} \
rel2 { \
to: item_number; \
relative: 19/20 1; \
} \
text { \
text: ""; \
size: 22; \
font: "Sans:style=Bold,Edje-Vera"; \
/*fit: 1 1; */\
align: 0 0.5; \
} \
} \
} \
collections {

View file

@ -30,6 +30,7 @@ CALC_SCREEN_NAME = "pyneo/calc/screen"
PIX_SCREEN_NAME = "pyneo/pix/screen"
CONTACTS_SCREEN_NAME = "pyneo/contacts/screen"
SMS_SCREEN_NAME = "pyneo/sms/screen"
SMS_DETAIL_SCREEN_NAME = "pyneo/sms/detail"
from datetime import datetime
from dbus import SystemBus
@ -96,6 +97,9 @@ class PyneoController(object):
brightness_value = None
call = None
callsigs = []
@classmethod
def register_callback(class_, event_name, callback):
print "In register_callback: ", event_name
@ -127,6 +131,8 @@ class PyneoController(object):
class_.hon_hotornot = object_by_url(class_.hon.GetDevice('hotornot'))
class_.call_type = 'nix'
class_.brightness_value = 60
class_.call = None
class_.callsigs = []
except Exception, e:
print "Pyneo error: " + str(e)
@ -139,8 +145,9 @@ class PyneoController(object):
# No error (anymore)
if class_._dbus_timer: class_._dbus_timer.stop()
# Register our own D-Bus callbacks
# Register our own D-Bus callbacks (device status, new calls, power status, new sms)
class_.gsm_wireless.connect_to_signal("Status", class_.on_gsm_wireless_status, dbus_interface=DIN_WIRELESS)
class_.gsm_wireless.connect_to_signal('New', class_.check_new_call, dbus_interface=DIN_WIRELESS)
class_.pwr.connect_to_signal("Status", class_.on_pwr_status, dbus_interface=DIN_POWERED)
class_.gsm_sms.connect_to_signal('New', class_.check_new_sms, dbus_interface=DIN_STORAGE)
@ -165,6 +172,10 @@ class PyneoController(object):
def vote_hon(class_, vote):
class_.hon_hotornot.HotOrNot(vote, dbus_interface=DIN_HOTORNOT)
@classmethod
def show_sms_detail(class_, number):
class_.notify_callbacks("show_sms_detail", number)
@classmethod
def power_up_gsm(class_):
try:
@ -220,20 +231,20 @@ class PyneoController(object):
os.system('alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore')
class_.notify_callbacks("gsm_phone_call_start")
name = class_.gsm_wireless.Initiate(number, dbus_interface=DIN_VOICE_CALL_INITIATOR, timeout=200)
call = object_by_url(name)
class_.call = object_by_url(name)
@classmethod
def gsm_hangup(class_):
os.system('alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore')
class_.call_type = 'nix'
call = object_by_url('dbus:///org/pyneo/gsmdevice/Call/1')
call.Hangup(dbus_interface=DIN_CALL)
class_.call = object_by_url('dbus:///org/pyneo/gsmdevice/Call/1')
class_.call.Hangup(dbus_interface=DIN_CALL)
@classmethod
def gsm_accept(class_):
os.system('alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore')
call = object_by_url('dbus:///org/pyneo/gsmdevice/Call/1')
call.Accept(dbus_interface=DIN_CALL)
# class_.call = object_by_url('dbus:///org/pyneo/gsmdevice/Call/1')
class_.call.Accept(dbus_interface=DIN_CALL)
@classmethod
def gsm_details(class_):
@ -259,17 +270,17 @@ class PyneoController(object):
elif nw_status == 4:
raise NotImplementedError("GSM registration has unknown state")
if status.has_key('phone_activity_status'):
ph_status = status['phone_activity_status']
if class_.call_type != 'outgoing':
if ph_status == 0:
class_.notify_callbacks("gsm_phone_call_end")
os.system('alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore')
if ph_status == 3:
class_.notify_callbacks("gsm_phone_ringing")
if ph_status == 4:
class_.notify_callbacks("gsm_phone_call_start")
# if status.has_key('phone_activity_status'):
# ph_status = status['phone_activity_status']
#
# if class_.call_type != 'outgoing':
# if ph_status == 0:
# class_.notify_callbacks("gsm_phone_call_end")
# os.system('alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore')
# if ph_status == 3:
# class_.notify_callbacks("gsm_phone_ringing")
# if ph_status == 4:
# class_.notify_callbacks("gsm_phone_call_start")
if status.has_key('rssi'):
class_.notify_callbacks("gsm_signal_strength_change", status['rssi'])
@ -409,6 +420,44 @@ class PyneoController(object):
def show_contacts_screen(class_):
class_.notify_callbacks("show_contacts_screen")
@classmethod
def check_new_call(class_, newmap):
def CallStatus(newmap):
newmap = dedbusmap(newmap)
print '---', 'CallStatus'
# for n, v in newmap.items():
# print '\t', n, ':', v
def CallRing(newmap):
newmap = dedbusmap(newmap)
class_.notify_callbacks("gsm_phone_ringing")
if newmap['number']: class_.notify_callbacks("gsm_number_display", newmap['number'])
print '---', 'CallRing'
# for n, v in newmap.items():
# print '\t', n, ':', v
def CallEnd(newmap):
class_.notify_callbacks("gsm_phone_call_end")
os.system('alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore')
newmap = dedbusmap(newmap)
print '---', 'CallEnd'
# for n, v in newmap.items():
# print '\t', n, ':', v
if class_.call:
class_.call = None
while class_.callsigs:
class_.callsigs.pop().remove()
newmap = dedbusmap(newmap)
print '---', 'CallNew'
os.system('alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore')
for n, v in newmap.items():
# print '\t', n, ':', v
class_.call = object_by_url(n)
class_.callsigs.append(class_.call.connect_to_signal('Ring', CallRing, dbus_interface=DIN_CALL, ))
class_.callsigs.append(class_.call.connect_to_signal('Status', CallStatus, dbus_interface=DIN_CALL, ))
class_.callsigs.append(class_.call.connect_to_signal('End', CallEnd, dbus_interface=DIN_CALL, ))
@classmethod
def check_new_sms(class_, newmap,):
def InsertSms(status, from_msisdn, time, text):
@ -449,6 +498,10 @@ class PyneoController(object):
def show_sms_screen(class_):
class_.notify_callbacks("show_sms_screen")
@classmethod
def show_sms_screen_detail(class_):
class_.notify_callbacks("show_sms_screen_detail")
from dialer_screen import *
from incall_screen import *
@ -459,6 +512,7 @@ from calc_screen import *
from pix_screen import *
from contacts_screen import *
from sms_screen import *
from sms_detail import *
class Dialer(object):
screens = None
@ -484,6 +538,7 @@ class Dialer(object):
PyneoController.register_callback("show_pix_screen", self.on_pix_screen)
PyneoController.register_callback("show_contacts_screen", self.on_contacts_screen)
PyneoController.register_callback("show_sms_screen", self.on_sms_screen)
PyneoController.register_callback("show_sms_screen_detail", self.on_sms_screen_detail)
# Initialize the D-Bus interface to pyneo
dbus_ml = e_dbus.DBusEcoreMainLoop()
@ -554,6 +609,10 @@ class Dialer(object):
self.init_screen(SMS_SCREEN_NAME, SmsScreen(self))
self.show_screen(SMS_SCREEN_NAME)
def on_sms_screen_detail(self):
self.init_screen(SMS_DETAIL_SCREEN_NAME, SmsDetail(self))
self.show_screen(SMS_DETAIL_SCREEN_NAME)
class EvasCanvas(object):
def __init__(self, fullscreen, engine_name):

View file

@ -19,7 +19,6 @@ class HonScreen(EdjeGroup):
def register_pyneo_callbacks(self):
PyneoController.register_callback("get_hon", self.on_get_hon)
PyneoController.register_callback("vote_hon", self.on_vote_hon)
def on_get_hon(self, status):
img = object_by_url(status['img']).read()

View file

@ -17,14 +17,19 @@ class InCallScreen(EdjeGroup):
def on_gsm_number_display(self, number):
connection = connect(DB_FILE_PATH)
cursor = connection.cursor()
try:
cursor.execute("SELECT * FROM contacts WHERE mobil LIKE '%" + str(number) + "' OR home LIKE '%" + str(number) + "' OR work LIKE '%" + str(number) + "'")
for row in cursor:
CallerNamemap = row[0], row[1], row[2], row[3], row[4]
if CallerNamemap[2] == str(number): source = 'mobil'
elif CallerNamemap[3] == str(number): source = 'home'
elif CallerNamemap[4] == str(number): source = 'work'
if CallerNamemap[1] and CallerNamemap[0]:
self.part_text_set("incall_number_text", "%s"% (CallerNamemap[1] + ', ' + CallerNamemap[0]))
else:
self.part_text_set("incall_number_text", "unbekannt")
self.part_text_set("incall_number_text", "%s: %s"% (source, CallerNamemap[1] + ', ' + CallerNamemap[0]))
except:
self.part_text_set("incall_number_text", "unknown")
@edje.decorators.signal_callback("dialer_incall_send", "*")
def on_edje_signal_dialer_incall_triggered(self, emission, source):

30
epydial/sms_detail.py Normal file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env python2.5
# -*- coding: utf-8 -*-
__author__ = "Soeren Apel (abraxa@dar-clan.de), Frank Gau (fgau@gau-net.de), Thomas Gstaedtner (thomas (a) gstaedtner (.) net)"
__version__ = "prototype"
__copyright__ = "Copyright (c) 2008"
__license__ = "GPL3"
from epydial import *
class SmsDetail(EdjeGroup):
def __init__(self, screen_manager):
EdjeGroup.__init__(self, screen_manager, SMS_DETAIL_SCREEN_NAME)
def register_pyneo_callbacks(self):
PyneoController.register_callback("show_sms_detail", self.on_show_sms_detail)
def on_show_sms_detail(self, sms_number):
connection = connect(DB_FILE_PATH)
cursor = connection.cursor()
cursor.execute("SELECT * FROM sms WHERE status='%s' ORDER BY time DESC LIMIT 1 OFFSET %s" %('REC UNREAD', sms_number))
for row in cursor:
self.part_text_set("sms_text_1", row[3])
@edje.decorators.signal_callback("mouse,up,1", "*")
def on_edje_signal_dialer_status_triggered(self, emission, source):
if source == "button_10":
PyneoController.show_dialer_screen()
print 'source: ', source

View file

@ -8,13 +8,73 @@ __license__ = "GPL3"
from epydial import *
class SmsScreen(EdjeGroup):
sms_offset = 0
sorted_by = 'REC UNREAD'
detail = False
def __init__(self, screen_manager):
EdjeGroup.__init__(self, screen_manager, SMS_SCREEN_NAME)
self.show_sms()
def del_displayed_sms(self):
x=1
while x < 5:
self.part_text_set("sms_status_%s" %x, "")
self.part_text_set("sms_time_number_%s" %x, "")
self.part_text_set("sms_text_%s" %x, "")
x += 1
def show_sms(self):
x = 1
self.detail = False
self.del_displayed_sms()
self.part_text_set("sort_by", "sorted by: %s" %self.sorted_by)
connection = connect(DB_FILE_PATH)
cursor = connection.cursor()
cursor.execute("SELECT * FROM sms WHERE status='%s' ORDER BY time DESC LIMIT 4 OFFSET %s" %(self.sorted_by, self.sms_offset))
for row in cursor:
if row[0] == 'REC UNREAD':
read_status = 'U: '
elif row[0] == 'REC READ':
read_status = 'R: '
self.part_text_set("sms_status_%s" %x, "%s" %read_status)
self.part_text_set("sms_time_number_%s" %x, "%s, %s" %(row[2][:14], row[1]))
self.part_text_set("sms_text_%s" %x, row[3])
x += 1
@edje.decorators.signal_callback("mouse,up,1", "*")
def on_edje_signal_dialer_status_triggered(self, emission, source):
if self.detail == False:
if source == "1":
PyneoController.show_sms_screen_detail()
PyneoController.show_sms_detail(self.sms_offset)
if source == "2":
self.sms_offset += 1
PyneoController.show_sms_screen_detail()
PyneoController.show_sms_detail(self.sms_offset)
if source == "3":
self.sms_offset += 2
PyneoController.show_sms_screen_detail()
PyneoController.show_sms_detail(self.sms_offset)
if source == "4":
self.sms_offset += 3
PyneoController.show_sms_screen_detail()
PyneoController.show_sms_detail(self.sms_offset)
if source == "button_10":
PyneoController.show_dialer_screen()
if source == "button_12":
self.sms_offset += 4
self.show_sms()
if source == "button_11":
self.sms_offset -= 4
self.show_sms()
if source == "headline" and self.sorted_by == "REC UNREAD":
self.sorted_by = 'REC READ'
self.sms_offset = 0
self.show_sms()
elif source == "headline" and self.sorted_by == "REC READ":
self.sorted_by = 'REC UNREAD'
self.sms_offset = 0
self.show_sms()
print 'source: ', source