All strings put in string.xml

Long press does not drag task lists anymore
Create task list button is themed
Arrows are shown in the scrollable tabs
Task form is now inside a scrollview (needs testing)
Total cycles is now correctly reset when there are no more tasks
This commit is contained in:
2016-01-25 17:42:14 -05:00
parent dd67ff4421
commit c810f3775a
13 changed files with 215 additions and 91 deletions

View File

@@ -8,8 +8,8 @@ android {
applicationId "com.wismna.geoffroy.donext"
minSdkVersion 15
targetSdkVersion 23
versionCode 7
versionName "0.7"
versionCode 8
versionName "0.8"
}
buildTypes {
release {

View File

@@ -14,12 +14,13 @@
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.SettingsActivity"
android:label="@string/settings_activity_title"
android:label="@string/action_settings"
android:parentActivityName=".activities.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
@@ -33,6 +34,14 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.MainActivity" />
</activity>
<activity
android:name=".activities.AboutActivity"
android:label="@string/action_about"
android:parentActivityName=".activities.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.MainActivity" />
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,20 @@
package com.wismna.geoffroy.donext.activities;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import com.wismna.geoffroy.donext.BuildConfig;
import com.wismna.geoffroy.donext.R;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
TextView version = (TextView) findViewById(R.id.version);
version.setText(getResources().getString(R.string.about_version, BuildConfig.VERSION_NAME));
}
}

View File

