Fix some bugs (#596)

remove redundant casting

Fix edittext layout when typing(reduce size), fix refresh drafts. Minor improvements

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/596
Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
M M Arif 2020-07-19 15:44:08 +02:00 committed by 6543
parent e6109ef36d
commit b529f81115
12 changed files with 28 additions and 24 deletions

View File

@ -50,14 +50,14 @@ dependencies {
androidTestImplementation "androidx.test:runner:1.2.0" androidTestImplementation "androidx.test:runner:1.2.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0" androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
implementation "com.github.vihtarb:tooltip:0.2.0" implementation "com.github.vihtarb:tooltip:0.2.0"
implementation 'com.squareup.okhttp3:okhttp:4.7.2' implementation 'com.squareup.okhttp3:okhttp:4.8.0'
implementation "com.google.code.gson:gson:2.8.6" implementation "com.google.code.gson:gson:2.8.6"
implementation "com.squareup.picasso:picasso:2.71828" implementation "com.squareup.picasso:picasso:2.71828"
implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1" implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1"
implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2' implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0'
implementation 'org.ocpsoft.prettytime:prettytime:4.0.5.Final' implementation 'org.ocpsoft.prettytime:prettytime:4.0.5.Final'
implementation "com.vdurmont:emoji-java:5.1.1" implementation "com.vdurmont:emoji-java:5.1.1"
implementation "com.pes.materialcolorpicker:library:1.2.5" implementation "com.pes.materialcolorpicker:library:1.2.5"

View File

@ -3,6 +3,7 @@ package org.mian.gitnex.adapters;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.text.Html;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -64,10 +65,10 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
itemView.setOnClickListener(itemEdit -> { itemView.setOnClickListener(itemEdit -> {
Intent intent = new Intent(mCtx, ReplyToIssueActivity.class); Intent intent = new Intent(mCtx, ReplyToIssueActivity.class);
intent.putExtra("commentBody", draftText.getText()); intent.putExtra("commentBody", draftText.getText().toString());
intent.putExtra("issueNumber", issueNumber.getText()); intent.putExtra("issueNumber", issueNumber.getText().toString());
intent.putExtra("repositoryId", repoId.getText()); intent.putExtra("repositoryId", repoId.getText().toString());
intent.putExtra("draftTitle", repoInfo.getText()); intent.putExtra("draftTitle", repoInfo.getText().toString());
TinyDB tinyDb = new TinyDB(mCtx); TinyDB tinyDb = new TinyDB(mCtx);
tinyDb.putString("issueNumber", issueNumber.getText().toString()); tinyDb.putString("issueNumber", issueNumber.getText().toString());
@ -116,7 +117,9 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
holder.repoOwner.setText(currentItem.getRepositoryOwner()); holder.repoOwner.setText(currentItem.getRepositoryOwner());
holder.repoName.setText(currentItem.getRepositoryName()); holder.repoName.setText(currentItem.getRepositoryName());
holder.draftText.setText(currentItem.getDraftText()); holder.draftText.setText(currentItem.getDraftText());
holder.repoInfo.setText(String.format("%s%d %s / %s", mCtx.getResources().getString(R.string.hash), currentItem.getIssueId(), currentItem.getRepositoryOwner(), currentItem.getRepositoryName()));
String issueNumber = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
holder.repoInfo.setText(Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName()));
} }

View File

@ -40,6 +40,7 @@ public class DraftsFragment extends Fragment {
private TextView noData; private TextView noData;
private List<DraftWithRepository> draftsList_; private List<DraftWithRepository> draftsList_;
private int currentActiveAccountId; private int currentActiveAccountId;
private SwipeRefreshLayout swipeRefresh;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -56,7 +57,7 @@ public class DraftsFragment extends Fragment {
noData = v.findViewById(R.id.noData); noData = v.findViewById(R.id.noData);
mRecyclerView = v.findViewById(R.id.recyclerView); mRecyclerView = v.findViewById(R.id.recyclerView);
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh); swipeRefresh = v.findViewById(R.id.pullToRefresh);
mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx)); mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
@ -67,16 +68,15 @@ public class DraftsFragment extends Fragment {
adapter = new DraftsAdapter(getContext(), draftsList_); adapter = new DraftsAdapter(getContext(), draftsList_);
currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> { swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
draftsList_.clear(); draftsList_.clear();
swipeRefresh.setRefreshing(false); fetchDataAsync(currentActiveAccountId);
fetchDataAsync(1);
}, 250)); }, 250));
currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
fetchDataAsync(currentActiveAccountId); fetchDataAsync(currentActiveAccountId);
return v; return v;
@ -87,6 +87,7 @@ public class DraftsFragment extends Fragment {
draftsApi.getDrafts(accountId).observe(getViewLifecycleOwner(), drafts -> { draftsApi.getDrafts(accountId).observe(getViewLifecycleOwner(), drafts -> {
swipeRefresh.setRefreshing(false);
assert drafts != null; assert drafts != null;
if(drafts.size() > 0) { if(drafts.size() > 0) {
@ -141,7 +142,7 @@ public class DraftsFragment extends Fragment {
SearchView searchView = (SearchView) searchItem.getActionView(); SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE); searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
((SearchView) searchView).setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) {

View File

@ -90,7 +90,7 @@
<com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView <com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView
android:id="@+id/newIssueDescription" android:id="@+id/newIssueDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="240dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:padding="10dp" android:padding="10dp"
android:completionThreshold="1" android:completionThreshold="1"

View File

@ -139,7 +139,7 @@
<EditText <EditText
android:id="@+id/releaseContent" android:id="@+id/releaseContent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="240dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:padding="10dp" android:padding="10dp"
android:maxLines="8" android:maxLines="8"

View File

@ -89,7 +89,7 @@
<com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView <com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView
android:id="@+id/editIssueDescription" android:id="@+id/editIssueDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="240dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:padding="10dp" android:padding="10dp"
android:completionThreshold="1" android:completionThreshold="1"

View File

@ -100,7 +100,7 @@
<EditText <EditText
android:id="@+id/newFileContent" android:id="@+id/newFileContent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="240dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:padding="10dp" android:padding="10dp"
android:maxLines="16" android:maxLines="16"

View File

@ -90,7 +90,7 @@
<EditText <EditText
android:id="@+id/milestoneDescription" android:id="@+id/milestoneDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="160dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:padding="10dp" android:padding="10dp"
android:maxLines="8" android:maxLines="8"

View File

@ -90,7 +90,7 @@
<EditText <EditText
android:id="@+id/newOrganizationDescription" android:id="@+id/newOrganizationDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="160dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:padding="10dp" android:padding="10dp"
android:maxLines="8" android:maxLines="8"

View File

@ -118,7 +118,7 @@
<EditText <EditText
android:id="@+id/newRepoDescription" android:id="@+id/newRepoDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="160dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:padding="10dp" android:padding="10dp"
android:background="@drawable/shape_inputs" android:background="@drawable/shape_inputs"

View File

@ -71,7 +71,7 @@
<com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView <com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView
android:id="@+id/addComment" android:id="@+id/addComment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="240dp"
android:padding="10dp" android:padding="10dp"
android:completionThreshold="1" android:completionThreshold="1"
android:background="@drawable/shape_inputs" android:background="@drawable/shape_inputs"

View File

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.0.0' classpath 'com.android.tools.build:gradle:4.0.1'
} }
} }