Better text and explanations when there are no tasks

Some code refactoring
This commit is contained in:
BONNEVILLE Geoffroy
2017-12-27 16:41:21 +01:00
parent 6778ec7904
commit b2afcea97e
18 changed files with 133 additions and 69 deletions

View File

@@ -1,8 +1,6 @@
package com.wismna.geoffroy.donext.activities;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import com.wismna.geoffroy.donext.R;
@@ -10,17 +8,12 @@ import com.wismna.geoffroy.donext.R;
* Created by gbe on 17-12-19.
* History Activity class
*/
public class HistoryActivity extends AppCompatActivity {
public class HistoryActivity extends ToolBarActivityBase {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
ActionBar toolbar = getSupportActionBar();
// Show back button on toolbar
assert toolbar != null;
toolbar.setDisplayHomeAsUpEnabled(true);
toolbar.setDisplayShowHomeEnabled(true);
initToolBar();
}
}

View File

@@ -1,41 +1,51 @@
package com.wismna.geoffroy.donext.activities;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import com.wismna.geoffroy.donext.R;
import com.wismna.geoffroy.donext.adapters.TaskRecyclerViewAdapter;
import com.wismna.geoffroy.donext.database.TaskDataAccess;
import com.wismna.geoffroy.donext.fragments.TodayFormDialogFragment;
public class TodayActivity extends AppCompatActivity
import org.joda.time.LocalDate;
import java.util.Locale;
public class TodayActivity extends ToolBarActivityBase
implements TodayFormDialogFragment.TodayTaskListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_today);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
initToolBar();
// Get a support ActionBar corresponding to this toolbar
ActionBar ab = getSupportActionBar();
// Show the date
TextView date = findViewById(R.id.today_date);
date.setText(LocalDate.now().toString("EEEE, dd MMMM yyyy", getCurrentLocale()));
if (ab != null) {
// Enable the Up button
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeButtonEnabled(true);
}
// Set the no tasks texts
TextView noTasks = findViewById(R.id.no_more_tasks);
noTasks.setText(R.string.today_no_tasks);
noTasks.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_smiley_satisfied_light, 0);
noTasks.setCompoundDrawablePadding(10);
TextView createTasks = findViewById(R.id.create_tasks);
createTasks.setText(R.string.today_create_tasks);
}
@Override
@@ -44,6 +54,22 @@ public class TodayActivity extends AppCompatActivity
return true;
}
@Override
public void onTodayTaskDialogPositiveClick(View dialogView) {
FloatingActionButton fab = findViewById(R.id.fab);
fab.setEnabled(false);
}
@Override
public void onTodayTasksUpdated() {
FloatingActionButton fab = findViewById(R.id.fab);
fab.setEnabled(true);
try (TaskDataAccess taskDataAccess = new TaskDataAccess(this)) {
RecyclerView recyclerView = findViewById(R.id.task_list_view);
((TaskRecyclerViewAdapter)recyclerView.getAdapter()).setItems(taskDataAccess.getTodayTasks());
}
}
/** Called when the user clicks on the Change Layout button */
public void changeLayout(MenuItem item) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
@@ -58,7 +84,6 @@ public class TodayActivity extends AppCompatActivity
this.recreate();
}
public void onNewTaskClick(View view) {
TodayFormDialogFragment taskDialogFragment =
TodayFormDialogFragment.newInstance(TodayActivity.this);
@@ -77,19 +102,13 @@ public class TodayActivity extends AppCompatActivity
taskDialogFragment.showFragment(fragmentManager, title, getResources().getBoolean(R.bool.large_layout));
}
@Override
public void onTodayTaskDialogPositiveClick(View dialogView) {
FloatingActionButton fab = findViewById(R.id.fab);
fab.setEnabled(false);
}
@Override
public void onTodayTasksUpdated() {
FloatingActionButton fab = findViewById(R.id.fab);
fab.setEnabled(true);
try (TaskDataAccess taskDataAccess = new TaskDataAccess(this)) {
RecyclerView recyclerView = findViewById(R.id.task_list_view);
((TaskRecyclerViewAdapter)recyclerView.getAdapter()).setItems(taskDataAccess.getTodayTasks());
private Locale getCurrentLocale(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
return getResources().getConfiguration().getLocales().get(0);
} else{
//noinspection deprecation
return getResources().getConfiguration().locale;
}
}
}

