mirror of https://github.com/tasks/tasks
Material 3 - WIP
parent
759b418dfb
commit
ba66deaddc
@ -1,119 +0,0 @@
|
||||
package org.tasks.themes;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import org.tasks.R;
|
||||
import org.tasks.dialogs.ColorPalettePicker.Pickable;
|
||||
|
||||
public class ThemeAccent implements Pickable {
|
||||
|
||||
public static final int[] ACCENTS =
|
||||
new int[] {
|
||||
R.style.BlueGreyAccent,
|
||||
R.style.RedAccent,
|
||||
R.style.PinkAccent,
|
||||
R.style.PurpleAccent,
|
||||
R.style.DeepPurpleAccent,
|
||||
R.style.IndigoAccent,
|
||||
R.style.BlueAccent,
|
||||
R.style.LightBlueAccent,
|
||||
R.style.CyanAccent,
|
||||
R.style.TealAccent,
|
||||
R.style.GreenAccent,
|
||||
R.style.LightGreenAccent,
|
||||
R.style.LimeAccent,
|
||||
R.style.YellowAccent,
|
||||
R.style.AmberAccent,
|
||||
R.style.OrangeAccent,
|
||||
R.style.DeepOrangeAccent
|
||||
};
|
||||
public static final int[] ACCENTS_DESATURATED =
|
||||
new int[] {
|
||||
R.style.BlueGreyAccentDesaturated,
|
||||
R.style.RedAccentDesaturated,
|
||||
R.style.PinkAccentDesaturated,
|
||||
R.style.PurpleAccentDesaturated,
|
||||
R.style.DeepPurpleAccentDesaturated,
|
||||
R.style.IndigoAccentDesaturated,
|
||||
R.style.BlueAccentDesaturated,
|
||||
R.style.LightBlueAccentDesaturated,
|
||||
R.style.CyanAccentDesaturated,
|
||||
R.style.TealAccentDesaturated,
|
||||
R.style.GreenAccentDesaturated,
|
||||
R.style.LightGreenAccentDesaturated,
|
||||
R.style.LimeAccentDesaturated,
|
||||
R.style.YellowAccentDesaturated,
|
||||
R.style.AmberAccentDesaturated,
|
||||
R.style.OrangeAccentDesaturated,
|
||||
R.style.DeepOrangeAccentDesaturated
|
||||
};
|
||||
|
||||
public static final Parcelable.Creator<ThemeAccent> CREATOR =
|
||||
new Parcelable.Creator<>() {
|
||||
@Override
|
||||
public ThemeAccent createFromParcel(Parcel source) {
|
||||
return new ThemeAccent(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThemeAccent[] newArray(int size) {
|
||||
return new ThemeAccent[size];
|
||||
}
|
||||
};
|
||||
private final int style;
|
||||
@Deprecated private final int accentColor;
|
||||
|
||||
public ThemeAccent(Context context, int style) {
|
||||
this.style = style;
|
||||
Resources.Theme theme = new ContextThemeWrapper(context, style).getTheme();
|
||||
this.accentColor = resolveAttribute(theme, com.google.android.material.R.attr.colorSecondary);
|
||||
}
|
||||
|
||||
private ThemeAccent(Parcel source) {
|
||||
style = source.readInt();
|
||||
accentColor = source.readInt();
|
||||
}
|
||||
|
||||
private static int resolveAttribute(Resources.Theme theme, int attribute) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
theme.resolveAttribute(attribute, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
public void applyStyle(Resources.Theme theme) {
|
||||
theme.applyStyle(style, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPickerColor() {
|
||||
return accentColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFree() {
|
||||
return style == R.style.BlueGreyAccent ||
|
||||
style == R.style.RedAccent ||
|
||||
style == R.style.BlueGreyAccentDesaturated ||
|
||||
style == R.style.RedAccentDesaturated;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getAccentColor() {
|
||||
return accentColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(style);
|
||||
dest.writeInt(accentColor);
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2019 The Android Open Source Project
|
||||
|
||||
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
|
||||
|
||||
https://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.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 24% opacity -->
|
||||
<item android:alpha="0.24" android:color="?attr/colorSecondary" android:state_enabled="true" android:state_selected="true"/>
|
||||
<item android:alpha="0.24" android:color="?attr/colorSecondary" android:state_enabled="true" android:state_checked="true"/>
|
||||
<!-- 12% of 87% opacity -->
|
||||
<item android:alpha="0.10" android:color="?attr/colorOnSurface" android:state_enabled="true"/>
|
||||
<item android:alpha="0.12" android:color="?attr/colorOnSurface"/>
|
||||
|
||||
</selector>
|
||||
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2019 The Android Open Source Project
|
||||
|
||||
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
|
||||
|
||||
https://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.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:color="?attr/colorSecondary" android:state_enabled="true" android:state_selected="true"/>
|
||||
<item android:color="?attr/colorSecondary" android:state_enabled="true" android:state_checked="true"/>
|
||||
<!-- 87% opacity. -->
|
||||
<item android:alpha="0.87" android:color="?attr/colorOnSurface" android:state_enabled="true"/>
|
||||
<!-- 38% of 87% opacity. -->
|
||||
<item android:alpha="0.33" android:color="?attr/colorOnSurface"/>
|
||||
|
||||
</selector>
|
||||
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2018 The Android Open Source Project
|
||||
~
|
||||
~ 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
|
||||
~
|
||||
~ https://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.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorSecondary" android:state_focused="true"/>
|
||||
<!-- 4% overlay over 42% colorOnSurface -->
|
||||
<item android:alpha="0.46" android:color="?attr/colorOnSurface" android:state_hovered="true"/>
|
||||
<item android:alpha="0.38" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
|
||||
<item android:alpha="0.42" android:color="?attr/colorOnSurface"/>
|
||||
</selector>
|
||||
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 The Android Open Source Project
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="1.00" android:color="?attr/colorSecondary" android:state_checkable="true" android:state_checked="true" android:state_enabled="true"/>
|
||||
<item android:alpha="0.60" android:color="?attr/colorOnSurface" android:state_checkable="true" android:state_checked="false" android:state_enabled="true"/>
|
||||
<item android:alpha="1.00" android:color="?attr/colorSecondary" android:state_enabled="true"/>
|
||||
<item android:alpha="0.38" android:color="?attr/colorOnSurface"/>
|
||||
</selector>
|
||||
@ -1,18 +1,29 @@
|
||||
<resources>
|
||||
<style name="DayNight" parent="Theme.MaterialComponents.NoActionBar"/>
|
||||
<style name="DayNight" parent="Theme.Material3.Dark.NoActionBar"/>
|
||||
|
||||
<style name="DayNightDialog" parent="Theme.MaterialComponents.Dialog"/>
|
||||
<style name="DayNightDialog" parent="Theme.Material3.Dark.Dialog"/>
|
||||
|
||||
<style name="DayNightAlert" parent="ThemeOverlay.MaterialComponents.Dialog.Alert"/>
|
||||
<style name="DayNightAlert" parent="ThemeOverlay.Material3.Dialog.Alert"/>
|
||||
|
||||
<style name="popup_overlay" parent="ThemeOverlay.MaterialComponents"/>
|
||||
<style name="ToolbarTheme" parent="ThemeOverlay.Material3.Dark">
|
||||
<item name="toolbarNavigationButtonStyle">@style/WhiteNavigation</item>
|
||||
<item name="iconTint">?attr/colorOnSurface</item>
|
||||
<item name="android:actionOverflowButtonStyle">@style/WhiteOverflow</item>
|
||||
<item name="android:editTextColor">@color/text_primary</item>
|
||||
<item name="android:textColorHint">@color/text_secondary</item>
|
||||
</style>
|
||||
|
||||
<!-- Location picker -->
|
||||
|
||||
<style name="popup_overlay" parent="ThemeOverlay.MaterialComponents.Dark"/>
|
||||
|
||||
<style name="ToolbarTheme" parent="@style/ThemeOverlay.MaterialComponents.Dark">
|
||||
<style name="LegacyToolbarTheme" parent="ThemeOverlay.MaterialComponents.Dark">
|
||||
<item name="toolbarNavigationButtonStyle">@style/WhiteNavigation</item>
|
||||
<item name="iconTint">@color/text_primary</item>
|
||||
<item name="iconTint">?attr/colorOnSurface</item>
|
||||
<item name="android:actionOverflowButtonStyle">@style/WhiteOverflow</item>
|
||||
<item name="android:editTextColor">@color/text_primary</item>
|
||||
<item name="android:textColorHint">@color/text_secondary</item>
|
||||
</style>
|
||||
|
||||
<!-- -->
|
||||
</resources>
|
||||
@ -1,140 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="AmberAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/amber_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="BlueAccent" parent="WhiteTint">
|
||||
<item name="colorSecondary">@color/blue_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="BlueGreyAccent" parent="WhiteTint">
|
||||
<item name="colorSecondary">@color/blue_grey_400</item>
|
||||
</style>
|
||||
|
||||
<style name="CyanAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/cyan_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="DeepOrangeAccent" parent="WhiteTint">
|
||||
<item name="colorSecondary">@color/deep_orange_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="DeepPurpleAccent" parent="WhiteTint">
|
||||
<item name="colorSecondary">@color/deep_purple_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="GreenAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/green_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="IndigoAccent" parent="WhiteTint">
|
||||
<item name="colorSecondary">@color/indigo_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="LightBlueAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/light_blue_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="LightGreenAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/light_green_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="LimeAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/lime_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="OrangeAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/orange_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="PinkAccent" parent="WhiteTint">
|
||||
<item name="colorSecondary">@color/pink_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="PurpleAccent" parent="WhiteTint">
|
||||
<item name="colorSecondary">@color/purple_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="RedAccent" parent="WhiteTint">
|
||||
<item name="colorSecondary">@color/red_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="TealAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/teal_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="YellowAccent" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/yellow_a400</item>
|
||||
</style>
|
||||
|
||||
<style name="AmberAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/amber_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="BlueAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/blue_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="BlueGreyAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/blue_grey_100</item>
|
||||
</style>
|
||||
|
||||
<style name="CyanAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/cyan_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="DeepOrangeAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/deep_orange_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="DeepPurpleAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/deep_purple_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="GreenAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/green_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="IndigoAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/indigo_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="LightBlueAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/light_blue_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="LightGreenAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/light_green_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="LimeAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/lime_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="OrangeAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/orange_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="PinkAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/pink_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="PurpleAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/purple_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="RedAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/red_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="TealAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/teal_a100</item>
|
||||
</style>
|
||||
|
||||
<style name="YellowAccentDesaturated" parent="BlackTint">
|
||||
<item name="colorSecondary">@color/yellow_a100</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@ -0,0 +1,26 @@
|
||||
package org.tasks.kmp.org.tasks.compose
|
||||
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.ime
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import co.touchlab.kermit.Logger
|
||||
|
||||
@Composable
|
||||
fun rememberImeState(): State<Boolean> {
|
||||
val density = LocalDensity.current
|
||||
val ime = WindowInsets.ime
|
||||
val imeState = remember {
|
||||
derivedStateOf {
|
||||
ime.getBottom(density) > 0
|
||||
}
|
||||
}
|
||||
LaunchedEffect(imeState.value) {
|
||||
Logger.d("imeState") { "keyboardOpen=${imeState.value}" }
|
||||
}
|
||||
return imeState
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package org.tasks.kmp.org.tasks.compose
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.platform.LocalViewConfiguration
|
||||
import androidx.compose.ui.platform.ViewConfiguration
|
||||
|
||||
@Composable
|
||||
fun TouchSlopMultiplier(
|
||||
multiplier: Float = 3f,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val current = LocalViewConfiguration.current
|
||||
|
||||
val viewConfiguration = object : ViewConfiguration by current {
|
||||
override val touchSlop: Float
|
||||
get() = current.touchSlop * multiplier
|
||||
}
|
||||
CompositionLocalProvider(LocalViewConfiguration provides viewConfiguration) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue