Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4450240c authored by Romain Hunault's avatar Romain Hunault 💻
Browse files

Merge branch 'issue_1726' into 'master'

Issue 1726

See merge request e/apps/tasks!13
parents 2ebe52a9 2894cedb
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.core.app.NavUtils;
import androidx.appcompat.app.ActionBar;

import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

+6 −4
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ public class QuickAddDialogFragment extends SupportDialogFragment
    private View mConfirmation;
    private View mContent;

    private View mSaveButton;
    private TextView mSaveButton;
    private View mSaveAndNextButton;

    private TasksListCursorSpinnerAdapter mTaskListAdapter;
@@ -221,7 +221,8 @@ public class QuickAddDialogFragment extends SupportDialogFragment
        }

        mColorBackground = view.findViewById(R.id.color_background);
        mColorBackground.setBackgroundColor(mLastColor);
        mColorBackground.setBackgroundColor(TaskListActivity.ACCENT_COLOR);


        mListSpinner = (Spinner) view.findViewById(R.id.task_list_spinner);
        mTaskListAdapter = new TasksListCursorSpinnerAdapter(getActivity(), R.layout.list_spinner_item_selected_quick_add, R.layout.list_spinner_item_dropdown);
@@ -237,7 +238,8 @@ public class QuickAddDialogFragment extends SupportDialogFragment
        mConfirmation = view.findViewById(R.id.created_confirmation);
        mContent = view.findViewById(R.id.content);

        mSaveButton = view.findViewById(android.R.id.button1);
        mSaveButton = (TextView)view.findViewById(android.R.id.button1);
        mSaveButton.setTextColor(TaskListActivity.ACCENT_COLOR);
        mSaveButton.setOnClickListener(this);
        mSaveAndNextButton = view.findViewById(android.R.id.button2);
        mSaveAndNextButton.setOnClickListener(this);
@@ -326,7 +328,7 @@ public class QuickAddDialogFragment extends SupportDialogFragment
    {
        Cursor c = (Cursor) parent.getItemAtPosition(position);
        mLastColor = TaskFieldAdapters.LIST_COLOR.get(c);
        mColorBackground.setBackgroundColor(mLastColor);
        mColorBackground.setBackgroundColor(TaskListActivity.ACCENT_COLOR);
        mSelectedListId = id;
    }

+56 −0
Original line number Diff line number Diff line
@@ -20,8 +20,12 @@ import android.annotation.SuppressLint;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;

import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
@@ -34,6 +38,7 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;

import androidx.appcompat.view.ContextThemeWrapper;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.core.view.MenuItemCompat;
@@ -44,6 +49,8 @@ import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.SearchView.OnQueryTextListener;
import androidx.appcompat.widget.Toolbar;

import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -181,6 +188,7 @@ public class TaskListActivity extends BaseActivity implements TaskListFragment.C
    private AppBarLayout mAppBarLayout;

    private FloatingActionButton mFloatingActionButton;
    public static int ACCENT_COLOR;


    @Override
@@ -264,6 +272,7 @@ public class TaskListActivity extends BaseActivity implements TaskListFragment.C
        mTabs.setupWithViewPager(mViewPager);
        setupTabIcons();


        mViewPager.addOnPageChangeListener(new OnPageChangeListener() {

            @Override
@@ -312,6 +321,7 @@ public class TaskListActivity extends BaseActivity implements TaskListFragment.C
        });

        mFloatingActionButton = (FloatingActionButton) findViewById(R.id.floating_action_button);

        if (mFloatingActionButton != null) {
            mFloatingActionButton.setOnClickListener(new OnClickListener() {

@@ -321,6 +331,11 @@ public class TaskListActivity extends BaseActivity implements TaskListFragment.C
                }
            });
        }

       ACCENT_COLOR=fetchAccentColor(this);
        mTabs.setBackgroundColor(ACCENT_COLOR);
        mFloatingActionButton.setBackgroundTintList(ColorStateList.valueOf(darkenColor20(ACCENT_COLOR)));

    }


