mirror of https://github.com/tasks/tasks
Bottom app bar
parent
db973b2419
commit
28f45b05ac
@ -1,80 +0,0 @@
|
|||||||
package org.tasks.tasklist;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.appcompat.app.WindowDecorActionBar;
|
|
||||||
import androidx.appcompat.view.StandaloneActionMode;
|
|
||||||
import androidx.appcompat.widget.ActionBarContextView;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import org.tasks.R;
|
|
||||||
import org.tasks.themes.ThemeColor;
|
|
||||||
|
|
||||||
public class ActionUtils {
|
|
||||||
|
|
||||||
// cribbed from Twittnuker
|
|
||||||
public static void applySupportActionModeColor(
|
|
||||||
ThemeColor themeColor, final androidx.appcompat.view.ActionMode modeCompat) {
|
|
||||||
// Very dirty implementation
|
|
||||||
// This call ensures TitleView created
|
|
||||||
modeCompat.setTitle(modeCompat.getTitle());
|
|
||||||
View contextView = null;
|
|
||||||
if (modeCompat instanceof WindowDecorActionBar.ActionModeImpl) {
|
|
||||||
WindowDecorActionBar actionBar =
|
|
||||||
(WindowDecorActionBar)
|
|
||||||
findFieldOfTypes(
|
|
||||||
modeCompat,
|
|
||||||
WindowDecorActionBar.ActionModeImpl.class,
|
|
||||||
WindowDecorActionBar.class);
|
|
||||||
if (actionBar == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
contextView =
|
|
||||||
(View)
|
|
||||||
findFieldOfTypes(actionBar, WindowDecorActionBar.class, ActionBarContextView.class);
|
|
||||||
} else if (modeCompat instanceof StandaloneActionMode) {
|
|
||||||
contextView =
|
|
||||||
(View)
|
|
||||||
findFieldOfTypes(modeCompat, StandaloneActionMode.class, ActionBarContextView.class);
|
|
||||||
}
|
|
||||||
if (!(contextView instanceof ActionBarContextView)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
contextView.setBackgroundColor(themeColor.getPrimaryColor());
|
|
||||||
|
|
||||||
TextView title = contextView.findViewById(R.id.action_bar_title);
|
|
||||||
if (title != null) {
|
|
||||||
title.setTextColor(themeColor.getColorOnPrimary());
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageView closeButton = contextView.findViewById(R.id.action_mode_close_button);
|
|
||||||
if (closeButton != null) {
|
|
||||||
closeButton.setColorFilter(themeColor.getColorOnPrimary());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> Object findFieldOfTypes(
|
|
||||||
T obj, Class<? extends T> cls, Class<?>... checkTypes) {
|
|
||||||
labelField:
|
|
||||||
for (Field field : cls.getDeclaredFields()) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
final Object fieldObj;
|
|
||||||
try {
|
|
||||||
fieldObj = field.get(obj);
|
|
||||||
} catch (Exception ignore) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (fieldObj != null) {
|
|
||||||
final Class<?> type = fieldObj.getClass();
|
|
||||||
for (Class<?> checkType : checkTypes) {
|
|
||||||
if (!checkType.isAssignableFrom(type)) {
|
|
||||||
continue labelField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fieldObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014 Google Inc.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.tasks.ui;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import org.tasks.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A layout that draws something in the insets passed to {@link #fitSystemWindows(Rect)}, i.e. the
|
|
||||||
* area above UI chrome (status and navigation bars, overlay action bars).
|
|
||||||
*/
|
|
||||||
public class ScrimInsetsFrameLayout extends FrameLayout {
|
|
||||||
|
|
||||||
private final Rect mTempRect = new Rect();
|
|
||||||
private Drawable mInsetForeground;
|
|
||||||
private Rect mInsets;
|
|
||||||
private OnInsetsCallback mOnInsetsCallback;
|
|
||||||
|
|
||||||
public ScrimInsetsFrameLayout(Context context) {
|
|
||||||
super(context);
|
|
||||||
init(context, null, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
init(context, attrs, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
init(context, attrs, defStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
final TypedArray a =
|
|
||||||
context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyle, 0);
|
|
||||||
if (a == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
|
|
||||||
a.recycle();
|
|
||||||
|
|
||||||
setWillNotDraw(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean fitSystemWindows(Rect insets) {
|
|
||||||
mInsets = new Rect(insets);
|
|
||||||
setWillNotDraw(mInsetForeground == null);
|
|
||||||
postInvalidateOnAnimation();
|
|
||||||
if (mOnInsetsCallback != null) {
|
|
||||||
mOnInsetsCallback.onInsetsChanged(insets);
|
|
||||||
}
|
|
||||||
return true; // consume insets
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Canvas canvas) {
|
|
||||||
super.draw(canvas);
|
|
||||||
|
|
||||||
int width = getWidth();
|
|
||||||
int height = getHeight();
|
|
||||||
if (mInsets != null && mInsetForeground != null) {
|
|
||||||
int sc = canvas.save();
|
|
||||||
canvas.translate(getScrollX(), getScrollY());
|
|
||||||
|
|
||||||
// Top
|
|
||||||
mTempRect.set(0, 0, width, mInsets.top);
|
|
||||||
mInsetForeground.setBounds(mTempRect);
|
|
||||||
mInsetForeground.draw(canvas);
|
|
||||||
|
|
||||||
// Bottom
|
|
||||||
mTempRect.set(0, height - mInsets.bottom, width, height);
|
|
||||||
mInsetForeground.setBounds(mTempRect);
|
|
||||||
mInsetForeground.draw(canvas);
|
|
||||||
|
|
||||||
// Left
|
|
||||||
mTempRect.set(0, mInsets.top, mInsets.left, height - mInsets.bottom);
|
|
||||||
mInsetForeground.setBounds(mTempRect);
|
|
||||||
mInsetForeground.draw(canvas);
|
|
||||||
|
|
||||||
// Right
|
|
||||||
mTempRect.set(width - mInsets.right, mInsets.top, width, height - mInsets.bottom);
|
|
||||||
mInsetForeground.setBounds(mTempRect);
|
|
||||||
mInsetForeground.draw(canvas);
|
|
||||||
|
|
||||||
canvas.restoreToCount(sc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onAttachedToWindow() {
|
|
||||||
super.onAttachedToWindow();
|
|
||||||
if (mInsetForeground != null) {
|
|
||||||
mInsetForeground.setCallback(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDetachedFromWindow() {
|
|
||||||
super.onDetachedFromWindow();
|
|
||||||
if (mInsetForeground != null) {
|
|
||||||
mInsetForeground.setCallback(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows the calling container to specify a callback for custom processing when insets change
|
|
||||||
* (i.e. when {@link #fitSystemWindows(Rect)} is called. This is useful for setting padding on UI
|
|
||||||
* elements based on UI chrome insets (e.g. a Google Map or a ListView). When using with ListView
|
|
||||||
* or GridView, remember to set clipToPadding to false.
|
|
||||||
*/
|
|
||||||
public void setOnInsetsCallback(OnInsetsCallback onInsetsCallback) {
|
|
||||||
mOnInsetsCallback = onInsetsCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnInsetsCallback {
|
|
||||||
|
|
||||||
void onInsetsChanged(Rect insets);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
<androidx.fragment.app.FragmentContainerView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/navigation_drawer"
|
|
||||||
android:layout_width="@dimen/navigation_drawer_width"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="start"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:name="org.tasks.ui.NavigationDrawerFragment"
|
|
||||||
tools:layout="@layout/fragment_navigation_drawer"/>
|
|
||||||
@ -1,25 +1,22 @@
|
|||||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/drawer_layout"
|
android:id="@+id/drawer_layout"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/master"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:ignore="InconsistentLayout"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/detail"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone"
|
android:orientation="vertical">
|
||||||
tools:ignore="InconsistentLayout"/>
|
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/master"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:ignore="InconsistentLayout" />
|
||||||
|
|
||||||
<include layout="@layout/navigation_drawer"/>
|
<FrameLayout
|
||||||
|
android:id="@+id/detail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:ignore="InconsistentLayout" />
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@ -1,50 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_voice_add"
|
|
||||||
android:icon="@drawable/ic_outline_mic_none_24px"
|
|
||||||
android:title="@string/EPr_voiceInputEnabled_title"
|
|
||||||
app:showAsAction="ifRoom"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_search"
|
|
||||||
android:icon="@drawable/ic_outline_search_24px"
|
|
||||||
android:title="@string/TLA_menu_search"
|
|
||||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
|
||||||
app:showAsAction="ifRoom|collapseActionView"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_sort"
|
|
||||||
android:icon="@drawable/ic_outline_sort_24px"
|
|
||||||
android:title="@string/TLA_menu_sort"
|
|
||||||
app:showAsAction="ifRoom"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_share"
|
|
||||||
android:icon="@drawable/ic_outline_send_24px"
|
|
||||||
android:title="@string/share"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
<group
|
|
||||||
android:checkableBehavior="all">
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_show_unstarted"
|
|
||||||
android:checkable="true"
|
|
||||||
android:title="@string/show_unstarted"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_show_completed"
|
|
||||||
android:checkable="true"
|
|
||||||
android:title="@string/show_completed"/>
|
|
||||||
</group>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_expand_subtasks"
|
|
||||||
android:title="@string/expand_subtasks"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_collapse_subtasks"
|
|
||||||
android:title="@string/collapse_subtasks"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_clear_completed"
|
|
||||||
android:title="@string/gtasks_GTA_clear_completed"
|
|
||||||
app:showAsAction="never"/>
|
|
||||||
</menu>
|
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_clear_completed"
|
||||||
|
android:title="@string/gtasks_GTA_clear_completed"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_collapse_subtasks"
|
||||||
|
android:title="@string/collapse_subtasks"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_expand_subtasks"
|
||||||
|
android:title="@string/expand_subtasks"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<group android:checkableBehavior="all">
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_show_completed"
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/show_completed" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_show_unstarted"
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/show_unstarted" />
|
||||||
|
</group>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_share"
|
||||||
|
android:icon="@drawable/ic_outline_send_24px"
|
||||||
|
android:title="@string/share" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_voice_add"
|
||||||
|
android:icon="@drawable/ic_outline_mic_none_24px"
|
||||||
|
android:title="@string/EPr_voiceInputEnabled_title"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_sort"
|
||||||
|
android:icon="@drawable/ic_outline_sort_24px"
|
||||||
|
android:title="@string/TLA_menu_sort"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
</menu>
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_search"
|
||||||
|
android:icon="@drawable/ic_outline_search_24px"
|
||||||
|
android:title="@string/TLA_menu_search"
|
||||||
|
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||||
|
app:showAsAction="ifRoom|collapseActionView"/>
|
||||||
|
</menu>
|
||||||
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<bool name="is_dark">true</bool>
|
<bool name="is_dark">true</bool>
|
||||||
|
<bool name="light_status_bar">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue