Style changes

This commit is contained in:
serso 2016-03-19 18:33:20 +01:00
parent b9432db42a
commit 9f542099fd
21 changed files with 130 additions and 182 deletions

View File

@ -36,7 +36,8 @@
android:clearTaskOnLaunch="true"
android:label="@string/c_app_name"
android:launchMode="singleTop"
android:windowSoftInputMode="stateHidden|adjustPan">
android:windowSoftInputMode="stateHidden|adjustPan"
android:theme="@style/Cpp.Theme.Material.Calculator">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -7,6 +7,7 @@ import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
@ -171,6 +172,14 @@ public class BaseActivity extends AppCompatActivity {
final ActionBar actionBar = getSupportActionBar();
Check.isNotNull(actionBar);
actionBar.setDisplayHomeAsUpEnabled(true);
if (App.isTablet(this)) {
final ViewGroup.LayoutParams lp = toolbar.getLayoutParams();
if (lp instanceof AppBarLayout.LayoutParams) {
((AppBarLayout.LayoutParams) lp).setScrollFlags(0);
toolbar.setLayoutParams(lp);
}
}
}
private void onPreCreate() {

View File

@ -303,17 +303,19 @@ public final class Preferences {
default_theme(R.style.Cpp_Theme_Gray),
violet_theme(R.style.Cpp_Theme_Violet),
light_blue_theme(R.style.Cpp_Theme_Blue),
metro_blue_theme(R.style.Cpp_Theme_Metro_Blue),
metro_purple_theme(R.style.Cpp_Theme_Metro_Purple),
metro_green_theme(R.style.Cpp_Theme_Metro_Green),
material_theme(R.style.Cpp_Theme_Material),
material_light_theme(R.style.Cpp_Theme_Material_Light, R.style.Cpp_Theme_Wizard_Light, R.style.Cpp_Theme_Material_Light_Dialog, R.style.Cpp_Theme_Material_Light_Dialog_Alert);
metro_blue_theme(R.style.Cpp_Theme_Metro_Blue, R.style.Cpp_Theme_Metro_Blue_Calculator, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Metro_Blue_Dialog, R.style.Cpp_Theme_Material_Dialog_Alert),
metro_purple_theme(R.style.Cpp_Theme_Metro_Purple, R.style.Cpp_Theme_Metro_Purple_Calculator, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Metro_Purple_Dialog, R.style.Cpp_Theme_Material_Dialog_Alert),
metro_green_theme(R.style.Cpp_Theme_Metro_Green, R.style.Cpp_Theme_Metro_Green_Calculator, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Metro_Green_Dialog, R.style.Cpp_Theme_Material_Dialog_Alert),
material_theme(R.style.Cpp_Theme_Material, R.style.Cpp_Theme_Material_Calculator),
material_light_theme(R.style.Cpp_Theme_Material_Light, R.style.Cpp_Theme_Material_Light, R.style.Cpp_Theme_Wizard_Light, R.style.Cpp_Theme_Material_Light_Dialog, R.style.Cpp_Theme_Material_Light_Dialog_Alert);
private static final SparseArray<TextColor> textColors = new SparseArray<>();
@StyleRes
public final int theme;
@StyleRes
public final int calculatorTheme;
@StyleRes
public final int wizardTheme;
@StyleRes
public final int dialogTheme;
@ -322,11 +324,16 @@ public final class Preferences {
public final boolean light;
Theme(@StyleRes int theme) {
this(theme, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Material_Dialog, R.style.Cpp_Theme_Material_Dialog_Alert);
this(theme, theme);
}
Theme(@StyleRes int theme, @StyleRes int wizardTheme, @StyleRes int dialogTheme, @StyleRes int alertDialogTheme) {
Theme(@StyleRes int theme, @StyleRes int calculatorTheme) {
this(theme, calculatorTheme, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Material_Dialog, R.style.Cpp_Theme_Material_Dialog_Alert);
}
Theme(@StyleRes int theme, @StyleRes int calculatorTheme, @StyleRes int wizardTheme, @StyleRes int dialogTheme, @StyleRes int alertDialogTheme) {
this.theme = theme;
this.calculatorTheme = calculatorTheme;
this.wizardTheme = wizardTheme;
this.dialogTheme = dialogTheme;
this.alertDialogTheme = alertDialogTheme;
@ -334,6 +341,9 @@ public final class Preferences {
}
public int getThemeFor(@Nonnull Context context) {
if (context instanceof CalculatorActivity) {
return calculatorTheme;
}
if (context instanceof WizardActivity) {
return wizardTheme;
}

View File

@ -26,7 +26,7 @@
a:color="?attr/colorControlHighlight">
<item>
<shape>
<solid a:color="?attr/cpp_main_bg" />
<solid a:color="?attr/cpp_editor_bg" />
</shape>
</item>
</ripple>

View File

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main"
style="@style/CppMain"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_scrollFlags="snap">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:overScrollMode="never"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
app:layout_behavior="org.solovyev.android.calculator.view.PagerViewFabBehavior"
android:id="@+id/fab"
style="@style/CppFab" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_scrollFlags="snap">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:overScrollMode="never"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
</android.support.v7.widget.Toolbar>
</merge>

View File

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main"
style="@style/CppMain"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="?actionBarSize" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
app:layout_behavior="org.solovyev.android.calculator.view.PagerViewFabBehavior"
android:id="@+id/fab"
style="@style/CppFab" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -40,22 +40,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
<include layout="@layout/activity_tabs_tablayout"/>
</android.support.design.widget.AppBarLayout>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_scrollFlags="scroll|snap" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
</merge>

View File

@ -53,7 +53,7 @@
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:layout_marginBottom="10dp"
a:background="?attr/cpp_main_bg"
a:background="?attr/cpp_editor_bg"
a:padding="3dp">
<org.solovyev.android.views.dragbutton.DirectionDragButton

View File

@ -26,7 +26,7 @@
xmlns:tools="http://schemas.android.com/tools"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:background="?attr/cpp_main_bg"
a:background="?attr/cpp_editor_bg"
a:minWidth="200dp"
a:orientation="vertical"
a:padding="3dp"

View File

@ -27,7 +27,7 @@
<attr name="cpp_button_style_control_highlighted" format="reference" />
<attr name="cpp_button_style_operation" format="reference" />
<attr name="cpp_button_style_operation_highlighted" format="reference" />
<attr name="cpp_main_bg" format="reference" />
<attr name="cpp_editor_bg" format="reference" />
<attr name="cpp_fab_bg" format="reference" />
<attr name="cpp_wizard_button_bg" format="reference" />

View File

@ -27,7 +27,8 @@
<color name="cpp_text_inverse_error">@color/cpp_text</color>
<color name="cpp_button_text">#ffffffff</color>
<color name="cpp_bg">@color/grey_950</color>
<color name="cpp_editor_bg">@color/grey_950</color>
<color name="cpp_bg">@color/grey_850</color>
<color name="cpp_bg_light">@color/grey_100</color>
<color name="cpp_widget_cursor">@color/grey_600</color>

View File

@ -6,7 +6,6 @@
<dimen name="cpp_widget_display_text_size">25sp</dimen>
<dimen name="cpp_widget_margin">6dp</dimen>
<dimen name="min_expanded_height_lock_screen">300dp</dimen>
<dimen name="cpp_text_size">20sp</dimen>
<dimen name="cpp_button_padding">1px</dimen>
<dimen name="cpp_direction_text_default_padding">2dp</dimen>
<dimen name="cpp_direction_text_min_size">9dp</dimen>

View File

@ -22,10 +22,6 @@
<resources>
<style name="cpp_default_text_size">
<item name="android:textSize">@dimen/cpp_text_size</item>
</style>
<style name="CppKeyboardButton" parent="BaseCppKeyboardButton"/>
<style name="BaseCppKeyboardButton">
<item name="android:layout_width">0dp</item>
@ -109,7 +105,7 @@
</style>
<style name="CppMain.Widget" parent="CppMain">
<item name="android:background">@color/cpp_bg</item>
<item name="android:background">@color/cpp_editor_bg</item>
<item name="android:padding">1dp</item>
<item name="android:layout_margin">@dimen/cpp_widget_margin</item>
</style>
@ -140,7 +136,7 @@
</style>
<style name="CppMain.Onscreen" parent="CppMain">
<item name="android:background">@color/cpp_bg</item>
<item name="android:background">@color/cpp_editor_bg</item>
<item name="android:padding">@dimen/cpp_onscreen_main_padding</item>
</style>
@ -287,8 +283,6 @@
<style name="CppListView">
<item name="android:id">@android:id/list</item>
<item name="android:dividerHeight">1px</item>
<item name="android:divider">@drawable/divider</item>
<item name="android:cacheColorHint">@android:color/transparent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item>

View File

@ -22,6 +22,10 @@
<resources>
<style name="Cpp.Theme.Calculator" parent="@style/Cpp.Theme">
<item name="android:windowBackground">@color/cpp_editor_bg</item>
</style>
<style name="Cpp.Theme" parent="@style/Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/grey_900</item>
<item name="colorPrimaryDark">@color/black</item>
@ -29,7 +33,7 @@
<item name="android:windowBackground">@color/cpp_bg</item>
<item name="cpp_main_bg">@color/cpp_bg</item>
<item name="cpp_editor_bg">@color/cpp_editor_bg</item>
<item name="cpp_fab_bg">@color/blue_900</item>
<item name="cpp_text_color">@color/cpp_text</item>
<item name="cpp_text_color_error">@color/cpp_text_error</item>
@ -47,8 +51,6 @@
</style>
<style name="Cpp.Theme.Dialog" parent="@style/Theme.AppCompat.DialogWhenLarge">
<item name="android:windowBackground">@color/cpp_bg</item>
<item name="colorPrimary">@color/grey_900</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/cpp_material_accent</item>
@ -58,7 +60,7 @@
<item name="windowActionBar">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="cpp_main_bg">@color/cpp_bg</item>
<item name="cpp_editor_bg">@color/cpp_bg</item>
<item name="cpp_fab_bg">@color/blue_900</item>
<item name="cpp_text_color">@color/cpp_text</item>
<item name="cpp_text_color_error">@color/cpp_text_error</item>
@ -72,7 +74,7 @@
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/cpp_material_accent</item>
<item name="cpp_main_bg">@color/cpp_bg</item>
<item name="cpp_editor_bg">@color/cpp_bg</item>
<item name="cpp_fab_bg">@color/blue_900</item>
<item name="cpp_text_color">@color/cpp_text</item>
<item name="cpp_text_color_error">@color/cpp_text_error</item>
@ -88,7 +90,7 @@
<item name="colorPrimaryDark">@color/teal_400</item>
<item name="colorAccent">@color/teal_400</item>
<item name="cpp_main_bg">@color/cpp_bg_light</item>
<item name="cpp_editor_bg">@color/cpp_bg_light</item>
<item name="cpp_fab_bg">@color/teal_400</item>
<item name="cpp_text_color">@color/cpp_text_inverse</item>
<item name="cpp_text_color_error">@color/cpp_text_inverse_error</item>
@ -99,8 +101,6 @@
</style>
<style name="Cpp.Theme.Light.Dialog" parent="@style/Theme.AppCompat.Light.DialogWhenLarge">
<item name="android:windowBackground">@color/cpp_bg_light</item>
<item name="colorPrimary">@color/teal_400</item>
<item name="colorPrimaryDark">@color/teal_400</item>
<item name="colorAccent">@color/teal_400</item>
@ -110,7 +110,7 @@
<item name="windowActionBar">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="cpp_main_bg">@color/cpp_bg_light</item>
<item name="cpp_editor_bg">@color/cpp_bg_light</item>
<item name="cpp_fab_bg">@color/teal_400</item>
<item name="cpp_text_color">@color/cpp_text_inverse</item>
<item name="cpp_text_color_error">@color/cpp_text_inverse_error</item>
@ -124,7 +124,7 @@
<item name="colorPrimaryDark">@color/teal_400</item>
<item name="colorAccent">@color/teal_400</item>
<item name="cpp_main_bg">@color/cpp_bg_light</item>
<item name="cpp_editor_bg">@color/cpp_bg_light</item>
<item name="cpp_fab_bg">@color/teal_400</item>
<item name="cpp_text_color">@color/cpp_text_inverse</item>
<item name="cpp_text_color_error">@color/cpp_text_inverse_error</item>
@ -134,6 +134,7 @@
</style>
<style name="Cpp.Theme.Wizard" parent="Cpp.Theme.Material">
<item name="android:windowBackground">@color/grey_950</item>
<item name="windowNoTitle">true</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>

View File

@ -64,6 +64,10 @@
<item name="android:textSize">@dimen/cpp_widget_keyboard_button_text_size</item>
</style>
<style name="Cpp.Theme.Material.Calculator" parent="Cpp.Theme.Material">
<item name="android:windowBackground">@color/cpp_editor_bg</item>
</style>
<style name="Cpp.Theme.Material" parent="Cpp.Theme">
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Material.Digit</item>
<item name="cpp_button_style_control">@style/CppKeyboardButton.Material.Digit</item>

View File

@ -26,7 +26,7 @@
<item name="android:background">@drawable/material_button_light</item>
</style>
<style name="CppKeyboardButton.Material.Light.Digit.Highlighted" parent="CppKeyboardButton">
<style name="CppKeyboardButton.Material.Light.Digit.Highlighted" parent="CppKeyboardButton.Material.Light.Digit">
<item name="android:background">@drawable/material_button_light_darker</item>
</style>

View File

@ -69,6 +69,20 @@
<item name="cpp_button_style_control_highlighted">@style/CppKeyboardButton.Metro.Blue.Control</item>
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Metro.Blue.Operation</item>
<item name="cpp_button_style_operation_highlighted">@style/CppKeyboardButton.Metro.Blue.Operation</item>
<item name="cpp_fab_bg">@color/blue_900</item>
</style>
<style name="Cpp.Theme.Metro.Blue.Dialog" parent="Cpp.Theme.Dialog">
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Metro.Blue.Digit</item>
<item name="cpp_button_style_control">@style/CppKeyboardButton.Metro.Blue.Control</item>
<item name="cpp_button_style_control_highlighted">@style/CppKeyboardButton.Metro.Blue.Control</item>
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Metro.Blue.Operation</item>
<item name="cpp_button_style_operation_highlighted">@style/CppKeyboardButton.Metro.Blue.Operation</item>
<item name="cpp_fab_bg">@color/blue_900</item>
</style>
<style name="Cpp.Theme.Metro.Blue.Calculator" parent="Cpp.Theme.Metro.Blue">
<item name="android:windowBackground">@color/cpp_editor_bg</item>
</style>
</resources>

View File

@ -32,4 +32,14 @@
<item name="cpp_fab_bg">@color/green_800</item>
</style>
<style name="Cpp.Theme.Metro.Green.Dialog" parent="Cpp.Theme.Metro.Blue.Dialog">
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Metro.Green.Operation</item>
<item name="cpp_button_style_operation_highlighted">@style/CppKeyboardButton.Metro.Green.Operation</item>
<item name="cpp_fab_bg">@color/green_800</item>
</style>
<style name="Cpp.Theme.Metro.Green.Calculator" parent="Cpp.Theme.Metro.Green">
<item name="android:windowBackground">@color/cpp_editor_bg</item>
</style>
</resources>

View File

@ -32,4 +32,14 @@
<item name="cpp_fab_bg">@color/pink_900</item>
</style>
<style name="Cpp.Theme.Metro.Purple.Dialog" parent="Cpp.Theme.Metro.Blue.Dialog">
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Metro.Purple.Digit</item>
<item name="cpp_button_style_operation_highlighted">@style/CppKeyboardButton.Metro.Purple.Digit</item>
<item name="cpp_fab_bg">@color/pink_900</item>
</style>
<style name="Cpp.Theme.Metro.Purple.Calculator" parent="Cpp.Theme.Metro.Purple">
<item name="android:windowBackground">@color/cpp_editor_bg</item>
</style>
</resources>