Improve single issue UI #518

Merged
mmarif merged 2 commits from single-issue-ui into master 2020-05-30 17:00:06 +00:00
3 changed files with 331 additions and 322 deletions

View File

@ -20,6 +20,7 @@ import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
@ -103,6 +104,8 @@ public class IssueDetailActivity extends BaseActivity {
private Context appCtx;
private LinearLayout labelsLayout;
private LinearLayout assigneesLayout;
private View divider;
private ProgressBar progressBar;
@Override
protected int getLayoutResourceId() {
@ -142,6 +145,8 @@ public class IssueDetailActivity extends BaseActivity {
createNewComment = findViewById(R.id.addNewComment);
labelsLayout = findViewById(R.id.frameLabels);
assigneesLayout = findViewById(R.id.frameAssignees);
divider = findViewById(R.id.divider);
progressBar = findViewById(R.id.progressBar);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
@ -258,67 +263,48 @@ public class IssueDetailActivity extends BaseActivity {
final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
if(tinyDb.getBoolean("commentPosted")) {
scrollViewComments.post(new Runnable() {
@Override
public void run() {
scrollViewComments.post(() -> {
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, ctx);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN);
}
}, 1000);
new Handler().postDelayed(() -> scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN), 1000);
tinyDb.putBoolean("commentPosted", false);
}
});
}
if(tinyDb.getBoolean("commentEdited")) {
scrollViewComments.post(new Runnable() {
@Override
public void run() {
scrollViewComments.post(() -> {
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, ctx);
tinyDb.putBoolean("commentEdited", false);
}
});
}
if(tinyDb.getBoolean("singleIssueUpdate")) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
new Handler().postDelayed(() -> {
assigneesLayout.removeAllViews();
labelsLayout.removeAllViews();
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
tinyDb.putBoolean("singleIssueUpdate", false);
}
}, 500);
}
if(tinyDb.getBoolean("issueEdited")) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
new Handler().postDelayed(() -> {
assigneesLayout.removeAllViews();
labelsLayout.removeAllViews();
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
tinyDb.putBoolean("issueEdited", false);
}
}, 500);
}
@ -334,8 +320,14 @@ public class IssueDetailActivity extends BaseActivity {
@Override
public void onChanged(@Nullable List<IssueComments> issueCommentsMain) {
assert issueCommentsMain != null;
if(issueCommentsMain.size() > 0) {
divider.setVisibility(View.VISIBLE);
}
adapter = new IssueCommentsAdapter(ctx, issueCommentsMain);
mRecyclerView.setAdapter(adapter);
}
});
@ -351,7 +343,6 @@ public class IssueDetailActivity extends BaseActivity {
@Override
public void onResponse(@NonNull Call<Issues> call, @NonNull Response<Issues> response) {
if(response.isSuccessful()) {
if(response.code() == 200) {
Issues singleIssue = response.body();
@ -469,13 +460,13 @@ public class IssueDetailActivity extends BaseActivity {
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
String dueDate = formatter.format(singleIssue.getDue_date());
issueDueDate.setText(getString(R.string.dueDate, dueDate));
issueDueDate.setText(dueDate);
issueDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getDue_date()), ctx));
}
else if(timeFormat.equals("normal1")) {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
String dueDate = formatter.format(singleIssue.getDue_date());
issueDueDate.setText(getString(R.string.dueDate, dueDate));
issueDueDate.setText(dueDate);
}
}
@ -534,9 +525,10 @@ public class IssueDetailActivity extends BaseActivity {
assigneeAvatar.setOnClickListener(new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getLogin(), ctx));
}
}
progressBar.setVisibility(View.GONE);
}
else if(response.code() == 401) {
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
@ -550,6 +542,7 @@ public class IssueDetailActivity extends BaseActivity {
Log.e("onFailure", t.toString());
}
});
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
@ -563,6 +556,7 @@ public class IssueDetailActivity extends BaseActivity {
if(response.isSuccessful()) {
assert response.body() != null;
tinyDb.putBoolean("issueSubscribed", response.body().getSubscribed());
}
@ -580,15 +574,11 @@ public class IssueDetailActivity extends BaseActivity {
tinyDb.putBoolean("issueSubscribed", false);
}
});
}
}
private void initCloseListener() {
View.OnClickListener onClickListener = view -> finish();
}
}

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="?attr/primaryBackgroundColor">
<com.google.android.material.appbar.AppBarLayout
@ -46,7 +46,7 @@
android:layout_height="wrap_content">
<ScrollView
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scrollViewComments"
android:fillViewport="true">
@ -54,7 +54,13 @@
<RelativeLayout
android:id="@+id/relativeLayoutFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/mainIssueLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">
<ImageView
@ -189,23 +195,30 @@
</RelativeLayout>
</RelativeLayout>
<View
android:layout_below="@id/issueTimeFrame"
android:layout_below="@id/mainIssueLayout"
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/divider"
android:layout_marginTop="15dp"
android:background="?attr/inputBackgroundColor" />
android:visibility="gone"
android:background="?attr/dividerColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/divider">
<androidx.recyclerview.widget.RecyclerView
android:layout_below="@+id/divider"
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/primaryBackgroundColor"
android:padding="4dp"
android:scrollbars="vertical" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
@ -225,6 +238,14 @@
android:padding="@dimen/fab_padding"
android:contentDescription="@string/addNewContent" />
<ProgressBar
android:id="@+id/progressBar"
style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_centerInParent="true" />
</RelativeLayout>
</LinearLayout>

View File

@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:padding="15dp"
android:id="@+id/relativeLayoutMainFrame"
tools:context=".activities.RepoDetailActivity"
android:background="?attr/primaryBackgroundColor">
<TextView