improve the widget config screen + style changes

This commit is contained in:
tibbi 2016-01-02 18:41:18 +01:00
parent fed4e15afb
commit ad9c907f12
11 changed files with 121 additions and 11 deletions

View File

@ -31,7 +31,8 @@
</receiver>
<activity
android:name=".MyWidgetConfigure">
android:name=".MyWidgetConfigure"
android:theme="@style/MyWidgetConfigTheme">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>

View File

@ -1,5 +1,6 @@
package calculator.simplemobiletools.com.simple_calculator;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
@ -21,6 +22,13 @@ public class MainActivity extends AppCompatActivity implements Calculator {
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
calc = new CalculatorImpl(this);
setupResultView();
}
private void setupResultView() {
final Resources res = getResources();
result.setBackgroundColor(res.getColor(android.R.color.white));
result.setTextColor(res.getColor(R.color.dark_grey));
}
@OnClick(R.id.btn_plus)

View File

@ -4,11 +4,15 @@ import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class MyWidgetConfigure extends AppCompatActivity {
@Bind(R.id.btn_reset) Button resetBtn;
private int widgetId;
@Override
@ -17,6 +21,7 @@ public class MyWidgetConfigure extends AppCompatActivity {
setContentView(R.layout.widget_config);
ButterKnife.bind(this);
resetBtn.setVisibility(View.VISIBLE);
final Intent intent = getIntent();
final Bundle extras = intent.getExtras();
if (extras != null) {

View File

@ -0,0 +1,9 @@
<?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"/>
<item
android:drawable="@drawable/button_normal"
android:state_pressed="false"/>
</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"/>
</shape>

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"/>
</shape>

View File

@ -4,18 +4,21 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/activity_margin"
tools:context="calculator.simplemobiletools.com.simple_calculator.MainActivity">
<TextView
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:background="@color/dark_grey"
android:gravity="right"
android:lines="1"
android:padding="@dimen/activity_margin"
android:paddingBottom="@dimen/result_padding"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/result_padding"
android:text="0"
android:textColor="@android:color/white"
android:textSize="@dimen/display_text_size"/>
<LinearLayout
@ -32,6 +35,7 @@
<Button
android:id="@+id/btn_modulo"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -40,6 +44,7 @@
<Button
android:id="@+id/btn_power"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -48,6 +53,7 @@
<Button
android:id="@+id/btn_root"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -56,6 +62,7 @@
<Button
android:id="@+id/btn_clear"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -64,6 +71,7 @@
<Button
android:id="@+id/btn_reset"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -80,6 +88,7 @@
<Button
android:id="@+id/btn_7"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -88,6 +97,7 @@
<Button
android:id="@+id/btn_8"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -96,6 +106,7 @@
<Button
android:id="@+id/btn_9"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -104,6 +115,7 @@
<Button
android:id="@+id/btn_divide"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -119,6 +131,7 @@
<Button
android:id="@+id/btn_4"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -127,6 +140,7 @@
<Button
android:id="@+id/btn_5"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -135,6 +149,7 @@
<Button
android:id="@+id/btn_6"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -143,6 +158,7 @@
<Button
android:id="@+id/btn_multiply"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -158,6 +174,7 @@
<Button
android:id="@+id/btn_1"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -166,6 +183,7 @@
<Button
android:id="@+id/btn_2"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -174,6 +192,7 @@
<Button
android:id="@+id/btn_3"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -182,6 +201,7 @@
<Button
android:id="@+id/btn_minus"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -197,6 +217,7 @@
<Button
android:id="@+id/btn_0"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -205,6 +226,7 @@
<Button
android:id="@+id/btn_decimal"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -213,6 +235,7 @@
<Button
android:id="@+id/btn_equals"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@ -221,6 +244,7 @@
<Button
android:id="@+id/btn_plus"
style="@style/MyButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"

View File

@ -2,12 +2,36 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_margin">
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="80dp"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_marginRight="@dimen/activity_margin"
android:layout_marginTop="@dimen/activity_margin">
<Button
android:id="@+id/config_save"
android:layout_width="wrap_content"
<include
android:id="@+id/config_calc"
layout="@layout/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/config_bottom"
android:layout_marginBottom="@dimen/activity_margin"/>
<RelativeLayout
android:id="@+id/config_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save"/>
android:layout_alignParentBottom="true"
android:background="@android:color/white">
<Button
android:id="@+id/config_save"
style="@android:style/Widget.Holo.Light.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:text="Save"/>
</RelativeLayout>
</RelativeLayout>

View File

@ -3,4 +3,6 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="dark_grey">#88000000</color>
<color name="dark_grey_pressed">#99000000</color>
</resources>

View File

@ -1,5 +1,6 @@
<resources>
<dimen name="activity_margin">16dp</dimen>
<dimen name="button_text_size">24sp</dimen>
<dimen name="result_padding">32dp</dimen>
<dimen name="button_text_size">28sp</dimen>
<dimen name="display_text_size">36sp</dimen>
</resources>

View File

@ -4,5 +4,29 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColor">@android:color/white</item>
<item name="buttonStyle">@style/MyButton</item>
<item name="android:buttonStyle">@style/MyButton</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>
<style name="MyWidgetConfigTheme" parent="@style/AppTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:actionBarStyle">@style/MyWidgetConfigActionBar</item>
</style>
<style name="MyWidgetConfigActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="android:background">@color/colorPrimary</item>
<item name="background">@color/colorPrimary</item>
</style>
</resources>