diff --git a/.travis.yml b/.travis.yml index 2475bcb7f..6ead9d428 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,6 @@ notifications: android: components: - - build-tools-28.0.3 + - build-tools-29.0.3 - android-28 - extra diff --git a/app/build.gradle b/app/build.gradle index 8e64d4554..20bd18bad 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.supla.android" minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) - versionCode 95 - versionName "2.3.40" + versionCode 96 + versionName "2.3.41" sourceSets.main { jniLibs.srcDir 'src/main/libs' @@ -39,7 +39,7 @@ android { lintOptions { checkReleaseBuilds false } testOptions { unitTests.returnDefaultValues = true } - buildToolsVersion '28.0.3' + buildToolsVersion '29.0.3' } repositories { diff --git a/app/src/main/java/org/supla/android/ChannelDetailEM.java b/app/src/main/java/org/supla/android/ChannelDetailEM.java index 19b2f9fe6..8b3192faf 100644 --- a/app/src/main/java/org/supla/android/ChannelDetailEM.java +++ b/app/src/main/java/org/supla/android/ChannelDetailEM.java @@ -96,7 +96,6 @@ public class ChannelDetailEM extends DetailLayout implements View.OnClickListene private TextView tvPhaseReverseActiveEnergyBalanced; private TextView tvlPhaseReverseActiveEnergyBalanced; private ImageView emImgIcon; - private TextView tvChannelTitle; private Button btnPhase1; private Button btnPhase2; private Button btnPhase3; @@ -178,7 +177,6 @@ protected void init() { findViewById(R.id.emtv_lPhaseReverseActiveEnergyBalanced); emImgIcon = findViewById(R.id.emimgIcon); - tvChannelTitle = findViewById(R.id.emtv_ChannelTitle); llBalance = findViewById(R.id.emtv_llBalance); tvlBalance = findViewById(R.id.emtv_lBalance); @@ -362,8 +360,6 @@ public void channelExtendedDataToViews(boolean setIcon) { emImgIcon.setImageBitmap(ImageCache.getBitmap(getContext(), channel.getImageIdx())); } - tvChannelTitle.setText(channel.getNotEmptyCaption(getContext())); - ChannelExtendedValue cev = channel.getExtendedValue(); setBtnBackground(btnPhase1, R.drawable.em_phase_btn_black); diff --git a/app/src/main/java/org/supla/android/ChannelDetailIC.java b/app/src/main/java/org/supla/android/ChannelDetailIC.java index 9302ff57f..5993088c9 100644 --- a/app/src/main/java/org/supla/android/ChannelDetailIC.java +++ b/app/src/main/java/org/supla/android/ChannelDetailIC.java @@ -55,7 +55,6 @@ public class ChannelDetailIC extends DetailLayout implements SuplaRestApiClientT private ImpulseCounterChartHelper chartHelper; private DownloadImpulseCounterMeasurements dtm; private ProgressBar icProgress; - private TextView tvChannelTitle; private TextView tvMeterValue; private TextView tvCurrentConsumption; private TextView tvCurrentCost; @@ -86,7 +85,6 @@ public ChannelDetailIC(Context context, AttributeSet attrs, int defStyleAttr, in protected void init() { super.init(); icProgress = findViewById(R.id.icProgressBar); - tvChannelTitle = findViewById(R.id.ictv_ChannelTitle); tvMeterValue = findViewById(R.id.ictv_MeterValue); tvTotalCost = findViewById(R.id.ictv_TotalCost); tvCurrentConsumption = findViewById(R.id.ictv_CurrentConsumption); @@ -130,7 +128,6 @@ public View inflateContentView() { private void channelExtendedDataToViews(boolean setIcon) { Channel channel = (Channel) getChannelFromDatabase(); - tvChannelTitle.setText(channel.getNotEmptyCaption(getContext())); if (setIcon) { icImgIcon.setBackgroundColor(Color.TRANSPARENT); diff --git a/app/src/main/java/org/supla/android/ChannelDetailRGB.java b/app/src/main/java/org/supla/android/ChannelDetailRGBW.java similarity index 54% rename from app/src/main/java/org/supla/android/ChannelDetailRGB.java rename to app/src/main/java/org/supla/android/ChannelDetailRGBW.java index 084823cda..9e6d0c0a1 100644 --- a/app/src/main/java/org/supla/android/ChannelDetailRGB.java +++ b/app/src/main/java/org/supla/android/ChannelDetailRGBW.java @@ -20,6 +20,7 @@ of the License, or (at your option) any later version. import android.annotation.SuppressLint; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; import android.content.res.Resources; import android.graphics.Color; @@ -27,10 +28,10 @@ of the License, or (at your option) any later version. import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; -import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; @@ -47,21 +48,25 @@ of the License, or (at your option) any later version. import java.util.Timer; import java.util.TimerTask; -public class ChannelDetailRGB extends DetailLayout implements View.OnClickListener, SuplaColorBrightnessPicker.OnColorBrightnessChangeListener, SuplaColorListPicker.OnColorListTouchListener { +public class ChannelDetailRGBW extends DetailLayout implements View.OnClickListener, + SuplaColorBrightnessPicker.OnColorBrightnessChangeListener, + SuplaColorListPicker.OnColorListTouchListener { final static private long MIN_REMOTE_UPDATE_PERIOD = 250; - final static private long MIN_UPDATE_DELAY = 2000; - private SuplaColorBrightnessPicker rgbPicker; + final static private long MIN_UPDATE_DELAY = 3500; + private SuplaColorBrightnessPicker cbPicker; private SuplaColorListPicker clPicker; private Button tabRGB; private Button tabDimmer; + private Button tabWheel; + private Button tabSlider; private ViewGroup tabs; - private TextView tvTitle; + private ViewGroup pickerTypeTabs; + private ViewGroup llExtraButtons; private Button btnSettings; + private Button btnInfo; private RelativeLayout rlMain; private VLCalibrationTool vlCalibrationTool = null; - private TextView tvStateCaption; - private ImageView stateImage; private long remoteUpdateTime; private long changeFinishedTime; private Timer delayTimer1; @@ -70,20 +75,22 @@ public class ChannelDetailRGB extends DetailLayout implements View.OnClickListen private int lastColor; private int lastColorBrightness; private int lastBrightness; + private Button btnPowerOnOff; + private Boolean varilight; - public ChannelDetailRGB(Context context, ChannelListView cLV) { + public ChannelDetailRGBW(Context context, ChannelListView cLV) { super(context, cLV); } - public ChannelDetailRGB(Context context, AttributeSet attrs) { + public ChannelDetailRGBW(Context context, AttributeSet attrs) { super(context, attrs); } - public ChannelDetailRGB(Context context, AttributeSet attrs, int defStyleAttr) { + public ChannelDetailRGBW(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } - public ChannelDetailRGB(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + public ChannelDetailRGBW(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @@ -91,11 +98,12 @@ protected void init() { super.init(); - tabs = findViewById(R.id.rlTabs); + tabs = findViewById(R.id.llTabs); + pickerTypeTabs = findViewById(R.id.llPickerTypeTabs); Resources r = getResources(); - status = findViewById(R.id.rgbstatus); + status = findViewById(R.id.rgbwstatus); status.setOnlineColor(getResources().getColor(R.color.channel_dot_on)); status.setOfflineColor(getResources().getColor(R.color.channel_dot_off)); @@ -108,38 +116,38 @@ protected void init() { clPicker.addItem(); clPicker.setOnTouchListener(this); - rgbPicker = findViewById(R.id.rgbPicker); - rgbPicker.setPercentVisible(false); - rgbPicker.setWheelWidth(r.getDimensionPixelSize(R.dimen.rgb_wheel_width)); - rgbPicker.setArrowHeight(r.getDimensionPixelSize(R.dimen.rgb_wheel_arrow_height)); - - rgbPicker.setOnChangeListener(this); + cbPicker = findViewById(R.id.cbPicker); + cbPicker.setOnChangeListener(this); tabRGB = findViewById(R.id.rgbTabBtn_RGB); tabDimmer = findViewById(R.id.rgbTabBtn_Dimmer); + tabWheel = findViewById(R.id.rgbTabBtn_Wheel); + tabSlider = findViewById(R.id.rgbTabBtn_Slider); tabRGB.setOnClickListener(this); tabDimmer.setOnClickListener(this); + tabWheel.setOnClickListener(this); + tabSlider.setOnClickListener(this); + + llExtraButtons = findViewById(R.id.llExtraButtons); + llExtraButtons.setVisibility(GONE); - btnSettings = findViewById(R.id.rgbBtnSettings); + btnInfo = findViewById(R.id.rgbwBtnInfo); + btnSettings = findViewById(R.id.rgbwBtnSettings); + btnInfo.setOnClickListener(this); btnSettings.setOnClickListener(this); - btnSettings.setVisibility(GONE); - rlMain = findViewById(R.id.rlRgbMain); + rlMain = findViewById(R.id.rlRgbwMain); rlMain.setVisibility(VISIBLE); + btnPowerOnOff = findViewById(R.id.rgbwBtnPowerOnOff); + btnPowerOnOff.setOnClickListener(this); + Typeface type = SuplaApp.getApp().getTypefaceOpenSansBold(); tabRGB.setTypeface(type); tabDimmer.setTypeface(type); - - tvStateCaption = findViewById(R.id.rgbDetailStateCaption); - tvStateCaption.setTypeface(type); - - tvTitle = findViewById(R.id.rgbDetailTitle); - tvTitle.setTypeface(SuplaApp.getApp().getTypefaceQuicksandRegular()); - - stateImage = findViewById(R.id.rgbDetailStateImage); - stateImage.setOnClickListener(this); + tabWheel.setTypeface(type); + tabSlider.setTypeface(type); remoteUpdateTime = 0; changeFinishedTime = 0; @@ -149,24 +157,46 @@ protected void init() { private void showRGB() { - - rgbPicker.setColorWheelVisible(true); - rgbPicker.setColorBrightnessWheelVisible(true); + cbPicker.setColorWheelVisible(true); + cbPicker.setSliderVisible(false); clPicker.setVisibility(View.VISIBLE); + pickerTypeTabs.setVisibility(GONE); + llExtraButtons.setVisibility(GONE); + btnPowerOnOff.setVisibility(GONE); channelDataToViews(); } private void showDimmer() { - rgbPicker.setBWBrightnessWheelVisible(true); + cbPicker.setColorWheelVisible(false); clPicker.setVisibility(View.GONE); + pickerTypeTabs.setVisibility(VISIBLE); - channelDataToViews(); - } + varilight = false; - public void onBackPressed() { + if (getChannelBase() instanceof Channel) { + Channel c = (Channel) getChannelBase(); + if (c.getManufacturerID() == SuplaConst.SUPLA_MFR_DOYLETRATT + && c.getProductID() == 1) { + varilight = true; + } + } + if (varilight) { + vlCalibrationTool = new VLCalibrationTool(this); + llExtraButtons.setVisibility(VISIBLE); + } + + Preferences prefs = new Preferences(getContext()); + + Boolean typeSlider = prefs.isBrightnessPickerTypeSlider(); + if (typeSlider == null) { + typeSlider = varilight; + } + + onClick(typeSlider ? tabSlider : tabWheel); + channelDataToViews(); } @Override @@ -188,27 +218,21 @@ public void onDetailShow() { public void setData(ChannelBase channel) { super.setData(channel); - btnSettings.setVisibility(GONE); + llExtraButtons.setVisibility(GONE); + pickerTypeTabs.setVisibility(GONE); + + varilight = false; + + if (vlCalibrationTool != null) { + vlCalibrationTool.Hide(); + vlCalibrationTool = null; + } switch (channel.getFunc()) { case SuplaConst.SUPLA_CHANNELFNC_DIMMER: showDimmer(); tabs.setVisibility(View.GONE); - - if (vlCalibrationTool != null) { - vlCalibrationTool.Hide(); - vlCalibrationTool = null; - } - - if (channel instanceof Channel) { - Channel c = (Channel) channel; - if (c.getManufacturerID() == SuplaConst.SUPLA_MFR_DOYLETRATT - && c.getProductID() == 1) { - vlCalibrationTool = new VLCalibrationTool(this); - btnSettings.setVisibility(VISIBLE); - } - } break; case SuplaConst.SUPLA_CHANNELFNC_RGBLIGHTING: @@ -217,8 +241,7 @@ public void setData(ChannelBase channel) { break; case SuplaConst.SUPLA_CHANNELFNC_DIMMERANDRGBLIGHTING: - rgbPicker.setColorWheelVisible(true); - rgbPicker.setColorBrightnessWheelVisible(true); + cbPicker.setColorWheelVisible(true); onClick(tabRGB); tabs.setVisibility(View.VISIBLE); @@ -233,49 +256,41 @@ public void setData(ChannelBase channel) { private void channelDataToViews() { int id = 0; - rgbPicker.setColorMarkers(null); - rgbPicker.setBrightnessMarkers(null); + cbPicker.setColorMarkers(null); + cbPicker.setBrightnessMarkers(null); if (isGroup()) { ChannelGroup cgroup = (ChannelGroup) getChannelFromDatabase(); - tvTitle.setText(cgroup.getNotEmptyCaption(getContext())); - - stateImage.setVisibility(View.GONE); - tvStateCaption.setVisibility(View.GONE); status.setVisibility(View.VISIBLE); status.setPercent(cgroup.getOnLinePercent()); ArrayList markers; - if (rgbPicker.getColorBrightnessWheelVisible() - || rgbPicker.getBWBrightnessWheelVisible()) { - - markers = rgbPicker.getColorBrightnessWheelVisible() ? cgroup.getColorBrightness() - : cgroup.getBrightness(); + markers = cbPicker.isColorWheelVisible() ? cgroup.getColorBrightness() + : cgroup.getBrightness(); - if (markers != null) { - if (markers.size() == 1) { - if (markers.get(0).intValue() != (int) rgbPicker.getBrightnessValue()) { - rgbPicker.setBrightnessValue(markers.get(0)); - } - } else { - rgbPicker.setBrightnessMarkers(markers); + if (markers != null) { + if (markers.size() == 1) { + if (markers.get(0).intValue() != (int) cbPicker.getBrightnessValue()) { + cbPicker.setBrightnessValue(markers.get(0)); } + } else { + cbPicker.setBrightnessMarkers(markers); } } - if (rgbPicker.getColorWheelVisible()) { + if (cbPicker.isColorWheelVisible()) { markers = cgroup.getColors(); if (markers != null) { if (markers.size() == 1) { - if (markers.get(0).intValue() != rgbPicker.getColor()) { - rgbPicker.setColor(markers.get(0).intValue()); + if (markers.get(0).intValue() != cbPicker.getColor()) { + cbPicker.setColor(markers.get(0).intValue()); } } else { - rgbPicker.setColorMarkers(markers); + cbPicker.setColorMarkers(markers); } } } @@ -284,22 +299,19 @@ private void channelDataToViews() { } else { Channel channel = (Channel) getChannelFromDatabase(); - tvTitle.setText(channel.getNotEmptyCaption(getContext())); status.setVisibility(View.GONE); - stateImage.setVisibility(View.VISIBLE); - tvStateCaption.setVisibility(View.VISIBLE); + if (cbPicker.isColorWheelVisible() + && (int) cbPicker.getBrightnessValue() != (int) channel.getColorBrightness()) { + cbPicker.setBrightnessValue(channel.getColorBrightness()); - if (rgbPicker.getColorBrightnessWheelVisible() - && (int) rgbPicker.getBrightnessValue() != (int) channel.getColorBrightness()) - rgbPicker.setBrightnessValue(channel.getColorBrightness()); - - if (rgbPicker.getBWBrightnessWheelVisible() - && (int) rgbPicker.getBrightnessValue() != (int) channel.getBrightness()) - rgbPicker.setBrightnessValue(channel.getBrightness()); + } else if (!cbPicker.isColorWheelVisible() + && (int) cbPicker.getBrightnessValue() != (int) channel.getBrightness()) { + cbPicker.setBrightnessValue(channel.getBrightness()); + } - if (rgbPicker.getColorWheelVisible()) - rgbPicker.setColor(channel.getColor()); + if (cbPicker.isColorWheelVisible()) + cbPicker.setColor(channel.getColor()); } @@ -317,18 +329,18 @@ private void channelDataToViews() { } - pickerToInfoPanel(); + pickerToUI(); } @Override public View inflateContentView() { - return inflateLayout(R.layout.detail_rgb); + return inflateLayout(R.layout.detail_rgbw); } private void setBtnBackground(Button btn, int id) { - Drawable d = getResources().getDrawable(id); + Drawable d = id == 0 ? null : getResources().getDrawable(id); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { btn.setBackground(d); @@ -337,20 +349,32 @@ private void setBtnBackground(Button btn, int id) { } } - @SuppressLint("SetTextI18n") - private void pickerToInfoPanel() { + private void setPowerBtnOn(boolean on) { + cbPicker.setPowerButtonOn(on); + setBtnBackground(btnPowerOnOff, on ? R.drawable.rgbwpoweron : R.drawable.rgbwpoweroff); + } - lastColor = rgbPicker.getColor(); + @SuppressLint("SetTextI18n") + private void pickerToUI() { - int brightness = (int) rgbPicker.getBrightnessValue(); - stateImage.setImageResource(brightness > 0 ? R.drawable.poweron : R.drawable.poweroff); + lastColor = cbPicker.getColor(); + int brightness = (int) cbPicker.getBrightnessValue(); + setPowerBtnOn(brightness > 0); - if (rgbPicker.getColorWheelVisible()) + if (cbPicker.isColorWheelVisible()) lastColorBrightness = brightness; else lastBrightness = brightness; } + @Override + public boolean onBackPressed() { + if (vlCalibrationTool != null && vlCalibrationTool.isVisible()) { + return vlCalibrationTool.onBackPressed(); + } + return true; + } + private void sendNewValues(boolean force, boolean turnOnOff) { if (delayTimer1 != null) { @@ -403,53 +427,113 @@ private void sendNewValues() { sendNewValues(false, false); } + private void showInformationDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + ViewGroup viewGroup = findViewById(android.R.id.content); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.vl_dimmer_info, + viewGroup, false); + builder.setView(dialogView); + final AlertDialog alertDialog = builder.create(); + + dialogView.findViewById(R.id.btnClose).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + alertDialog.dismiss(); + } + }); + + Typeface quicksand = SuplaApp.getApp().getTypefaceQuicksandRegular(); + Typeface opensansbold = SuplaApp.getApp().getTypefaceOpenSansBold(); + Typeface opensans = SuplaApp.getApp().getTypefaceOpenSansRegular(); + + ((TextView) dialogView.findViewById(R.id.tvInfoTitle)).setTypeface(quicksand); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt1)).setTypeface(opensansbold); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt2)).setTypeface(opensans); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt3)).setTypeface(opensans); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt4)).setTypeface(opensans); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt5)).setTypeface(opensans); + + alertDialog.show(); + } + @Override public void onClick(View v) { - if (v == tabRGB) { showRGB(); - setBtnBackground(tabRGB, R.drawable.rounded_rgb_left_sel_btn); - setBtnBackground(tabDimmer, R.drawable.rounded_rgb_right_btn); + setBtnBackground(tabRGB, R.drawable.rounded_sel_btn); + setBtnBackground(tabDimmer, 0); - tabRGB.setTextColor(getResources().getColor(R.color.detail_rgb_gb)); + tabRGB.setTextColor(Color.WHITE); tabDimmer.setTextColor(Color.BLACK); } else if (v == tabDimmer) { showDimmer(); - setBtnBackground(tabRGB, R.drawable.rounded_rgb_left_btn); - setBtnBackground(tabDimmer, R.drawable.rounded_rgb_right_sel_btn); + setBtnBackground(tabDimmer, R.drawable.rounded_sel_btn); + setBtnBackground(tabRGB, 0); tabRGB.setTextColor(Color.BLACK); - tabDimmer.setTextColor(getResources().getColor(R.color.detail_rgb_gb)); - } else if (v == stateImage) { - rgbPicker.setBrightnessValue(rgbPicker.getBrightnessValue() > 0 ? 0 : 100); - pickerToInfoPanel(); - sendNewValues(true, true); - onChangeFinished(); + tabDimmer.setTextColor(Color.WHITE); + } else if (v == tabWheel) { + setBtnBackground(tabWheel, R.drawable.rounded_sel_btn); + setBtnBackground(tabSlider, 0); + + tabWheel.setTextColor(Color.WHITE); + tabSlider.setTextColor(Color.BLACK); + btnPowerOnOff.setVisibility(GONE); + + } else if (v == tabSlider) { + setBtnBackground(tabWheel, 0); + setBtnBackground(tabSlider, R.drawable.rounded_sel_btn); + + tabWheel.setTextColor(Color.BLACK); + tabSlider.setTextColor(Color.WHITE); + btnPowerOnOff.setVisibility(VISIBLE); } else if (v == btnSettings && vlCalibrationTool != null) { vlCalibrationTool.Show(); + } else if (v == btnPowerOnOff) { + cbPicker.setPowerButtonOn(!cbPicker.isPowerButtonOn()); + onPowerButtonClick(cbPicker); + } else if (v == btnInfo) { + if (varilight) { + showInformationDialog(); + } } if (v == tabDimmer || v == tabRGB) { channelDataToViews(); } + if (v == tabWheel || v == tabSlider) { + cbPicker.setSliderVisible(v == tabSlider); + + Preferences prefs = new Preferences(getContext()); + prefs.setBrightnessPickerTypeSlider(cbPicker.isSliderVisible()); + } + } @Override public void onColorChanged(SuplaColorBrightnessPicker scbPicker, int color) { - pickerToInfoPanel(); + pickerToUI(); sendNewValues(); } @Override public void onBrightnessChanged(SuplaColorBrightnessPicker scbPicker, double brightness) { - pickerToInfoPanel(); + pickerToUI(); sendNewValues(); } + @Override + public void onPowerButtonClick(SuplaColorBrightnessPicker scbPicker) { + scbPicker.setBrightnessValue(scbPicker.isPowerButtonOn() ? 100 : 0); + pickerToUI(); + sendNewValues(true, true); + onChangeFinished(scbPicker); + } + private void updateDelayed() { if (delayTimer2 != null) { @@ -458,7 +542,7 @@ private void updateDelayed() { } if (!isDetailVisible() - || rgbPicker.getMoving()) + || cbPicker.isMoving()) return; if (System.currentTimeMillis() - changeFinishedTime >= MIN_UPDATE_DELAY) { @@ -498,8 +582,7 @@ public void run() { } @Override - public void onChangeFinished() { - + public void onChangeFinished(SuplaColorBrightnessPicker scbPicker) { changeFinishedTime = System.currentTimeMillis(); updateDelayed(); } @@ -517,11 +600,11 @@ public void OnChannelDataChanged() { @Override public void onColorTouched(SuplaColorListPicker sclPicker, int color, short percent) { - if (color != Color.TRANSPARENT && rgbPicker.getColorBrightnessWheelVisible()) { - rgbPicker.setColor(color); - rgbPicker.setBrightnessValue(percent); + if (color != Color.TRANSPARENT && cbPicker.isColorWheelVisible()) { + cbPicker.setColor(color); + cbPicker.setBrightnessValue(percent); - onColorChanged(rgbPicker, color); + onColorChanged(cbPicker, color); } } @@ -529,9 +612,9 @@ public void onColorTouched(SuplaColorListPicker sclPicker, int color, short perc @Override public void onEdit(SuplaColorListPicker sclPicker, int idx) { - if (idx > 0 && rgbPicker.getColorBrightnessWheelVisible()) { - sclPicker.setItemColor(idx, rgbPicker.getColor()); - sclPicker.setItemPercent(idx, (short) rgbPicker.getBrightnessValue()); + if (idx > 0 && cbPicker.isColorWheelVisible()) { + sclPicker.setItemColor(idx, cbPicker.getColor()); + sclPicker.setItemPercent(idx, (short) cbPicker.getBrightnessValue()); if (getRemoteId() != 0) { @@ -539,8 +622,8 @@ public void onEdit(SuplaColorListPicker sclPicker, int idx) { cli.setRemoteId(getRemoteId()); cli.setGroup(isGroup()); cli.setIdx(idx); - cli.setColor(rgbPicker.getColor()); - cli.setBrightness((short) rgbPicker.getBrightnessValue()); + cli.setColor(cbPicker.getColor()); + cli.setBrightness((short) cbPicker.getBrightnessValue()); DBH.updateColorListItemValue(cli); } diff --git a/app/src/main/java/org/supla/android/ChannelDetailRS.java b/app/src/main/java/org/supla/android/ChannelDetailRS.java index 72992229f..1e43553e3 100644 --- a/app/src/main/java/org/supla/android/ChannelDetailRS.java +++ b/app/src/main/java/org/supla/android/ChannelDetailRS.java @@ -44,7 +44,6 @@ public class ChannelDetailRS extends DetailLayout implements SuplaRollerShutter. private SuplaRollerShutter rs; private SuplaChannelStatus status; - private TextView tvTitle; private TextView tvPercentCaption; private TextView tvPercent; private Button btnUp; @@ -101,9 +100,6 @@ protected void init() { tvPercent = findViewById(R.id.rsDetailPercent); tvPercent.setTypeface(type); - tvTitle = findViewById(R.id.rsDetailTitle); - tvTitle.setTypeface(SuplaApp.getApp().getTypefaceQuicksandRegular()); - addOnLayoutChangeListener(this); delayTimer1 = null; } @@ -126,8 +122,6 @@ private void OnChannelDataChanged(boolean withoutDelay) { byte p = channel.getRollerShutterPosition(); - tvTitle.setText(channel.getNotEmptyCaption(getContext())); - rs.setMarkers(null); rs.setPercent(p); @@ -140,7 +134,6 @@ private void OnChannelDataChanged(boolean withoutDelay) { status.setVisibility(View.VISIBLE); ChannelGroup cgroup = (ChannelGroup) getChannelFromDatabase(); - tvTitle.setText(cgroup.getNotEmptyCaption(getContext())); rs.setPercent(0); status.setPercent(cgroup.getOnLinePercent()); diff --git a/app/src/main/java/org/supla/android/ChannelDetailTemperature.java b/app/src/main/java/org/supla/android/ChannelDetailTemperature.java index 68625faca..b0e1d6de7 100644 --- a/app/src/main/java/org/supla/android/ChannelDetailTemperature.java +++ b/app/src/main/java/org/supla/android/ChannelDetailTemperature.java @@ -55,7 +55,6 @@ public class ChannelDetailTemperature extends DetailLayout implements protected ChartHelper chartHelper; private DownloadMeasurementLogs downloadMeasurementLogs; private ProgressBar tvProgress; - private TextView tvChannelTitle; private ImageView ivThermometerIcon; private Spinner thSpinner; private ImageView ivGraph; @@ -95,7 +94,6 @@ public View inflateContentView() { protected void init() { super.init(); tvProgress = findViewById(R.id.thProgressBar); - tvChannelTitle = findViewById(R.id.thtv_ChannelTitle); thSpinner = findViewById(R.id.thSpinner); ivThermometerIcon = findViewById(R.id.thThermometerIcon); @@ -133,7 +131,6 @@ private void runDownloadTask() { } protected void OnChannelDataChanged(Channel channel) { - tvChannelTitle.setText(channel.getNotEmptyCaption(getContext())); tvTemperature.setText(channel.getHumanReadableValue()); } diff --git a/app/src/main/java/org/supla/android/ChannelDetailThermostatHP.java b/app/src/main/java/org/supla/android/ChannelDetailThermostatHP.java index cece49720..5807db2ef 100644 --- a/app/src/main/java/org/supla/android/ChannelDetailThermostatHP.java +++ b/app/src/main/java/org/supla/android/ChannelDetailThermostatHP.java @@ -62,7 +62,6 @@ public class ChannelDetailThermostatHP extends DetailLayout implements View.OnCl public final static int BTN_SET_TOGGLE = 2; private final static int PROG_ECO = 1; private final static int PROG_COMFORT = 2; - private TextView tvChannelTitle; private Button btnSettings; private Button btnSchedule; private Button btnOnOff; @@ -91,6 +90,7 @@ public class ChannelDetailThermostatHP extends DetailLayout implements View.OnCl private LinearLayout llChart; private ListView lvChannelList; private TextView tvErrorMessage; + public ChannelDetailThermostatHP(Context context, ChannelListView cLV) { super(context, cLV); } @@ -111,9 +111,6 @@ public ChannelDetailThermostatHP(Context context, AttributeSet attrs, int defSty protected void init() { super.init(); - - tvChannelTitle = findViewById(R.id.hptv_ChannelTitle); - rlMain = findViewById(R.id.hpMain); rlMain.setVisibility(VISIBLE); @@ -351,7 +348,6 @@ public void setCfgValue(int id, Double value) { private void OnChannelGroupDataChanged() { ChannelGroup channelGroup = DBH.getChannelGroup(getRemoteId()); - tvChannelTitle.setText(channelGroup.getNotEmptyCaption(this.getContext())); Double t = channelGroup.getMinimumPresetTemperature(); presetTemperatureMin = t == null ? 0 : t.intValue(); @@ -383,8 +379,6 @@ public void OnChannelDataChanged() { Channel channel = DBH.getChannel(getRemoteId()); - tvChannelTitle.setText(channel.getNotEmptyCaption(this.getContext())); - tvErrorMessage.setVisibility(GONE); tvErrorMessage.setText(""); diff --git a/app/src/main/java/org/supla/android/MainActivity.java b/app/src/main/java/org/supla/android/MainActivity.java index 3f8f1234a..c9b60a9dc 100644 --- a/app/src/main/java/org/supla/android/MainActivity.java +++ b/app/src/main/java/org/supla/android/MainActivity.java @@ -508,7 +508,7 @@ public void onChannelButtonTouch(ChannelListView clv, boolean left, boolean up, public void onBackPressed() { if (channelLV.isDetailVisible()) { - channelLV.hideDetail(true); + channelLV.onBackPressed(); } else { gotoMain(); } @@ -517,8 +517,9 @@ public void onBackPressed() { @Override - public void onChannelDetailShow() { - hideMenuButton(); + public void onChannelDetailShow(ChannelBase channel) { + setMenubarDetailTitle(channel.getNotEmptyCaption(this)); + showBackButton(); } @Override diff --git a/app/src/main/java/org/supla/android/NavigationActivity.java b/app/src/main/java/org/supla/android/NavigationActivity.java index 199b926e4..b15ff24c2 100644 --- a/app/src/main/java/org/supla/android/NavigationActivity.java +++ b/app/src/main/java/org/supla/android/NavigationActivity.java @@ -27,6 +27,7 @@ of the License, or (at your option) any later version. import android.net.Uri; import android.os.Build; import android.view.LayoutInflater; +import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -51,6 +52,8 @@ public class NavigationActivity extends BaseActivity implements View.OnClickList private Button GroupButton; private boolean Anim = false; private SuperuserAuthorizationDialog mAuthDialog; + private TextView title; + private TextView detailTitle; private static void showActivity(Activity sender, Class cls, int flags) { @@ -126,9 +129,12 @@ private RelativeLayout getMenuBarLayout() { MenuBarLayout = (RelativeLayout) Inflate(R.layout.menubar, null); MenuBarLayout.setVisibility(View.GONE); - TextView title = MenuBarLayout.findViewById(R.id.menubar_title); + title = MenuBarLayout.findViewById(R.id.menubar_title); title.setTypeface(SuplaApp.getApp().getTypefaceQuicksandRegular()); + detailTitle = MenuBarLayout.findViewById(R.id.menubar_detail_title); + detailTitle.setTypeface(SuplaApp.getApp().getTypefaceQuicksandRegular()); + getRootLayout().addView(MenuBarLayout); MenuButton = findViewById(R.id.menubutton); @@ -192,8 +198,20 @@ public void setContentView(int layoutResID) { public void showMenuButton() { getMenuBarLayout(); + setBtnBackground(MenuButton, R.drawable.menu); MenuButton.setVisibility(View.VISIBLE); + MenuButton.setTag(Integer.valueOf(0)); GroupButton.setVisibility(View.VISIBLE); + title.setVisibility(View.VISIBLE); + detailTitle.setVisibility(View.INVISIBLE); + } + + public void showBackButton() { + getMenuBarLayout(); + setBtnBackground(MenuButton, R.drawable.back); + MenuButton.setVisibility(View.VISIBLE); + MenuButton.setTag(Integer.valueOf(1)); + GroupButton.setVisibility(View.GONE); } public void hideMenuButton() { @@ -202,6 +220,13 @@ public void hideMenuButton() { GroupButton.setVisibility(View.GONE); } + public void setMenubarDetailTitle(String txt) { + getMenuBarLayout(); + detailTitle.setText(txt); + title.setVisibility(View.INVISIBLE); + detailTitle.setVisibility(View.VISIBLE); + } + protected void onGroupButtonTouch(boolean On) { } @@ -344,9 +369,22 @@ public void gotoMain() { startActivity(intent); } + private void setBtnBackground(Button btn, int imgResId) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + btn.setBackground(getResources().getDrawable(imgResId)); + } else { + btn.setBackgroundDrawable(getResources().getDrawable(imgResId)); + } + } + @Override public void onClick(View v) { + if (v == MenuButton && MenuButton.getTag().equals(Integer.valueOf(1))) { + onBackPressed(); + return; + } + if (v != MenuButton && menuIsVisible()) { @@ -372,12 +410,7 @@ && menuIsVisible()) { img = R.drawable.groupoff; } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - GroupButton.setBackground(getResources().getDrawable(img)); - } else { - GroupButton.setBackgroundDrawable(getResources().getDrawable(img)); - } - + setBtnBackground(GroupButton, img); onGroupButtonTouch(img == R.drawable.groupon); } else { switch (MenuItemsLayout.getButtonId(v)) { @@ -421,6 +454,13 @@ protected void beforeStatusMsg() { } } + public static NavigationActivity getCurrentNavigationActivity() { + if (CurrentActivity != null && CurrentActivity instanceof NavigationActivity) { + return (NavigationActivity)CurrentActivity; + } + return null; + } + public void SuperUserAuthorize(int sourceBtnId) { if (mAuthDialog != null) { mAuthDialog.close(); diff --git a/app/src/main/java/org/supla/android/Preferences.java b/app/src/main/java/org/supla/android/Preferences.java index 6c5b2932f..7de52127d 100644 --- a/app/src/main/java/org/supla/android/Preferences.java +++ b/app/src/main/java/org/supla/android/Preferences.java @@ -47,6 +47,8 @@ public class Preferences { private static final String pref_wizard_selected_wifi = "pref_wizard_selected_wifi"; private static final String pref_hp_turbo_time = "pref_hp_turbo_time"; private static final String pref_hp_eco_reduction = "pref_hp_eco_reduction"; + private static final String pref_brightness_picker_type_slider + = "pref_brightness_picker_type_slider"; private SharedPreferences _prefs; private Context _context; @@ -249,4 +251,17 @@ public void wizardSetSelectedWifi(String SSID) { editor.putString(pref_wizard_selected_wifi, SSID); editor.apply(); } + + public void setBrightnessPickerTypeSlider(boolean slider) { + SharedPreferences.Editor editor = _prefs.edit(); + editor.putBoolean(pref_brightness_picker_type_slider, slider); + editor.apply(); + } + + public Boolean isBrightnessPickerTypeSlider() { + if (_prefs.contains(pref_brightness_picker_type_slider)) { + return _prefs.getBoolean(pref_brightness_picker_type_slider, false); + } + return null; + } } diff --git a/app/src/main/java/org/supla/android/SuplaChannelStatus.java b/app/src/main/java/org/supla/android/SuplaChannelStatus.java index a63fe3133..bb3b2c009 100644 --- a/app/src/main/java/org/supla/android/SuplaChannelStatus.java +++ b/app/src/main/java/org/supla/android/SuplaChannelStatus.java @@ -42,6 +42,7 @@ public class SuplaChannelStatus extends View { private DisplayMetrics metrics = getResources().getDisplayMetrics(); private float FrameLineWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 1, metrics); + public SuplaChannelStatus(Context context) { super(context); } diff --git a/app/src/main/java/org/supla/android/SuplaColorBrightnessPicker.java b/app/src/main/java/org/supla/android/SuplaColorBrightnessPicker.java index 7f4d75dc9..839befd31 100644 --- a/app/src/main/java/org/supla/android/SuplaColorBrightnessPicker.java +++ b/app/src/main/java/org/supla/android/SuplaColorBrightnessPicker.java @@ -3,14 +3,14 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.LinearGradient; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Path; -import android.graphics.Rect; +import android.graphics.PointF; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.SweepGradient; -import android.graphics.Typeface; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; @@ -33,10 +33,6 @@ of the License, or (at your option) any later version. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Fragments of code based on: - https://github.com/chiralcode/Android-Color-Picker/blob/master/src/com/chiralcode/colorpicker/ColorPicker.java - https://github.com/LarsWerkman/HoloColorPicker/blob/master/libary/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java */ public class SuplaColorBrightnessPicker extends View { @@ -49,54 +45,59 @@ public class SuplaColorBrightnessPicker extends View { final static private double m90d = Math.toRadians(-90); final static private double m90_01d = Math.toRadians(-90.01); final static private double m20d = Math.toRadians(-20); + final static private double p40d = Math.toRadians(40); private int[] BW = new int[]{ Color.BLACK, Color.WHITE, Color.WHITE }; - private PointerTop outerTop; - private PointerTop innerTop; + private PointF colorPointerCenter; + private PointF brightnessPointerCenter; private RectF rectF = new RectF(); private float centerX; private float centerY; - private float wheelWidth; - private float arrowHeight; - private float outerWheelWidth; - private double outerArrowHeight_a; - private double outerArrowHeight_b; - private float outerWheelRadius; - private double outerWheelPointerAngle; - private double innerArrowHeight_a; - private double innerArrowHeight_b; - private float innerWheelWidth; - private float innerWheelRadius; - private double innerWheelPointerAngle; + private float colorWheelWidth; + private double pointerHeight; + private double arrowHeight_a; + private double arrowHeight_b; + private float colorWheelRadius; + private double colorWheelPointerAngle; + private float brightnessWheelWidth; + private float brightnessWheelRadius; + private double brightnessWheelPointerAngle; private int selectedColor; private double selectedBrightness; - private int selectedBrightnessColor; - private Path outerArrowPath; - private Paint outerArrowPaint; - private Path innerArrowPath; - private Paint innerArrowPaint; + private Path colorArrowPath; + private Paint colorArrowPaint; + private Path brightnessArrowPath; + private Paint brightnessArrowPaint; private Paint paint; + private Paint slPaint; // slider paint + private Shader slShader; // slider shader private Paint cwPaint; // color wheel paint private Shader cwShader; // color wheel shader private Paint bwPaint; // brightness wheel paint private Shader bwShader; // brightness wheel shader - private Matrix gradientRotationMatrix; private boolean colorWheelVisible; - private boolean bwBrightnessWheelVisible; - private boolean colorBrightnessWheelVisible; - private boolean percentVisible; - private boolean colorWheelMove; - private boolean brightnessWheelMove; - private double lastTouchedAngle; + private boolean colorPointerMoving; + private boolean brightnessWheelPointerMoving; + private boolean colorfulBrightnessWheel; + private boolean circleInsteadArrow; + private double touchDiff; private OnColorBrightnessChangeListener mOnChangeListener; - private Rect bounds; - private Paint textPaint; - private ArrayList ColorMarkers; - private ArrayList BrightnessMarkers; + private ArrayList colorMarkers; + private ArrayList brightnessMarkers; + private boolean sliderVisible; + private RectF sliderRect; + private boolean powerButtonVisible; + private boolean powerButtonEnabled; + private boolean powerButtonOn; + private int powerButtonColorOn; + private int powerButtonColorOff; + private float powerButtonRadius; + private boolean powerButtonTouched; + public SuplaColorBrightnessPicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); @@ -115,8 +116,6 @@ public SuplaColorBrightnessPicker(Context context) { private void init() { colorWheelVisible = true; - bwBrightnessWheelVisible = false; - colorBrightnessWheelVisible = false; paint = new Paint(); @@ -124,44 +123,35 @@ private void init() { cwPaint = new Paint(Paint.ANTI_ALIAS_FLAG); cwPaint.setStyle(Paint.Style.STROKE); - bwShader = new SweepGradient(0, 0, BW, null); bwPaint = new Paint(Paint.ANTI_ALIAS_FLAG); bwPaint.setStyle(Paint.Style.STROKE); - outerArrowPath = new Path(); - outerArrowPaint = new Paint(); - - outerTop = new PointerTop(); - innerTop = new PointerTop(); - - outerWheelPointerAngle = Math.toRadians(-90); - selectedColor = calculateColor((float) outerWheelPointerAngle, Colors); - - innerArrowPath = new Path(); - innerArrowPaint = new Paint(); - - innerWheelPointerAngle = Math.toRadians(-90); - selectedBrightnessColor = calculateColor((float) (innerWheelPointerAngle - m90d), BW); - selectedBrightness = 0; - - gradientRotationMatrix = new Matrix(); - gradientRotationMatrix.preRotate(-90); - bwShader.setLocalMatrix(gradientRotationMatrix); + slPaint = new Paint(); + slPaint.setAntiAlias(true); + slPaint.setStyle(Paint.Style.FILL); + slPaint.setStrokeWidth(2); - colorWheelMove = false; - brightnessWheelMove = false; + colorArrowPath = new Path(); + colorArrowPaint = new Paint(); - percentVisible = true; + colorPointerCenter = new PointF(); + brightnessPointerCenter = new PointF(); - bounds = new Rect(); - textPaint = new Paint(); + brightnessArrowPath = new Path(); + brightnessArrowPaint = new Paint(); - textPaint.setAntiAlias(true); - textPaint.setColor(Color.BLACK); + colorPointerMoving = false; + brightnessWheelPointerMoving = false; + colorfulBrightnessWheel = true; + circleInsteadArrow = true; + powerButtonColorOn = 0xffffffff; + powerButtonColorOff = 0xff404040; - setWheelWidth(100); - setArrowHeight(100); + powerButtonVisible = true; + powerButtonEnabled = true; + setBrightnessValue(0); + setColor(0xff00ff00); } private int ave(int s, int d, float p) { @@ -210,16 +200,28 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(size, size); } - private void drawMarkers(Canvas canvas, float radius, float markerSize, ArrayList markers, boolean brightness) { - - double angle; + private void drawMarker(Canvas canvas, float x, float y, float markerSize) { paint.setAntiAlias(true); - paint.setStrokeWidth(markerSize / 4); + paint.setStrokeWidth(markerSize / 5); + paint.setColor(Color.WHITE); + paint.setStyle(Paint.Style.FILL); + + canvas.drawCircle(x, y, markerSize, paint); + + paint.setStyle(Paint.Style.STROKE); + paint.setColor(Color.BLACK); + + canvas.drawCircle(x, y, markerSize, paint); + } + private void drawWheelMarkers(Canvas canvas, float radius, float markerSize, + ArrayList markers, boolean brightness) { if (markers == null) { return; } + double angle; + for (int a = 0; a < markers.size(); a++) { double v = markers.get(a); @@ -235,111 +237,226 @@ private void drawMarkers(Canvas canvas, float radius, float markerSize, ArrayLis angle = colorToAngle((int) v); } - float x = (float) Math.cos(angle) * radius; - float y = (float) Math.sin(angle) * radius; + drawMarker(canvas, + (float) Math.cos(angle) * radius, + (float) Math.sin(angle) * radius, + markerSize); + - paint.setColor(Color.WHITE); - paint.setStyle(Paint.Style.FILL); + } - canvas.drawCircle(x, y, markerSize, paint); + } - paint.setStyle(Paint.Style.STROKE); - paint.setColor(Color.BLACK); + private void drawSliderMarkers(Canvas canvas, float markerSize) { + if (brightnessMarkers == null) { + return; + } - canvas.drawCircle(x, y, markerSize, paint); + float h = sliderRect.height() - (float) pointerHeight; + for (int a = 0; a < brightnessMarkers.size(); a++) { + drawMarker(canvas, + 0, + h / 2 - h * brightnessMarkers.get(a).floatValue() / 100f, + markerSize); } + } + + private void drawCirclePointer(Canvas canvas, int color, PointF center) { + float lw = (float) pointerHeight * 0.05f; + + paint.setAntiAlias(true); + paint.setStyle(Paint.Style.FILL); + paint.setColor(color); + canvas.drawCircle(center.x, center.y, (float) pointerHeight / 2 - lw / 2, paint); + + paint.setStrokeWidth(lw); + paint.setStyle(Paint.Style.STROKE); + paint.setColor(Color.WHITE); + canvas.drawCircle(center.x, center.y, (float) pointerHeight / 2 - lw * 1.5f, paint); } - @Override - protected void onDraw(Canvas canvas) { + private void drawCirclePointer(Canvas canvas, double angle, + float wheelRadius, int color, PointF center) { - canvas.translate(centerX, centerY); + center.x = (float) Math.cos(angle) * wheelRadius; + center.y = (float) Math.sin(angle) * wheelRadius; + drawCirclePointer(canvas, color, center); + } + + private float trimBrightnessColorAngle(float rad) { + if (rad >= 0 && rad <= 0.4f) { + rad = 0.4f; + } else if (rad >= 2.7 || rad < 0) { + rad = 2.7f; + } + return rad; + } + + private void drawPowerButton(Canvas canvas, float wheelRadius) { + powerButtonRadius = wheelRadius * 0.3f; + + Paint paint = new Paint(); + paint.setAntiAlias(true); + paint.setStyle(Paint.Style.STROKE); + paint.setColor(powerButtonOn ? powerButtonColorOn : powerButtonColorOff); + paint.setStrokeWidth(powerButtonRadius * 0.2f); + + Path path = new Path(); + paint.setStrokeCap(Paint.Cap.ROUND); + RectF rect = new RectF(-powerButtonRadius, -powerButtonRadius, + powerButtonRadius, powerButtonRadius); + path.addArc(rect, -60f, 300f); + path.moveTo(0f, powerButtonRadius * -1f - powerButtonRadius * 0.15f); + path.lineTo(0f, powerButtonRadius * -1f + powerButtonRadius * 0.6f); + + canvas.drawPath(path, paint); + + } + + private void drawWheel(Canvas canvas) { if (colorWheelVisible) { cwPaint.setShader(cwShader); - rectF.set(-outerWheelRadius, -outerWheelRadius, outerWheelRadius, outerWheelRadius); + rectF.set(-colorWheelRadius, -colorWheelRadius, colorWheelRadius, colorWheelRadius); canvas.drawOval(rectF, cwPaint); - drawOuterPointerArrow(canvas, outerTop, - outerWheelPointerAngle, - outerWheelRadius, - outerWheelWidth, - -(outerArrowHeight_a / 4), - outerArrowHeight_a, - outerArrowHeight_b, - selectedColor, - outerArrowPath, - outerArrowPaint); - - drawMarkers(canvas, outerWheelRadius, - outerWheelWidth / 6, ColorMarkers, false); + + if (circleInsteadArrow) { + drawCirclePointer(canvas, colorWheelPointerAngle, + colorWheelRadius, selectedColor, colorPointerCenter); + } else { + drawArrow(canvas, colorPointerCenter, + colorWheelPointerAngle, + colorWheelRadius, + colorWheelWidth, + -(arrowHeight_a / 4), + arrowHeight_a, + arrowHeight_b, + selectedColor, + colorArrowPath, + colorArrowPaint); + } + + drawWheelMarkers(canvas, colorWheelRadius, + colorWheelWidth / (circleInsteadArrow ? 9 : 6), + colorMarkers, false); } - if (bwBrightnessWheelVisible - || colorBrightnessWheelVisible) { + bwPaint.setStyle(Paint.Style.STROKE); + bwPaint.setShader(bwShader); + rectF.set(-brightnessWheelRadius, -brightnessWheelRadius, brightnessWheelRadius, brightnessWheelRadius); + canvas.drawOval(rectF, bwPaint); - bwPaint.setShader(bwShader); - rectF.set(-innerWheelRadius, -innerWheelRadius, innerWheelRadius, innerWheelRadius); - canvas.drawOval(rectF, bwPaint); + int negative; + double arrowOffset; - int negative; - double arrowOffset; + if (colorWheelVisible) { + negative = -1; + arrowOffset = arrowHeight_a / 4 - brightnessWheelWidth; + } else { + negative = 1; + arrowOffset = -(arrowHeight_a / 4); + } - if (colorWheelVisible) { - negative = -1; - arrowOffset = innerArrowHeight_a / 4 - innerWheelWidth; - } else { - negative = 1; - arrowOffset = -(innerArrowHeight_a / 4); - } - drawOuterPointerArrow(canvas, innerTop, - innerWheelPointerAngle, - innerWheelRadius, - innerWheelWidth, + if (circleInsteadArrow) { + float angle = (float) (brightnessWheelPointerAngle - m90d); + if (!colorfulBrightnessWheel || !colorWheelVisible + || (colorWheelVisible && (selectedColor & 0xffffff) == 0xffffff)) { + angle = trimBrightnessColorAngle(angle); + } + drawCirclePointer(canvas, brightnessWheelPointerAngle, + brightnessWheelRadius, calculateColor(angle, BW), brightnessPointerCenter); + } else { + drawArrow(canvas, brightnessPointerCenter, + brightnessWheelPointerAngle, + brightnessWheelRadius, + brightnessWheelWidth, arrowOffset, - negative * innerArrowHeight_a, - negative * innerArrowHeight_b, - selectedBrightnessColor, - innerArrowPath, - innerArrowPaint); + negative * arrowHeight_a, + negative * arrowHeight_b, + calculateColor((float) (brightnessWheelPointerAngle - m90d), BW), + brightnessArrowPath, + brightnessArrowPaint); + } - if (percentVisible) { + drawWheelMarkers(canvas, brightnessWheelRadius, + brightnessWheelWidth / (circleInsteadArrow ? 9 : 6), + brightnessMarkers, true); - String text = Integer.toString((int) selectedBrightness) + "%"; + if (powerButtonVisible) { + drawPowerButton(canvas, brightnessWheelRadius * 0.8f); + } + } - textPaint.getTextBounds(text, 0, text.length(), bounds); - canvas.drawText(text, -(bounds.width() / 2), bounds.height() / 2, textPaint); - } + private void drawSlider(Canvas canvas) { + float height = getHeight() - (float) pointerHeight / 2; + float x = (float) pointerHeight / -2; + float y = height / -2; - drawMarkers(canvas, innerWheelRadius, innerWheelWidth / 6, - BrightnessMarkers, true); + sliderRect = new RectF(x, y, x + (float) pointerHeight, y + height); + if (slShader == null) { + slShader = new LinearGradient(0, height/-3, 0, height/2, Color.WHITE, + Color.BLACK, Shader.TileMode.CLAMP); + slPaint.setShader(slShader); } + canvas.drawRoundRect(sliderRect, 90, 90, slPaint); + + height -= pointerHeight; + brightnessPointerCenter.x = 0; + brightnessPointerCenter.y = height / 2 - height * (float) selectedBrightness / 100f; + + float percent = (float) selectedBrightness; + + if (percent > 85f) { + percent = 85f; + } else if (percent < 15f) { + percent = 15f; + } + + float[] hsv = new float[3]; + Color.colorToHSV(Color.WHITE, hsv); + hsv[2] = 1 * percent / 100f; + drawCirclePointer(canvas, Color.HSVToColor(hsv), brightnessPointerCenter); + drawSliderMarkers(canvas, (float) pointerHeight / 10f); } - private void drawOuterPointerArrow(Canvas canvas, PointerTop top, double topAngle, - float wheelRadius, float wheelWidth, double arrowOffset, - double arrowHeight_a, double arrowHeight_b, - int color, Path arrowPath, Paint arrowPaint) { + @Override + protected void onDraw(Canvas canvas) { + canvas.translate(centerX, centerY); + if (sliderVisible) { + drawSlider(canvas); + } else { + drawWheel(canvas); + } + } + + private void drawArrow(Canvas canvas, PointF center, double topAngle, + float wheelRadius, float wheelWidth, double arrowOffset, + double arrowHeight_a, double arrowHeight_b, + int color, Path arrowPath, Paint arrowPaint) { - top.X = Math.cos(topAngle) * (wheelRadius + wheelWidth / 2 + arrowOffset); - top.Y = Math.sin(topAngle) * (wheelRadius + wheelWidth / 2 + arrowOffset); + float hh = (float) (arrowHeight_a + arrowHeight_b) / 2.0f; + double radius = wheelRadius + wheelWidth / 2 + arrowOffset; + float x = (float) (Math.cos(topAngle) * radius); + float y = (float) (Math.sin(topAngle) * radius); - top.Height = Math.abs(arrowHeight_a + arrowHeight_b); + center.x = (float) (Math.cos(topAngle) * (radius + hh)); + center.y = (float) (Math.sin(topAngle) * (radius + hh)); double arrowRad = Math.toRadians(40); - double leftX = top.X + Math.cos(topAngle + arrowRad) * arrowHeight_a; - double leftY = top.Y + Math.sin(topAngle + arrowRad) * arrowHeight_a; + double leftX = x + Math.cos(topAngle + arrowRad) * arrowHeight_a; + double leftY = y + Math.sin(topAngle + arrowRad) * arrowHeight_a; - double rightX = top.X + Math.cos(topAngle - arrowRad) * arrowHeight_a; - double rightY = top.Y + Math.sin(topAngle - arrowRad) * arrowHeight_a; + double rightX = x + Math.cos(topAngle - arrowRad) * arrowHeight_a; + double rightY = y + Math.sin(topAngle - arrowRad) * arrowHeight_a; double backLeftX = leftX + Math.cos(topAngle) * arrowHeight_b; double backLeftY = leftY + Math.sin(topAngle) * arrowHeight_b; @@ -348,11 +465,11 @@ private void drawOuterPointerArrow(Canvas canvas, PointerTop top, double topAngl double backRightY = rightY + Math.sin(topAngle) * arrowHeight_b; arrowPath.reset(); - arrowPath.moveTo((float) top.X, (float) top.Y); + arrowPath.moveTo(x, y); arrowPath.lineTo((float) leftX, (float) leftY); arrowPath.lineTo((float) backLeftX, (float) backLeftY); - arrowPath.moveTo((float) top.X, (float) top.Y); + arrowPath.moveTo(x, y); arrowPath.lineTo((float) rightX, (float) rightY); arrowPath.lineTo((float) backRightX, (float) backRightY); arrowPath.lineTo((float) backLeftX, (float) backLeftY); @@ -370,51 +487,65 @@ private void drawOuterPointerArrow(Canvas canvas, PointerTop top, double topAngl } private void setBWcolor() { - int color = colorBrightnessWheelVisible ? selectedColor : Color.WHITE; + int color = colorWheelVisible + && colorfulBrightnessWheel && !sliderVisible ? selectedColor : Color.WHITE; if (BW[1] != color) { BW[1] = color; BW[2] = color; bwShader = new SweepGradient(0, 0, BW, null); + Matrix gradientRotationMatrix = new Matrix(); + gradientRotationMatrix.preRotate(-90); bwShader.setLocalMatrix(gradientRotationMatrix); + } } private void _onSizeChanged() { - outerWheelWidth = wheelWidth / 2; - outerArrowHeight_a = arrowHeight; - outerArrowHeight_b = outerArrowHeight_a * 0.6; - outerArrowHeight_a -= outerArrowHeight_b; + float w = this.getWidth() > this.getHeight() ? this.getHeight() : this.getWidth(); - innerWheelWidth = outerWheelWidth; - innerArrowHeight_a = arrowHeight; - innerArrowHeight_b = innerArrowHeight_a * 0.6; - innerArrowHeight_a -= innerArrowHeight_b; + if (sliderVisible) { + pointerHeight = w / 6.5f; + } else if (circleInsteadArrow) { + w /= 7.0f; + pointerHeight = w; + } else { + w /= 10.0f; + pointerHeight = w * 0.9f; + } + + colorWheelWidth = w / 2f; + arrowHeight_a = pointerHeight; + arrowHeight_b = arrowHeight_a * 0.6; + arrowHeight_a -= arrowHeight_b; - centerX = this.getWidth() / 2; - centerY = this.getHeight() / 2; + brightnessWheelWidth = colorWheelWidth; - if (colorWheelVisible - && (bwBrightnessWheelVisible || colorBrightnessWheelVisible)) { - outerWheelWidth = wheelWidth / 2; + centerX = this.getWidth() / 2f; + centerY = this.getHeight() / 2f; + + if (colorWheelVisible && !circleInsteadArrow) { + colorWheelWidth = w / 2f; } else { - outerWheelWidth = wheelWidth; + colorWheelWidth = w; } - innerWheelWidth = outerWheelWidth; - outerWheelRadius = Math.min(centerX, centerY) - outerWheelWidth / 2 - (int) (arrowHeight); + brightnessWheelWidth = colorWheelWidth; + int margin = circleInsteadArrow ? 0 : (int) (pointerHeight); + colorWheelRadius = Math.min(centerX, centerY) - colorWheelWidth / 2 - margin; if (colorWheelVisible) { - innerWheelRadius = outerWheelRadius - innerWheelWidth; + brightnessWheelRadius = colorWheelRadius - brightnessWheelWidth; } else { - innerWheelRadius = outerWheelRadius; + brightnessWheelRadius = colorWheelRadius; } - textPaint.setTextSize((int) (innerWheelRadius * 0.4)); - cwPaint.setStrokeWidth(outerWheelWidth); - bwPaint.setStrokeWidth(innerWheelWidth); + cwPaint.setStrokeWidth(colorWheelWidth); + bwPaint.setStrokeWidth(brightnessWheelWidth); + + slShader = null; } @Override @@ -424,57 +555,21 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); } - private double calculateAngle(double pointerAngle, double inRads) { - - double delta; - - if (Math.abs(lastTouchedAngle - inRads) > Math.PI) { - - delta = 2 * Math.PI - Math.abs(lastTouchedAngle) - Math.abs(inRads); - - if (lastTouchedAngle > 0 && inRads < 0) { - delta *= -1; - } - - } else { - delta = lastTouchedAngle - inRads; - } - - double result = (pointerAngle - delta); - - if (Math.abs(result) > Math.PI) { - - result = Math.PI - (Math.abs(result) % Math.PI); - - if (lastTouchedAngle < inRads) { - result *= -1; - } - } - - - return result; + private boolean touchOverPointer(PointF touchPoint, PointF pointerCenter, + double pointerHeight) { + return Math.sqrt(Math.pow(pointerCenter.x - touchPoint.x, 2) + + Math.pow(pointerCenter.y - touchPoint.y, 2)) <= pointerHeight / 2; } - private void calculateBrightness() { - - double d = Math.toDegrees(innerWheelPointerAngle) + 90; - - if (d < 0) - d = d + 360; - - if (d >= 359.99) - d = 360; - - selectedBrightness = (d / 360) * 100; + public double pointToRadians(PointF point) { + return Math.atan2(point.y, point.x); } @Override public boolean onTouchEvent(MotionEvent event) { - float x = event.getX() - centerX; - float y = event.getY() - centerY; - - double inRads = (float) Math.atan2(y, x); + PointF touchPoint = new PointF(event.getX() - centerX, event.getY() - centerY); + double touchAngle = pointToRadians(touchPoint); int action = event.getAction(); @@ -482,60 +577,80 @@ public boolean onTouchEvent(MotionEvent event) { case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: - colorWheelMove = false; - brightnessWheelMove = false; + colorPointerMoving = false; + brightnessWheelPointerMoving = false; + + if (powerButtonTouched) { + setPowerButtonOn(!isPowerButtonOn()); + + if (mOnChangeListener != null) + mOnChangeListener.onPowerButtonClick(this); + } if (mOnChangeListener != null) - mOnChangeListener.onChangeFinished(); + mOnChangeListener.onChangeFinished(this); + powerButtonTouched = false; break; case MotionEvent.ACTION_DOWN: - double sqrt = Math.sqrt(x * x + y * y); - - - if (colorWheelVisible - && Math.abs(outerTop.X - x) <= outerTop.Height - && Math.abs(outerTop.Y - y) <= outerTop.Height - && sqrt >= outerWheelRadius - outerWheelWidth / 2 - && sqrt <= outerWheelRadius + (outerArrowHeight_a + outerArrowHeight_b) * 2) { - - colorWheelMove = true; - brightnessWheelMove = false; - - } else if ((bwBrightnessWheelVisible || colorBrightnessWheelVisible) - && Math.abs(innerTop.X - x) <= innerTop.Height - && Math.abs(innerTop.Y - y) <= innerTop.Height - && ((colorWheelVisible - && sqrt <= innerWheelRadius - innerWheelWidth / 2 - && sqrt >= innerWheelRadius - (innerArrowHeight_a + innerArrowHeight_b) * 2) - || (!colorWheelVisible - && sqrt <= innerWheelRadius + (innerArrowHeight_a + innerArrowHeight_b) * 2 - && sqrt >= innerWheelRadius - innerWheelWidth / 2))) { + colorPointerMoving = false; + brightnessWheelPointerMoving = false; + powerButtonTouched = false; + + if (!sliderVisible + && colorWheelVisible + && touchOverPointer(touchPoint, colorPointerCenter, pointerHeight)) { + colorPointerMoving = true; + touchDiff = pointToRadians(colorPointerCenter) - touchAngle; + } else if (touchOverPointer(touchPoint, brightnessPointerCenter, pointerHeight)) { + brightnessWheelPointerMoving = true; + if (sliderVisible) { + touchDiff = brightnessPointerCenter.y - touchPoint.y; + } else { + touchDiff = pointToRadians(brightnessPointerCenter) - touchAngle; + } + } else if (powerButtonVisible + && powerButtonEnabled + && touchOverPointer(touchPoint, new PointF(0, 0), + powerButtonRadius * 2.2)) { + powerButtonTouched = true; + } - colorWheelMove = false; - brightnessWheelMove = true; + if (!isMoving() && !powerButtonTouched) { + return super.onTouchEvent(event); } + break; + case MotionEvent.ACTION_MOVE: - lastTouchedAngle = inRads; + if (sliderVisible) { + if (brightnessWheelPointerMoving) { + float h = sliderRect.height() - (float) pointerHeight; + float brightness = 100 - ((h / 2) + (float) touchDiff + touchPoint.y) * 100 / h; - if (!getMoving()) - return super.onTouchEvent(event); + if (brightness > 100) { + brightness = 100; + } else if (brightness < 0) { + brightness = 0; + } - break; + if (selectedBrightness != brightness) { + setBrightnessValue(brightness); - case MotionEvent.ACTION_MOVE: + if (mOnChangeListener != null) + mOnChangeListener.onBrightnessChanged(this, selectedBrightness); + } - if (colorWheelMove) { + } + } else if (colorPointerMoving) { - outerWheelPointerAngle = calculateAngle(outerWheelPointerAngle, inRads); + colorWheelPointerAngle = touchAngle + touchDiff; - int newColor = calculateColor((float) outerWheelPointerAngle, Colors); + int newColor = calculateColor((float) colorWheelPointerAngle, Colors); if (newColor != selectedColor) { - selectedColor = newColor; setBWcolor(); invalidate(); @@ -545,52 +660,47 @@ public boolean onTouchEvent(MotionEvent event) { } - } else if (brightnessWheelMove) { + } else if (brightnessWheelPointerMoving) { - double newAngle = calculateAngle(innerWheelPointerAngle, inRads); + double newAngle = touchAngle + touchDiff; + if (brightnessWheelPointerAngle >= m160d + && brightnessWheelPointerAngle <= m20d) { - if (newAngle >= m160d - && newAngle <= m20d) { - - if (innerWheelPointerAngle > newAngle) { + if (Math.abs(brightnessWheelPointerAngle - newAngle) > p40d) { + newAngle = brightnessWheelPointerAngle; + } - if (innerWheelPointerAngle >= m90d + if (brightnessWheelPointerAngle > newAngle) { + if (brightnessWheelPointerAngle >= m90d && newAngle < m90d) { newAngle = m90d; } - - } else if (innerWheelPointerAngle < newAngle) { - - if (innerWheelPointerAngle <= m90_01d + } else if (brightnessWheelPointerAngle < newAngle) { + if (brightnessWheelPointerAngle <= m90_01d && newAngle > m90_01d) { newAngle = m90_01d; } - } - } - if (innerWheelPointerAngle != newAngle) { + if (brightnessWheelPointerAngle != newAngle) { + double d = Math.toDegrees(newAngle) + 90; - innerWheelPointerAngle = newAngle; + if (d < 0) { + d += 360; + } - calculateBrightness(); - invalidate(); + if (d >= 359.99) { + d = 360; + } + + setBrightnessValue((d / 360) * 100); if (mOnChangeListener != null) mOnChangeListener.onBrightnessChanged(this, selectedBrightness); - } - } - if ((colorWheelMove || brightnessWheelMove) - && (bwBrightnessWheelVisible || colorBrightnessWheelVisible)) { - selectedBrightnessColor = calculateColor((float) (innerWheelPointerAngle - m90d), BW); - } - - lastTouchedAngle = inRads; - break; } @@ -606,55 +716,27 @@ public int getColor() { } public void setColor(int color) { - - if ((color & 0xFFFFFF) == 0xFFFFFF) - color = 0xFFFFFFFF; + color |= 0xff000000; if (selectedColor != color) { - selectedColor = color; + colorWheelPointerAngle = colorToAngle(color); setBWcolor(); - outerWheelPointerAngle = colorToAngle(color); - - if (color == Color.WHITE) - selectedColor = color; - else - selectedColor = calculateColor((float) outerWheelPointerAngle, Colors); - - setBWcolor(); - setBrightnessValue(selectedBrightness); + invalidate(); } - } - public boolean getColorWheelVisible() { + public boolean isColorWheelVisible() { return colorWheelVisible; } public void setColorWheelVisible(boolean visible) { - if (visible != colorWheelVisible) { - - if (visible) { - bwBrightnessWheelVisible = false; - colorBrightnessWheelVisible = false; - } else { - bwBrightnessWheelVisible = true; - colorBrightnessWheelVisible = false; - } - colorWheelVisible = visible; + setBWcolor(); _onSizeChanged(); invalidate(); } - - } - - public void setPercentVisible(boolean visible) { - if (percentVisible != visible) { - percentVisible = visible; - invalidate(); - } } public double getBrightnessValue() { @@ -663,12 +745,16 @@ public double getBrightnessValue() { public void setBrightnessValue(double value) { - innerWheelPointerAngle = brightnessToAngle(value); - selectedBrightnessColor = calculateColor((float) (innerWheelPointerAngle - m90d), BW); + if (value > 100) { + value = 100; + } else if (value < 0) { + value = 0; + } + + brightnessWheelPointerAngle = brightnessToAngle(value); selectedBrightness = value; invalidate(); - } private double brightnessToAngle(double value) { @@ -696,100 +782,103 @@ else if (value > 100) return result; } - public float getWheelWidth() { - return wheelWidth; + public boolean isMoving() { + return colorPointerMoving || brightnessWheelPointerMoving; } - public void setWheelWidth(float wheelWidth) { - this.wheelWidth = wheelWidth; - _onSizeChanged(); - invalidate(); + public ArrayList getColorMarkers() { + return colorMarkers == null ? null : new ArrayList<>(colorMarkers); } - public float getArrowHeight() { - return arrowHeight; - } + public void setColorMarkers(ArrayList colorMarkers) { + this.colorMarkers = colorMarkers == null ? + null : new ArrayList<>(colorMarkers); - public void setArrowHeight(float arrowHeight) { - this.arrowHeight = arrowHeight; + invalidate(); } - public void setTextTypeface(Typeface typeface) { + public ArrayList getBrightnessMarkers() { + return brightnessMarkers == null ? null : new ArrayList<>(brightnessMarkers); + } - textPaint.setTypeface(typeface); + public void setBrightnessMarkers(ArrayList brightnessMarkers) { + this.brightnessMarkers = brightnessMarkers == null ? + null : new ArrayList<>(brightnessMarkers); invalidate(); } - public boolean getColorBrightnessWheelVisible() { - return colorBrightnessWheelVisible; + public boolean isColorfulBrightnessWheel() { + return colorfulBrightnessWheel; } - public void setColorBrightnessWheelVisible(boolean visible) { - - if (visible != colorBrightnessWheelVisible) { - - if (visible) { - colorWheelVisible = true; - bwBrightnessWheelVisible = false; - } - - colorBrightnessWheelVisible = visible; - - setBWcolor(); - selectedBrightnessColor = calculateColor((float) (innerWheelPointerAngle - m90d), BW); - - _onSizeChanged(); - invalidate(); - } + public void setColorfulBrightnessWheel(boolean colorfulBrightnessWheel) { + this.colorfulBrightnessWheel = colorfulBrightnessWheel; + setBWcolor(); + invalidate(); + } + public boolean isCircleInsteadArrow() { + return circleInsteadArrow; } - public boolean getBWBrightnessWheelVisible() { - return bwBrightnessWheelVisible; + public void setCircleInsteadArrow(boolean circleInsteadArrow) { + this.circleInsteadArrow = circleInsteadArrow; + _onSizeChanged(); + invalidate(); } - public void setBWBrightnessWheelVisible(boolean visible) { + public boolean isSliderVisible() { + return sliderVisible; + } - if (visible != bwBrightnessWheelVisible) { + public void setSliderVisible(boolean sliderVisible) { + this.sliderVisible = sliderVisible; + _onSizeChanged(); + setBWcolor(); + invalidate(); + } - if (visible) { - colorBrightnessWheelVisible = false; - colorWheelVisible = false; - } else { - colorBrightnessWheelVisible = false; - colorWheelVisible = true; - } + public boolean isPowerButtonVisible() { + return powerButtonVisible; + } - bwBrightnessWheelVisible = visible; + public void setPowerButtonVisible(boolean powerButtonVisible) { + this.powerButtonVisible = powerButtonVisible; + invalidate(); + } - setBWcolor(); - selectedBrightnessColor = calculateColor((float) (innerWheelPointerAngle - m90d), BW); + public boolean isPowerButtonEnabled() { + return powerButtonEnabled; + } - _onSizeChanged(); - invalidate(); - } + public void setPowerButtonEnabled(boolean powerButtonEnabled) { + this.powerButtonEnabled = powerButtonEnabled; + } + public boolean isPowerButtonOn() { + return powerButtonOn; } - public boolean getMoving() { - return colorWheelMove || brightnessWheelMove; + public void setPowerButtonOn(boolean powerButtonOn) { + this.powerButtonOn = powerButtonOn; + invalidate(); } - public ArrayList getColorMarkers() { - return new ArrayList<>(ColorMarkers); + public int getPowerButtonColorOn() { + return powerButtonColorOn; } - public void setColorMarkers(ArrayList colorMarkers) { - ColorMarkers = colorMarkers == null ? null : new ArrayList<>(colorMarkers); + public void setPowerButtonColorOn(int powerButtonColorOn) { + this.powerButtonColorOn = powerButtonColorOn; invalidate(); } - public ArrayList getBrightnessMarkers() { - return new ArrayList<>(BrightnessMarkers); + public int getPowerButtonColorOff() { + return powerButtonColorOff; } - public void setBrightnessMarkers(ArrayList brightnessMarkers) { - BrightnessMarkers = brightnessMarkers == null ? null : new ArrayList<>(brightnessMarkers); + public void setPowerButtonColorOff(int powerButtonColorOff) { + this.powerButtonColorOff = powerButtonColorOff; invalidate(); } @@ -798,13 +887,9 @@ public interface OnColorBrightnessChangeListener { void onBrightnessChanged(SuplaColorBrightnessPicker scbPicker, double brightness); - void onChangeFinished(); - } + void onChangeFinished(SuplaColorBrightnessPicker scbPicker); - private class PointerTop { - double X; - double Y; - double Height; + void onPowerButtonClick(SuplaColorBrightnessPicker scbPicker); } } diff --git a/app/src/main/java/org/supla/android/SuplaColorListPicker.java b/app/src/main/java/org/supla/android/SuplaColorListPicker.java index 12ae69c34..f9c0dd313 100644 --- a/app/src/main/java/org/supla/android/SuplaColorListPicker.java +++ b/app/src/main/java/org/supla/android/SuplaColorListPicker.java @@ -38,7 +38,8 @@ public class SuplaColorListPicker extends View { private ArrayList Items = null; private float Space = 0; private float BorderWidth = 0; - private int BorderColor = Color.BLACK; + private int BorderColor = Color.WHITE; + private int BrightnessLevelColor = Color.BLACK; private int BorderColorSelected = Color.YELLOW; private ListItem TouchedItem = null; private OnColorListTouchListener mOnTouchListener; @@ -203,6 +204,15 @@ public void setBorderColorSelected(int borderColorSelected) { invalidate(); } + public int getBrightnessLevelColor() { + return BrightnessLevelColor; + } + + public void setBrightnessLevelColor(int brightnessLevelColor) { + BrightnessLevelColor = brightnessLevelColor; + invalidate(); + } + @Override protected void onDraw(Canvas canvas) { @@ -239,7 +249,7 @@ protected void onDraw(Canvas canvas) { if (i.getPercent() > 0) { - p.setColor(BorderColor); + p.setColor(BrightnessLevelColor); double rl_margin = width * 0.05; double b_margin = width * 0.1; diff --git a/app/src/main/java/org/supla/android/SuplaRangeCalibrationWheel.java b/app/src/main/java/org/supla/android/SuplaRangeCalibrationWheel.java index 4ed31783f..9162d86dd 100644 --- a/app/src/main/java/org/supla/android/SuplaRangeCalibrationWheel.java +++ b/app/src/main/java/org/supla/android/SuplaRangeCalibrationWheel.java @@ -51,12 +51,12 @@ public class SuplaRangeCalibrationWheel extends View { private double btnRad; private double lastTouchedDegree; - private int wheelColor = 0xB0ABAB; - private int borderColor = 0x575757; - private int btnColor = 0x575757; - private int rangeColor = 0xFFE617; - private int boostLineColor = 0x12A61F; - private int insideBtnColor = 0xFFFFFF; + private int wheelColor = 0xFFB0ABAB; + private int borderColor = 0xFF575757; + private int btnColor = 0xFF575757; + private int rangeColor = 0xFFFFE617; + private int boostLineColor = 0xFF12A61F; + private int insideBtnColor = 0xFFFFFFFF; private double maximumValue = 1000; private double minimumRange = maximumValue * 0.1; @@ -425,10 +425,10 @@ private void drawValue(Canvas canvas) { } float hh = ((bottom - top) + borderLineWidth * 2.0f) - * (float)boostLineHeightFactor / 2.0f; + * (float) boostLineHeightFactor / 2.0f; paint.setColor(boostLineColor); - canvas.drawLine(vleft, btnLeftCenter.y - hh , + canvas.drawLine(vleft, btnLeftCenter.y - hh, vleft, btnLeftCenter.y + hh, paint); } } diff --git a/app/src/main/java/org/supla/android/VLCalibrationTool.java b/app/src/main/java/org/supla/android/VLCalibrationTool.java index 287b4a720..b61fcd933 100644 --- a/app/src/main/java/org/supla/android/VLCalibrationTool.java +++ b/app/src/main/java/org/supla/android/VLCalibrationTool.java @@ -3,12 +3,20 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; +import android.content.Intent; import android.graphics.Color; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Build; import android.os.Handler; import android.os.Message; +import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.Button; import android.widget.RelativeLayout; +import android.widget.TextView; import org.supla.android.lib.SuplaClientMsg; import org.supla.android.lib.SuplaConst; @@ -16,7 +24,9 @@ import java.util.Timer; import java.util.TimerTask; -public class VLCalibrationTool implements View.OnClickListener, SuplaRangeCalibrationWheel.OnChangeListener, SuperuserAuthorizationDialog.OnAuthorizarionResultListener { +public class VLCalibrationTool implements View.OnClickListener, + SuplaRangeCalibrationWheel.OnChangeListener, + SuperuserAuthorizationDialog.OnAuthorizarionResultListener { private final static int VL_MSG_RESTORE_DEFAULTS = 0x4E; private final static int VL_MSG_CONFIGURATION_MODE = 0x44; private final static int VL_MSG_CONFIGURATION_ACK = 0x45; @@ -32,10 +42,10 @@ public class VLCalibrationTool implements View.OnClickListener, SuplaRangeCalibr private final static int UI_REFRESH_LOCK_TIME = 2000; private final static int MIN_SEND_DELAY_TIME = 500; private final static int DISPLAY_DELAY_TIME = 1000; - private ChannelDetailRGB detailRGB; + private ChannelDetailRGBW detailRGB; private Button btnOK; private Button btnRestore; - private Button btnCancel; + private Button btnInfo; private Button btnDmAuto; private Button btnDm1; private Button btnDm2; @@ -58,7 +68,7 @@ public class VLCalibrationTool implements View.OnClickListener, SuplaRangeCalibr private long lastCalCfgTime = 0; private Handler _sc_msg_handler = null; - public VLCalibrationTool(ChannelDetailRGB detailRGB) { + public VLCalibrationTool(ChannelDetailRGBW detailRGB) { this.detailRGB = detailRGB; mainView = (RelativeLayout) detailRGB.inflateLayout(R.layout.vl_calibration); @@ -67,7 +77,7 @@ public VLCalibrationTool(ChannelDetailRGB detailRGB) { btnOK = getBtn(R.id.vlBtnOK); btnRestore = getBtn(R.id.vlBtnRestore); - btnCancel = getBtn(R.id.vlBtnCancel); + btnInfo = getBtn(R.id.vlBtnInfo); btnDmAuto = getBtn(R.id.vlCfgDmAuto); btnDm1 = getBtn(R.id.vlCfgDm1); btnDm2 = getBtn(R.id.vlCfgDm2); @@ -84,6 +94,9 @@ public VLCalibrationTool(ChannelDetailRGB detailRGB) { mColorDisabled = detailRGB.getContext().getResources().getColor(R.color.vl_btn_disabled); + + btnDmAuto.setVisibility(View.GONE); + btnBoostAuto.setVisibility(View.GONE); } private void registerMessageHandler() { @@ -134,6 +147,12 @@ private void onCalCfgResult(int Command, int Result, byte[] Data) { switch (Command) { case VL_MSG_CONFIGURATION_ACK: if (Result == SuplaConst.SUPLA_RESULTCODE_TRUE && authDialog != null) { + + NavigationActivity activity = NavigationActivity.getCurrentNavigationActivity(); + if (activity!=null) { + activity.showBackButton(); + } + authDialog.close(); authDialog = null; @@ -152,10 +171,6 @@ private void onCalCfgResult(int Command, int Result, byte[] Data) { } } - public View getMainView() { - return getMainView(); - } - private Button getBtn(int resid) { Button btn = mainView.findViewById(resid); btn.setOnClickListener(this); @@ -192,44 +207,63 @@ private int viewToBoost(View btn) { VLCfgParameters.BOOST_UNKNOWN : boost; } + private Button modeToBtn(int mode) { + switch (mode) { + case VLCfgParameters.MODE_AUTO: + return btnDmAuto; + case VLCfgParameters.MODE_1: + return btnDm1; + case VLCfgParameters.MODE_2: + return btnDm2; + case VLCfgParameters.MODE_3: + return btnDm3; + } + return null; + } + + private Button boostToBtn(int boost) { + switch (boost) { + case VLCfgParameters.BOOST_AUTO: + return btnBoostAuto; + case VLCfgParameters.BOOST_YES: + return btnBoostYes; + case VLCfgParameters.BOOST_NO: + return btnBoostNo; + } + return null; + } + private void setBtnApparance(Button btn, int resid, int textColor) { - btn.setBackgroundResource(resid); + Drawable d = resid == 0 ? null : detailRGB.getResources().getDrawable(resid); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + btn.setBackground(d); + } else { + btn.setBackgroundDrawable(d); + } + btn.setTextColor(textColor); } private void setMode(int mode) { - - setBtnApparance(btnDmAuto, R.drawable.vl_left_btn_off, + setBtnApparance(btnDmAuto, 0, cfgParameters.isModeDisabled(VLCfgParameters.MODE_AUTO) ? mColorDisabled : Color.BLACK); - setBtnApparance(btnDm1, R.drawable.vl_middle_btn_off, + setBtnApparance(btnDm1, 0, cfgParameters.isModeDisabled(VLCfgParameters.MODE_1) ? mColorDisabled : Color.BLACK); - setBtnApparance(btnDm2, R.drawable.vl_middle_btn_off, + setBtnApparance(btnDm2, 0, cfgParameters.isModeDisabled(VLCfgParameters.MODE_2) ? mColorDisabled : Color.BLACK); - setBtnApparance(btnDm3, R.drawable.vl_right_btn_off, + setBtnApparance(btnDm3, 0, cfgParameters.isModeDisabled(VLCfgParameters.MODE_3) ? mColorDisabled : Color.BLACK); if (!cfgParameters.isModeDisabled(mode)) { - switch (mode) { - case VLCfgParameters.MODE_AUTO: - setBtnApparance(btnDmAuto, R.drawable.vl_left_btn_on, Color.WHITE); - break; - case VLCfgParameters.MODE_1: - setBtnApparance(btnDm1, R.drawable.vl_middle_btn_on, Color.WHITE); - break; - case VLCfgParameters.MODE_2: - setBtnApparance(btnDm2, R.drawable.vl_middle_btn_on, Color.WHITE); - break; - case VLCfgParameters.MODE_3: - setBtnApparance(btnDm3, R.drawable.vl_right_btn_on, Color.WHITE); - break; - } + setBtnApparance(modeToBtn(mode), R.drawable.rounded_sel_btn, Color.WHITE); } } @@ -238,30 +272,20 @@ private void setMode() { } private void setBoost(int boost) { - setBtnApparance(btnBoostAuto, R.drawable.vl_left_btn_off, + setBtnApparance(btnBoostAuto, 0, cfgParameters.isBoostDisabled(VLCfgParameters.BOOST_AUTO) ? mColorDisabled : Color.BLACK); - setBtnApparance(btnBoostYes, R.drawable.vl_middle_btn_off, + setBtnApparance(btnBoostYes, 0, cfgParameters.isBoostDisabled(VLCfgParameters.BOOST_YES) ? mColorDisabled : Color.BLACK); - setBtnApparance(btnBoostNo, R.drawable.vl_right_btn_off, + setBtnApparance(btnBoostNo, 0, cfgParameters.isBoostDisabled(VLCfgParameters.BOOST_NO) ? mColorDisabled : Color.BLACK); if (!cfgParameters.isBoostDisabled(boost)) { - switch (boost) { - case VLCfgParameters.BOOST_AUTO: - setBtnApparance(btnBoostAuto, R.drawable.vl_left_btn_on, Color.WHITE); - break; - case VLCfgParameters.BOOST_YES: - setBtnApparance(btnBoostYes, R.drawable.vl_middle_btn_on, Color.WHITE); - break; - case VLCfgParameters.BOOST_NO: - setBtnApparance(btnBoostNo, R.drawable.vl_right_btn_on, Color.WHITE); - break; - } + setBtnApparance(boostToBtn(boost), R.drawable.rounded_sel_btn, Color.WHITE); if (boost == VLCfgParameters.BOOST_YES) { btnBoost.setVisibility(View.VISIBLE); @@ -279,12 +303,12 @@ private void setBoost() { private void displayOpRange(boolean display) { if (display) { - setBtnApparance(btnOpRange, R.drawable.vl_tab_on, Color.WHITE); - setBtnApparance(btnBoost, R.drawable.vl_tab_off, Color.BLACK); + setBtnApparance(btnOpRange, R.drawable.vl_tab, Color.BLACK); + setBtnApparance(btnBoost, 0, Color.BLACK); calibrationWheel.setBoostVisible(false); } else { - setBtnApparance(btnOpRange, R.drawable.vl_tab_off, Color.BLACK); - setBtnApparance(btnBoost, R.drawable.vl_tab_on, Color.WHITE); + setBtnApparance(btnOpRange, 0, Color.BLACK); + setBtnApparance(btnBoost, R.drawable.vl_tab, Color.BLACK); calibrationWheel.setBoostVisible(true); } } @@ -381,6 +405,49 @@ public void onClick(DialogInterface dialog, int id) { alert.show(); } + private void showInformationDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(detailRGB.getContext()); + ViewGroup viewGroup = detailRGB.findViewById(android.R.id.content); + View dialogView = LayoutInflater.from( + detailRGB.getContext()).inflate(R.layout.vl_dimmer_config_info, + viewGroup, false); + builder.setView(dialogView); + final AlertDialog alertDialog = builder.create(); + + dialogView.findViewById(R.id.btnClose).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + alertDialog.dismiss(); + } + }); + + dialogView.findViewById(R.id.btnUrl).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + alertDialog.dismiss(); + Intent browserIntent = new Intent(Intent.ACTION_VIEW, + Uri.parse(((Button) v).getText().toString())); + detailRGB.getContext().startActivity(browserIntent); + } + }); + + Typeface quicksand = SuplaApp.getApp().getTypefaceQuicksandRegular(); + Typeface opensansbold = SuplaApp.getApp().getTypefaceOpenSansBold(); + Typeface opensans = SuplaApp.getApp().getTypefaceOpenSansRegular(); + + ((TextView) dialogView.findViewById(R.id.tvInfoTitle)).setTypeface(quicksand); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt1)).setTypeface(opensansbold); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt2)).setTypeface(opensans); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt3)).setTypeface(opensans); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt4)).setTypeface(opensans); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt5)).setTypeface(opensans); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt6)).setTypeface(opensansbold); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt7)).setTypeface(opensans); + ((TextView) dialogView.findViewById(R.id.tvInfoTxt8)).setTypeface(opensans); + + alertDialog.show(); + } + public void onClick(View v) { if (v == btnOK) { @@ -390,8 +457,8 @@ public void onClick(View v) { return; } else if (v == btnRestore) { showRestoreConfirmDialog(); - } else if (v == btnCancel) { - Hide(); + } else if (v == btnInfo) { + showInformationDialog(); return; } @@ -433,6 +500,7 @@ public void Show() { public void Hide() { unregisterMessageHandler(); + if (mainView.getVisibility() == View.VISIBLE) { mainView.setVisibility(View.GONE); detailRGB.getContentView().setVisibility(View.VISIBLE); @@ -504,6 +572,11 @@ public void onBoostChanged(SuplaRangeCalibrationWheel calibrationWheel) { calCfgDelayed(VL_MSG_SET_BOOST_LEVEL); } + public boolean onBackPressed() { + Hide(); + return false; + } + class DisplayDelayedTask extends TimerTask { private int msg; diff --git a/app/src/main/java/org/supla/android/lib/SuplaChannelElectricityMeterValue.java b/app/src/main/java/org/supla/android/lib/SuplaChannelElectricityMeterValue.java index 0c689c9ac..102bcb7a1 100644 --- a/app/src/main/java/org/supla/android/lib/SuplaChannelElectricityMeterValue.java +++ b/app/src/main/java/org/supla/android/lib/SuplaChannelElectricityMeterValue.java @@ -35,6 +35,7 @@ public class SuplaChannelElectricityMeterValue implements Serializable { // Unit - kWh private double TotalForwardActiveEnergyBalanced; private double TotalReverseActiveEnergyBalanced; + SuplaChannelElectricityMeterValue(int MeasuredValues, int Period, int TotalCost, int PricePerUnit, String Currency, long TotalForwardActiveEnergyBalanced, diff --git a/app/src/main/java/org/supla/android/lib/SuplaChannelThermostatValue.java b/app/src/main/java/org/supla/android/lib/SuplaChannelThermostatValue.java index 2ab732c2b..295585757 100644 --- a/app/src/main/java/org/supla/android/lib/SuplaChannelThermostatValue.java +++ b/app/src/main/java/org/supla/android/lib/SuplaChannelThermostatValue.java @@ -28,6 +28,7 @@ public class SuplaChannelThermostatValue implements Serializable { private Integer[] Values; private Schedule mSchedule; private Time mTime; + SuplaChannelThermostatValue() { MeasuredTemperature = null; PresetTemperature = null; diff --git a/app/src/main/java/org/supla/android/listview/ChannelListView.java b/app/src/main/java/org/supla/android/listview/ChannelListView.java index 13034afc7..44ba7884a 100644 --- a/app/src/main/java/org/supla/android/listview/ChannelListView.java +++ b/app/src/main/java/org/supla/android/listview/ChannelListView.java @@ -36,7 +36,7 @@ of the License, or (at your option) any later version. import org.supla.android.ChannelDetailEM; import org.supla.android.ChannelDetailIC; -import org.supla.android.ChannelDetailRGB; +import org.supla.android.ChannelDetailRGBW; import org.supla.android.ChannelDetailRS; import org.supla.android.ChannelDetailTempHumidity; import org.supla.android.ChannelDetailTemperature; @@ -112,7 +112,7 @@ private DetailLayout getDetailLayout(ChannelBase cbase) { case SuplaConst.SUPLA_CHANNELFNC_DIMMERANDRGBLIGHTING: case SuplaConst.SUPLA_CHANNELFNC_RGBLIGHTING: - if (!(mDetailLayout instanceof ChannelDetailRGB)) + if (!(mDetailLayout instanceof ChannelDetailRGBW)) mDetailLayout = null; break; @@ -176,7 +176,7 @@ private DetailLayout getDetailLayout(ChannelBase cbase) { case SuplaConst.SUPLA_CHANNELFNC_DIMMER: case SuplaConst.SUPLA_CHANNELFNC_DIMMERANDRGBLIGHTING: case SuplaConst.SUPLA_CHANNELFNC_RGBLIGHTING: - mDetailLayout = new ChannelDetailRGB(getContext(), this); + mDetailLayout = new ChannelDetailRGBW(getContext(), this); break; case SuplaConst.SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER: mDetailLayout = new ChannelDetailRS(getContext(), this); @@ -599,7 +599,7 @@ private void onDetailShow() { mDetailLayout.onDetailShow(); if (onDetailListener != null) - onDetailListener.onChannelDetailShow(); + onDetailListener.onChannelDetailShow(mDetailLayout.getChannelBase()); } private void onDetailHide() { @@ -736,6 +736,9 @@ public boolean isDetailVisible() { } public void onBackPressed() { + if (mDetailLayout.onBackPressed()) { + hideDetail(true); + } } public void hideDetail(boolean animated) { @@ -791,7 +794,7 @@ public interface OnChannelButtonTouchListener { public interface OnDetailListener { - void onChannelDetailShow(); + void onChannelDetailShow(ChannelBase channel); void onChannelDetailHide(); } diff --git a/app/src/main/java/org/supla/android/listview/DetailLayout.java b/app/src/main/java/org/supla/android/listview/DetailLayout.java index b02f845a9..28c27a589 100644 --- a/app/src/main/java/org/supla/android/listview/DetailLayout.java +++ b/app/src/main/java/org/supla/android/listview/DetailLayout.java @@ -206,4 +206,8 @@ public void deviceCalCfgRequest(int cmd, Short data) { deviceCalCfgRequest(cmd, 0, data == null ? null : arr); } + + public boolean onBackPressed() { + return true; + } } diff --git a/app/src/main/java/org/supla/android/listview/SectionLayout.java b/app/src/main/java/org/supla/android/listview/SectionLayout.java index 26ff3813e..e81db999f 100644 --- a/app/src/main/java/org/supla/android/listview/SectionLayout.java +++ b/app/src/main/java/org/supla/android/listview/SectionLayout.java @@ -36,6 +36,7 @@ public class SectionLayout extends LinearLayout { private TextView Caption; private FrameLayout frmCollapsed; private OnSectionLayoutTouchListener onSectionLayoutTouchListener; + public SectionLayout(Context context) { super(context); Init(context); diff --git a/app/src/main/res/drawable/back.png b/app/src/main/res/drawable/back.png new file mode 100644 index 000000000..4c030b31c Binary files /dev/null and b/app/src/main/res/drawable/back.png differ diff --git a/app/src/main/res/drawable/infoclose.png b/app/src/main/res/drawable/infoclose.png new file mode 100644 index 000000000..1f3cf2e46 Binary files /dev/null and b/app/src/main/res/drawable/infoclose.png differ diff --git a/app/src/main/res/drawable/rgbwinfo.png b/app/src/main/res/drawable/rgbwinfo.png new file mode 100644 index 000000000..2d59c98f1 Binary files /dev/null and b/app/src/main/res/drawable/rgbwinfo.png differ diff --git a/app/src/main/res/drawable/rgbwpoweroff.png b/app/src/main/res/drawable/rgbwpoweroff.png new file mode 100644 index 000000000..a77455e02 Binary files /dev/null and b/app/src/main/res/drawable/rgbwpoweroff.png differ diff --git a/app/src/main/res/drawable/rgbwpoweron.png b/app/src/main/res/drawable/rgbwpoweron.png new file mode 100644 index 000000000..2c09aae76 Binary files /dev/null and b/app/src/main/res/drawable/rgbwpoweron.png differ diff --git a/app/src/main/res/drawable/rgbwsettings.png b/app/src/main/res/drawable/rgbwsettings.png new file mode 100644 index 000000000..4cc435742 Binary files /dev/null and b/app/src/main/res/drawable/rgbwsettings.png differ diff --git a/app/src/main/res/drawable/rounded_rgb_left_btn.xml b/app/src/main/res/drawable/rounded_rgb_left_btn.xml deleted file mode 100644 index c4429e028..000000000 --- a/app/src/main/res/drawable/rounded_rgb_left_btn.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_rgb_left_sel_btn.xml b/app/src/main/res/drawable/rounded_rgb_left_sel_btn.xml deleted file mode 100644 index b174d8783..000000000 --- a/app/src/main/res/drawable/rounded_rgb_left_sel_btn.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_rgb_right_btn.xml b/app/src/main/res/drawable/rounded_rgb_right_btn.xml deleted file mode 100644 index 9733d32a7..000000000 --- a/app/src/main/res/drawable/rounded_rgb_right_btn.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_rgb_right_sel_btn.xml b/app/src/main/res/drawable/rounded_rgb_right_sel_btn.xml deleted file mode 100644 index b1299882a..000000000 --- a/app/src/main/res/drawable/rounded_rgb_right_sel_btn.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_sel_btn.xml b/app/src/main/res/drawable/rounded_sel_btn.xml new file mode 100644 index 000000000..7d68f357f --- /dev/null +++ b/app/src/main/res/drawable/rounded_sel_btn.xml @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_tab_background.xml b/app/src/main/res/drawable/rounded_tab_background.xml new file mode 100644 index 000000000..032d11df0 --- /dev/null +++ b/app/src/main/res/drawable/rounded_tab_background.xml @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/vl_left_btn_off.xml b/app/src/main/res/drawable/vl_left_btn_off.xml deleted file mode 100644 index aa9f7fab1..000000000 --- a/app/src/main/res/drawable/vl_left_btn_off.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vl_left_btn_on.xml b/app/src/main/res/drawable/vl_left_btn_on.xml deleted file mode 100644 index 8a48b3ca8..000000000 --- a/app/src/main/res/drawable/vl_left_btn_on.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vl_middle_btn_off.xml b/app/src/main/res/drawable/vl_middle_btn_off.xml deleted file mode 100644 index 206c4875d..000000000 --- a/app/src/main/res/drawable/vl_middle_btn_off.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vl_middle_btn_on.xml b/app/src/main/res/drawable/vl_middle_btn_on.xml deleted file mode 100644 index 7657e127e..000000000 --- a/app/src/main/res/drawable/vl_middle_btn_on.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vl_right_btn_off.xml b/app/src/main/res/drawable/vl_right_btn_off.xml deleted file mode 100644 index 91726ddb7..000000000 --- a/app/src/main/res/drawable/vl_right_btn_off.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vl_right_btn_on.xml b/app/src/main/res/drawable/vl_right_btn_on.xml deleted file mode 100644 index 6755eb000..000000000 --- a/app/src/main/res/drawable/vl_right_btn_on.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vl_tab_on.xml b/app/src/main/res/drawable/vl_tab.xml similarity index 60% rename from app/src/main/res/drawable/vl_tab_on.xml rename to app/src/main/res/drawable/vl_tab.xml index fdedc3d2d..55bd4309b 100644 --- a/app/src/main/res/drawable/vl_tab_on.xml +++ b/app/src/main/res/drawable/vl_tab.xml @@ -1,15 +1,10 @@ - - - - + + android:topRightRadius="5dp" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/vl_tab_off.xml b/app/src/main/res/drawable/vl_tab_off.xml deleted file mode 100644 index 16cd714ce..000000000 --- a/app/src/main/res/drawable/vl_tab_off.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/vlinfo.png b/app/src/main/res/drawable/vlinfo.png new file mode 100644 index 000000000..67aacaab6 Binary files /dev/null and b/app/src/main/res/drawable/vlinfo.png differ diff --git a/app/src/main/res/drawable/vlrestore.png b/app/src/main/res/drawable/vlrestore.png new file mode 100644 index 000000000..5aebd3a7c Binary files /dev/null and b/app/src/main/res/drawable/vlrestore.png differ diff --git a/app/src/main/res/drawable/vprosmart.png b/app/src/main/res/drawable/vprosmart.png new file mode 100644 index 000000000..a24b28ed7 Binary files /dev/null and b/app/src/main/res/drawable/vprosmart.png differ diff --git a/app/src/main/res/layout-sw600dp/detail_homeplus.xml b/app/src/main/res/layout-sw600dp/detail_homeplus.xml index c0be26517..ff26c83f1 100644 --- a/app/src/main/res/layout-sw600dp/detail_homeplus.xml +++ b/app/src/main/res/layout-sw600dp/detail_homeplus.xml @@ -1,6 +1,5 @@ - - - - - - - - diff --git a/app/src/main/res/layout-sw600dp/detail_rs.xml b/app/src/main/res/layout-sw600dp/detail_rs.xml index 6312ee168..1f0505612 100644 --- a/app/src/main/res/layout-sw600dp/detail_rs.xml +++ b/app/src/main/res/layout-sw600dp/detail_rs.xml @@ -124,16 +124,6 @@ android:layout_centerVertical="true" android:orientation="vertical"> - - + android:layout_height="85dp" + android:layout_alignParentTop="true" + android:background="@color/menubar"> - -