diff cagou/plugins/plugin_wid_contact_list.py @ 322:e2b51663d8b8

core, android: new share widget + added Cagou to "share" menu: - new intent filter to add Cagou to share menu for all media types - minimum Kivy version is now 1.11.0 - new "Share" widget to display data to share via SàT and select the target - new core.platform_ module (the suffix "_" avoid trouble with standard "platform" module), for platform specific code. - Android intent are now checked on startup and "on_new_intent" events - if a android.intent.action.SEND action is received (i.e. some data is shared), the "Share" widget is shown - new Cagou.share method to share data using "Share" widget - new Cagou.getAncestorWidget method to easily retrieve an instance of a specific class in a widget's ancestors - ContactList's Avatar and ContactItem widgets have been moved to core.common
author Goffi <goffi@goffi.org>
date Fri, 06 Dec 2019 13:23:03 +0100
parents 772c170b47a9
children 9c6fe392d623
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_contact_list.py	Fri Dec 06 13:23:03 2019 +0100
+++ b/cagou/plugins/plugin_wid_contact_list.py	Fri Dec 06 13:23:03 2019 +0100
@@ -21,16 +21,14 @@
 from sat.core import log as logging
 log = logging.getLogger(__name__)
 from cagou.core.constants import Const as C
+from ..core.common import ContactItem
 from sat.core.i18n import _
 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList
 from sat_frontends.tools import jid
-from kivy.uix.boxlayout import BoxLayout
 from cagou.core.utils import FilterBehavior
 from cagou.core.menu import SideMenu, TouchMenuBehaviour, TouchMenuItemBehaviour
-from kivy.metrics import dp
 from kivy import properties
 from cagou.core import cagou_widget
-from cagou.core import image
 from cagou import G
 from functools import partial
 import bisect
@@ -99,19 +97,7 @@
             message=_("error while trying to remove contact: {msg}")))
 
 
-
-class Avatar(image.Image):
-    pass
-
-
-class ContactItem(TouchMenuItemBehaviour, BoxLayout):
-    base_width = dp(150)
-    profile = properties.StringProperty()
-    data = properties.DictProperty()
-    jid = properties.StringProperty('')
-
-    def __init__(self, **kwargs):
-        super(ContactItem, self).__init__(**kwargs)
+class CLContactItem(TouchMenuItemBehaviour, ContactItem):
 
     def do_item_action(self, touch):
         assert self.profile
@@ -162,14 +148,14 @@
                        )
 
     def _addContactItem(self, bare_jid, profile):
-        """Create a new ContactItem instance, and add it
+        """Create a new CLContactItem instance, and add it
 
         item will be added in a sorted position
         @param bare_jid(jid.JID): entity bare JID
         @param profile(unicode): profile where the contact is
         """
         data = G.host.contact_lists[profile].getItem(bare_jid)
-        wid = ContactItem(profile=profile, data=data, jid=bare_jid, main_wid=self)
+        wid = CLContactItem(profile=profile, data=data, jid=bare_jid, main_wid=self)
         child_jids = [c.jid for c in reversed(self.layout.children)]
         idx = bisect.bisect_right(child_jids, bare_jid)
         self.layout.add_widget(wid, -idx)
@@ -181,7 +167,7 @@
             log.debug("full contact list update")
             self.layout.clear_widgets()
             for bare_jid, data in self.items_sorted.items():
-                wid = ContactItem(profile=profile, data=data, jid=bare_jid, main_wid=self)
+                wid = CLContactItem(profile=profile, data=data, jid=bare_jid, main_wid=self)
                 self.layout.add_widget(wid)
                 self._wid_map[(profile, bare_jid)] = wid
         elif type_ == C.UPDATE_MODIFY: