Insert note to a release
This commit is contained in:
parent
7b14ef39b4
commit
810e09673e
|
@ -36,7 +36,7 @@ Option 2 - Open the terminal (Linux) and navigate to the project directory. Then
|
|||
- Pull requests
|
||||
- Files diff for PRs
|
||||
- Notifications
|
||||
- Drafts
|
||||
- Notes
|
||||
- Repositories / issues list
|
||||
- [& more...](https://codeberg.org/gitnex/GitNex/wiki/Features)
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ public class CreateIssueActivity extends BaseActivity
|
|||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilderNotes;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
private boolean renderMd = false;
|
||||
|
@ -111,6 +112,8 @@ public class CreateIssueActivity extends BaseActivity
|
|||
|
||||
materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
materialAlertDialogBuilderNotes =
|
||||
new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
|
@ -212,12 +215,12 @@ public class CreateIssueActivity extends BaseActivity
|
|||
customInsertNoteBinding = CustomInsertNoteBinding.inflate(LayoutInflater.from(ctx));
|
||||
|
||||
View view = customInsertNoteBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
materialAlertDialogBuilderNotes.setView(view);
|
||||
|
||||
customInsertNoteBinding.recyclerView.setHasFixedSize(true);
|
||||
customInsertNoteBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
adapter = new NotesAdapter(ctx, notesList, "insert");
|
||||
adapter = new NotesAdapter(ctx, notesList, "insert", "issue");
|
||||
|
||||
customInsertNoteBinding.pullToRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
|
@ -235,7 +238,7 @@ public class CreateIssueActivity extends BaseActivity
|
|||
|
||||
if (notesApi.getCount() > 0) {
|
||||
fetchNotes();
|
||||
dialogNotes = materialAlertDialogBuilder.show();
|
||||
dialogNotes = materialAlertDialogBuilderNotes.show();
|
||||
} else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noNotes));
|
||||
}
|
||||
|
|
|
@ -3,10 +3,15 @@ package org.mian.gitnex.activities;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -17,11 +22,17 @@ import org.gitnex.tea4j.v2.models.CreateTagOption;
|
|||
import org.gitnex.tea4j.v2.models.Release;
|
||||
import org.gitnex.tea4j.v2.models.Tag;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.NotesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.NotesApi;
|
||||
import org.mian.gitnex.database.models.Notes;
|
||||
import org.mian.gitnex.databinding.ActivityCreateReleaseBinding;
|
||||
import org.mian.gitnex.databinding.CustomInsertNoteBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
@ -36,6 +47,12 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
private String selectedBranch;
|
||||
private RepositoryContext repository;
|
||||
private boolean renderMd = false;
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
private CustomInsertNoteBinding customInsertNoteBinding;
|
||||
private NotesAdapter adapter;
|
||||
private NotesApi notesApi;
|
||||
private List<Notes> notesList;
|
||||
public AlertDialog dialogNotes;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -48,6 +65,9 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
binding.releaseContent.setOnTouchListener(
|
||||
(touchView, motionEvent) -> {
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
@ -60,10 +80,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
return false;
|
||||
});
|
||||
|
||||
binding.topAppBar.setNavigationOnClickListener(
|
||||
v -> {
|
||||
finish();
|
||||
});
|
||||
binding.topAppBar.setNavigationOnClickListener(v -> finish());
|
||||
|
||||
binding.topAppBar.setOnMenuItemClickListener(
|
||||
menuItem -> {
|
||||
|
@ -103,9 +120,67 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
}
|
||||
});
|
||||
|
||||
binding.insertNote.setOnClickListener(insertNote -> showAllNotes());
|
||||
|
||||
getBranches(repository.getOwner(), repository.getName());
|
||||
}
|
||||
|
||||
private void showAllNotes() {
|
||||
|
||||
notesList = new ArrayList<>();
|
||||
notesApi = BaseApi.getInstance(ctx, NotesApi.class);
|
||||
|
||||
customInsertNoteBinding = CustomInsertNoteBinding.inflate(LayoutInflater.from(ctx));
|
||||
|
||||
View view = customInsertNoteBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
customInsertNoteBinding.recyclerView.setHasFixedSize(true);
|
||||
customInsertNoteBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
adapter = new NotesAdapter(ctx, notesList, "insert", "release");
|
||||
|
||||
customInsertNoteBinding.pullToRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
notesList.clear();
|
||||
customInsertNoteBinding.pullToRefresh.setRefreshing(
|
||||
false);
|
||||
customInsertNoteBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
fetchNotes();
|
||||
},
|
||||
250));
|
||||
|
||||
if (notesApi.getCount() > 0) {
|
||||
fetchNotes();
|
||||
dialogNotes = materialAlertDialogBuilder.show();
|
||||
} else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noNotes));
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchNotes() {
|
||||
|
||||
notesApi.fetchAllNotes()
|
||||
.observe(
|
||||
this,
|
||||
allNotes -> {
|
||||
assert allNotes != null;
|
||||
if (!allNotes.isEmpty()) {
|
||||
|
||||
notesList.clear();
|
||||
|
||||
notesList.addAll(allNotes);
|
||||
adapter.notifyDataChanged();
|
||||
customInsertNoteBinding.recyclerView.setAdapter(adapter);
|
||||
}
|
||||
customInsertNoteBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
private void createNewTag() {
|
||||
|
||||
String tagName = Objects.requireNonNull(binding.releaseTagName.getText()).toString();
|
||||
|
@ -114,7 +189,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
+ "\n\n"
|
||||
+ Objects.requireNonNull(binding.releaseContent.getText());
|
||||
|
||||
if (tagName.equals("")) {
|
||||
if (tagName.isEmpty()) {
|
||||
SnackBar.error(
|
||||
ctx, findViewById(android.R.id.content), getString(R.string.tagNameErrorEmpty));
|
||||
return;
|
||||
|
@ -187,13 +262,13 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
boolean newReleaseType = binding.releaseType.isChecked();
|
||||
boolean newReleaseDraft = binding.releaseDraft.isChecked();
|
||||
|
||||
if (newReleaseTitle.equals("")) {
|
||||
if (newReleaseTitle.isEmpty()) {
|
||||
SnackBar.error(
|
||||
ctx, findViewById(android.R.id.content), getString(R.string.titleErrorEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newReleaseTagName.equals("")) {
|
||||
if (newReleaseTagName.isEmpty()) {
|
||||
SnackBar.error(
|
||||
ctx, findViewById(android.R.id.content), getString(R.string.tagNameErrorEmpty));
|
||||
return;
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateIssueActivity;
|
||||
import org.mian.gitnex.activities.CreateNoteActivity;
|
||||
import org.mian.gitnex.activities.CreateReleaseActivity;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.NotesApi;
|
||||
import org.mian.gitnex.database.models.Notes;
|
||||
|
@ -38,12 +39,14 @@ public class NotesAdapter extends RecyclerView.Adapter<NotesAdapter.NotesViewHol
|
|||
private final Context ctx;
|
||||
private final Intent noteIntent;
|
||||
private final String insert;
|
||||
private final String source;
|
||||
|
||||
public NotesAdapter(Context ctx, List<Notes> notesListMain, String insert) {
|
||||
public NotesAdapter(Context ctx, List<Notes> notesListMain, String insert, String source) {
|
||||
this.ctx = ctx;
|
||||
this.notesList = notesListMain;
|
||||
noteIntent = new Intent(ctx, CreateNoteActivity.class);
|
||||
this.insert = insert;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public class NotesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
@ -87,7 +90,7 @@ public class NotesAdapter extends RecyclerView.Adapter<NotesAdapter.NotesViewHol
|
|||
.show();
|
||||
});
|
||||
|
||||
if (insert.equalsIgnoreCase("insert")) {
|
||||
if (insert.equalsIgnoreCase("insert") && source.equalsIgnoreCase("issue")) {
|
||||
|
||||
deleteNote.setVisibility(View.GONE);
|
||||
|
||||
|
@ -100,6 +103,20 @@ public class NotesAdapter extends RecyclerView.Adapter<NotesAdapter.NotesViewHol
|
|||
parentActivity.dialogNotes.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
if (insert.equalsIgnoreCase("insert") && source.equalsIgnoreCase("release")) {
|
||||
|
||||
deleteNote.setVisibility(View.GONE);
|
||||
|
||||
itemView.setOnClickListener(
|
||||
view -> {
|
||||
CreateReleaseActivity parentActivity = (CreateReleaseActivity) ctx;
|
||||
EditText text = parentActivity.findViewById(R.id.releaseContent);
|
||||
text.append(notes.getContent());
|
||||
|
||||
parentActivity.dialogNotes.dismiss();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class NotesFragment extends Fragment {
|
|||
binding.recyclerView.setPadding(0, 0, 0, 220);
|
||||
binding.recyclerView.setClipToPadding(false);
|
||||
|
||||
adapter = new NotesAdapter(ctx, notesList, "");
|
||||
adapter = new NotesAdapter(ctx, notesList, "", "");
|
||||
|
||||
binding.pullToRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
|
|
|
@ -99,6 +99,17 @@
|
|||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/insertNote"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="@dimen/dimen8dp"
|
||||
android:layout_marginBottom="@dimen/dimen0dp"
|
||||
android:text="@string/insertNote"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen14sp"/>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/releaseContentLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue