mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-01 19:58:14 +08:00
modify idgen and common_function.cmake,remove CreatePO,R.h's namespace can custom by user now
This commit is contained in:
parent
6916394e96
commit
5cdc1606e6
@ -22,8 +22,6 @@ add_definitions(--include cdlog.h)
|
||||
link_directories(${CMAKE_BINARY_DIR}/lib)
|
||||
add_executable(uidemo1 ${DEMO_SRCS})
|
||||
|
||||
CreatePO(${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} uidemo1)
|
||||
|
||||
CreatePAK(uidemo1 ${PROJECT_SOURCE_DIR}/assets ${PROJECT_BINARY_DIR}/uidemo1.pak ${PROJECT_SOURCE_DIR}/R.h)
|
||||
|
||||
add_custom_target(uidemo1translate
|
||||
|
@ -20,8 +20,6 @@ aux_source_directory(./ DEMO_SRCS)
|
||||
link_directories(${CMAKE_BINARY_DIR}/lib)
|
||||
add_executable(uidemo2 ${DEMO_SRCS})
|
||||
|
||||
CreatePO(${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} uidemo2)
|
||||
|
||||
CreatePAK(uidemo2 ${PROJECT_SOURCE_DIR}/assets ${PROJECT_BINARY_DIR}/uidemo2.pak ${PROJECT_SOURCE_DIR}/R.h)
|
||||
|
||||
add_custom_target(uidemotranslate
|
||||
|
@ -21,8 +21,6 @@ add_definitions(--include cdlog.h)
|
||||
link_directories(${CMAKE_BINARY_DIR}/lib)
|
||||
add_executable(w9 ${W9_SRCS})
|
||||
|
||||
CreatePO(${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} w9)
|
||||
|
||||
CreatePAK(w9 ${PROJECT_SOURCE_DIR}/assets ${PROJECT_BINARY_DIR}/w9.pak ${PROJECT_SOURCE_DIR}/R.h)
|
||||
|
||||
add_custom_target(w9translate
|
||||
|
@ -1,11 +1,3 @@
|
||||
<resources lang="zh_CN">
|
||||
<string name="weathertips">weathertips</string>
|
||||
<string-array name="cleverwash">
|
||||
<item>10分钟</item>
|
||||
<item>20分钟</item>
|
||||
<item>30分钟</item>
|
||||
<item>40分钟</item>
|
||||
<item>50分钟</item>
|
||||
<item>60分钟</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -2,15 +2,38 @@
|
||||
#include <washoptions.h>
|
||||
#include <cdroid.h>
|
||||
#include <R.h>
|
||||
|
||||
HomeWindow::HomeWindow(int mode):Window(0,0,-1,-1){
|
||||
LayoutInflater::from(getContext())->inflate("@layout/main",this);
|
||||
|
||||
RelativeLayout*rl=(RelativeLayout*)findViewById(w9::R::id::relativeLayout);
|
||||
HorizontalScrollView*sv=(HorizontalScrollView*)findViewById(w9::R::id::horizontalScroll);
|
||||
View*v=findViewById(w9::R::id::horizontalScroll);
|
||||
v->setHorizontalScrollBarEnabled(true);
|
||||
v->setOnScrollChangeListener([](View& view, int x, int y, int oldX, int oldY){
|
||||
//LOGD("x=%d->%d",oldX,x);
|
||||
});
|
||||
screenWidth=getWidth();
|
||||
mCurScrollX=mOldScrollX=0;
|
||||
v->setOnTouchListener([this](View&v, MotionEvent&event){
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent::ACTION_DOWN:
|
||||
mOldScrollX = v.getScrollX();
|
||||
break;
|
||||
case MotionEvent::ACTION_UP:
|
||||
mCurScrollX = v.getScrollX();
|
||||
//每次手滑动距离大于200或者小于-200才可以触发ScrolView滚动一屏幕距离,否则恢复原位
|
||||
LOGD("distance=%d mCurScrollX=%d",std::abs(mCurScrollX - mOldScrollX),mCurScrollX);
|
||||
if ((mCurScrollX - mOldScrollX) > 200) {
|
||||
v.scrollTo(mOldScrollX + screenWidth, 0);
|
||||
} else if ((mCurScrollX - mOldScrollX) < -200) {
|
||||
v.scrollTo(mOldScrollX - screenWidth, 0);
|
||||
} else {
|
||||
v.scrollTo(mOldScrollX, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
v=findViewById(w9::R::id::often);
|
||||
auto btn_listener=std::bind(&HomeWindow::onButtonClick,this,std::placeholders::_1);
|
||||
|
@ -2,6 +2,10 @@
|
||||
#include <widget/cdwindow.h>
|
||||
class HomeWindow:public Window{
|
||||
private:
|
||||
int mCurScrollX;
|
||||
int mOldScrollX;
|
||||
int screenWidth;
|
||||
protected:
|
||||
void onButtonClick(View&);
|
||||
void onWashOptionClick(View&);
|
||||
public:
|
||||
|
@ -21,7 +21,7 @@ OptionPicker::OptionPicker(Context*ctx,const AttributeSet&attr):RelativeLayout(c
|
||||
mText2->setText(attr.getString("text2"));
|
||||
TextView*v=dynamic_cast<EditText*>(findViewById(cdroid::R::id::numberpicker_input));
|
||||
if(v){
|
||||
v->setEnabled(false);//Visibility(View::GONE);
|
||||
v->setVisibility(View::GONE);
|
||||
v->setTextSize(48);
|
||||
}
|
||||
mNumberPicker->setTextSize(40);
|
||||
|
@ -11,7 +11,7 @@ endmacro()
|
||||
|
||||
function(CreatePAK project ResourceDIR PakPath rhpath)
|
||||
add_custom_target(${project}_assets
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/scripts/idgen.py ${ResourceDIR} ${rhpath}
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/scripts/idgen.py ${project} ${ResourceDIR} ${rhpath}
|
||||
COMMAND zip -q -r -D -0 ${PakPath} ./
|
||||
WORKING_DIRECTORY ${ResourceDIR}
|
||||
COMMENT "Pckage Assets from ${ResourceDIR} to:${PakPath}")
|
||||
|
@ -129,11 +129,13 @@ class IDGenerater(object):
|
||||
writer.write("/>%s" % (newl))
|
||||
|
||||
def strings2XML(self,filename):
|
||||
print self.Handler.strings
|
||||
if not os.path.exists(filename):
|
||||
dom=parseString('<?xml version="1.0" encoding="utf-8"?>\n<resources lang="zh_CN"></resources>')
|
||||
else:
|
||||
print(self.Handler.strings)
|
||||
try:
|
||||
dom=parse(filename)
|
||||
except:#(xml.parsers.expat.ExpatError)
|
||||
print(filename+" open failed or syntax error")
|
||||
dom=parseString('<?xml version="1.0" encoding="utf-8"?>\n<resources lang="zh_CN"></resources>')
|
||||
|
||||
root = dom.documentElement
|
||||
stringsNodeInFile=root.getElementsByTagName('string')
|
||||
for str in self.Handler.strings:
|
||||
@ -171,27 +173,29 @@ class IDGenerater(object):
|
||||
return lastmodifytime
|
||||
|
||||
if ( __name__ == "__main__"):
|
||||
#arg0 is myname(idgen.py)
|
||||
#arg1 is namespace
|
||||
#arg2 is resource directory
|
||||
#arg3 is directory which R.h generate to
|
||||
idstart=10000
|
||||
if len(sys.argv)<3:
|
||||
print(sys.argv[0])#+'assetspath R.h_path ID.xml'
|
||||
print("arg1="+sys.argv[1])
|
||||
segments=sys.argv[1].split('/')
|
||||
namespace=segments[len(segments)-2]
|
||||
if sys.argv[2].find("widget/R.h")>=0 and (namespace=='gui'):
|
||||
namespace='cdroid'
|
||||
print(sys.argv[0])
|
||||
print(sys.argv)
|
||||
namespace=sys.argv[1]
|
||||
if namespace=='cdroid':
|
||||
idstart=1000
|
||||
print("namespace="+namespace)
|
||||
lastmodifytime=0
|
||||
if os.path.exists(sys.argv[2]):
|
||||
fstat=os.stat(sys.argv[2])
|
||||
if os.path.exists(sys.argv[3]):
|
||||
fstat=os.stat(sys.argv[3])
|
||||
lastmodifytime=fstat.st_mtime
|
||||
idgen=IDGenerater(idstart,namespace)
|
||||
if not os.path.exists(sys.argv[1]+"/values"):
|
||||
os.makedirs(sys.argv[1]+"/values")
|
||||
if idgen.scanxml(sys.argv[1])>lastmodifytime:
|
||||
idgen.dict2RH(sys.argv[2])
|
||||
idgen.dict2ID(sys.argv[1]+"/values/ID.xml")
|
||||
idgen.strings2XML(sys.argv[1]+"/values/strings.xml")
|
||||
if not os.path.exists(sys.argv[2]+"/values"):
|
||||
os.makedirs(sys.argv[2]+"/values")
|
||||
if idgen.scanxml(sys.argv[2])>lastmodifytime:
|
||||
idgen.dict2RH(sys.argv[3])
|
||||
idgen.dict2ID(sys.argv[2]+"/values/ID.xml")
|
||||
idgen.strings2XML(sys.argv[2]+"/values/strings.xml")
|
||||
else:
|
||||
print(sys.argv[2]+" is latest ,skipped.")
|
||||
print(sys.argv[3]+" is latest ,skipped.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user