Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.

Commit 5fd0d22

Browse files
committed
Fix label jotting and subtask bugs
* Make jottings clickable in LabelActivity by calling bindView in RecyclableJottingsListAdapter#onBindViewHolder * Add or remove strikethrough when request is complete to update the completed property of a subtask v2.3.1
1 parent 1a729f6 commit 5fd0d22

5 files changed

Lines changed: 34 additions & 36 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.boruminc.borumjot.android"
99
minSdkVersion 16
1010
targetSdkVersion 29
11-
versionCode 49
12-
versionName "2.3.0"
11+
versionCode 50
12+
versionName "2.3.1"
1313

1414
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1515
}

app/src/main/java/com/boruminc/borumjot/android/HelpActivity.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
import android.content.Intent;
44
import android.net.Uri;
5-
import android.os.Build;
65
import android.os.Bundle;
7-
import android.util.Log;
86
import android.view.View;
9-
import android.webkit.WebView;
10-
import android.widget.Toast;
117

128
import androidx.annotation.Nullable;
13-
import androidx.annotation.RequiresApi;
149
import androidx.appcompat.app.AppCompatActivity;
1510

1611
public class HelpActivity extends AppCompatActivity {

app/src/main/java/com/boruminc/borumjot/android/RecyclableJottingsListAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public JottingViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewT
5252

5353
@Override
5454
public void onBindViewHolder(@NonNull JottingViewHolder holder, int position) {
55-
holder.jottingName.setText(jottingData.get(position).getName());
55+
holder.bindView(jottingData.get(position));
5656
}
5757

5858
@Override

app/src/main/java/com/boruminc/borumjot/android/TaskActivity.java

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ private void showLabelImageBtn() {
185185
labelsList.addView(labelControlsBtn, 0);
186186
}
187187

188+
private void setSubtask(EditText view, boolean isCompleted) {
189+
if (isCompleted)
190+
// Add a strikethrough to the already existing paint flags using "|" bitwise operator
191+
view.setPaintFlags(view.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
192+
else
193+
view.setPaintFlags(view.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
194+
}
195+
188196
/**
189197
* Loads the subtasks.
190198
*/
@@ -539,13 +547,11 @@ public JSONObject call() {
539547
@Override
540548
public void onComplete(JSONObject data) {
541549
super.onComplete(data);
542-
if (data != null) {
543-
if (data.has("error") || !ranOk()) {
544-
Toast.makeText(getApplicationContext(), "An error occurred and the task could not be marked as "
545-
+ (completed == 1 ? "completed" : "incomplete"), Toast.LENGTH_LONG).show();
546-
} else {
547-
appBarFrag.displayStrikethrough(completed == 1);
548-
}
550+
if (ranOk()) {
551+
appBarFrag.displayStrikethrough(completed == 1);
552+
} else {
553+
Toast.makeText(getApplicationContext(), "An error occurred and the task could not be marked as "
554+
+ (completed == 1 ? "completed" : "incomplete"), Toast.LENGTH_LONG).show();
549555
}
550556
}
551557
}
@@ -633,28 +639,25 @@ public JSONObject call() {
633639
);
634640
}
635641
},
636-
data -> {
637-
try {
638-
if (data != null) {
639-
if (data.has("error") || data.getInt("statusCode") != 200) {
640-
Toast.makeText(this, "An error occurred and the task could not be marked as "
641-
+ (completed == 1 ? "complete" : "incomplete"), Toast.LENGTH_LONG).show();
642-
} else {
643-
EditText subtaskTxt = (EditText) subtaskRow.getChildAt(1);
644-
// TODO Move into new class/fragment? because same code as in AppNameAppBarFragment
645-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
646-
if (completed == 1)
647-
// Add a strikethrough to the already existing paint flags using "|" bitwise operator
648-
subtaskTxt.setPaintFlags(subtaskTxt.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
649-
else
650-
// Remove the strikethrough from the paint flags using "&" bitwise operator
651-
subtaskTxt.setPaintFlags(subtaskTxt.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
652-
}
642+
new ApiResponseExecutor() {
643+
@Override
644+
public void onComplete(JSONObject result) {
645+
super.onComplete(result);
646+
if (ranOk()) {
647+
EditText subtaskTxt = (EditText) subtaskRow.getChildAt(1);
648+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
649+
if (completed == 1)
650+
setSubtask(subtaskTxt, true);
651+
else
652+
setSubtask(subtaskTxt, false);
653653
}
654+
} else {
655+
Toast.makeText(
656+
getApplicationContext(),
657+
"An error occurred and the task could not be marked as " + (completed == 1 ? "complete" : "incomplete"),
658+
Toast.LENGTH_LONG
659+
).show();
654660
}
655-
} catch (JSONException e) {
656-
e.printStackTrace();
657-
Toast.makeText(this, "A server error occurred. The task was not updated", Toast.LENGTH_SHORT).show();
658661
}
659662
}
660663
);

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<string name="delete_content_desc">Trashcan or delete icon</string>
9393
<string name="save_content_desc">Save icon</string>
9494
<string name="action_help">Help</string>
95-
<string name="version_name">Version 2.3.0</string>
95+
<string name="version_name">Version 2.3.1</string>
9696
<string name="action_labels">Labels</string>
9797
<string name="copyright_notice">Copyright 2021 Varun Singh</string>
9898
<string name="support_email">support@borumtech.com</string>

0 commit comments

Comments
 (0)