@@ -2,6 +2,7 @@ package com.wismna.geoffroy.donext.activities;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Point;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
@@ -79,8 +80,26 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
mViewPager.setCurrentItem(sharedPref.getInt("last_opened_tab", 0));
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
// TODO: hide arrows on start when not needed
final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
tabLayout.setOnScrollChangeListener(new View.OnScrollChangeListener() {
@Override
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
// Hide left arrow when scrolled to the left
View leftArrow = findViewById(R.id.left_arrow);
if (scrollX <= 1) leftArrow.setVisibility(View.GONE);
else leftArrow.setVisibility(View.VISIBLE);
// Hide right arrow when scrolled to the right
View rightArrow = findViewById(R.id.right_arrow);
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
if (scrollX == tabLayout.getChildAt(0).getMeasuredWidth() - size.x)
rightArrow.setVisibility(View.GONE);
else rightArrow.setVisibility(View.VISIBLE);
}
});
// Hide or show new task floating button
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
@@ -183,6 +202,12 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
startActivity(intent);
}
/** Called when the user clicks the About button */
public void openAbout(MenuItem menuItem) {
Intent intent = new Intent(this, AboutActivity.class);
startActivity(intent);
}
private TaskRecyclerViewAdapter getSpecificTabAdapter(int position) {
TasksFragment taskFragment = (TasksFragment) mSectionsPagerAdapter.getRegisteredFragment(position);
if (taskFragment == null) return null;

View File

@@ -3,6 +3,7 @@ package com.wismna.geoffroy.donext.fragments;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
@@ -122,7 +123,7 @@ public class TasksFragment extends Fragment implements
((MainActivity.SectionsPagerAdapter) viewPager.getAdapter()).getAllItems(), TasksFragment.this);
taskDialogFragment.setArguments(args);
taskDialogFragment.show(manager, "Edit task");
taskDialogFragment.show(manager, getResources().getString(R.string.action_edit_task));
}
})
);
@@ -131,27 +132,29 @@ public class TasksFragment extends Fragment implements
recyclerView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
// isAdded is tested to prevent an IllegalStateException when fast switching between tabs
if (!isAdded()) return true;
Resources resources = getResources();
// Update total cycle count
int totalCycles = taskRecyclerViewAdapter.getCycleCount();
if (totalCycles != 0) {
TextView totalCyclesView = (TextView) view.findViewById(R.id.total_task_cycles);
totalCyclesView.setText(String.valueOf(totalCycles + " cycles"));
}
TextView totalCyclesView = (TextView) view.findViewById(R.id.total_task_cycles);
if (totalCycles != 0)
totalCyclesView.setText(resources.getString(R.string.task_total_cycles, totalCycles, (totalCycles > 1 ? "s" : "")));
else totalCyclesView.setText("");
// Update total tasks
int totalTasks = taskRecyclerViewAdapter.getItemCount();
TextView totalTasksView = (TextView) view.findViewById(R.id.total_task_count);
// isAdded is to prevent an IllegalStateException when fast switching between tabs
if (totalTasks == 0 && isAdded()) totalTasksView.setText(getResources().getText(R.string.task_no_tasks));
else totalTasksView.setText(String.valueOf(totalTasks + " task" + (totalTasks > 1 ? "s" : "")));
if (totalTasks == 0) totalTasksView.setText(resources.getText(R.string.task_no_tasks));
else totalTasksView.setText(resources.getString(R.string.task_total, totalTasks, (totalTasks > 1 ? "s" : "")));
// Update remaining tasks
TextView remainingTasksView = (TextView) view.findViewById(R.id.remaining_task_count);
NoScrollingLayoutManager layoutManager = (NoScrollingLayoutManager) recyclerView.getLayoutManager();
int remainingTaskCount = totalTasks - layoutManager.findLastVisibleItemPosition() - 1;
if (remainingTaskCount == 0) remainingTasksView.setText("");
else remainingTasksView.setText(String.valueOf(
remainingTaskCount + " more task" + (remainingTaskCount > 1 ? "s" : "")));
else remainingTasksView.setText(resources.getString(R.string.task_remaining, remainingTaskCount, (remainingTaskCount > 1 ? "s" : "")));
//recyclerView.getViewTreeObserver().removeOnPreDrawListener(this);
return true;
@@ -180,28 +183,30 @@ public class TasksFragment extends Fragment implements
final long itemId = taskRecyclerViewAdapter.getItemId(itemPosition);
final Task task = taskRecyclerViewAdapter.getItem(itemPosition);
String action = "";
Resources resources = getResources();
taskRecyclerViewAdapter.remove(itemPosition);
switch (direction)
{
// Mark item as Done
case ItemTouchHelper.LEFT:
action = "done";
action = resources.getString(R.string.snackabar_action_done);
break;
// Increase task cycle count
case ItemTouchHelper.RIGHT:
action = "nexted";
action = resources.getString(R.string.snackabar_action_next);
task.setCycle(task.getCycle() + 1);
taskRecyclerViewAdapter.add(task, taskRecyclerViewAdapter.getItemCount());
break;
case -1:
action = "deleted";
action = resources.getString(R.string.snackabar_action_deleted);
break;
}
// Setup the snack bar
snackbar = Snackbar.make(view, "Task " + action, Snackbar.LENGTH_LONG)
.setAction("Undo", new View.OnClickListener() {
snackbar = Snackbar.make(view, resources.getString(R.string.snackabar_label, action), Snackbar.LENGTH_LONG)
.setAction(resources.getString(R.string.snackabar_button), new View.OnClickListener() {
@Override
public void onClick(View v) {
// Undo adapter changes
@@ -231,6 +236,7 @@ public class TasksFragment extends Fragment implements
// When clicked on undo, do not write to DB
if (event == DISMISS_EVENT_ACTION) return;
// TODO: correct bug when fast switching between tabs
// Commit the changes to DB
switch (direction)
{

View File

@@ -33,7 +33,7 @@ public class TaskListTouchHelper extends ItemTouchHelper.SimpleCallback {
@Override
public boolean isLongPressDragEnabled() {
return true;
return false;
}
@Override

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.wismna.geoffroy.donext.activities.AboutActivity">
<TextView
android:id="@+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

View File

@@ -23,12 +23,33 @@
app:layout_scrollFlags="enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/left_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:contentDescription="@string/tab_left_arrow"
android:src="@drawable/ic_keyboard_arrow_left_white_24dp" />
<ImageView
android:id="@+id/right_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:contentDescription="@string/tab_right_arrow"
android:src="@drawable/ic_keyboard_arrow_right_white_24dp" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable" />
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<com.wismna.geoffroy.donext.widgets.NonSwipeableViewPager

View File

@@ -1,70 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="@dimen/text_margin"
android:orientation="vertical"
tools:context=".activities.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/new_task_list"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/new_task_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_task_name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/new_task_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/new_task_name_hint" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_task_description"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/new_task_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/new_task_description_hint"
android:gravity="top|start"
android:lines="3"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/new_task_priority"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RadioGroup
android:id="@+id/new_task_priority"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/new_task_priority_low"
android:text="@string/new_task_priority_low"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</RadioButton>
<RadioButton
android:id="@+id/new_task_priority_normal"
android:text="@string/new_task_priority_normal"
android:padding="@dimen/text_margin"
android:orientation="vertical"
tools:context=".activities.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_task_list"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/new_task_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_task_name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/new_task_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true">
</RadioButton>
<RadioButton
android:id="@+id/new_task_priority_high"
android:text="@string/new_task_priority_high"
android:hint="@string/new_task_name_hint" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_task_description"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/new_task_description"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</RadioButton>
</RadioGroup>
</LinearLayout>
android:layout_height="wrap_content"
android:hint="@string/new_task_description_hint"
android:gravity="top|start"
android:lines="3"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/new_task_priority"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RadioGroup
android:id="@+id/new_task_priority"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/new_task_priority_low"
android:text="@string/new_task_priority_low"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</RadioButton>
<RadioButton
android:id="@+id/new_task_priority_normal"
android:text="@string/new_task_priority_normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true">
</RadioButton>
<RadioButton
android:id="@+id/new_task_priority_high"
android:text="@string/new_task_priority_high"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</RadioButton>
</RadioGroup>
</LinearLayout>
</ScrollView>

View File

@@ -27,6 +27,7 @@
android:id="@+id/new_task_list_button"
android:layout_width="80dp"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.Button.Colored"
android:text="@string/task_list_new_list_create"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView

View File

@@ -32,5 +32,6 @@
android:id="@+id/action_about"
android:orderInCategory="40"
android:title="@string/action_about"
android:onClick="openAbout"
app:showAsAction="never" />
</menu>

View File

@@ -6,8 +6,12 @@
<string name="action_editTabs">Edit lists</string>
<string name="action_about">About</string>
<string name="action_new_task">New task</string>
<string name="action_edit_task">Edit task</string>
<string name="action_changeLayout">Change layout</string>
<string name="settings_activity_title">Settings</string>
<!-- Strings related to tabs -->
<string name="tab_left_arrow">Left scroll arrow</string>
<string name="tab_right_arrow">Right scroll arrow</string>
<!-- Strings related to Task List edition -->
<string name="task_list_new_list_hint">New list name</string>
@@ -35,6 +39,16 @@
<!-- Strings related to task details activity -->
<string name="task_details_activity_title">Details</string>
<string name="task_no_tasks">Yeah! No more tasks!</string>
<string name="task_total_cycles">%1$d cycle%2$s</string>
<string name="task_total">%1$d task%2$s</string>
<string name="task_remaining">%1$d more task%2$s</string>
<!-- String related to the SnackBar -->
<string name="snackabar_label">Task %s</string>
<string name="snackabar_action_done">done</string>
<string name="snackabar_action_next">nexted</string>
<string name="snackabar_action_deleted">deleted</string>
<string name="snackabar_button">Undo</string>
<!-- Strings related to the confirmation dialog -->
<string name="task_confirmation_done_text">Mark task as Done?</string>
@@ -74,4 +88,7 @@
<item>7</item>
</string-array>
<string name="title_activity_task_list">TaskListActivity</string>
<!-- Strings related to About -->
<string name="about_version">Version %s</string>
</resources>

View File

@@ -17,4 +17,8 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="ButtonTheme" parent="android:Widget.Button">
<item name="android:textColor">@color/colorAccent</item>
<item name="android:background">@color/colorPrimary</item>
</style>
</resources>