From 12682733bae8b9fc2030296741a16bc2db6096e5 Mon Sep 17 00:00:00 2001 From: houzh Date: Mon, 12 Jun 2023 14:14:23 +0000 Subject: [PATCH] modify idgen.py,skip id from other packages --- scripts/idgen.py | 20 +++++++++++++++++--- src/gui/core/layout.cc | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/idgen.py b/scripts/idgen.py index 41fcc349..6dc63364 100755 --- a/scripts/idgen.py +++ b/scripts/idgen.py @@ -16,11 +16,26 @@ class CDROIDHandler( xml.sax.ContentHandler ): self.strings=[] self.namespace=namespace + def isMyNS(self,idname):#parse @android:id/ @+id/ @id/ + ns="" + if idname.find(":")>0: + ns = idname.split(":") + ns =ns[0] + else: + pos = idname.find("id/") + ns = idname[0:pos] + ns= ns.replace("@","") + ns= ns.replace("+","") + #print(idname+"==>"+ns) + if ns.strip():#not empty + return (ns==namespace) or (ns=="android" and namespace=="cdroid") or (ns=="cdroid" and namespace=="android") + return True def startElement(self, tag, attributes): for attr in attributes.getNames(): value = attributes.get(attr) if ':id' in attr: - self.addID(value) + if self.isMyNS(value): + self.addID(value) if 'string/' in value: self.addString(value) @@ -205,9 +220,8 @@ if ( __name__ == "__main__"): msg = "not changed " if not isIDSame:#True if same,otherwise False #content is changed,we must copy ftempids to fidxml(sys.argv[2]+"/values/ID.xml) - print(namespace+"'s IDs is changed "+ftempids+":"+fidxml) shutil.copyfile(ftempids,fidxml) idgen.dict2RH(sys.argv[3]) msg="changed " - print(namespace+"'s IDs is:"+msg+ftempids+":"+fidxml) + print(namespace+"'s IDs is:"+msg+ftempids+" : "+fidxml) os.remove(ftempids) diff --git a/src/gui/core/layout.cc b/src/gui/core/layout.cc index 9bc42002..7c803dfe 100644 --- a/src/gui/core/layout.cc +++ b/src/gui/core/layout.cc @@ -609,7 +609,7 @@ void Layout::drawText(Canvas&canvas,int firstLine,int lastLine){ switch(mAlignment){ case ALIGN_NORMAL: case ALIGN_LEFT : - default : x = te.x_bearing ; break; + default : x = 0 ; break; case ALIGN_CENTER: x = (mWidth-lw)/2 ; break; case ALIGN_OPPOSITE: case ALIGN_RIGHT : x = mWidth-lw ; break;