modify idgen.py,skip id from other packages

This commit is contained in:
houzh 2023-06-12 14:14:23 +00:00
parent ff72f6ccf0
commit 12682733ba
2 changed files with 18 additions and 4 deletions

View File

@ -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)

View File

@ -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;