Finished translations (and connected layout issues)

Adds text behind task swipe
This commit is contained in:
2017-02-07 16:55:09 -05:00
committed by bg45
parent 2e0483a3ca
commit 257fbcc67e
9 changed files with 117 additions and 40 deletions

1
DoNExt/.idea/.name generated
View File

@@ -1 +0,0 @@
DoNExt

View File

@@ -1,8 +0,0 @@
<component name="ProjectDictionaryState">
<dictionary name="geoffroy">
<words>
<w>geoffroy</w>
<w>wismna</w>
</words>
</dictionary>
</component>

View File

@@ -5,8 +5,7 @@
<GradleProjectSettings> <GradleProjectSettings>
<option name="distributionType" value="LOCAL" /> <option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.14.1" /> <option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.14.1" />
<option name="gradleJvm" value="1.7" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View File

@@ -8,8 +8,8 @@ android {
applicationId "com.wismna.geoffroy.donext" applicationId "com.wismna.geoffroy.donext"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 25 targetSdkVersion 25
versionCode 11 versionCode 12
versionName "1.0.0" versionName "1.1.0"
} }
buildTypes { buildTypes {
release { release {

View File

@@ -239,7 +239,7 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
*/ */
public class SectionsPagerAdapter extends SmartFragmentStatePagerAdapter { public class SectionsPagerAdapter extends SmartFragmentStatePagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) { SectionsPagerAdapter(FragmentManager fm) {
super(fm); super(fm);
} }

View File

@@ -1,11 +1,18 @@
package com.wismna.geoffroy.donext.helpers; package com.wismna.geoffroy.donext.helpers;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper; import android.support.v7.widget.helper.ItemTouchHelper;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.view.View; import android.view.View;
import com.wismna.geoffroy.donext.R;
/** /**
* Created by geoffroy on 15-12-04. * Created by geoffroy on 15-12-04.
* Helper class that handles all swipe events on a Task * Helper class that handles all swipe events on a Task
@@ -44,30 +51,72 @@ public class TaskTouchHelper extends ItemTouchHelper.SimpleCallback {
@Override @Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
float dX, float dY, int actionState, boolean isCurrentlyActive) { float dX, float dY, int actionState, boolean isCurrentlyActive) {
// TODO: add NEXT and DONE texts while swiping (eventually buttons?) // Get RecyclerView item from the ViewHolder
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { View itemView = viewHolder.itemView;
// Get RecyclerView item from the ViewHolder //View backgroundView = recyclerView.getRootView().findViewById(R.id.task_list_background);
View itemView = viewHolder.itemView; //View textView;
/*if (dX > 0) {
Paint p = new Paint(); textView = recyclerView.getRootView().findViewById(R.id.task_background_next);
p.setARGB(255, 222, 222, 222); } else {
if (dX > 0) { textView = recyclerView.getRootView().findViewById(R.id.task_background_done);
// Set your color for positive displacement
//p.setARGB(255, 204, 229, 255);
// Draw Rect with varying right side, equal to displacement dX
c.drawRect((float) itemView.getLeft(), (float) itemView.getTop(), dX,
(float) itemView.getBottom(), p);
} else {
// Set your color for negative displacement
//p.setARGB(255, 204, 255, 229);
// Draw Rect with varying left side, equal to the item's right side plus negative displacement dX
c.drawRect((float) itemView.getRight() + dX, (float) itemView.getTop(),
(float) itemView.getRight(), (float) itemView.getBottom(), p);
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
} }
//backgroundView.setY(itemView.getTop());
if (isCurrentlyActive) {
backgroundView.setVisibility(View.VISIBLE);
textView.setVisibility(View.VISIBLE);
} else {
backgroundView.setVisibility(View.GONE);
textView.setVisibility(View.GONE);
}*/
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
Paint background = new Paint();
background.setARGB(255, 222, 222, 222);
TextPaint textPaint = new TextPaint();
textPaint.setAntiAlias(true);
textPaint.setTextSize(25 * itemView.getResources().getDisplayMetrics().density);
textPaint.setColor(Color.WHITE);
int heightOffset = 55;
int widthOffset = 30;
// Set your color for positive displacement
if (dX > 0) {
//p.setARGB(255, 204, 229, 255);
// Draw Rect with varying right side, equal to displacement dX
Rect rect = new Rect(itemView.getLeft(), itemView.getTop(), (int) dX,
itemView.getBottom());
c.drawRect(rect, background);
// Draw text in the rectangle
String text = itemView.getResources().getString(R.string.task_confirmation_next_button).toUpperCase();
int width = (int) textPaint.measureText(text);
float textXCoordinate = rect.left + widthOffset;
c.translate(textXCoordinate, dY + heightOffset);
StaticLayout staticLayout = new StaticLayout(text, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0, false);
staticLayout.draw(c);
//textView = recyclerView.getRootView().findViewById(R.id.task_background_next);
} else {
// Set your color for negative displacement
//p.setARGB(255, 204, 255, 229);
// Draw Rect with varying left side, equal to the item's right side plus negative displacement dX
Rect rect = new Rect(itemView.getRight() + (int)dX, itemView.getTop(),
itemView.getRight(), itemView.getBottom());
c.drawRect(rect, background);
// Draw text in the rectangle
String text = itemView.getResources().getString(R.string.task_confirmation_done_button).toUpperCase();
int width = (int) textPaint.measureText(text);
float textXCoordinate = rect.right - width - widthOffset;
c.translate(textXCoordinate, dY + heightOffset);
StaticLayout staticLayout = new StaticLayout(text, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0, false);
staticLayout.draw(c);
//textView = recyclerView.getRootView().findViewById(R.id.task_background_done);
}
//textView.draw(c);
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
} }
/*@Override /*@Override

View File

@@ -25,7 +25,7 @@
android:textAppearance="?android:attr/textAppearanceLarge"/> android:textAppearance="?android:attr/textAppearanceLarge"/>
<Button <Button
android:id="@+id/task_list_delete" android:id="@+id/task_list_delete"
android:layout_width="80dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="10dp" android:padding="10dp"
android:text="@string/task_list_delete" /> android:text="@string/task_list_delete" />

View File

@@ -18,16 +18,50 @@
android:layout_centerHorizontal="true" /> android:layout_centerHorizontal="true" />
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/task_list_view" android:id="@+id/task_list_view"
android:name="com.wismna.geoffroy.donext.activities.TaskFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="@dimen/text_margin" android:layout_marginLeft="@dimen/text_margin"
android:layout_marginRight="@dimen/text_margin" android:layout_marginRight="@dimen/text_margin"
android:layout_below="@id/total_task_cycles" android:layout_below="@id/total_task_cycles"
android:name="com.wismna.geoffroy.donext.activities.TaskFragment"
app:layoutManager="LinearLayoutManager" app:layoutManager="LinearLayoutManager"
app:layout_heightPercent="90%" app:layout_heightPercent="90%"
tools:context=".fragments.TasksFragment" tools:context=".fragments.TasksFragment"
tools:listitem="@layout/fragment_task_detailed" /> tools:listitem="@layout/fragment_task_detailed" />
<RelativeLayout
android:id="@+id/task_list_background"
android:layout_marginLeft="@dimen/text_margin"
android:layout_marginRight="@dimen/text_margin"
android:layout_below="@id/total_task_cycles"
android:layout_height="70dp"
android:layout_width="match_parent"
android:background="@color/colorAccent"
android:visibility="gone">
<TextView
android:id="@+id/task_background_done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/task_confirmation_done_button"
android:textAllCaps="true"
android:textSize="20sp"
android:textColor="@android:color/white"
android:visibility="gone"/>
<TextView
android:id="@+id/task_background_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="@string/task_confirmation_next_button"
android:textAllCaps="true"
android:textSize="20sp"
android:textColor="@android:color/white"
android:visibility="gone"/>
</RelativeLayout>
<TextView <TextView
android:id="@+id/remaining_task_count" android:id="@+id/remaining_task_count"
android:layout_width="150dp" android:layout_width="150dp"

View File

@@ -31,6 +31,10 @@
<string name="settings_confirm_message">Changer l\'état de la tâche en</string> <string name="settings_confirm_message">Changer l\'état de la tâche en</string>
<string name="settings_max_lists_label">Nombre de listes maximum:</string> <string name="settings_max_lists_label">Nombre de listes maximum:</string>
<string name="settings_task_layout">Apparence des tâches:</string> <string name="settings_task_layout">Apparence des tâches:</string>
<string-array name="settings_task_layouts">
<item>Simple</item>
<item>Détaillée</item>
</string-array>
<string name="snackabar_action_deleted">supprimée</string> <string name="snackabar_action_deleted">supprimée</string>
<string name="snackabar_action_done">terminée</string> <string name="snackabar_action_done">terminée</string>
<string name="snackabar_action_next">suivante</string> <string name="snackabar_action_next">suivante</string>
@@ -56,7 +60,7 @@
<string name="task_list_new_list_hint">Nom de la liste</string> <string name="task_list_new_list_hint">Nom de la liste</string>
<string name="task_no_tasks">Super! Aucune tâche en cours!</string> <string name="task_no_tasks">Super! Aucune tâche en cours!</string>
<string name="task_remaining">%1$d tâche%2$s restante%2$s</string> <string name="task_remaining">%1$d tâche%2$s restante%2$s</string>
<string name="task_total">%1$d tâch%2$s</string> <string name="task_total">%1$d tâche%2$s</string>
<string name="task_total_cycles">%1$d cycle%2$s</string> <string name="task_total_cycles">%1$d cycle%2$s</string>
<string name="title_activity_task_list">TaskListActivity</string> <string name="title_activity_task_list">TaskListActivity</string>
</resources> </resources>