View File

@@ -0,0 +1,20 @@
package com.wismna.geoffroy.donext.activities;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
/**
* Created by GBE on 27/12/2017.
* Defines a template for sub activities
*/
public abstract class ToolBarActivityBase extends AppCompatActivity {
protected void initToolBar() {
ActionBar toolbar = getSupportActionBar();
// Show back button on toolbar
assert toolbar != null;
toolbar.setDisplayHomeAsUpEnabled(true);
toolbar.setDisplayShowHomeEnabled(true);
}
}

View File

@@ -197,12 +197,15 @@ public class TasksFragment extends Fragment implements
int totalTasks = taskRecyclerViewAdapter.getItemCount();
TextView totalTasksView = view.findViewById(R.id.total_task_count);
View noMoreTasks = view.findViewById(R.id.no_more_tasks);
View createTasks = view.findViewById(R.id.create_tasks);
if (totalTasks == 0) {
noMoreTasks.setVisibility(View.VISIBLE);
createTasks.setVisibility(View.VISIBLE);
totalTasksView.setVisibility(View.GONE);
}
else {
noMoreTasks.setVisibility(View.GONE);
createTasks.setVisibility(View.GONE);
totalTasksView.setVisibility(View.VISIBLE);
totalTasksView.setText(resources.getQuantityString(R.plurals.task_total, totalTasks, totalTasks));
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -14,20 +14,6 @@
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".activities.MainActivity">
<TextView
android:id="@+id/new_task_list_label"
android:text="@string/new_task_list"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/new_task_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_toEndOf="@id/new_task_list_label">
</Spinner>
<EditText
android:id="@+id/new_task_name"
android:hint="@string/new_task_name_hint"
@@ -36,7 +22,6 @@
android:textSize="30sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_list"
android:imeOptions="flagNoFullscreen"/>
<EditText
android:id="@+id/new_task_description"
@@ -116,5 +101,21 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_due_date_label" />
<TextView
android:id="@+id/new_task_list_label"
android:text="@string/new_task_list"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_due_date" />
<Spinner
android:id="@+id/new_task_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/new_task_due_date"
android:layout_alignParentEnd="true">
</Spinner>
</com.wismna.geoffroy.donext.widgets.InterceptTouchRelativeLayout>
</ScrollView>

View File

@@ -12,7 +12,13 @@
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<include layout="@layout/toolbar" android:id="@+id/toolbar" />
<TextView
android:id="@+id/today_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textAlignment="center"
android:textSize="24sp"/>
</android.support.design.widget.AppBarLayout>
<fragment

View File

@@ -14,20 +14,6 @@
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".activities.MainActivity">
<TextView
android:id="@+id/new_task_list_label"
android:text="@string/new_task_list"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/new_task_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_toEndOf="@id/new_task_list_label">
</Spinner>
<EditText
android:id="@+id/new_task_name"
android:hint="@string/new_task_name_hint"
@@ -36,7 +22,6 @@
android:textSize="30sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_list"
android:imeOptions="flagNoFullscreen"/>
<EditText
android:id="@+id/new_task_description"
@@ -115,5 +100,21 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_due_date_label" />
<TextView
android:id="@+id/new_task_list_label"
android:text="@string/new_task_list"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_due_date" />
<Spinner
android:id="@+id/new_task_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/new_task_due_date"
android:layout_alignParentEnd="true">
</Spinner>
</com.wismna.geoffroy.donext.widgets.InterceptTouchRelativeLayout>
</ScrollView>

View File

@@ -18,10 +18,25 @@
<TextView
android:id="@+id/no_more_tasks"
android:text="@string/task_no_tasks"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center"
android:gravity="center_vertical"
android:visibility="gone"/>
<TextView
android:id="@+id/create_tasks"
android:text="@string/create_tasks"
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_marginBottom="30dp"
android:drawableEnd="@drawable/ic_arrow_right_light"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:visibility="gone"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/task_list_view"

View File

@@ -12,7 +12,7 @@
<string name="new_task_cancel">Annuler</string>
<string name="new_task_delete">Supprimer</string>
<string name="new_task_description_hint">Description de la tâche (optionnel)</string>
<string name="new_task_list">Liste</string>
<string name="new_task_list">Ajouter à la liste</string>
<string name="new_task_name_error">Le nom de la tâche ne peut pas être vide</string>
<string name="new_task_name_hint">Nom de la tâche</string>
<string name="new_task_priority">Priorité</string>
@@ -46,7 +46,7 @@
<string name="task_list_new_list_error">Le nom de la liste ne peut pas être vide</string>
<string name="task_list_new_list_hint">Nom de la liste</string>
<string name="task_list_no_lists">Créer une nouvelle liste de tâches</string>
<string name="task_no_tasks">Super! Aucune tâche en cours!</string>
<string name="task_no_tasks">Aucune tâche !</string>
<string name="settings_today_title">Vue Aujourd\'hui</string>
<string name="settings_today_enable">Activer la vue Aujourd\'hui?</string>
<string name="settings_today_desc">La vue Aujourd\'hui est une façon particulière d\'organiser vos tâches. Choisissez quelles tâches vous voulez faire dans la journée et elles apparaîtront dans cette vue. À la fin de la journée, cette vue est réinitialisée.</string>
@@ -66,4 +66,7 @@
<string name="donext_description">DoNext est un nouveau genre de gestionnaire de tâches, basé sur le principe que créer trop de tâches est contre-productif. Faites plutôt glisser vos tâches vers la gauche ou la droite pour les mettre à la fin de votre liste et travailler dessus plus tard !</string>
<string name="default_task_list_name">Mes tâches</string>
<string name="task_list_edit">Editer les listes de tâches</string>
<string name="today_no_tasks">Rien à faire aujourd\'hui</string>
<string name="create_tasks">Créez-en une là</string>
<string name="today_create_tasks">Ajoutez des tâches là</string>
</resources>

View File

@@ -7,6 +7,7 @@
<string name="action_new_task">New task</string>
<string name="action_edit_task">Edit</string>
<string name="action_changeLayout">Change layout</string>
<string name="action_history">History</string>
<!-- Strings related to tabs -->
<string name="tab_left_arrow">Left scroll arrow</string>
@@ -24,7 +25,7 @@
<string name="task_list_ok">OK</string>
<!-- Strings related to new task dialog -->
<string name="new_task_list">List</string>
<string name="new_task_list">Add to list</string>
<string name="new_task_name_hint">New task name</string>
<string name="new_task_name_error">Task name cannot be blank</string>
<string name="new_task_description_hint">Optional task description</string>
@@ -35,8 +36,9 @@
<string name="new_task_delete">Delete</string>
<!-- Strings related to task details activity -->
<string name="task_no_tasks">Yay! No more tasks!</string>
<string name="task_no_tasks">No tasks here!</string>
<string name="task_alarm">Task is past due date</string>
<string name="create_tasks">Create one there</string>
<!-- String related to the SnackBar -->
<string name="snackabar_label">Task %s</string>
@@ -82,7 +84,8 @@
<string name="action_today_select">Select tasks</string>
<string name="task_list_edit_list_hint">List name</string>
<string name="incompatible_sdk_version">Sorry, your Android version is not supported.</string>
<string name="action_history">History</string>
<string name="today_no_tasks">Noting to do today</string>
<string name="today_create_tasks">Add some tasks there</string>
<!-- String related to History -->
<string name="title_activity_history">History</string>