def chooseitem(items): c = andlib.Chooser(droid) return c.choose( "Choose item", andlib.items2assoc(items) )
def step(): global items for condition in [condition for condition in conditions if conditions[condition].activated]: items = [item for item in items if conditions[condition].apply(item)] droid.dialogDismiss() chooser = andlib.Chooser(droid) conditions_string = ", ".join( [condition for condition in conditions if conditions[condition].activated ] ) if conditions_string: conditions_string = " (%s)" % conditions_string if configs.get("auto_select").activated: item = items[0] else: item = chooser.choose( "Choose item %s%s" % ( len(items), conditions_string, ), andlib.items2assoc(items), "Menu", "Quit" ) if type(item) == bool and item == True: # menu choice = menu(chooser) if not ( type(choice) == bool and choice == True ): choice(item) elif type(item) == bool and item == False: droid.makeToast("Bye") sys.exit(0) elif item is not None: # show the menu about the item choice = None first_time = True while choice != False: choices = ( "open", "open origin", "gtd mail origin", ("A", get_priority_setter('A')), ("B", get_priority_setter('B')), ("C", get_priority_setter('C')), ("describe", lambda x: chooser.choose( str(x), ( str(x), "url: %s" % x.url ), ) ), ("toggle read", lambda x: toggle_read(x)), ("dl", lambda x: dl_item(x)), ("dl light", lambda x: dl_item(x, ril.DOWNLOAD_LIGHT_MODE)), ("dl mirror", lambda x: dl_item(x, ril.DOWNLOAD_MIRROR_MODE)), ("Wget log", show_wget_log), ("clean", lambda x: x.clean()), ("rm", rm_item), ("rm_and_back", rm_item_and_back), "back", ) if choice == None and first_time and configs["auto_open"].activated: choice = "open" else: choice = chooser.choose(str(item), choices, "Menu", "Quit" ) first_time = False if type(choice) == bool and choice == True: # menu choice = menu(chooser) if not ( type(choice) == bool and choice == True ): choice(item) elif type(choice) == bool and choice == False: droid.makeToast("Bye") sys.exit(0) elif type(choice) == str and choice == "open": chooser.choose_show("Opening url, click on ok when done (%s left)"% len(items), (item.title_html_unescaped,), "OK", "Rm and back") print "Opening %s" % str(item) item.open() choice2 = chooser.choose_get_res() if choice2 == False: choice = rm_item_and_back(item) elif choice is None: choice = False elif type(choice) == str and choice == "open origin": chooser.choose_show("Click on ok when done", (item.url,), "OK") os.system("konix_android_browser_open.sh '%s'" % item.url) chooser.choose_get_res() elif type(choice) == str and choice == "gtd mail origin": chooser.choose_show("Click on ok when done", (item.url,), "OK") os.system("echo '%s'|andgtd.sh" % item.url) chooser.choose_get_res() elif type(choice) == str and choice == "back": choice = False elif type(choice) != bool: choice = choice(item) else: assert False, "not handled choice %s" % choice