mirror of
https://github.com/MatomoCamp/matomocamp-companion-android.git
synced 2024-09-19 16:13:46 +02:00
Use default error colors from material theme attributes for error Snackbar and to highlight conflicting bookmarks
This commit is contained in:
parent
0752dbc6ee
commit
b766e38d00
8 changed files with 34 additions and 19 deletions
|
@ -3,13 +3,13 @@ package be.digitalia.fosdem.activities;
|
|||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
@ -74,9 +74,14 @@ public class SearchResultActivity extends SimpleToolbarActivity {
|
|||
viewModel.setQuery(query);
|
||||
|
||||
if (SearchViewModel.isQueryTooShort(query)) {
|
||||
TypedArray a = getTheme().obtainStyledAttributes(R.styleable.ErrorColors);
|
||||
int textColor = a.getColor(R.styleable.ErrorColors_colorOnError, 0);
|
||||
int backgroundColor = a.getColor(R.styleable.ErrorColors_colorError, 0);
|
||||
a.recycle();
|
||||
|
||||
Snackbar.make(findViewById(R.id.content), R.string.search_length_error, Snackbar.LENGTH_LONG)
|
||||
.setTextColor(ContextCompat.getColor(this, R.color.color_on_error))
|
||||
.setBackgroundTint(ContextCompat.getColor(this, R.color.color_error))
|
||||
.setTextColor(textColor)
|
||||
.setBackgroundTint(backgroundColor)
|
||||
.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package be.digitalia.fosdem.adapters;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
|
@ -13,11 +14,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -30,6 +26,12 @@ import androidx.recyclerview.widget.DiffUtil;
|
|||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.savedstate.SavedStateRegistryOwner;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import be.digitalia.fosdem.R;
|
||||
import be.digitalia.fosdem.activities.EventDetailsActivity;
|
||||
import be.digitalia.fosdem.api.FosdemApi;
|
||||
|
@ -68,7 +70,9 @@ public class BookmarksAdapter extends ListAdapter<Event, BookmarksAdapter.ViewHo
|
|||
super(DIFF_CALLBACK);
|
||||
setHasStableIds(true);
|
||||
timeDateFormat = DateUtils.getTimeDateFormat(activity);
|
||||
errorColor = ContextCompat.getColor(activity, R.color.color_error);
|
||||
TypedArray a = activity.getTheme().obtainStyledAttributes(R.styleable.ErrorColors);
|
||||
errorColor = a.getColor(R.styleable.ErrorColors_colorError, 0);
|
||||
a.recycle();
|
||||
|
||||
multiChoiceHelper = new MultiChoiceHelper(activity, owner, this);
|
||||
multiChoiceHelper.setMultiChoiceModeListener(multiChoiceModeListener);
|
||||
|
|
4
app/src/main/res/color/abstract_background.xml
Normal file
4
app/src/main/res/color/abstract_background.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="0.05" android:color="?attr/colorOnSurface" />
|
||||
</selector>
|
BIN
app/src/main/res/drawable-nodpi/white_background.png
Normal file
BIN
app/src/main/res/drawable-nodpi/white_background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 83 B |
|
@ -95,12 +95,13 @@
|
|||
android:id="@+id/abstract_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/abstract_background"
|
||||
android:background="@drawable/white_background"
|
||||
android:padding="@dimen/content_margin"
|
||||
android:saveEnabled="false"
|
||||
android:textAppearance="?textAppearanceBody1"
|
||||
android:textIsSelectable="true"
|
||||
tools:text="FOSDEM welcome and opening talk."/>
|
||||
app:backgroundTint="@color/abstract_background"
|
||||
tools:text="FOSDEM welcome and opening talk." />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
|
|
|
@ -2,12 +2,17 @@
|
|||
<resources>
|
||||
|
||||
<!-- Drawable used as a background for activated items. -->
|
||||
<attr name="activatedBackgroundIndicator" format="reference"/>
|
||||
<attr name="materialHorizontalProgressBarStyle" format="reference"/>
|
||||
<attr name="activatedBackgroundIndicator" format="reference" />
|
||||
<attr name="materialHorizontalProgressBarStyle" format="reference" />
|
||||
|
||||
<declare-styleable name="PrimaryTextColors">
|
||||
<attr name="android:textColorPrimary"/>
|
||||
<attr name="android:textColorPrimaryInverse"/>
|
||||
<attr name="android:textColorPrimary" />
|
||||
<attr name="android:textColorPrimaryInverse" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="ErrorColors">
|
||||
<attr name="colorError" />
|
||||
<attr name="colorOnError" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
|
@ -5,11 +5,8 @@
|
|||
<color name="color_primary_dark">#76005e</color>
|
||||
<color name="color_secondary">#3479c4</color>
|
||||
<color name="color_activated">#663479c4</color>
|
||||
<color name="abstract_background">#0c000000</color>
|
||||
<color name="schedule_time_background">#29000000</color>
|
||||
<color name="schedule_time_running_background">@color/color_secondary</color>
|
||||
<color name="color_error">@color/design_default_color_error</color>
|
||||
<color name="color_on_error">@color/design_default_color_on_error</color>
|
||||
<color name="shortcut_background">#F5F5F5</color>
|
||||
|
||||
<!-- Track types -->
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
<item name="colorSecondary">@color/color_secondary</item>
|
||||
<item name="colorOnPrimary">@color/design_default_color_on_primary</item>
|
||||
<item name="colorOnSecondary">@color/design_default_color_on_primary</item>
|
||||
<item name="colorError">@color/color_error</item>
|
||||
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
|
||||
|
|
Loading…
Reference in a new issue