diff --git a/.travis.yml b/.travis.yml index d31766a9b..d50cab0b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ android: - platform-tools - tools - build-tools-28.0.3 - - build-tools-29.0.2 + - build-tools-29.0.3 - android-24 - android-28 - android-29 diff --git a/dependencies.gradle b/dependencies.gradle index 431cf10cb..12c470531 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -4,9 +4,9 @@ def androidx_test_runner_version = '1.1.1' ext.deps = [ // Support & Google libraries - support_appcompat : 'androidx.appcompat:appcompat:1.0.2', - support_annotations: 'androidx.annotation:annotation:1.0.0', - support_design : 'com.google.android.material:material:1.0.0', + support_appcompat : 'androidx.appcompat:appcompat:1.2.0', + support_annotations: 'androidx.annotation:annotation:1.1.0', + support_design : 'com.google.android.material:material:1.2.1', android_dashclock : 'com.google.android.apps.dashclock:dashclock-api:2.0.0', // dmfs diff --git a/gradle.properties b/gradle.properties index d87befd02..e32164be7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ COMPILE_SDK_VERSION=29 -MIN_SDK_VERSION=19 +MIN_SDK_VERSION=21 TARGET_SDK_VERSION=29 VERSION_OVERRIDE=0 android.enableJetifier=true diff --git a/opentasks-theme/.gitignore b/opentasks-theme/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/opentasks-theme/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/opentasks-theme/build.gradle b/opentasks-theme/build.gradle new file mode 100644 index 000000000..3e7338fb7 --- /dev/null +++ b/opentasks-theme/build.gradle @@ -0,0 +1,49 @@ +/* + * Copyright 2021 dmfs GmbH + * + * 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. + */ + +plugins { + id 'com.android.library' +} + +android { + compileSdkVersion COMPILE_SDK_VERSION.toInteger() + buildToolsVersion "29.0.3" + + defaultConfig { + minSdkVersion MIN_SDK_VERSION + targetSdkVersion TARGET_SDK_VERSION + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.2.1' +} \ No newline at end of file diff --git a/opentasks-theme/src/main/AndroidManifest.xml b/opentasks-theme/src/main/AndroidManifest.xml new file mode 100644 index 000000000..7e97eb3a4 --- /dev/null +++ b/opentasks-theme/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/opentasks-theme/src/main/res/values-v23/theme_light.xml b/opentasks-theme/src/main/res/values-v23/theme_light.xml new file mode 100644 index 000000000..9334e12f4 --- /dev/null +++ b/opentasks-theme/src/main/res/values-v23/theme_light.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/opentasks-theme/src/main/res/values/attrs.xml b/opentasks-theme/src/main/res/values/attrs.xml new file mode 100644 index 000000000..986d64e26 --- /dev/null +++ b/opentasks-theme/src/main/res/values/attrs.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/opentasks-theme/src/main/res/values/colors.xml b/opentasks-theme/src/main/res/values/colors.xml new file mode 100644 index 000000000..c65fd4ea0 --- /dev/null +++ b/opentasks-theme/src/main/res/values/colors.xml @@ -0,0 +1,31 @@ + + + + + #009688 + #00796B + #ff5722 + #ff5722 + + + + + #4caf50 + + + #f44336 + #d32f2f + #b71c1c + + + #009688 + #00796B + + + #ffc107 + + + #ff5722 + #bf360c + + \ No newline at end of file diff --git a/opentasks-theme/src/main/res/values/theme.xml b/opentasks-theme/src/main/res/values/theme.xml new file mode 100644 index 000000000..894ecc9cc --- /dev/null +++ b/opentasks-theme/src/main/res/values/theme.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/opentasks/build.gradle b/opentasks/build.gradle index de5be1922..6e7947b2d 100644 --- a/opentasks/build.gradle +++ b/opentasks/build.gradle @@ -60,6 +60,7 @@ android { } dependencies { + implementation project(':opentasks-theme') implementation project(':opentasks-provider') implementation deps.support_appcompat implementation deps.support_design diff --git a/opentasks/src/main/AndroidManifest.xml b/opentasks/src/main/AndroidManifest.xml index ce40af080..69578ee27 100644 --- a/opentasks/src/main/AndroidManifest.xml +++ b/opentasks/src/main/AndroidManifest.xml @@ -24,7 +24,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="false" android:taskAffinity="org.dmfs.tasks.TaskListActivity" - android:theme="@style/OpenTasksAppTheme"> + android:theme="@style/OpenTasks_Theme.Default"> + android:theme="@style/OpenTasksAppTheme" + android:parentActivityName=".TaskListActivity"> @@ -156,7 +156,7 @@ + android:theme="@style/OpenTasks_BaseTheme.Light.Dialog"> @@ -260,7 +260,7 @@ + android:theme="@style/OpenTasks_Theme.Default.Dialog"> diff --git a/opentasks/src/main/java/org/dmfs/tasks/EditTaskFragment.java b/opentasks/src/main/java/org/dmfs/tasks/EditTaskFragment.java index 07d31711f..2eb3cda7b 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/EditTaskFragment.java +++ b/opentasks/src/main/java/org/dmfs/tasks/EditTaskFragment.java @@ -24,7 +24,6 @@ import android.database.Cursor; import android.graphics.drawable.ColorDrawable; import android.net.Uri; -import android.os.Build.VERSION; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; @@ -643,13 +642,10 @@ private void updateColor(float percentage) actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); - if (VERSION.SDK_INT >= 21) - { - Window window = getActivity().getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(new Mixed(newColor, mListColor).argb()); - // window.setNavigationBarColor(mixColors(newColor, mListColor)); - } + Window window = getActivity().getWindow(); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(new Mixed(newColor, mListColor).argb()); + mTaskListBar.setBackgroundColor(mListColor); if (mColorBar != null) { diff --git a/opentasks/src/main/java/org/dmfs/tasks/QuickAddDialogFragment.java b/opentasks/src/main/java/org/dmfs/tasks/QuickAddDialogFragment.java index ac9cad2ee..b5c21bbac 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/QuickAddDialogFragment.java +++ b/opentasks/src/main/java/org/dmfs/tasks/QuickAddDialogFragment.java @@ -23,9 +23,6 @@ import android.graphics.Color; import android.net.Uri; import android.os.Bundle; -import androidx.loader.app.LoaderManager; -import androidx.loader.content.CursorLoader; -import androidx.loader.content.Loader; import android.text.Editable; import android.text.TextWatcher; import android.view.ContextThemeWrapper; @@ -58,6 +55,10 @@ import org.dmfs.tasks.utils.SafeFragmentUiRunnable; import org.dmfs.tasks.utils.TasksListCursorSpinnerAdapter; +import androidx.loader.app.LoaderManager; +import androidx.loader.content.CursorLoader; +import androidx.loader.content.Loader; + /** * A quick add dialog. It allows the user to enter a new task without having to deal with the full blown editor interface. At present it support task with a @@ -200,16 +201,12 @@ public Dialog onCreateDialog(Bundle savedInstanceState) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - - // create ContextThemeWrapper from the original Activity Context with the custom theme - final Context contextThemeWrapperLight = new ContextThemeWrapper(getActivity(), R.style.ThemeOverlay_AppCompat_Light); final Context contextThemeWrapperDark = new ContextThemeWrapper(getActivity(), R.style.Base_Theme_AppCompat); - LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapperLight); - View view = localInflater.inflate(R.layout.fragment_quick_add_dialog, container); + View view = inflater.inflate(R.layout.fragment_quick_add_dialog, container); ViewGroup headerContainer = (ViewGroup) view.findViewById(R.id.header_container); - localInflater = inflater.cloneInContext(contextThemeWrapperDark); + LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapperDark); localInflater.inflate(R.layout.fragment_quick_add_dialog_header, headerContainer); if (savedInstanceState == null) diff --git a/opentasks/src/main/java/org/dmfs/tasks/SettingsListFragment.java b/opentasks/src/main/java/org/dmfs/tasks/SettingsListFragment.java index 14d785186..2fd897e56 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/SettingsListFragment.java +++ b/opentasks/src/main/java/org/dmfs/tasks/SettingsListFragment.java @@ -25,14 +25,9 @@ import android.content.DialogInterface; import android.content.OperationApplicationException; import android.database.Cursor; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.RemoteException; -import androidx.fragment.app.ListFragment; -import androidx.loader.app.LoaderManager; -import androidx.loader.content.CursorLoader; -import androidx.loader.content.Loader; -import androidx.cursoradapter.widget.CursorAdapter; -import androidx.appcompat.app.AlertDialog; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -46,6 +41,7 @@ import android.widget.TextView; import android.widget.Toast; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.android.widgets.ColoredShapeCheckBox; import org.dmfs.provider.tasks.AuthorityUtil; import org.dmfs.tasks.contract.TaskContract; @@ -57,6 +53,15 @@ import java.util.Iterator; import java.util.List; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.core.graphics.drawable.DrawableCompat; +import androidx.cursoradapter.widget.CursorAdapter; +import androidx.fragment.app.ListFragment; +import androidx.loader.app.LoaderManager; +import androidx.loader.content.CursorLoader; +import androidx.loader.content.Loader; + /** * This fragment is used to display a list of task-providers. It show the task-providers which are visible in main {@link TaskListFragment} and also the @@ -187,9 +192,17 @@ public void onClick(DialogInterface dialog, int which) * Adds an action to the ActionBar to create local lists. */ @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) + public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.list_settings_menu, menu); + // for now we tint all icons manually + for (int i = 0; i < menu.size(); ++i) + { + MenuItem item = menu.getItem(0); + Drawable drawable = DrawableCompat.wrap(item.getIcon()); + drawable.setTint(0x80000000); + item.setIcon(drawable); + } } diff --git a/opentasks/src/main/java/org/dmfs/tasks/SyncSettingsActivity.java b/opentasks/src/main/java/org/dmfs/tasks/SyncSettingsActivity.java index 6f36181f4..ba078da81 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/SyncSettingsActivity.java +++ b/opentasks/src/main/java/org/dmfs/tasks/SyncSettingsActivity.java @@ -16,11 +16,15 @@ package org.dmfs.tasks; import android.os.Bundle; + +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import android.view.View; import android.widget.Button; +import com.google.android.material.appbar.AppBarLayout; + import org.dmfs.tasks.contract.TaskContract; import org.dmfs.tasks.utils.BaseActivity; @@ -42,6 +46,10 @@ protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); // Show the Up button in the action bar. + AppBarLayout mAppBarLayout = findViewById(R.id.appbar); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); mManager = getSupportFragmentManager(); diff --git a/opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java b/opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java index 64d5c4fe9..f152e0ae2 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java +++ b/opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java @@ -20,38 +20,26 @@ import android.app.SearchManager; import android.content.Context; import android.content.Intent; -import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Build.VERSION; import android.os.Bundle; import android.os.Handler; import android.provider.Settings; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.android.material.tabs.TabLayout; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.core.view.MenuItemCompat; -import androidx.core.view.MenuItemCompat.OnActionExpandListener; -import androidx.viewpager.widget.ViewPager; -import androidx.viewpager.widget.ViewPager.OnPageChangeListener; -import androidx.appcompat.widget.SearchView; -import androidx.appcompat.widget.SearchView.OnQueryTextListener; -import androidx.appcompat.widget.Toolbar; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; -import android.view.Window; -import android.view.WindowManager; + +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.tabs.TabLayout; import org.dmfs.android.bolts.color.Color; import org.dmfs.android.bolts.color.colors.PrimaryColor; import org.dmfs.android.bolts.color.elementary.ValueColor; import org.dmfs.android.retentionmagic.annotations.Retain; +import org.dmfs.jems.single.adapters.Unchecked; import org.dmfs.provider.tasks.AuthorityUtil; import org.dmfs.tasks.contract.TaskContract.Tasks; import org.dmfs.tasks.groupings.AbstractGroupingFactory; @@ -65,8 +53,18 @@ import org.dmfs.tasks.utils.BaseActivity; import org.dmfs.tasks.utils.ExpandableGroupDescriptor; import org.dmfs.tasks.utils.SearchHistoryHelper; -import org.dmfs.jems.single.adapters.Unchecked; -import org.dmfs.tasks.utils.colors.DarkenedForStatusBar; + +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.appcompat.widget.SearchView; +import androidx.appcompat.widget.SearchView.OnQueryTextListener; +import androidx.appcompat.widget.Toolbar; +import androidx.core.view.MenuItemCompat; +import androidx.core.view.MenuItemCompat.OnActionExpandListener; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.viewpager.widget.ViewPager; +import androidx.viewpager.widget.ViewPager.OnPageChangeListener; /** @@ -538,7 +536,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) See https://github.com/dmfs/opentasks/issues/643 and https://stackoverflow.com/questions/42209046/tablayout-icons-disappear-after-viewpager-refresh */ setupTabIcons(); + return; } + super.onActivityResult(requestCode, resultCode, intent); } @@ -586,25 +586,7 @@ public void onTaskCompleted(@NonNull Uri taskUri) @Override public void onListColorLoaded(@NonNull Color color) { - mLastUsedColor = color.argb(); - if (mTwoPane) - { - int colorInt = color.argb(); - getSupportActionBar().setBackgroundDrawable(new ColorDrawable(colorInt)); - mTabs.setBackgroundColor(colorInt); - - if (mAppBarLayout != null) - { - mAppBarLayout.setBackgroundColor(colorInt); - } - - if (VERSION.SDK_INT >= 21) - { - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(new DarkenedForStatusBar(color).argb()); - } - } + // nothing to do } diff --git a/opentasks/src/main/java/org/dmfs/tasks/TaskListFragment.java b/opentasks/src/main/java/org/dmfs/tasks/TaskListFragment.java index fbbb192aa..9b936911d 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/TaskListFragment.java +++ b/opentasks/src/main/java/org/dmfs/tasks/TaskListFragment.java @@ -286,12 +286,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View rootView = inflater.inflate(R.layout.fragment_expandable_task_list, container, false); mExpandableListView = (RetainExpandableListView) rootView.findViewById(android.R.id.list); - if (!mTwoPaneLayout) - { - // Add a footer to make sure the floating action button doesn't hide anything. - mExpandableListView.addFooterView(inflater.inflate(R.layout.task_list_group, mExpandableListView, false)); - } - if (mGroupDescriptor == null) { loadGroupDescriptor(); diff --git a/opentasks/src/main/java/org/dmfs/tasks/ViewTaskActivity.java b/opentasks/src/main/java/org/dmfs/tasks/ViewTaskActivity.java index 2a9b0e66c..edd5ea74b 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/ViewTaskActivity.java +++ b/opentasks/src/main/java/org/dmfs/tasks/ViewTaskActivity.java @@ -16,15 +16,10 @@ package org.dmfs.tasks; -import android.annotation.SuppressLint; import android.content.Intent; import android.net.Uri; -import android.os.Build.VERSION; import android.os.Bundle; import android.os.Handler; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; @@ -36,6 +31,10 @@ import org.dmfs.tasks.utils.BaseActivity; import org.dmfs.tasks.utils.colors.DarkenedForStatusBar; +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + /** * An activity representing a single Task detail screen. This activity is only used on handset devices. On tablet-size devices, item details are presented @@ -152,17 +151,12 @@ public void onTaskCompleted(@NonNull Uri taskUri) } - @SuppressLint("NewApi") @Override public void onListColorLoaded(@NonNull Color color) { - - if (VERSION.SDK_INT >= 21) - { - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(new DarkenedForStatusBar(color).argb()); - } + Window window = getWindow(); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(new DarkenedForStatusBar(color).argb()); } } diff --git a/opentasks/src/main/java/org/dmfs/tasks/actions/NotifyAction.java b/opentasks/src/main/java/org/dmfs/tasks/actions/NotifyAction.java index 8bdb226db..072f07502 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/actions/NotifyAction.java +++ b/opentasks/src/main/java/org/dmfs/tasks/actions/NotifyAction.java @@ -29,7 +29,7 @@ import android.os.RemoteException; import android.text.format.DateUtils; -import org.dmfs.android.bolts.color.colors.ResourceColor; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.android.contentpal.RowDataSnapshot; import org.dmfs.jems.function.Function; import org.dmfs.jems.optional.Optional; @@ -50,6 +50,7 @@ import org.dmfs.tasks.notification.signals.Conditional; import org.dmfs.tasks.utils.DateFormatter; +import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; @@ -171,11 +172,7 @@ public void execute(Context context, ContentProviderClient contentProviderClient builder.setOnlyAlertOnce(!mRepost); builder.setOngoing(pin); builder.setShowWhen(false); - if (Build.VERSION.SDK_INT >= 21) - { - // don't execute this on Android 4, otherwise no notification will show up - builder.setGroup(pin ? GROUP_PINS : GROUP_ALERTS); - } + builder.setGroup(pin ? GROUP_PINS : GROUP_ALERTS); builder.setPriority(pin ? NotificationCompat.PRIORITY_DEFAULT : NotificationCompat.PRIORITY_HIGH); if (Build.VERSION.SDK_INT < 26) @@ -183,7 +180,7 @@ public void execute(Context context, ContentProviderClient contentProviderClient builder.setDefaults(new Conditional(mRepost, context).value()); } // TODO: for now we only use the primary app color, later we allow the user to select how to color notifications: default, list, priority - builder.setColor(new ResourceColor(context, R.color.primary).argb()); + builder.setColor(new AttributeColor(new ContextThemeWrapper(context, R.style.OpenTasks_Theme_Default), R.attr.colorPrimary).argb()); //builder.setColor(new EffectiveTaskColor(data).argb()); NotificationManagerCompat.from(context).notify("tasks", notificationId, builder.build()); } diff --git a/opentasks/src/main/java/org/dmfs/tasks/actions/PostUndoAction.java b/opentasks/src/main/java/org/dmfs/tasks/actions/PostUndoAction.java index 3395e6f9d..e705a2781 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/actions/PostUndoAction.java +++ b/opentasks/src/main/java/org/dmfs/tasks/actions/PostUndoAction.java @@ -23,13 +23,10 @@ import android.content.Intent; import android.content.OperationApplicationException; import android.net.Uri; -import android.os.Build; import android.os.RemoteException; -import androidx.core.app.NotificationCompat; -import androidx.core.app.NotificationManagerCompat; import android.widget.RemoteViews; -import org.dmfs.android.bolts.color.colors.ResourceColor; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.android.contentpal.RowDataSnapshot; import org.dmfs.tasks.R; import org.dmfs.tasks.contract.TaskContract; @@ -37,6 +34,10 @@ import org.dmfs.tasks.notification.ActionService; import org.dmfs.tasks.notification.signals.NoSignal; +import androidx.appcompat.view.ContextThemeWrapper; +import androidx.core.app.NotificationCompat; +import androidx.core.app.NotificationManagerCompat; + /** * Post a notification. @@ -79,12 +80,8 @@ public void execute(Context context, ContentProviderClient contentProviderClient new Intent(context, ActionReceiver.class).setData(taskUri).setAction(ActionService.ACTION_FINISH_COMPLETE), PendingIntent.FLAG_CANCEL_CURRENT)); builder.setShowWhen(false); - if (Build.VERSION.SDK_INT >= 21) - { - // don't execute this on Android 4, otherwise no notification will show up - builder.setGroup(GROUP_UNDO); - } - builder.setColor(new ResourceColor(context, R.color.primary).argb()); + builder.setGroup(GROUP_UNDO); + builder.setColor(new AttributeColor(new ContextThemeWrapper(context, R.style.OpenTasks_Theme_Default), R.attr.colorPrimary).argb()); NotificationManagerCompat.from(context).notify("tasks.undo", id, builder.build()); } diff --git a/opentasks/src/main/java/org/dmfs/tasks/groupings/BaseTaskViewDescriptor.java b/opentasks/src/main/java/org/dmfs/tasks/groupings/BaseTaskViewDescriptor.java index b5f91de59..0160109ed 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/groupings/BaseTaskViewDescriptor.java +++ b/opentasks/src/main/java/org/dmfs/tasks/groupings/BaseTaskViewDescriptor.java @@ -18,13 +18,15 @@ import android.annotation.SuppressLint; import android.database.Cursor; -import androidx.collection.SparseArrayCompat; import android.text.TextUtils; import android.text.format.Time; import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import com.google.android.material.card.MaterialCardView; + +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.tasks.R; import org.dmfs.tasks.model.TaskFieldAdapters; import org.dmfs.tasks.utils.DateFormatter; @@ -33,6 +35,13 @@ import java.util.TimeZone; +import androidx.collection.SparseArrayCompat; +import androidx.core.graphics.ColorUtils; + +import static org.dmfs.tasks.contract.TaskContract.TaskColumns.STATUS_CANCELLED; +import static org.dmfs.tasks.model.TaskFieldAdapters.IS_CLOSED; +import static org.dmfs.tasks.model.TaskFieldAdapters.STATUS; + /** * A base implementation of a {@link ViewDescriptor}. It has a number of commonly used methods. @@ -101,18 +110,6 @@ else if (view != null) protected void setOverlay(View view, int position, int count) { - View overlayTop = getView(view, R.id.overlay_top); - View overlayBottom = getView(view, R.id.overlay_bottom); - - if (overlayTop != null) - { - overlayTop.setVisibility(position == 0 ? View.VISIBLE : View.GONE); - } - - if (overlayBottom != null) - { - overlayBottom.setVisibility(position == count - 1 ? View.VISIBLE : View.GONE); - } } @@ -120,13 +117,14 @@ protected void setDescription(View view, Cursor cursor) { String description = TaskFieldAdapters.DESCRIPTION.get(cursor); TextView descriptionView = getView(view, android.R.id.text1); + View content = getView(view, R.id.cardcontent); if (TextUtils.isEmpty(description)) { - descriptionView.setVisibility(View.GONE); + content.setVisibility(View.GONE); } else { - descriptionView.setVisibility(View.VISIBLE); + content.setVisibility(View.VISIBLE); if (description.length() > 150) { description = description.substring(0, 150); @@ -138,10 +136,37 @@ protected void setDescription(View view, Cursor cursor) protected void setColorBar(View view, Cursor cursor) { - View colorbar = getView(view, R.id.colorbar); - if (colorbar != null) + MaterialCardView cardView = getView(view, R.id.flingContentView); + if (cardView != null) { - colorbar.setBackgroundColor(TaskFieldAdapters.LIST_COLOR.get(cursor)); + if (IS_CLOSED.get(cursor)) + { + if (STATUS.get(cursor) == STATUS_CANCELLED) + { + cardView.setCardBackgroundColor(0xfff0f0f0); + cardView.setStrokeColor(0); + ((TextView) cardView.findViewById(android.R.id.title)).setTextColor(0x50000000); + cardView.setStrokeWidth(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_open_border_width)); + + } + else + { + cardView.setCardBackgroundColor(new AttributeColor(view.getContext(), android.R.attr.windowBackground).argb()); + //cardView.setCardElevation(1f); + ((TextView) cardView.findViewById(android.R.id.title)).setTextColor(0x80000000); + cardView.setStrokeColor(0xffc0c0c0); + cardView.setStrokeWidth(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_closed_border_width)); + } + cardView.setCardElevation(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_closed_elevation)); + } + else + { + cardView.setCardBackgroundColor(TaskFieldAdapters.LIST_COLOR.get(cursor)); + cardView.setStrokeColor(0); + ((TextView) cardView.findViewById(android.R.id.title)).setTextColor(0xffffffff); + cardView.setStrokeWidth(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_open_border_width)); + cardView.setCardElevation(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_open_elevation)); + } } } diff --git a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByDueDate.java b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByDueDate.java index 139228519..54a28be58 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByDueDate.java +++ b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByDueDate.java @@ -24,8 +24,7 @@ import android.widget.BaseExpandableListAdapter; import android.widget.TextView; -import org.dmfs.jems.optional.elementary.NullSafe; -import org.dmfs.jems.single.combined.Backed; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.tasks.R; import org.dmfs.tasks.contract.TaskContract.Instances; import org.dmfs.tasks.groupings.cursorloaders.TimeRangeCursorFactory; @@ -36,7 +35,6 @@ import org.dmfs.tasks.utils.ExpandableGroupDescriptor; import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter; import org.dmfs.tasks.utils.ViewDescriptor; -import org.dmfs.tasks.widget.ProgressBackgroundView; import java.text.DateFormatSymbols; @@ -98,34 +96,30 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed); - View divider = getView(view, R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE); - } - // display priority - int priority = TaskFieldAdapters.PRIORITY.get(cursor); - View priorityView = getView(view, R.id.task_priority_view_medium); - priorityView.setBackgroundResource(android.R.color.transparent); - priorityView.setVisibility(View.VISIBLE); - - if (priority > 0 && priority < 5) - { - priorityView.setBackgroundResource(R.color.priority_red); - } - if (priority == 5) + View prioLabel = getView(view, R.id.priority_label); + Integer priority = TaskFieldAdapters.PRIORITY.get(cursor); + if (priority > 0) { - priorityView.setBackgroundResource(R.color.priority_yellow); + if (priority > 0 && priority < 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorHighPriority).argb()); + } + if (priority == 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorMediumPriority).argb()); + } + if (priority > 5 && priority <= 9) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorLowPriority).argb()); + } + prioLabel.setVisibility(View.VISIBLE); } - if (priority > 5 && priority <= 9) + else { - priorityView.setBackgroundResource(R.color.priority_green); + prioLabel.setVisibility(View.GONE); } - new ProgressBackgroundView(getView(view, R.id.percentage_background_view)) - .update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor))); - setColorBar(view, cursor); setDescription(view, cursor); setOverlay(view, cursor.getPosition(), cursor.getCount()); @@ -190,19 +184,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount)); } - - // show/hide divider - View divider = view.findViewById(R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE); - } - - View colorbar = view.findViewById(R.id.colorbar1); - if (colorbar != null) - { - colorbar.setVisibility(View.GONE); - } } @@ -303,7 +284,6 @@ ExpandableChildDescriptor makeExpandableChildDescriptor(String authority) } - @Override ExpandableGroupDescriptor makeExpandableGroupDescriptor(String authority) { diff --git a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByList.java b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByList.java index abc06b011..c12ef019b 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByList.java +++ b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByList.java @@ -20,13 +20,12 @@ import android.content.res.Resources; import android.database.Cursor; import android.graphics.Paint; -import androidx.fragment.app.FragmentActivity; import android.view.View; import android.view.View.OnClickListener; import android.widget.BaseExpandableListAdapter; import android.widget.TextView; -import org.dmfs.jems.optional.elementary.NullSafe; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.tasks.QuickAddDialogFragment; import org.dmfs.tasks.R; import org.dmfs.tasks.contract.TaskContract.Instances; @@ -37,7 +36,8 @@ import org.dmfs.tasks.utils.ExpandableGroupDescriptor; import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter; import org.dmfs.tasks.utils.ViewDescriptor; -import org.dmfs.tasks.widget.ProgressBackgroundView; + +import androidx.fragment.app.FragmentActivity; /** @@ -94,34 +94,30 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed); - View divider = getView(view, R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE); - } - // display priority + View prioLabel = getView(view, R.id.priority_label); int priority = TaskFieldAdapters.PRIORITY.get(cursor); - View priorityView = getView(view, R.id.task_priority_view_medium); - priorityView.setBackgroundResource(android.R.color.transparent); - priorityView.setVisibility(View.VISIBLE); - - if (priority > 0 && priority < 5) + if (priority > 0) { - priorityView.setBackgroundResource(R.color.priority_red); - } - if (priority == 5) - { - priorityView.setBackgroundResource(R.color.priority_yellow); + if (priority > 0 && priority < 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorHighPriority).argb()); + } + if (priority == 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorMediumPriority).argb()); + } + if (priority > 5 && priority <= 9) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorLowPriority).argb()); + } + prioLabel.setVisibility(View.VISIBLE); } - if (priority > 5 && priority <= 9) + else { - priorityView.setBackgroundResource(R.color.priority_green); + prioLabel.setVisibility(View.GONE); } - new ProgressBackgroundView(getView(view, R.id.percentage_background_view)) - .update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor))); - setColorBar(view, cursor); setDescription(view, cursor); setOverlay(view, cursor.getPosition(), cursor.getCount()); @@ -191,15 +187,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount)); } - // show/hide divider - View divider = view.findViewById(R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE); - } - - View colorbar1 = view.findViewById(R.id.colorbar1); - View colorbar2 = view.findViewById(R.id.colorbar2); View quickAddTask = view.findViewById(R.id.quick_add_task); if (quickAddTask != null) { @@ -209,16 +196,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada if ((flags & FLAG_IS_EXPANDED) != 0) { - if (colorbar1 != null) - { - colorbar1.setBackgroundColor(TaskFieldAdapters.LIST_COLOR.get(cursor)); - colorbar1.setVisibility(View.VISIBLE); - } - if (colorbar2 != null) - { - colorbar2.setVisibility(View.GONE); - } - // show quick add and hide task count if (quickAddTask != null) { @@ -231,16 +208,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada } else { - if (colorbar1 != null) - { - colorbar1.setVisibility(View.INVISIBLE); - } - if (colorbar2 != null) - { - colorbar2.setBackgroundColor(TaskFieldAdapters.LIST_COLOR.get(cursor)); - colorbar2.setVisibility(View.VISIBLE); - } - // hide quick add and show task count if (quickAddTask != null) { diff --git a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByPriority.java b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByPriority.java index 7f0d5fe32..3e2145ee5 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByPriority.java +++ b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByPriority.java @@ -20,13 +20,12 @@ import android.content.res.Resources; import android.database.Cursor; import android.graphics.Paint; -import androidx.fragment.app.FragmentActivity; import android.view.View; import android.view.View.OnClickListener; import android.widget.BaseExpandableListAdapter; import android.widget.TextView; -import org.dmfs.jems.optional.elementary.NullSafe; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.provider.tasks.AuthorityUtil; import org.dmfs.tasks.QuickAddDialogFragment; import org.dmfs.tasks.R; @@ -40,7 +39,8 @@ import org.dmfs.tasks.utils.ExpandableGroupDescriptor; import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter; import org.dmfs.tasks.utils.ViewDescriptor; -import org.dmfs.tasks.widget.ProgressBackgroundView; + +import androidx.fragment.app.FragmentActivity; /** @@ -86,34 +86,30 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed); - View divider = getView(view, R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE); - } - // display priority - int priority = TaskFieldAdapters.PRIORITY.get(cursor); - View priorityView = getView(view, R.id.task_priority_view_medium); - priorityView.setBackgroundResource(android.R.color.transparent); - priorityView.setVisibility(View.VISIBLE); - - if (priority > 0 && priority < 5) + View prioLabel = getView(view, R.id.priority_label); + Integer priority = TaskFieldAdapters.PRIORITY.get(cursor); + if (priority > 0) { - priorityView.setBackgroundResource(R.color.priority_red); - } - if (priority == 5) - { - priorityView.setBackgroundResource(R.color.priority_yellow); + if (priority > 0 && priority < 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorHighPriority).argb()); + } + if (priority == 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorMediumPriority).argb()); + } + if (priority > 5 && priority <= 9) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorLowPriority).argb()); + } + prioLabel.setVisibility(View.VISIBLE); } - if (priority > 5 && priority <= 9) + else { - priorityView.setBackgroundResource(R.color.priority_green); + prioLabel.setVisibility(View.GONE); } - new ProgressBackgroundView(getView(view, R.id.percentage_background_view)) - .update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor))); - setColorBar(view, cursor); setDescription(view, cursor); setOverlay(view, cursor.getPosition(), cursor.getCount()); @@ -176,15 +172,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount)); } - // show/hide divider - View divider = view.findViewById(R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE); - } - - View colorbar1 = view.findViewById(R.id.colorbar1); - View colorbar2 = view.findViewById(R.id.colorbar2); View quickAddTask = view.findViewById(R.id.quick_add_task); if (quickAddTask != null) { @@ -194,16 +181,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada if ((flags & FLAG_IS_EXPANDED) != 0) { - if (colorbar1 != null) - { - colorbar1.setBackgroundColor(cursor.getInt(2)); - colorbar1.setVisibility(View.VISIBLE); - } - if (colorbar2 != null) - { - colorbar2.setVisibility(View.GONE); - } - // show quick add and hide task count if (quickAddTask != null) { @@ -216,16 +193,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada } else { - if (colorbar1 != null) - { - colorbar1.setVisibility(View.INVISIBLE); - } - if (colorbar2 != null) - { - colorbar2.setBackgroundColor(cursor.getInt(2)); - colorbar2.setVisibility(View.VISIBLE); - } - // hide quick add and show task count if (quickAddTask != null) { diff --git a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByProgress.java b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByProgress.java index 70ec1ec9b..24780d6d2 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByProgress.java +++ b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByProgress.java @@ -24,7 +24,7 @@ import android.widget.BaseExpandableListAdapter; import android.widget.TextView; -import org.dmfs.jems.optional.elementary.NullSafe; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.tasks.R; import org.dmfs.tasks.contract.TaskContract.Instances; import org.dmfs.tasks.groupings.cursorloaders.ProgressCursorFactory; @@ -34,7 +34,6 @@ import org.dmfs.tasks.utils.ExpandableGroupDescriptor; import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter; import org.dmfs.tasks.utils.ViewDescriptor; -import org.dmfs.tasks.widget.ProgressBackgroundView; /** @@ -79,34 +78,30 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed); - View divider = getView(view, R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE); - } - // display priority - int priority = TaskFieldAdapters.PRIORITY.get(cursor); - View priorityView = getView(view, R.id.task_priority_view_medium); - priorityView.setBackgroundResource(android.R.color.transparent); - priorityView.setVisibility(View.VISIBLE); - - if (priority > 0 && priority < 5) + View prioLabel = getView(view, R.id.priority_label); + Integer priority = TaskFieldAdapters.PRIORITY.get(cursor); + if (priority > 0) { - priorityView.setBackgroundResource(R.color.priority_red); - } - if (priority == 5) - { - priorityView.setBackgroundResource(R.color.priority_yellow); + if (priority > 0 && priority < 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorHighPriority).argb()); + } + if (priority == 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorMediumPriority).argb()); + } + if (priority > 5 && priority <= 9) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorLowPriority).argb()); + } + prioLabel.setVisibility(View.VISIBLE); } - if (priority > 5 && priority <= 9) + else { - priorityView.setBackgroundResource(R.color.priority_green); + prioLabel.setVisibility(View.GONE); } - new ProgressBackgroundView(getView(view, R.id.percentage_background_view)) - .update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor))); - setColorBar(view, cursor); setDescription(view, cursor); setOverlay(view, cursor.getPosition(), cursor.getCount()); @@ -168,41 +163,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount)); } - - // show/hide divider - View divider = view.findViewById(R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE); - } - - View colorbar1 = view.findViewById(R.id.colorbar1); - View colorbar2 = view.findViewById(R.id.colorbar2); - - if ((flags & FLAG_IS_EXPANDED) != 0) - { - if (colorbar1 != null) - { - colorbar1.setBackgroundColor(cursor.getInt(2)); - colorbar1.setVisibility(View.GONE); - } - if (colorbar2 != null) - { - colorbar2.setVisibility(View.GONE); - } - } - else - { - if (colorbar1 != null) - { - colorbar1.setVisibility(View.GONE); - } - if (colorbar2 != null) - { - colorbar2.setBackgroundColor(cursor.getInt(2)); - colorbar2.setVisibility(View.GONE); - } - } } diff --git a/opentasks/src/main/java/org/dmfs/tasks/groupings/BySearch.java b/opentasks/src/main/java/org/dmfs/tasks/groupings/BySearch.java index 66b731030..a33b73fe9 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/groupings/BySearch.java +++ b/opentasks/src/main/java/org/dmfs/tasks/groupings/BySearch.java @@ -30,7 +30,7 @@ import android.widget.TextView; import android.widget.Toast; -import org.dmfs.jems.optional.elementary.NullSafe; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.tasks.R; import org.dmfs.tasks.contract.TaskContract.Instances; import org.dmfs.tasks.contract.TaskContract.Tasks; @@ -44,7 +44,6 @@ import org.dmfs.tasks.utils.SearchHistoryDatabaseHelper.SearchHistoryColumns; import org.dmfs.tasks.utils.SearchHistoryHelper; import org.dmfs.tasks.utils.ViewDescriptor; -import org.dmfs.tasks.widget.ProgressBackgroundView; /** @@ -92,34 +91,30 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed); - View divider = getView(view, R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE); - } - // display priority - int priority = TaskFieldAdapters.PRIORITY.get(cursor); - View priorityView = getView(view, R.id.task_priority_view_medium); - priorityView.setBackgroundResource(android.R.color.transparent); - priorityView.setVisibility(View.VISIBLE); - - if (priority > 0 && priority < 5) - { - priorityView.setBackgroundResource(R.color.priority_red); - } - if (priority == 5) + View prioLabel = getView(view, R.id.priority_label); + Integer priority = TaskFieldAdapters.PRIORITY.get(cursor); + if (priority > 0) { - priorityView.setBackgroundResource(R.color.priority_yellow); + if (priority > 0 && priority < 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorHighPriority).argb()); + } + if (priority == 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorMediumPriority).argb()); + } + if (priority > 5 && priority <= 9) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorLowPriority).argb()); + } + prioLabel.setVisibility(View.VISIBLE); } - if (priority > 5 && priority <= 9) + else { - priorityView.setBackgroundResource(R.color.priority_green); + prioLabel.setVisibility(View.GONE); } - new ProgressBackgroundView(getView(view, R.id.percentage_background_view)) - .update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor))); - setColorBar(view, cursor); setDescription(view, cursor); setOverlay(view, cursor.getPosition(), cursor.getCount()); @@ -192,25 +187,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount)); } - // show/hide divider - View divider = view.findViewById(R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE); - } - - View colorbar1 = view.findViewById(R.id.colorbar1); - View colorbar2 = view.findViewById(R.id.colorbar2); - - if (colorbar1 != null) - { - colorbar1.setVisibility(View.GONE); - } - if (colorbar2 != null) - { - colorbar2.setVisibility(View.GONE); - } - View removeSearch = view.findViewById(R.id.quick_add_task); if (removeSearch != null) { diff --git a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByStartDate.java b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByStartDate.java index d323ab74d..368f66562 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/groupings/ByStartDate.java +++ b/opentasks/src/main/java/org/dmfs/tasks/groupings/ByStartDate.java @@ -26,7 +26,7 @@ import android.widget.ImageView; import android.widget.TextView; -import org.dmfs.jems.optional.elementary.NullSafe; +import org.dmfs.android.bolts.color.colors.AttributeColor; import org.dmfs.tasks.R; import org.dmfs.tasks.contract.TaskContract.Instances; import org.dmfs.tasks.groupings.cursorloaders.TimeRangeCursorFactory; @@ -39,7 +39,6 @@ import org.dmfs.tasks.utils.ExpandableGroupDescriptor; import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter; import org.dmfs.tasks.utils.ViewDescriptor; -import org.dmfs.tasks.widget.ProgressBackgroundView; /** @@ -111,34 +110,30 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada } } - View divider = getView(view, R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE); - } - // display priority - int priority = TaskFieldAdapters.PRIORITY.get(cursor); - View priorityView = getView(view, R.id.task_priority_view_medium); - priorityView.setBackgroundResource(android.R.color.transparent); - priorityView.setVisibility(View.VISIBLE); - - if (priority > 0 && priority < 5) - { - priorityView.setBackgroundResource(R.color.priority_red); - } - if (priority == 5) + View prioLabel = getView(view, R.id.priority_label); + Integer priority = TaskFieldAdapters.PRIORITY.get(cursor); + if (priority > 0) { - priorityView.setBackgroundResource(R.color.priority_yellow); + if (priority > 0 && priority < 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorHighPriority).argb()); + } + if (priority == 5) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorMediumPriority).argb()); + } + if (priority > 5 && priority <= 9) + { + prioLabel.setBackgroundColor(new AttributeColor(prioLabel.getContext(), R.attr.colorLowPriority).argb()); + } + prioLabel.setVisibility(View.VISIBLE); } - if (priority > 5 && priority <= 9) + else { - priorityView.setBackgroundResource(R.color.priority_green); + prioLabel.setVisibility(View.GONE); } - new ProgressBackgroundView(getView(view, R.id.percentage_background_view)) - .update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor))); - setColorBar(view, cursor); setDescription(view, cursor); setOverlay(view, cursor.getPosition(), cursor.getCount()); @@ -199,19 +194,6 @@ public void populateView(View view, Cursor cursor, BaseExpandableListAdapter ada text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount)); } - - // show/hide divider - View divider = view.findViewById(R.id.divider); - if (divider != null) - { - divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE); - } - - View colorbar = view.findViewById(R.id.colorbar1); - if (colorbar != null) - { - colorbar.setVisibility(View.GONE); - } } diff --git a/opentasks/src/main/java/org/dmfs/tasks/utils/ExpandableGroupDescriptorAdapter.java b/opentasks/src/main/java/org/dmfs/tasks/utils/ExpandableGroupDescriptorAdapter.java index 1fe3bac0c..800b57a84 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/utils/ExpandableGroupDescriptorAdapter.java +++ b/opentasks/src/main/java/org/dmfs/tasks/utils/ExpandableGroupDescriptorAdapter.java @@ -18,6 +18,7 @@ import android.content.Context; import android.database.Cursor; +import android.database.MatrixCursor; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; @@ -87,6 +88,22 @@ public boolean childCursorLoaded(int position) } + @Override + public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) + { + try + { + return super.getGroupView(groupPosition, isExpanded, convertView, parent); + } + catch (IllegalStateException e) + { + // temporary workaround for Exception with unknown reason + // for no w we simply try to ignore it + return newGroupView(mContext, new MatrixCursor(new String[0], 1), isExpanded, parent); + } + } + + @NonNull @Override public Loader onCreateLoader(int pos, Bundle arguments) @@ -112,22 +129,6 @@ public boolean hasStableIds() } - @Override - public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) - { - try - { - return super.getGroupView(groupPosition, isExpanded, convertView, parent); - } - catch (IllegalStateException e) - { - // try to silence an issue which appears to be a race condition until we've gotten rid of ExpandableListView - // for now we just return an empty group view - return newGroupView(mContext, null /* we don't use this */, false, parent); - } - } - - @Override public void onLoadFinished(Loader loader, Cursor cursor) { diff --git a/opentasks/src/main/java/org/dmfs/tasks/widget/ProgressBackgroundView.java b/opentasks/src/main/java/org/dmfs/tasks/widget/ProgressBackgroundView.java deleted file mode 100644 index 4c1fd9979..000000000 --- a/opentasks/src/main/java/org/dmfs/tasks/widget/ProgressBackgroundView.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2017 dmfs GmbH - * - * 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.dmfs.tasks.widget; - -import android.view.View; - -import org.dmfs.jems.optional.Optional; -import org.dmfs.tasks.R; - - -/** - * {@link SmartView} adapting any {@link View} so that its background can be updated with a progress in percent, - * so that it shows the value as a proportionate horizontal overlay. - * - * @author Gabor Keszthelyi - */ -public final class ProgressBackgroundView implements SmartView> -{ - private final View mBackgroundView; - - - public ProgressBackgroundView(View backgroundView) - { - mBackgroundView = backgroundView; - } - - - @Override - public void update(Optional percentComplete) - { - if (percentComplete.isPresent()) - { - mBackgroundView.setPivotX(0); - if (percentComplete.value() < 100) - { - mBackgroundView.setScaleX(percentComplete.value() / 100f); - mBackgroundView.setBackgroundResource(R.drawable.task_progress_background_shade); - } - else - { - mBackgroundView.setScaleX(1); - mBackgroundView.setBackgroundResource(R.drawable.complete_task_background_overlay); - } - } - } -} diff --git a/opentasks/src/main/res/color/due_date_text.xml b/opentasks/src/main/res/color/due_date_text.xml index f7fd2c339..0abff9a56 100644 --- a/opentasks/src/main/res/color/due_date_text.xml +++ b/opentasks/src/main/res/color/due_date_text.xml @@ -3,6 +3,6 @@ + android:color="#c0ffffff"/> \ No newline at end of file diff --git a/opentasks/src/main/res/color/overdue_date_text.xml b/opentasks/src/main/res/color/overdue_date_text.xml index 4ff73b980..6c0945144 100644 --- a/opentasks/src/main/res/color/overdue_date_text.xml +++ b/opentasks/src/main/res/color/overdue_date_text.xml @@ -3,6 +3,6 @@ + android:color="#ffffffff"/> \ No newline at end of file diff --git a/opentasks/src/main/res/drawable/shape_color_circle.xml b/opentasks/src/main/res/drawable/shape_color_circle.xml index c2e52e572..0570138d5 100644 --- a/opentasks/src/main/res/drawable/shape_color_circle.xml +++ b/opentasks/src/main/res/drawable/shape_color_circle.xml @@ -2,7 +2,7 @@ - + + + + + + + + + + + + \ No newline at end of file diff --git a/opentasks/src/main/res/layout/account_list_item_dialog.xml b/opentasks/src/main/res/layout/account_list_item_dialog.xml index c34d487bc..23450ebad 100644 --- a/opentasks/src/main/res/layout/account_list_item_dialog.xml +++ b/opentasks/src/main/res/layout/account_list_item_dialog.xml @@ -13,7 +13,7 @@ android:layout_marginLeft="24dp" android:layout_marginStart="24dp" android:src="@drawable/ic_24_account_circle_black50" - android:tint="?attr/colorAccent"/> + android:tint="?attr/colorSecondary"/> - + android:textColor="?attr/colorWarning"/> - + android:textColor="?attr/colorPrimary"/> \ No newline at end of file diff --git a/opentasks/src/main/res/layout/activity_settings.xml b/opentasks/src/main/res/layout/activity_settings.xml index 68b0a4bdb..be2e8ed1a 100644 --- a/opentasks/src/main/res/layout/activity_settings.xml +++ b/opentasks/src/main/res/layout/activity_settings.xml @@ -1,5 +1,21 @@ - + android:orientation="vertical" + android:layout_height="match_parent"> + + + + + + + + \ No newline at end of file diff --git a/opentasks/src/main/res/layout/activity_task_list.xml b/opentasks/src/main/res/layout/activity_task_list.xml index afba29584..6fbfa47ac 100644 --- a/opentasks/src/main/res/layout/activity_task_list.xml +++ b/opentasks/src/main/res/layout/activity_task_list.xml @@ -7,23 +7,23 @@ + android:background="?android:windowBackground"> + android:layout_height="?attr/actionBarSize" /> + app:tabMode="fixed" /> + tools:context=".MainActivity" /> + app:layout_anchorGravity="bottom|right|end" /> \ No newline at end of file diff --git a/opentasks/src/main/res/layout/activity_task_twopane.xml b/opentasks/src/main/res/layout/activity_task_twopane.xml index d9fe8a156..e37463e7b 100644 --- a/opentasks/src/main/res/layout/activity_task_twopane.xml +++ b/opentasks/src/main/res/layout/activity_task_twopane.xml @@ -8,24 +8,24 @@ android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" - app:elevation="0dp"> + android:background="?android:windowBackground" + > + android:layout_height="?attr/actionBarSize" /> + app:tabMode="fixed" /> + android:layout_marginBottom="-8dp" + android:elevation="8dp" + android:background="@drawable/opentasks_popup_background_mtrl_mult" /> + tools:context=".MainActivity" /> + app:layout_anchorGravity="bottom|right|end" /> \ No newline at end of file diff --git a/opentasks/src/main/res/layout/activity_task_twopane_small.xml b/opentasks/src/main/res/layout/activity_task_twopane_small.xml index 837d1aadb..475b9eb83 100644 --- a/opentasks/src/main/res/layout/activity_task_twopane_small.xml +++ b/opentasks/src/main/res/layout/activity_task_twopane_small.xml @@ -8,22 +8,22 @@ android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" + android:background="?android:windowBackground" app:elevation="0dp"> + android:layout_height="?attr/actionBarSize" /> diff --git a/opentasks/src/main/res/layout/fragment_input_text_dialog.xml b/opentasks/src/main/res/layout/fragment_input_text_dialog.xml index f1c2f613e..0988f37a0 100644 --- a/opentasks/src/main/res/layout/fragment_input_text_dialog.xml +++ b/opentasks/src/main/res/layout/fragment_input_text_dialog.xml @@ -46,7 +46,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" - android:textColor="@color/priority_red" + android:textColor="@color/material_red_700" android:visibility="invisible"/> + android:textColor="?android:textColorSecondary"/> + android:textColor="?attr/colorPrimary"/> \ No newline at end of file diff --git a/opentasks/src/main/res/layout/fragment_quick_add_dialog.xml b/opentasks/src/main/res/layout/fragment_quick_add_dialog.xml index f021be295..5113fb30f 100644 --- a/opentasks/src/main/res/layout/fragment_quick_add_dialog.xml +++ b/opentasks/src/main/res/layout/fragment_quick_add_dialog.xml @@ -1,5 +1,6 @@ + android:layout_height="wrap_content" /> + android:layout_height="0dp" /> + android:minWidth="240dp" /> - + android:visibility="invisible" + app:drawableStartCompat="@drawable/ic_checkmark_light" /> \ No newline at end of file diff --git a/opentasks/src/main/res/layout/fragment_task_list_selection.xml b/opentasks/src/main/res/layout/fragment_task_list_selection.xml index 74e9aed53..7fc1bacb1 100644 --- a/opentasks/src/main/res/layout/fragment_task_list_selection.xml +++ b/opentasks/src/main/res/layout/fragment_task_list_selection.xml @@ -7,16 +7,6 @@ android:orientation="vertical" android:padding="16dp"> - - - - - - - - - - - - - - - - - + + + + + + + + android:layout_marginLeft="16dp" + android:layout_marginTop="8dp" + android:layout_marginRight="16dp" + android:layout_marginBottom="8dp" + app:cardCornerRadius="4dp"> + android:layout_height="@dimen/opentasks_cardlist_title_height" + android:layout_gravity="top" + android:visibility="gone" /> + + - - + android:paddingLeft="0dp" + android:paddingRight="8dp"> + android:visibility="gone" /> - + android:tint="#d0ffffff" + android:visibility="gone" /> - + android:textSize="12sp" /> - + android:tint="#d0ffffff" + android:visibility="gone" /> - + android:paddingRight="8dp" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="@color/dark_gray" + android:textIsSelectable="false" /> - + + + + + + - + android:textColor="#c0ffffff" + android:textIsSelectable="false" + android:textSize="12sp" /> + + + - - - - - - - - - - - - - + android:layout_gravity="start" + android:background="#ffffffff" + android:minHeight="@dimen/opentasks_cardlist_title_height" /> + + - + \ No newline at end of file diff --git a/opentasks/src/main/res/layout/task_list_group.xml b/opentasks/src/main/res/layout/task_list_group.xml index a6141657b..23ab79698 100644 --- a/opentasks/src/main/res/layout/task_list_group.xml +++ b/opentasks/src/main/res/layout/task_list_group.xml @@ -1,39 +1,22 @@ - - - + android:visibility="gone" /> + android:textIsSelectable="false" /> + android:textIsSelectable="false" /> + android:textIsSelectable="false" /> - + android:visibility="gone" + app:tint="?attr/tabIndicatorColor" /> - diff --git a/opentasks/src/main/res/layout/task_list_group_single_line.xml b/opentasks/src/main/res/layout/task_list_group_single_line.xml index fdae24376..77faa6fc9 100644 --- a/opentasks/src/main/res/layout/task_list_group_single_line.xml +++ b/opentasks/src/main/res/layout/task_list_group_single_line.xml @@ -3,24 +3,22 @@ style="@style/task_group_list_item" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="#fff0f0f0" - android:paddingBottom="8dp" android:paddingLeft="@dimen/task_list_left_margin" + android:paddingTop="8dp" android:paddingRight="@dimen/task_list_right_margin" - android:paddingTop="8dp"> + android:paddingBottom="8dp"> + android:textIsSelectable="false" /> + android:textIsSelectable="false" /> - - + android:visibility="gone" /> \ No newline at end of file diff --git a/opentasks/src/main/res/layout/undo_notification.xml b/opentasks/src/main/res/layout/undo_notification.xml index a61a34086..15248e69a 100644 --- a/opentasks/src/main/res/layout/undo_notification.xml +++ b/opentasks/src/main/res/layout/undo_notification.xml @@ -13,7 +13,7 @@ android:layout_height="40dp" android:layout_margin="12dp" android:background="@drawable/shape_color_circle" - android:backgroundTint="@color/primary" + android:backgroundTint="?attr/colorPrimary" android:padding="11dp" android:scaleType="fitCenter" android:src="@drawable/ic_notification"/> diff --git a/opentasks/src/main/res/layout/visible_task_list_item.xml b/opentasks/src/main/res/layout/visible_task_list_item.xml index d32a3795d..8197a9df1 100644 --- a/opentasks/src/main/res/layout/visible_task_list_item.xml +++ b/opentasks/src/main/res/layout/visible_task_list_item.xml @@ -3,28 +3,28 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingBottom="8dip" - android:paddingTop="8dip"> + android:paddingTop="8dip" + android:paddingBottom="8dip"> + app:lightCheckmark="@drawable/org_dmfs_colorshape_checkbox_white_shape_selector" /> - + android:src="@drawable/ic_24_settings_black50" /> + android:textColor="#c0000000" + android:textIsSelectable="false" /> + android:textColor="#c0000000" + android:textIsSelectable="false" /> \ No newline at end of file diff --git a/opentasks/src/main/res/values-large/styles.xml b/opentasks/src/main/res/values-large/styles.xml index 850581ef0..193787ab3 100644 --- a/opentasks/src/main/res/values-large/styles.xml +++ b/opentasks/src/main/res/values-large/styles.xml @@ -12,12 +12,8 @@ fill_parent - - diff --git a/opentasks/src/main/res/values-sw600dp/styles.xml b/opentasks/src/main/res/values-sw600dp/styles.xml index 850581ef0..46786d0ba 100644 --- a/opentasks/src/main/res/values-sw600dp/styles.xml +++ b/opentasks/src/main/res/values-sw600dp/styles.xml @@ -12,12 +12,7 @@ fill_parent - - - diff --git a/opentasks/src/main/res/values/colors.xml b/opentasks/src/main/res/values/colors.xml index 5141e76bb..dd55c5776 100644 --- a/opentasks/src/main/res/values/colors.xml +++ b/opentasks/src/main/res/values/colors.xml @@ -9,9 +9,6 @@ #22FFFFFF #BB222222 #CC33B5E5 - #4caf50 - #f44336 - #ffc107 #11000000 #33000000 @@ -37,9 +34,9 @@ #ff00ddff #f44336 - - #FF009688 - #FF00796B - #FFFF5722 + #FF009688 + #FF00796B + #FFFF5722 + \ No newline at end of file diff --git a/opentasks/src/main/res/values/dimens.xml b/opentasks/src/main/res/values/dimens.xml index 75429d8d7..09f14fed0 100644 --- a/opentasks/src/main/res/values/dimens.xml +++ b/opentasks/src/main/res/values/dimens.xml @@ -3,11 +3,16 @@ 16dp 16dp - 0dp - 0dp + 8dp + 8dp 52dp 432dp 120dp -80dp + 1dp + 0dp + 0dp + 2dp + 40dp \ No newline at end of file diff --git a/opentasks/src/main/res/values/strings.xml b/opentasks/src/main/res/values/strings.xml index 1a4090ca3..0d54fd82b 100644 --- a/opentasks/src/main/res/values/strings.xml +++ b/opentasks/src/main/res/values/strings.xml @@ -212,7 +212,7 @@ Complete Edit Delete - Uncomplete + Resume icon for the start date of the task diff --git a/opentasks/src/main/res/values/styles.xml b/opentasks/src/main/res/values/styles.xml index 8d477619d..fccc24cd9 100644 --- a/opentasks/src/main/res/values/styles.xml +++ b/opentasks/src/main/res/values/styles.xml @@ -95,7 +95,6 @@ insideOverlay 20dp @null - #fff0f0f0 @@ -289,6 +287,7 @@ diff --git a/settings.gradle b/settings.gradle index 229de52f5..f5592faa5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,2 @@ +include ':opentasks-theme' include ':opentasks', ':opentasks-provider', ':opentasks-contract', ':opentaskspal'