diff --git a/apps/w9/R.h b/apps/w9/R.h
index 415b0774..7897a4b5 100644
--- a/apps/w9/R.h
+++ b/apps/w9/R.h
@@ -14,9 +14,11 @@ namespace R{
static constexpr int often = 0x00002715 ;/*10005*/
static constexpr int care = 0x00002716 ;/*10006*/
static constexpr int favorite = 0x00002717 ;/*10007*/
- static constexpr int content = 0x00002718 ;/*10008*/
- static constexpr int options = 0x00002719 ;/*10009*/
- static constexpr int optionsContainer = 0x0000271A ;/*10010*/
+ static constexpr int options = 0x00002718 ;/*10008*/
+ static constexpr int text1 = 0x00002719 ;/*10009*/
+ static constexpr int text2 = 0x0000271A ;/*10010*/
+ static constexpr int content = 0x0000271B ;/*10011*/
+ static constexpr int optionsContainer = 0x0000271C ;/*10012*/
};/*namespace id*/
namespace strings{
diff --git a/apps/w9/assets/layout/content_main.xml b/apps/w9/assets/layout/main.xml
similarity index 78%
rename from apps/w9/assets/layout/content_main.xml
rename to apps/w9/assets/layout/main.xml
index 394043ee..47648b55 100755
--- a/apps/w9/assets/layout/content_main.xml
+++ b/apps/w9/assets/layout/main.xml
@@ -4,8 +4,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarSize="10dp"
- android:scrollbars="vertical"
- android:overScrollMode="always"
+ android:scrollbars="horizontal"
+ android:overScrollMode="never"
android:scrollIndicators="top">
+ android:text="@string/weathertips"/>
diff --git a/apps/w9/assets/layout/main2.xml b/apps/w9/assets/layout/main2.xml
deleted file mode 100644
index 8f676ac4..00000000
--- a/apps/w9/assets/layout/main2.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apps/w9/assets/layout/optionitem.xml b/apps/w9/assets/layout/optionitem.xml
new file mode 100755
index 00000000..8d811809
--- /dev/null
+++ b/apps/w9/assets/layout/optionitem.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
diff --git a/apps/w9/assets/mipmap/chenshan.png b/apps/w9/assets/mipmap/chenshan.png
index 6665d5b8..9622a34d 100755
Binary files a/apps/w9/assets/mipmap/chenshan.png and b/apps/w9/assets/mipmap/chenshan.png differ
diff --git a/apps/w9/assets/mipmap/chujun.png b/apps/w9/assets/mipmap/chujun.png
index ec0df348..b0f8e0f3 100755
Binary files a/apps/w9/assets/mipmap/chujun.png and b/apps/w9/assets/mipmap/chujun.png differ
diff --git a/apps/w9/assets/mipmap/husexi.png b/apps/w9/assets/mipmap/husexi.png
index 32a0d672..e3defd9e 100755
Binary files a/apps/w9/assets/mipmap/husexi.png and b/apps/w9/assets/mipmap/husexi.png differ
diff --git a/apps/w9/assets/mipmap/mianma.png b/apps/w9/assets/mipmap/mianma.png
index 0391d071..de957bc8 100755
Binary files a/apps/w9/assets/mipmap/mianma.png and b/apps/w9/assets/mipmap/mianma.png differ
diff --git a/apps/w9/assets/mipmap/niuzai.png b/apps/w9/assets/mipmap/niuzai.png
index cdaea4d7..9575cb57 100755
Binary files a/apps/w9/assets/mipmap/niuzai.png and b/apps/w9/assets/mipmap/niuzai.png differ
diff --git a/apps/w9/assets/mipmap/tuoshui.png b/apps/w9/assets/mipmap/tuoshui.png
index 98149a21..65b51257 100755
Binary files a/apps/w9/assets/mipmap/tuoshui.png and b/apps/w9/assets/mipmap/tuoshui.png differ
diff --git a/apps/w9/assets/mipmap/zhenqihuli.png b/apps/w9/assets/mipmap/zhenqihuli.png
index 4ad068bb..38c38a60 100755
Binary files a/apps/w9/assets/mipmap/zhenqihuli.png and b/apps/w9/assets/mipmap/zhenqihuli.png differ
diff --git a/apps/w9/assets/mipmap/zhensi.png b/apps/w9/assets/mipmap/zhensi.png
index 52e2f442..9ef4fa96 100755
Binary files a/apps/w9/assets/mipmap/zhensi.png and b/apps/w9/assets/mipmap/zhensi.png differ
diff --git a/apps/w9/assets/mipmap/zhinengxi.png b/apps/w9/assets/mipmap/zhinengxi.png
index e63519f5..b51cb2ad 100755
Binary files a/apps/w9/assets/mipmap/zhinengxi.png and b/apps/w9/assets/mipmap/zhinengxi.png differ
diff --git a/apps/w9/assets/mipmap/zhiyanqinxin.png b/apps/w9/assets/mipmap/zhiyanqinxin.png
index a939d40f..26415fd1 100755
Binary files a/apps/w9/assets/mipmap/zhiyanqinxin.png and b/apps/w9/assets/mipmap/zhiyanqinxin.png differ
diff --git a/apps/w9/assets/values/ID.xml b/apps/w9/assets/values/ID.xml
index 74e4be6b..a7f5ac82 100644
--- a/apps/w9/assets/values/ID.xml
+++ b/apps/w9/assets/values/ID.xml
@@ -8,8 +8,10 @@
0x00002715
0x00002716
0x00002717
- 0x00002718
- 0x00002719
- 0x0000271a
+ 0x00002718
+ 0x00002719
+ 0x0000271a
+ 0x0000271b
+ 0x0000271c
diff --git a/apps/w9/homewindow.cc b/apps/w9/homewindow.cc
index ac99b879..4d1ddfcc 100644
--- a/apps/w9/homewindow.cc
+++ b/apps/w9/homewindow.cc
@@ -2,9 +2,8 @@
#include
#include
#include
-HomeWindow::HomeWindow(int mode):Window(0,0,1280,800){
- LayoutInflater::from(getContext())->inflate("@layout/content_main",this);
- //LayoutInflater::from(getContext())->inflate("@layout/main2",this);
+HomeWindow::HomeWindow(int mode):Window(0,0,-1,-1){
+ LayoutInflater::from(getContext())->inflate("@layout/main",this);
RelativeLayout*rl=(RelativeLayout*)findViewById(w9::R::id::relativeLayout);
View*v=findViewById(w9::R::id::horizontalScroll);
@@ -12,53 +11,45 @@ HomeWindow::HomeWindow(int mode):Window(0,0,1280,800){
v->setOnScrollChangeListener([](View& view, int x, int y, int oldX, int oldY){
//LOGD("x=%d->%d",oldX,x);
});
+
v=findViewById(w9::R::id::often);
- View::OnClickListener ls=[](View&v ){
- LOGD("click %d",v.getId());
- };
- if(v)v->setOnClickListener(ls);
+ auto btn_listener=std::bind(&HomeWindow::onButtonClick,this,std::placeholders::_1);
+ v->setOnClickListener(btn_listener);
v=findViewById(w9::R::id::care);
- if(v)v->setOnClickListener(ls);
+ v->setOnClickListener(btn_listener);
v=findViewById(w9::R::id::favorite);
- if(v)v->setOnClickListener(ls);
+ if(v)v->setOnClickListener(btn_listener);
+
LinearLayout*ll=(LinearLayout*)findViewById(w9::R::id::linearLayout);
const char* res[]={
- "@mipmap/zhinengxi",
- "@mipmap/chenshan",
- "@mipmap/chujun",
- "@mipmap/husexi",
- "@mipmap/mianma",
- "@mipmap/niuzai",
- "@mipmap/tuoshui",
- "@mipmap/zhenqihuli",
- "@mipmap/zhensi",
- "@mipmap/zhiyanqinxin",
- nullptr
+ "@mipmap/zhinengxi", "@mipmap/chenshan", "@mipmap/chujun", "@mipmap/husexi",
+ "@mipmap/mianma", "@mipmap/niuzai", "@mipmap/tuoshui", "@mipmap/zhenqihuli",
+ "@mipmap/zhensi", "@mipmap/zhiyanqinxin", nullptr
};
+ const char* texts[]={"智能洗","衬衫","除菌","护色洗","棉麻","牛仔","脱水","蒸汽护理","真丝","智氧清洗"};
for(int i=0;res[i];i++){
- ImageView*img=new ImageView(100,100);
LinearLayout::LayoutParams*lp=new LinearLayout::LayoutParams(LayoutParams::WRAP_CONTENT,LayoutParams::WRAP_CONTENT);
lp->gravity=Gravity::CENTER_VERTICAL;
- ll->addView(img,lp).setId(100+i);
- img->setImageResource(res[i]);
- img->setOnClickListener(std::bind(&HomeWindow::onClick,this,std::placeholders::_1));
+ TextView*txt=new TextView(texts[i],100,100);
+ txt->setGravity(Gravity::BOTTOM|Gravity::CENTER_HORIZONTAL);
+ txt->setTextSize(36);
+ ll->addView(txt,lp).setId(100+i);
+ txt->setBackgroundResource(res[i]);
+ txt->setOnClickListener(std::bind(&HomeWindow::onWashOptionClick,this,std::placeholders::_1));
}
- View::OnLayoutChangeListener layoutlistener={[](View& v, int left, int top, int width, int height,
- int oldLeft, int oldTop, int oldwidth, int oldheight){
- v.setRotation(270.0f);
- v.setTranslationX(-0);
- v.setTranslationY(-160);
- LOGD("LayoutChangeListener size=%dx%d",width,height);
- }};
- rl->addOnLayoutChangeListener(layoutlistener);
+ ll->requestLayout();
}
-void HomeWindow::onClick(View&v){
- switch(v.getId()){
- case 100:
+void HomeWindow::onButtonClick(View&v){
+ LOGD("click %d",v.getId());
+}
+
+void HomeWindow::onWashOptionClick(View&v){
+ switch(v.getId()){
+ case 100:
new WashOptionsWindow(-1);
break;
- default:
+ default:
LOGD("TODO for %d",v.getId());
break;
}
diff --git a/apps/w9/homewindow.h b/apps/w9/homewindow.h
index 2b1cd56e..c464fade 100644
--- a/apps/w9/homewindow.h
+++ b/apps/w9/homewindow.h
@@ -2,7 +2,8 @@
#include
class HomeWindow:public Window{
private:
- void onClick(View&);
+ void onButtonClick(View&);
+ void onWashOptionClick(View&);
public:
HomeWindow(int mode);
};
diff --git a/src/gui/widget/numberpicker.cc b/src/gui/widget/numberpicker.cc
index 5affeb92..f543962d 100644
--- a/src/gui/widget/numberpicker.cc
+++ b/src/gui/widget/numberpicker.cc
@@ -97,9 +97,9 @@ NumberPicker::NumberPicker(Context* context,const AttributeSet& atts)
mInputText =(EditText*)findViewById(cdroid::R::id::numberpicker_input);
ViewConfiguration configuration = ViewConfiguration::get(context);
mTextSize = (int) mInputText->getTextSize();
-
+ ColorStateList*colors=mInputText->getTextColors();
+ mTextColor = colors->getColorForState(StateSet::get(StateSet::VIEW_STATE_ENABLED),Color::WHITE);
updateInputTextView();
-
}
NumberPicker::~NumberPicker(){
@@ -516,13 +516,53 @@ bool NumberPicker::performLongClick() {
}
void NumberPicker::showSoftInput(){
+
}
void NumberPicker::hideSoftInput(){
+ if (mHasSelectorWheel) {
+ mInputText->setVisibility(View::INVISIBLE);
+ }
}
void NumberPicker::tryComputeMaxWidth(){
-
+ if (!mComputeMaxWidth) {
+ return;
+ };
+ int maxTextWidth = 0;
+ if (mDisplayedValues.size()==0) {
+ float maxDigitWidth = 0;
+ for (int i = 0; i <= 9; i++) {
+ const float digitWidth = mTextSize;//mSelectorWheelPaint.measureText(formatNumberWithLocale(i));
+ if (digitWidth > maxDigitWidth) {
+ maxDigitWidth = digitWidth;
+ }
+ }
+ int numberOfDigits = 0;
+ int current = mMaxValue;
+ while (current > 0) {
+ numberOfDigits++;
+ current = current / 10;
+ }
+ maxTextWidth = (int) (numberOfDigits * maxDigitWidth);
+ } else {
+ const int valueCount = mDisplayedValues.size();
+ for (int i = 0; i < valueCount; i++) {
+ const float textWidth = mTextSize;//mSelectorWheelPaint.measureText(mDisplayedValues[i]);
+ if (textWidth > maxTextWidth) {
+ maxTextWidth = (int) textWidth;
+ }
+ }
+ }
+ maxTextWidth += mInputText->getPaddingLeft() + mInputText->getPaddingRight();
+ if (mMaxWidth != maxTextWidth) {
+ if (maxTextWidth > mMinWidth) {
+ mMaxWidth = maxTextWidth;
+ } else {
+ mMaxWidth = mMinWidth;
+ }
+ invalidate();
+ }
}
bool NumberPicker::getWrapSelectorWheel()const{
@@ -600,12 +640,15 @@ void NumberPicker::setMaxValue(int maxValue) {
void NumberPicker::setMinHeight(int h){
mMinHeight = h;
}
+
void NumberPicker::setMaxHeight(int h){
mMaxHeight = h;
}
+
int NumberPicker::getMinHeight()const{
return mMinHeight;
}
+
int NumberPicker::getMaxHeight()const{
return mMaxHeight;
}
@@ -639,6 +682,31 @@ void NumberPicker::jumpDrawablesToCurrentState() {
}
}
+void NumberPicker::onResolveDrawables(int layoutDirection){
+ ViewGroup::onResolveDrawables(layoutDirection);
+ if (mSelectionDivider) {
+ mSelectionDivider->setLayoutDirection(layoutDirection);
+ }
+}
+
+void NumberPicker::setTextColor(int color){
+ mInputText->setTextColor(color);
+ mTextColor = color;
+ invalidate();
+}
+
+int NumberPicker::getTextColor()const{
+ return mTextColor;
+}
+
+void NumberPicker::setTextSize(int size){
+ mInputText->setTextSize(size);
+}
+
+int NumberPicker::getTextSize()const{
+ return mInputText->getTextSize();
+}
+
void NumberPicker::onDraw(Canvas&canvas){
if (!mHasSelectorWheel) {
LinearLayout::onDraw(canvas);
@@ -690,7 +758,8 @@ void NumberPicker::onDraw(Canvas&canvas){
if((i!=mMiddleItemIndex-1)&&(i!=mMiddleItemIndex))
alpha=(255-500.*std::abs(i-mMiddleItemIndex+(i>mMiddleItemIndex?1:0))/(selectorIndices.size()+1));
mSelectionDivider->setAlpha(alpha);
- mSelectionDivider->setBounds(0,y+mTextSize-mCurrentScrollOffset+mSelectorTextGapHeight,mRight-mLeft,std::min(mSelectorTextGapHeight,mSelectionDividerHeight));
+ mSelectionDivider->setBounds(0,y+mTextSize-mCurrentScrollOffset+mSelectorTextGapHeight,mRight-mLeft,
+ std::min(mSelectorTextGapHeight,mSelectionDividerHeight));
mSelectionDivider->draw(canvas);
canvas.restore();
}
@@ -992,8 +1061,8 @@ void NumberPicker::pshCancel(){
mPSHMode =0;
mPSHManagedButton=0;
if(mPressedStateHelpers!=nullptr){
- removeCallbacks(mPressedStateHelpers);
- invalidate(0, mBottomSelectionDividerBottom, mRight-mLeft, mBottom-mTop);
+ removeCallbacks(mPressedStateHelpers);
+ invalidate(0, mBottomSelectionDividerBottom, mRight-mLeft, mBottom-mTop);
}
mPressedStateHelpers =[this](){
pshRun();
diff --git a/src/gui/widget/numberpicker.h b/src/gui/widget/numberpicker.h
index 0b48c3d0..fae5bd09 100755
--- a/src/gui/widget/numberpicker.h
+++ b/src/gui/widget/numberpicker.h
@@ -43,6 +43,7 @@ private:
int mMaxWidth;
bool mComputeMaxWidth;
int mTextSize;
+ int mTextColor;
int mSelectorTextGapHeight;
std::vector mDisplayedValues;
int mMinValue;
@@ -136,7 +137,6 @@ protected:
int computeVerticalScrollRange();
int computeVerticalScrollExtent();
void drawableStateChanged();
- void jumpDrawablesToCurrentState();
void onDraw(Canvas&canvas)override;
public:
NumberPicker(int w,int h);
@@ -171,6 +171,13 @@ public:
void setWrapSelectorWheel(bool);
void setOnLongPressUpdateInterval(long);
void setSelector(int items,int focused=-1);
+
+ void jumpDrawablesToCurrentState();
+ void onResolveDrawables(int layoutDirection)override;
+ void setTextColor(int color);
+ int getTextColor()const;
+ void setTextSize(int size);
+ int getTextSize()const;
};
}//namespace