misc changes to the widget

This commit is contained in:
tibbi 2016-02-28 16:12:44 +01:00
parent 3bd2c6296d
commit d0c6f6e973
7 changed files with 36 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
@ -32,6 +33,7 @@ public class MyWidgetConfigure extends AppCompatActivity implements Calendar {
@Bind(R.id.config_bg_seekbar) SeekBar bgSeekBar;
@Bind(R.id.config_text_color) View textColorPicker;
@Bind(R.id.config_calendar) View widgetBackground;
@Bind(R.id.config_save) Button saveBtn;
@BindDimen(R.dimen.day_text_size) float dayTextSize;
@BindDimen(R.dimen.today_text_size) float todayTextSize;
@ -75,9 +77,15 @@ public class MyWidgetConfigure extends AppCompatActivity implements Calendar {
textColorWithoutTransparency = prefs.getInt(Constants.WIDGET_TEXT_COLOR, Color.WHITE);
updateTextColors();
bgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, Color.BLACK);
bgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, 0);
if (bgColor == 0) {
bgColor = Color.BLACK;
bgAlpha = .5f;
} else {
bgAlpha = Color.alpha(bgColor) / (float) 255;
}
bgColorWithoutTransparency = Color.rgb(Color.red(bgColor), Color.green(bgColor), Color.blue(bgColor));
bgAlpha = Color.alpha(bgColor) / (float) 255;
bgSeekBar.setOnSeekBarChangeListener(bgSeekbarChangeListener);
bgSeekBar.setProgress((int) (bgAlpha * 100));
updateBgColor();
@ -156,6 +164,7 @@ public class MyWidgetConfigure extends AppCompatActivity implements Calendar {
rightArrow.getDrawable().mutate().setColorFilter(textColor, PorterDuff.Mode.SRC_ATOP);
monthTV.setTextColor(textColor);
textColorPicker.setBackgroundColor(textColor);
saveBtn.setTextColor(textColor);
updateLabels();
}
@ -163,6 +172,7 @@ public class MyWidgetConfigure extends AppCompatActivity implements Calendar {
bgColor = Helpers.adjustAlpha(bgColorWithoutTransparency, bgAlpha);
widgetBackground.setBackgroundColor(bgColor);
bgColorPicker.setBackgroundColor(bgColor);
saveBtn.setBackgroundColor(bgColor);
}
private void updateDays() {

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/button_pressed"
android:state_pressed="true"/>
</selector>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/dark_grey_pressed_mask"/>
</shape>

View File

@ -53,5 +53,6 @@
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:text="OK"
android:textSize="18sp"/>
android:textColor="@android:color/white"
android:textSize="@dimen/config_text_size"/>
</RelativeLayout>

View File

@ -3,4 +3,5 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="dark_grey_pressed_mask">#22000000</color>
</resources>

View File

@ -2,4 +2,5 @@
<dimen name="activity_margin">16dp</dimen>
<dimen name="day_text_size">16sp</dimen>
<dimen name="today_text_size">32sp</dimen>
<dimen name="config_text_size">18sp</dimen>
</resources>

View File

@ -4,6 +4,8 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="buttonStyle">@style/MyButton</item>
<item name="android:buttonStyle">@style/MyButton</item>
</style>
<style name="DayView">
@ -16,4 +18,10 @@
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="MyButton" parent="Widget.AppCompat.Button">
<item name="android:textColor">@android:color/white</item>
<item name="background">@drawable/button</item>
<item name="android:background">@drawable/button</item>
</style>
</resources>