@@ -687,4 +702,45 @@ public class TaskListActivity extends BaseActivity implements TaskListFragment.C
    public boolean isInTransientState() {
        return mTransientState;
    }

    /*
     * get Accent color from OS
     * */
    private int fetchAccentColor(Context context) {

        TypedValue typedValue = new TypedValue();
        ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(this,
                android.R.style.Theme_DeviceDefault);
        contextThemeWrapper.getTheme().resolveAttribute(android.R.attr.colorAccent,
                typedValue, true);
        int color_accent = typedValue.data;
        Log.e("TAG", "accent Colour  #"+Integer.toHexString(color_accent));

        //change toolbar color
        getSupportActionBar().setBackgroundDrawable(
                new ColorDrawable(color_accent));

        //change status bar color
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

            window.setStatusBarColor(darkenColor(color_accent));
        }

        return color_accent;
    }

    @ColorInt int darkenColor(@ColorInt int color) {
        float[] hsv = new float[3];
        android.graphics.Color.colorToHSV(color, hsv);
        hsv[2] *= 0.8f;
        return android.graphics.Color.HSVToColor(hsv);
    }
    @ColorInt int darkenColor20(@ColorInt int color) {
        float[] hsv = new float[3];
        android.graphics.Color.colorToHSV(color, hsv);
        hsv[2] *= 0.6f;
        return android.graphics.Color.HSVToColor(hsv);
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.SharedPreferences;
import android.database.Cursor;
import android.preference.PreferenceManager;
import android.text.format.Time;
import android.util.Log;

import com.google.android.apps.dashclock.api.DashClockExtension;
import com.google.android.apps.dashclock.api.ExtensionData;
@@ -277,6 +278,7 @@ public class TasksExtension extends DashClockExtension

    private boolean isDueEvent(Cursor c, boolean isAllDay)
    {

        if (c.isNull(c.getColumnIndex(Instances.DUE)))
        {
            return false;
@@ -291,6 +293,7 @@ public class TasksExtension extends DashClockExtension

        if (isAllDay)
        {

            // get start of today in UTC
            Calendar calendar = Calendar.getInstance();
            calendar.set(Calendar.HOUR_OF_DAY, 0); // clear would not reset the hour of day
@@ -322,6 +325,7 @@ public class TasksExtension extends DashClockExtension

    private Cursor loadPinnedTaskCursor()
    {

        return getContentResolver().query(Instances.getContentUri(mAuthority), INSTANCE_PROJECTION, INSTANCE_PINNED_SELECTION, null,
                Tasks.PRIORITY + " is not null, " + Tasks.PRIORITY + " DESC");
    }
@@ -329,6 +333,7 @@ public class TasksExtension extends DashClockExtension

    private Cursor loadRecentDueTaskCursor()
    {

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR_OF_DAY, RECENT_HOURS); // clear would not reset the hour of day
        long later = calendar.getTimeInMillis();
@@ -340,6 +345,7 @@ public class TasksExtension extends DashClockExtension

    private Cursor loadRecentStartTaskCursor()
    {

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR_OF_DAY, RECENT_HOURS); // clear would not reset the hour of day
        long later = calendar.getTimeInMillis();
@@ -351,6 +357,7 @@ public class TasksExtension extends DashClockExtension

    private Cursor loadRecentStartDueTaskCursor()
    {

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR_OF_DAY, RECENT_HOURS); // clear would not reset the hour of day
        long later = calendar.getTimeInMillis();
@@ -363,6 +370,7 @@ public class TasksExtension extends DashClockExtension

    private Cursor loadAllDayTasksDueTodayCursor()
    {

        // get start of today in UTC
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0); // clear would not reset the hour of day
@@ -379,6 +387,7 @@ public class TasksExtension extends DashClockExtension

    private Cursor loadAllDayTasksStartTodayCursor()
    {

        // get start of today in UTC
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0); // clear would not reset the hour of day
@@ -395,6 +404,7 @@ public class TasksExtension extends DashClockExtension

    private Cursor loadAllDayTasksStartDueTodayCursor()
    {

        // get start of today in UTC
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0); // clear would not reset the hour of day
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.widget.TextView;
import org.dmfs.jems.optional.elementary.NullSafe;
import org.dmfs.jems.single.combined.Backed;
import org.dmfs.tasks.R;
import org.dmfs.tasks.TaskListActivity;
import org.dmfs.tasks.contract.TaskContract.Instances;
import org.dmfs.tasks.groupings.cursorloaders.TimeRangeCursorFactory;
import org.dmfs.tasks.groupings.cursorloaders.TimeRangeCursorLoaderFactory;
@@ -179,6 +180,7 @@ public class ByDueDate extends AbstractGroupingFactory
            if (title != null)
            {
                title.setText(getTitle(cursor, view.getContext()));
                title.setTextColor(TaskListActivity.ACCENT_COLOR);
            }

            // set list elements
Loading