Skip to content

Commit 379c06a

Browse files
author
Gabor Keszthelyi
committed
Show subtasks on details view. #442
1 parent 9b0f528 commit 379c06a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1383
-36
lines changed

.idea/dictionaries/dictionary.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ CONTENTPAL_VERSION=fc8cca91
88
ROBOLECTRIC_VERSION=3.1.4
99
JEMS_VERSION=1.13
1010
ANDROID_TEST_RUNNER_VERSION=0.5
11+
BOLTS_VERSION=a43822b

opentasks-provider/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies {
3838
}
3939
compile 'org.dmfs:jems:' + JEMS_VERSION
4040
androidTestCompile 'com.android.support:support-annotations:' + SUPPORT_LIBRARY_VERSION
41-
androidTestCompile 'com.android.support.test:runner:0.5'
42-
androidTestCompile 'com.android.support.test:rules:0.5'
41+
androidTestCompile 'com.android.support.test:runner:' + ANDROID_TEST_RUNNER_VERSION
42+
androidTestCompile 'com.android.support.test:rules:' + ANDROID_TEST_RUNNER_VERSION
4343
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
4444
}

opentasks/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ android {
4242
sourceCompatibility JavaVersion.VERSION_1_7
4343
targetCompatibility JavaVersion.VERSION_1_7
4444
}
45+
dataBinding {
46+
enabled = true
47+
}
4548
}
4649

4750
dependencies {
@@ -52,6 +55,7 @@ dependencies {
5255
exclude group: 'xmlpull', module: 'xmlpull'
5356
}
5457
compile project(':opentasks-provider')
58+
compile project(':opentaskspal')
5559
compile 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
5660
compile 'com.github.dmfs:color-picker:1.0'
5761
compile ('au.com.codeka:carrot:2.4.0'){
@@ -64,6 +68,9 @@ dependencies {
6468
exclude module: 'jems'
6569
}
6670
compile 'org.dmfs:jems:' + JEMS_VERSION
71+
compile 'io.reactivex.rxjava2:rxjava:2.1.5'
72+
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
73+
compile 'com.github.dmfs.bolts:color-bolts:' + BOLTS_VERSION
6774

6875
testCompile 'junit:junit:4.12'
6976

opentasks/proguard.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,7 @@
7777
java.lang.String TAG;
7878
@org.dmfs.android.retentionmagic.annotations.* <fields>;
7979
private long mId;
80-
}
80+
}
81+
82+
-dontwarn android.databinding.**
83+
-keep class android.databinding.** { *; }

opentasks/src/main/AndroidManifest.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="org.dmfs.tasks">
45

56
<uses-permission android:name="org.dmfs.permission.READ_TASKS"/>
@@ -11,12 +12,16 @@
1112
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
1213
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
1314

15+
<!--TODO Remove after https://github.com/dmfs/opentasks/issues/392-->
16+
<uses-sdk tools:overrideLibrary="org.dmfs.android.bolts"/>
17+
1418
<application
1519
android:icon="@drawable/ic_launcher"
1620
android:label="@string/app_name"
1721
android:name=".TasksApplication"
1822
android:taskAffinity="org.dmfs.tasks.TaskListActivity"
19-
android:theme="@style/OpenTasksAppTheme">
23+
android:theme="@style/OpenTasksAppTheme"
24+
android:supportsRtl="false">
2025

2126
<!-- TaskListActivity listens for MAIN intents -->
2227
<activity

opentasks/src/main/java/org/dmfs/tasks/EditTaskFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.dmfs.tasks.model.OnContentChangeListener;
6161
import org.dmfs.tasks.model.Sources;
6262
import org.dmfs.tasks.model.TaskFieldAdapters;
63+
import org.dmfs.tasks.utils.BasicTaskDetailsUi;
6364
import org.dmfs.tasks.utils.ContentValueMapper;
6465
import org.dmfs.tasks.utils.OnModelLoadedListener;
6566
import org.dmfs.tasks.utils.RecentlyUsedLists;
@@ -809,7 +810,7 @@ public void saveAndExit()
809810
activity.finish();
810811
if (isNewTask)
811812
{
812-
activity.startActivity(new Intent("android.intent.action.VIEW", mTaskUri));
813+
new BasicTaskDetailsUi(mTaskUri).show(activity);
813814
}
814815
}
815816
else

opentasks/src/main/java/org/dmfs/tasks/ViewTaskActivity.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import android.annotation.SuppressLint;
2020
import android.content.Intent;
21-
import android.graphics.Color;
2221
import android.net.Uri;
2322
import android.os.Build.VERSION;
2423
import android.os.Bundle;
@@ -30,6 +29,7 @@
3029

3130
import org.dmfs.tasks.model.ContentSet;
3231
import org.dmfs.tasks.utils.BaseActivity;
32+
import org.dmfs.tasks.utils.Darkened;
3333

3434

