Styles
This commit is contained in:
parent
cf322d04ee
commit
c1e6389024
@ -1,43 +1,43 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||||
~ For more information, please, contact se.solovyev@gmail.com
|
~ For more information, please, contact se.solovyev@gmail.com
|
||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="button_style" parent="button_style_parent">
|
<style name="button_style" parent="button_style_parent">
|
||||||
<item name="android:layout_width">fill_parent</item>
|
<item name="android:layout_width">fill_parent</item>
|
||||||
<item name="android:layout_height">fill_parent</item>
|
<item name="android:layout_height">fill_parent</item>
|
||||||
<item name="android:layout_weight">1</item>
|
<item name="android:layout_weight">1</item>
|
||||||
<item name="android:focusable">true</item>
|
<item name="android:focusable">true</item>
|
||||||
<item name="android:background">@drawable/default_button_dark</item>
|
<item name="android:background">@drawable/default_button_dark</item>
|
||||||
<item name="android:layout_marginLeft">1dp</item>
|
<item name="android:layout_margin">0.5dp</item>
|
||||||
<item name="android:layout_marginBottom">1dp</item>
|
</style>
|
||||||
</style>
|
|
||||||
|
<style name="editor_style" parent="editor_style_parent">
|
||||||
<style name="editor_style" parent="editor_style_parent">
|
<item name="android:gravity">left|top</item>
|
||||||
<item name="android:gravity">left|top</item>
|
<item name="android:layout_width">fill_parent</item>
|
||||||
<item name="android:layout_width">fill_parent</item>
|
<item name="android:layout_height">fill_parent</item>
|
||||||
<item name="android:layout_height">fill_parent</item>
|
</style>
|
||||||
</style>
|
|
||||||
|
<style name="display_style" parent="display_style_parent">
|
||||||
<style name="display_style" parent="display_style_parent">
|
<item name="android:gravity">top|right</item>
|
||||||
<item name="android:gravity">top|right</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
<item name="android:layout_width">fill_parent</item>
|
<item name="android:layout_height">match_parent</item>
|
||||||
<item name="android:layout_height">fill_parent</item>
|
<item name="android:layout_margin">0.5dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="about_style" parent="about_style_parent">
|
<style name="about_style" parent="about_style_parent">
|
||||||
<item name="android:gravity">center</item>
|
<item name="android:gravity">center</item>
|
||||||
<item name="android:layout_width">fill_parent</item>
|
<item name="android:layout_width">fill_parent</item>
|
||||||
<item name="android:layout_height">fill_parent</item>
|
<item name="android:layout_height">fill_parent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="default_text">
|
<style name="default_text">
|
||||||
<item name="android:background">@color/default_background</item>
|
<item name="android:background">@color/default_background</item>
|
||||||
<item name="android:textColor">@color/default_text_color</item>
|
<item name="android:textColor">@color/default_text_color</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="metro_digit_button_style" parent="button_style">
|
<style name="metro_digit_button_style" parent="button_style">
|
||||||
<item name="android:background">@drawable/metro_button_dark</item>
|
<item name="android:background">@drawable/metro_button_dark</item>
|
||||||
<item name="android:layout_marginLeft">2dp</item>
|
</style>
|
||||||
<item name="android:layout_marginBottom">2dp</item>
|
|
||||||
</style>
|
<style name="metro_control_button_style" parent="metro_digit_button_style">
|
||||||
|
<item name="android:background">@drawable/metro_button_light</item>
|
||||||
<style name="metro_control_button_style" parent="metro_digit_button_style">
|
</style>
|
||||||
<item name="android:background">@drawable/metro_button_light</item>
|
|
||||||
</style>
|
<style name="metro_blue_operation_button_style" parent="metro_digit_button_style">
|
||||||
|
<item name="android:background">@drawable/metro_button_blue</item>
|
||||||
<style name="metro_blue_operation_button_style" parent="metro_digit_button_style">
|
</style>
|
||||||
<item name="android:background">@drawable/metro_button_blue</item>
|
|
||||||
</style>
|
<style name="metro_control_image_button_style" parent="metro_control_button_style">
|
||||||
|
<item name="android:padding">6dp</item>
|
||||||
<style name="metro_control_image_button_style" parent="metro_control_button_style">
|
</style>
|
||||||
<item name="android:padding">6dp</item>
|
|
||||||
</style>
|
<style name="metro_blue_theme">
|
||||||
|
<item name="digitButtonStyle">@style/metro_digit_button_style</item>
|
||||||
<style name="metro_blue_theme">
|
<item name="controlButtonStyle">@style/metro_control_button_style</item>
|
||||||
<item name="digitButtonStyle">@style/metro_digit_button_style</item>
|
<item name="controlImageButtonStyle">@style/metro_control_image_button_style</item>
|
||||||
<item name="controlButtonStyle">@style/metro_control_button_style</item>
|
<item name="operationButtonStyle">@style/metro_blue_operation_button_style</item>
|
||||||
<item name="controlImageButtonStyle">@style/metro_control_image_button_style</item>
|
</style>
|
||||||
<item name="operationButtonStyle">@style/metro_blue_operation_button_style</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -1,28 +1,26 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="metro_digit_button_style" parent="button_style">
|
<style name="metro_digit_button_style" parent="button_style">
|
||||||
<item name="android:background">@drawable/metro_button_dark</item>
|
<item name="android:background">@drawable/metro_button_dark</item>
|
||||||
<item name="android:layout_marginLeft">2dp</item>
|
</style>
|
||||||
<item name="android:layout_marginBottom">2dp</item>
|
|
||||||
</style>
|
<style name="metro_control_button_style" parent="metro_digit_button_style">
|
||||||
|
<item name="android:background">@drawable/metro_button_light</item>
|
||||||
<style name="metro_control_button_style" parent="metro_digit_button_style">
|
</style>
|
||||||
<item name="android:background">@drawable/metro_button_light</item>
|
|
||||||
</style>
|
<style name="metro_green_operation_button_style" parent="metro_digit_button_style">
|
||||||
|
<item name="android:background">@drawable/metro_button_green</item>
|
||||||
<style name="metro_green_operation_button_style" parent="metro_digit_button_style">
|
</style>
|
||||||
<item name="android:background">@drawable/metro_button_green</item>
|
|
||||||
</style>
|
<style name="metro_control_image_button_style" parent="metro_control_button_style">
|
||||||
|
<item name="android:padding">6dp</item>
|
||||||
<style name="metro_control_image_button_style" parent="metro_control_button_style">
|
</style>
|
||||||
<item name="android:padding">6dp</item>
|
|
||||||
</style>
|
<style name="metro_green_theme">
|
||||||
|
<item name="digitButtonStyle">@style/metro_digit_button_style</item>
|
||||||
<style name="metro_green_theme">
|
<item name="controlButtonStyle">@style/metro_control_button_style</item>
|
||||||
<item name="digitButtonStyle">@style/metro_digit_button_style</item>
|
<item name="controlImageButtonStyle">@style/metro_control_image_button_style</item>
|
||||||
<item name="controlButtonStyle">@style/metro_control_button_style</item>
|
<item name="operationButtonStyle">@style/metro_green_operation_button_style</item>
|
||||||
<item name="controlImageButtonStyle">@style/metro_control_image_button_style</item>
|
</style>
|
||||||
<item name="operationButtonStyle">@style/metro_green_operation_button_style</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -1,28 +1,26 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="metro_digit_button_style" parent="button_style">
|
<style name="metro_digit_button_style" parent="button_style">
|
||||||
<item name="android:background">@drawable/metro_button_dark</item>
|
<item name="android:background">@drawable/metro_button_dark</item>
|
||||||
<item name="android:layout_marginLeft">2dp</item>
|
</style>
|
||||||
<item name="android:layout_marginBottom">2dp</item>
|
|
||||||
</style>
|
<style name="metro_control_button_style" parent="metro_digit_button_style">
|
||||||
|
<item name="android:background">@drawable/metro_button_light</item>
|
||||||
<style name="metro_control_button_style" parent="metro_digit_button_style">
|
</style>
|
||||||
<item name="android:background">@drawable/metro_button_light</item>
|
|
||||||
</style>
|
<style name="metro_purple_operation_button_style" parent="metro_digit_button_style">
|
||||||
|
<item name="android:background">@drawable/metro_button_purple</item>
|
||||||
<style name="metro_purple_operation_button_style" parent="metro_digit_button_style">
|
</style>
|
||||||
<item name="android:background">@drawable/metro_button_purple</item>
|
|
||||||
</style>
|
<style name="metro_control_image_button_style" parent="metro_control_button_style">
|
||||||
|
<item name="android:padding">6dp</item>
|
||||||
<style name="metro_control_image_button_style" parent="metro_control_button_style">
|
</style>
|
||||||
<item name="android:padding">6dp</item>
|
|
||||||
</style>
|
<style name="metro_purple_theme">
|
||||||
|
<item name="digitButtonStyle">@style/metro_digit_button_style</item>
|
||||||
<style name="metro_purple_theme">
|
<item name="controlButtonStyle">@style/metro_control_button_style</item>
|
||||||
<item name="digitButtonStyle">@style/metro_digit_button_style</item>
|
<item name="controlImageButtonStyle">@style/metro_control_image_button_style</item>
|
||||||
<item name="controlButtonStyle">@style/metro_control_button_style</item>
|
<item name="operationButtonStyle">@style/metro_purple_operation_button_style</item>
|
||||||
<item name="controlImageButtonStyle">@style/metro_control_image_button_style</item>
|
</style>
|
||||||
<item name="operationButtonStyle">@style/metro_purple_operation_button_style</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -74,7 +74,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setLayout(preferences);
|
setLayout(preferences);
|
||||||
|
|
||||||
CalculatorKeyboardFragment.fixThemeParameters(findViewById(R.id.main_layout), true, this, theme);
|
CalculatorKeyboardFragment.fixThemeParameters(true, theme, this.getWindow().getDecorView());
|
||||||
|
|
||||||
final FragmentManager fragmentManager = getFragmentManager();
|
final FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import android.content.res.Configuration;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -156,7 +155,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
|||||||
|
|
||||||
numeralBaseButtons.toggleNumericDigits(this.getActivity(), preferences);
|
numeralBaseButtons.toggleNumericDigits(this.getActivity(), preferences);
|
||||||
|
|
||||||
fixThemeParameters(root, true, this.getActivity(), theme);
|
fixThemeParameters(true, theme, this.getView());
|
||||||
|
|
||||||
toggleEqualsButton(preferences, this.getActivity(), theme, root);
|
toggleEqualsButton(preferences, this.getActivity(), theme, root);
|
||||||
|
|
||||||
@ -172,45 +171,20 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
|||||||
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fixThemeParameters(@NotNull View root, boolean fixMagicFlames, @NotNull Activity activity, @NotNull CalculatorPreferences.Gui.Theme theme) {
|
public static void fixThemeParameters(boolean fixMagicFlames,
|
||||||
|
@NotNull CalculatorPreferences.Gui.Theme theme,
|
||||||
|
@NotNull View root) {
|
||||||
if (theme.getThemeType() == CalculatorPreferences.Gui.ThemeType.metro) {
|
if (theme.getThemeType() == CalculatorPreferences.Gui.ThemeType.metro) {
|
||||||
|
|
||||||
if (fixMagicFlames) {
|
if (fixMagicFlames) {
|
||||||
// for metro themes we should turn off magic flames
|
// for metro themes we should turn off magic flames
|
||||||
AndroidUtils.processViewsOfType(activity.getWindow().getDecorView(), ColorButton.class, new AndroidUtils.ViewProcessor<ColorButton>() {
|
AndroidUtils.processViewsOfType(root, ColorButton.class, new AndroidUtils.ViewProcessor<ColorButton>() {
|
||||||
@Override
|
@Override
|
||||||
public void process(@NotNull ColorButton colorButton) {
|
public void process(@NotNull ColorButton colorButton) {
|
||||||
colorButton.setDrawMagicFlame(false);
|
colorButton.setDrawMagicFlame(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fixMargins(root, 2, 2, activity);
|
|
||||||
} else {
|
|
||||||
fixMargins(root, 1, 1, activity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fixMargins(@NotNull View root, int marginLeft, int marginBottom, @NotNull Activity activity) {
|
|
||||||
// sad but true
|
|
||||||
|
|
||||||
final View equalsButton = root.findViewById(R.id.equalsButton);
|
|
||||||
final View rightButton = root.findViewById(R.id.rightButton);
|
|
||||||
final View leftButton = root.findViewById(R.id.leftButton);
|
|
||||||
final View clearButton = root.findViewById(R.id.clearButton);
|
|
||||||
final View eraseButton = root.findViewById(R.id.eraseButton);
|
|
||||||
|
|
||||||
int orientation = AndroidUtils.getScreenOrientation(activity);
|
|
||||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
||||||
setMarginsForView(equalsButton, marginLeft, marginBottom, activity);
|
|
||||||
setMarginsForView(getCalculatorDisplayView(), marginLeft, marginBottom, activity);
|
|
||||||
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
||||||
setMarginsForView(leftButton, marginLeft, marginBottom, activity);
|
|
||||||
setMarginsForView(eraseButton, marginLeft, marginBottom, activity);
|
|
||||||
setMarginsForView(clearButton, marginLeft, marginBottom, activity);
|
|
||||||
setMarginsForView(rightButton, marginLeft, marginBottom, activity);
|
|
||||||
// magic magic magic
|
|
||||||
setMarginsForView(getCalculatorDisplayView(), 3 * marginLeft, marginBottom, activity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +195,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @NotNull Context context) {
|
/* private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @NotNull Context context) {
|
||||||
// IMPORTANT: this is workaround for probably android bug
|
// IMPORTANT: this is workaround for probably android bug
|
||||||
// currently margin values set in styles are not applied for some reasons to the views (using include tag) => set them manually
|
// currently margin values set in styles are not applied for some reasons to the views (using include tag) => set them manually
|
||||||
|
|
||||||
@ -234,7 +208,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
|||||||
view.setLayoutParams(newParams);
|
view.setLayoutParams(newParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
@ -338,7 +312,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixThemeParameters(root, false, activity, theme);
|
fixThemeParameters(false, theme, root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user