Add entries to the welcome wizard for using the Kindle reader app on an Android device

This commit is contained in:
Kovid Goyal 2012-02-04 10:16:45 +05:30
parent 7e03588bad
commit b65b295dd9
4 changed files with 48 additions and 6 deletions

View File

@ -447,10 +447,10 @@ def plugin_for_catalog_format(fmt):
# }}}
def device_plugins(): # {{{
def device_plugins(include_disabled=False): # {{{
for plugin in _initialized_plugins:
if isinstance(plugin, DevicePlugin):
if not is_disabled(plugin):
if include_disabled or not is_disabled(plugin):
if platform in plugin.supported_platforms:
yield plugin
# }}}

View File

@ -221,6 +221,20 @@ class ANDROID(USBMS):
drives['main'] = letter_a
return drives
@classmethod
def configure_for_kindle_app(cls):
proxy = cls._configProxy()
proxy['format_map'] = ['mobi', 'azw', 'azw1', 'azw4', 'pdf']
proxy['use_subdirs'] = False
proxy['extra_customization'] = ','.join(['kindle']+cls.EBOOK_DIR_MAIN)
@classmethod
def configure_for_generic_epub_app(cls):
proxy = cls._configProxy()
del proxy['format_map']
del proxy['use_subdirs']
del proxy['extra_customization']
class S60(USBMS):
name = 'S60 driver'

View File

@ -28,6 +28,7 @@ from calibre.gui2 import min_available_height, available_width
from calibre.utils.config import dynamic, prefs
from calibre.gui2 import NONE, choose_dir, error_dialog
from calibre.gui2.dialogs.progress import ProgressDialog
from calibre.customize.ui import device_plugins
# Devices {{{
@ -251,15 +252,39 @@ class Android(Device):
id = 'android'
supports_color = True
class AndroidTablet(Device):
@classmethod
def commit(cls):
super(Android, cls).commit()
for plugin in device_plugins(include_disabled=True):
if plugin.name == 'Android driver':
plugin.configure_for_generic_epub_app()
class AndroidTablet(Android):
name = 'Android tablet'
output_format = 'EPUB'
manufacturer = 'Android'
id = 'android_tablet'
supports_color = True
output_profile = 'tablet'
class AndroidPhoneWithKindle(Android):
name = 'Android phone with Kindle reader'
output_format = 'MOBI'
id = 'android_phone_with_kindle'
output_profile = 'kindle'
@classmethod
def commit(cls):
super(Android, cls).commit()
for plugin in device_plugins(include_disabled=True):
if plugin.name == 'Android driver':
plugin.configure_for_kindle_app()
class AndroidTabletWithKindle(AndroidPhoneWithKindle):
name = 'Android tablet with Kindle reader'
id = 'android_tablet_with_kindle'
output_profile = 'kindle_fire'
class HanlinV3(Device):
name = 'Hanlin V3'

View File

@ -351,6 +351,9 @@ class ConfigProxy(object):
def __setitem__(self, key, val):
return self.set(key, val)
def __delitem__(self, key):
self.set(key, self.defaults[key])
def get(self, key):
if self.__opts is None:
self.refresh()