modift w9's resource
@ -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{
|
||||
|
@ -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">
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
@ -15,25 +15,28 @@
|
||||
android:id="@+id/relativeLayout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_gravity="center"
|
||||
android:background="#111111"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginVertical="10dp">
|
||||
<TextView
|
||||
android:id="@+id/temp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginVertical="10dp"
|
||||
android:text="气温28"
|
||||
android:textSize="40dp"/>
|
||||
<TextView
|
||||
android:id="@id/tips"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="10dp"
|
||||
android:layout_below="@id/temp"
|
||||
android:text="@string/weathertips"/>
|
||||
android:text="@string/weathertips"/>
|
||||
<Button
|
||||
android:id="@+id/often"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tips"
|
||||
android:layout_alignParentLeft="true"
|
||||
@ -42,14 +45,15 @@
|
||||
android:id="@+id/care"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="护理"/>
|
||||
<Button
|
||||
android:id="+id/favorite"
|
||||
android:layout_below="@id/care"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="5dp"
|
||||
android:text="收藏"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
@ -1,108 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/horizontalScroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
android:overScrollMode="always"
|
||||
android:verticalScrollbarPosition="left">
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<RelativeLayout
|
||||
android:id="@+id/relativeLayout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320p"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginVertical="10dp">
|
||||
<TextView
|
||||
android:id="@+id/temp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="气温28"
|
||||
android:textSize="40dp"/>
|
||||
<TextView
|
||||
android:id="@id/tips"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/temp"
|
||||
android:text="今天天气适合晾晒"/>
|
||||
<Button
|
||||
android:id="@+id/often"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tips"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="常用"/>
|
||||
<Button
|
||||
android:id="@+id/care"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="护理"/>
|
||||
<Button
|
||||
android:id="+id/favorite"
|
||||
android:layout_below="@id/care"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="收藏"/>
|
||||
</RelativeLayout>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/zhinengxi"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/chenshan"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/chujun"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/husexi"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/mianma"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/niuzai"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/tuoshui"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/zhenqihuli"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/zhensi"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/zhiyanqinxin"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
29
apps/w9/assets/layout/optionitem.xml
Executable file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/relativeLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:background="#111111"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginVertical="10dp">
|
||||
<NumberPicker
|
||||
android:id="@+id/options"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/text1"/>
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/text2"
|
||||
android:text="护理"/>
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginVertical="5dp"
|
||||
android:text="收藏"/>
|
||||
</RelativeLayout>
|
||||
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 122 KiB |
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 102 KiB |
@ -8,8 +8,10 @@
|
||||
<id name="often">0x00002715</id>
|
||||
<id name="care">0x00002716</id>
|
||||
<id name="favorite">0x00002717</id>
|
||||
<id name="content">0x00002718</id>
|
||||
<id name="options">0x00002719</id>
|
||||
<id name="optionsContainer">0x0000271a</id>
|
||||
<id name="options">0x00002718</id>
|
||||
<id name="text1">0x00002719</id>
|
||||
<id name="text2">0x0000271a</id>
|
||||
<id name="content">0x0000271b</id>
|
||||
<id name="optionsContainer">0x0000271c</id>
|
||||
</resources>
|
||||
|
||||
|
@ -2,9 +2,8 @@
|
||||
#include <washoptions.h>
|
||||
#include <cdroid.h>
|
||||
#include <R.h>
|
||||
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;
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
#include <widget/cdwindow.h>
|
||||
class HomeWindow:public Window{
|
||||
private:
|
||||
void onClick(View&);
|
||||
void onButtonClick(View&);
|
||||
void onWashOptionClick(View&);
|
||||
public:
|
||||
HomeWindow(int mode);
|
||||
};
|
||||
|
@ -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();
|
||||
|
@ -43,6 +43,7 @@ private:
|
||||
int mMaxWidth;
|
||||
bool mComputeMaxWidth;
|
||||
int mTextSize;
|
||||
int mTextColor;
|
||||
int mSelectorTextGapHeight;
|
||||
std::vector<std::string> 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
|
||||
|