3535
/**
@@ -132,16 +132,6 @@ public void onDelete(Uri taskUri)
132132
}
133133

134134

135-
private int darkenColor(int color)
136-
{
137-
float[] hsv = new float[3];
138-
Color.colorToHSV(color, hsv);
139-
hsv[2] = hsv[2] * 0.75f;
140-
color = Color.HSVToColor(hsv);
141-
return color;
142-
}
143-
144-
145135
@SuppressLint("NewApi")
146136
@Override
147137
public void updateColor(int color)
@@ -151,7 +141,7 @@ public void updateColor(int color)
151141
{
152142
Window window = getWindow();
153143
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
154-
window.setStatusBarColor(darkenColor(color));
144+
window.setStatusBarColor(new Darkened(color).argb());
155145
}
156146
}
157147

opentasks/src/main/java/org/dmfs/tasks/ViewTaskFragment.java

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@
5252
import android.view.animation.AlphaAnimation;
5353
import android.widget.TextView;
5454

55+
import org.dmfs.android.contentpal.RowDataSnapshot;
5556
import org.dmfs.android.retentionmagic.SupportFragment;
5657
import org.dmfs.android.retentionmagic.annotations.Parameter;
5758
import org.dmfs.android.retentionmagic.annotations.Retain;
59+
import org.dmfs.tasks.contract.TaskContract;
5860
import org.dmfs.tasks.contract.TaskContract.Tasks;
61+
import org.dmfs.tasks.data.SubtasksSource;
5962
import org.dmfs.tasks.model.ContentSet;
6063
import org.dmfs.tasks.model.Model;
6164
import org.dmfs.tasks.model.OnContentChangeListener;
@@ -64,13 +67,18 @@
6467
import org.dmfs.tasks.notification.TaskNotificationHandler;
6568
import org.dmfs.tasks.share.ShareIntentFactory;
6669
import org.dmfs.tasks.utils.ContentValueMapper;
70+
import org.dmfs.tasks.utils.Darkened;
6771
import org.dmfs.tasks.utils.OnModelLoadedListener;
72+
import org.dmfs.tasks.widget.SubtasksView;
6873
import org.dmfs.tasks.widget.TaskView;
6974

7075
import java.util.Arrays;
7176
import java.util.HashSet;
7277
import java.util.Set;
7378

79+
import io.reactivex.disposables.CompositeDisposable;
80+
import io.reactivex.functions.Consumer;
81+
7482

7583
/**
7684
* A fragment representing a single Task detail screen. This fragment is either contained in a {@link TaskListActivity} in two-pane mode (on tablets) or in a
@@ -131,6 +139,8 @@ public class ViewTaskFragment extends SupportFragment
131139
*/
132140
private TaskView mDetailView;
133141

142+
private CompositeDisposable mDisposables;
143+
134144
private int mListColor;
135145
private int mOldStatus = -1;
136146
private boolean mPinned = false;
@@ -208,14 +218,6 @@ public static ViewTaskFragment newInstance(Uri uri)
208218
}
209219

210220

211-
/**
212-
* Mandatory empty constructor for the fragment manager to instantiate the fragment (e.g. upon screen orientation changes).
213-
*/
214-
public ViewTaskFragment()
215-
{
216-
}
217-
218-
219221
@Override
220222
public void onCreate(Bundle savedInstanceState)
221223
{
@@ -266,6 +268,7 @@ public void onDestroyView()
266268
mDetailView.setValues(null);
267269
}
268270

271+
mDisposables.dispose();
269272
}
270273

271274

@@ -320,6 +323,8 @@ else if (mTaskUri != null)
320323
loadUri(uri);
321324
}
322325

326+
mDisposables = new CompositeDisposable();
327+
323328
return mRootView;
324329
}
325330

@@ -401,7 +406,11 @@ public void loadUri(Uri uri)
401406
if ((oldUri == null) != (uri == null))
402407
{
403408
/*
409+
<<<<<<< HEAD
404410
* getActivity().invalidateOptionsMenu() doesn't work in Android 2.x so use the compat lib
411+
=======
412+
* getActivity().invalidateOptionsMenu() doesn't work in Android 2.x so use the compat lib
413+
>>>>>>> bb000fc... Show subtasks on details view. #442
405414
*/
406415
ActivityCompat.invalidateOptionsMenu(getActivity());
407416
}
@@ -492,7 +501,11 @@ public void onModelLoaded(Model model)
492501
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
493502
{
494503
/*
504+
<<<<<<< HEAD
495505
* Don't show any options if we don't have a task to show.
506+
=======
507+
* Don't show any options if we don't have a task to show.
508+
>>>>>>> bb000fc... Show subtasks on details view. #442
496509
*/
497510
if (mTaskUri != null)
498511
{
@@ -717,6 +730,23 @@ public void onContentLoaded(ContentSet contentSet)
717730
postUpdateView();
718731
}
719732
}
733+
734+
mDisposables.add(
735+
new SubtasksSource(mAppContext, mTaskUri)
736+
.subscribe(new Consumer<Iterable<RowDataSnapshot<TaskContract.Tasks>>>()
737+
{
738+
@Override
739+
public void accept(Iterable<RowDataSnapshot<TaskContract.Tasks>> subTasks)
740+
{
741+
if (subTasks.iterator().hasNext())
742+
{
743+
new SubtasksView(mContent).update(subTasks);
744+
((TextView) mContent.findViewById(R.id.opentasks_view_item_task_details_subtitles_section_header))
745+
.setTextColor(new Darkened(mListColor).argb());
746+
mContent.requestLayout();
747+
}
748+
}
749+
}));
720750
}
721751

722752

0 commit comments

Comments
 (0)