From cb29478e7101ecf11847a3a24291e0a19412f997 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Tue, 3 Mar 2020 08:01:48 -0600 Subject: [PATCH] Fix two pane layout --- .../todoroo/astrid/activity/MainActivity.java | 2 +- .../org/tasks/ui/EmptyTaskEditFragment.kt | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/todoroo/astrid/activity/MainActivity.java b/app/src/main/java/com/todoroo/astrid/activity/MainActivity.java index 4e505f575..7a30f6362 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/MainActivity.java +++ b/app/src/main/java/com/todoroo/astrid/activity/MainActivity.java @@ -266,7 +266,7 @@ public class MainActivity extends InjectingAppCompatActivity private void hideDetailFragment() { getSupportFragmentManager() .beginTransaction() - .replace(R.id.detail, new EmptyTaskEditFragment()) + .replace(R.id.detail, EmptyTaskEditFragment.Companion.newEmptyTaskEditFragment(filter)) .commit(); if (isSinglePaneLayout()) { diff --git a/app/src/main/java/org/tasks/ui/EmptyTaskEditFragment.kt b/app/src/main/java/org/tasks/ui/EmptyTaskEditFragment.kt index b9d0056ec..2142936d0 100644 --- a/app/src/main/java/org/tasks/ui/EmptyTaskEditFragment.kt +++ b/app/src/main/java/org/tasks/ui/EmptyTaskEditFragment.kt @@ -4,22 +4,43 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import com.todoroo.astrid.api.Filter import org.tasks.databinding.FragmentTaskEditEmptyBinding import org.tasks.injection.FragmentComponent import org.tasks.injection.InjectingFragment import org.tasks.themes.ThemeColor +import org.tasks.themes.ThemeColor.newThemeColor import javax.inject.Inject class EmptyTaskEditFragment : InjectingFragment() { @Inject lateinit var themeColor: ThemeColor + companion object { + const val EXTRA_FILTER = "extra_filter" + + fun newEmptyTaskEditFragment(filter: Filter): EmptyTaskEditFragment { + val arguments = Bundle() + arguments.putParcelable(EXTRA_FILTER, filter) + val fragment = EmptyTaskEditFragment() + fragment.arguments = arguments + return fragment + } + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { val binding = FragmentTaskEditEmptyBinding.inflate(inflater) - themeColor.apply(binding.toolbar.toolbar) + val tint = arguments?.getParcelable(EXTRA_FILTER)?.tint + + val color = newThemeColor( + context!!, + if (tint == null || tint == 0) themeColor.primaryColor else tint + ) + + color.apply(binding.toolbar.toolbar) return binding.root }