mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
notes db, listing, editing and adding
This commit is contained in:
parent
dd3346259e
commit
24e46c0ee6
|
@ -17,7 +17,11 @@ import org.mian.gitnex.database.api.BaseApi;
|
|||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.structs.Protocol;
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
|
|
|
@ -10,7 +10,11 @@ import com.amrdeveloper.codeview.Code;
|
|||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivityCodeEditorBinding;
|
||||
import org.mian.gitnex.helpers.codeeditor.*;
|
||||
import org.mian.gitnex.helpers.codeeditor.CustomCodeViewAdapter;
|
||||
import org.mian.gitnex.helpers.codeeditor.LanguageManager;
|
||||
import org.mian.gitnex.helpers.codeeditor.LanguageName;
|
||||
import org.mian.gitnex.helpers.codeeditor.SourcePositionListener;
|
||||
import org.mian.gitnex.helpers.codeeditor.ThemeName;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -15,7 +15,12 @@ import androidx.activity.result.ActivityResultLauncher;
|
|||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.DeleteFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.FileDeleteResponse;
|
||||
import org.gitnex.tea4j.v2.models.FileResponse;
|
||||
import org.gitnex.tea4j.v2.models.UpdateFileOptions;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateFileBinding;
|
||||
|
|
|
@ -12,7 +12,11 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.gitnex.tea4j.v2.models.CreateIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.AssigneesActions;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
|
@ -28,7 +32,12 @@ import org.mian.gitnex.helpers.AppUtil;
|
|||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.ReplacementSpan;
|
||||
import android.text.style.StrikethroughSpan;
|
||||
import android.util.Log;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.mian.gitnex.R;
|
||||
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.ActivityCreateNoteBinding;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.SoftBreakAddsNewLinePlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.core.spans.BlockQuoteSpan;
|
||||
import io.noties.markwon.core.spans.CodeSpan;
|
||||
import io.noties.markwon.core.spans.HeadingSpan;
|
||||
import io.noties.markwon.core.spans.LinkSpan;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
|
@ -30,8 +28,11 @@ import io.noties.markwon.core.spans.LinkSpan;
|
|||
public class CreateNoteActivity extends BaseActivity {
|
||||
|
||||
private ActivityCreateNoteBinding activityCreateNoteBinding;
|
||||
private View.OnClickListener onClickListener;
|
||||
private final View.OnClickListener createNoteListener = v -> processNewNote();
|
||||
private boolean renderMd = false;
|
||||
private String action;
|
||||
private Notes notes;
|
||||
private NotesApi notesApi;
|
||||
private int noteId;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -39,58 +40,139 @@ public class CreateNoteActivity extends BaseActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
activityCreateNoteBinding = ActivityCreateNoteBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateNoteBinding.getRoot());
|
||||
notesApi = BaseApi.getInstance(ctx, NotesApi.class);
|
||||
|
||||
//boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
setContentView(activityCreateNoteBinding.getRoot());
|
||||
setSupportActionBar(activityCreateNoteBinding.toolbar);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
activityCreateNoteBinding.noteTitle.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(activityCreateNoteBinding.noteTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||
imm.showSoftInput(activityCreateNoteBinding.noteContent, InputMethodManager.SHOW_IMPLICIT);
|
||||
activityCreateNoteBinding.noteContent.requestFocus();
|
||||
|
||||
/*activityCreateNoteBinding.setOnTouchListener((touchView, motionEvent) -> {
|
||||
activityCreateNoteBinding.close.setOnClickListener(view -> finish());
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});*/
|
||||
|
||||
initCloseListener();
|
||||
activityCreateNoteBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
//createOrganizationButton = activityCreateOrganizationBinding.createNewOrganizationButton;
|
||||
|
||||
/*if(!connToInternet) {
|
||||
|
||||
activityCreateNoteBinding.createNote.setEnabled(false);
|
||||
if(getIntent().getStringExtra("action") != null) {
|
||||
action = getIntent().getStringExtra("action");
|
||||
}
|
||||
else {
|
||||
action = "";
|
||||
}
|
||||
|
||||
activityCreateNoteBinding.createNote.setOnClickListener(createNoteListener);
|
||||
}*/
|
||||
activityCreateNoteBinding.close.setOnClickListener(close -> finish());
|
||||
activityCreateNoteBinding.toolbarTitle.setMovementMethod(new ScrollingMovementMethod());
|
||||
|
||||
if(action.equalsIgnoreCase("edit")) {
|
||||
|
||||
noteId = getIntent().getIntExtra( "noteId", 0);
|
||||
notes = notesApi.fetchNoteById(noteId);
|
||||
activityCreateNoteBinding.noteContent.setText(notes.getContent());
|
||||
|
||||
activityCreateNoteBinding.markdownPreview.setVisibility(View.GONE);
|
||||
activityCreateNoteBinding.toolbarTitle.setText(R.string.editNote);
|
||||
|
||||
activityCreateNoteBinding.noteContent.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
String text = activityCreateNoteBinding.noteContent.getText().toString();
|
||||
|
||||
if(!text.isEmpty()) {
|
||||
|
||||
updateNote(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(action.equalsIgnoreCase("add")) {
|
||||
|
||||
activityCreateNoteBinding.markdownPreview.setVisibility(View.GONE);
|
||||
|
||||
activityCreateNoteBinding.noteContent.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
String text = activityCreateNoteBinding.noteContent.getText().toString();
|
||||
|
||||
if(!text.isEmpty() && text.length() > 4) {
|
||||
|
||||
if(noteId > 0) {
|
||||
updateNote(text);
|
||||
}
|
||||
else {
|
||||
noteId = (int) notesApi.insertNote(text, (int) Instant.now().getEpochSecond());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
activityCreateNoteBinding.markdownPreview.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void processNewNote() {
|
||||
|
||||
private void updateNote(String content) {
|
||||
notesApi.updateNote(content, Instant.now().getEpochSecond(), noteId);
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.markdown_switcher, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
//activityCreateNoteBinding.createNote.setEnabled(false);
|
||||
}
|
||||
int id = item.getItemId();
|
||||
|
||||
private void enableProcessButton() {
|
||||
if(id == android.R.id.home) {
|
||||
|
||||
//activityCreateNoteBinding.createNote.setEnabled(true);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.markdown) {
|
||||
|
||||
if(action.equalsIgnoreCase("edit") || action.equalsIgnoreCase("add")) {
|
||||
if(!renderMd) {
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(Objects.requireNonNull(activityCreateNoteBinding.noteContent.getText().toString())), activityCreateNoteBinding.markdownPreview);
|
||||
|
||||
activityCreateNoteBinding.markdownPreview.setVisibility(View.VISIBLE);
|
||||
activityCreateNoteBinding.noteContent.setVisibility(View.GONE);
|
||||
renderMd = true;
|
||||
}
|
||||
else {
|
||||
activityCreateNoteBinding.markdownPreview.setVisibility(View.GONE);
|
||||
activityCreateNoteBinding.noteContent.setVisibility(View.VISIBLE);
|
||||
renderMd = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,11 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreatePullRequestOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
|
@ -22,7 +26,12 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
|
|||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
|
|
@ -8,9 +8,18 @@ import android.util.Log;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.*;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateReleaseOption;
|
||||
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.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateReleaseBinding;
|
||||
|
|
|
@ -7,7 +7,12 @@ import android.os.Looper;
|
|||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.*;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.CreateRepoOption;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
|
|
|
@ -9,7 +9,11 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.gitnex.tea4j.v2.models.ContentsResponse;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
|
|
|
@ -11,7 +11,12 @@ import android.util.Log;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.*;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
|
@ -28,7 +33,12 @@ import org.mian.gitnex.helpers.Toasty;
|
|||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
|
|
@ -3,17 +3,30 @@ package org.mian.gitnex.activities;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.*;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.gitnex.tea4j.v2.models.AccessToken;
|
||||
import org.gitnex.tea4j.v2.models.CreateAccessTokenOption;
|
||||
import org.gitnex.tea4j.v2.models.GeneralAPISettings;
|
||||
import org.gitnex.tea4j.v2.models.ServerVersion;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityLoginBinding;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.NetworkStatusObserver;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.structs.Protocol;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
|
|
@ -34,8 +34,27 @@ import org.mian.gitnex.database.api.BaseApi;
|
|||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityMainBinding;
|
||||
import org.mian.gitnex.fragments.*;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetMyIssuesFilterFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
import org.mian.gitnex.fragments.ExploreFragment;
|
||||
import org.mian.gitnex.fragments.MostVisitedReposFragment;
|
||||
import org.mian.gitnex.fragments.MyIssuesFragment;
|
||||
import org.mian.gitnex.fragments.MyProfileFragment;
|
||||
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.NotesFragment;
|
||||
import org.mian.gitnex.fragments.NotificationsFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ChangeLog;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.structs.FragmentRefreshListener;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -19,7 +19,12 @@ import com.google.android.material.tabs.TabLayoutMediator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetUserProfileFragment;
|
||||
import org.mian.gitnex.fragments.profile.*;
|
||||
import org.mian.gitnex.fragments.profile.DetailFragment;
|
||||
import org.mian.gitnex.fragments.profile.FollowersFragment;
|
||||
import org.mian.gitnex.fragments.profile.FollowingFragment;
|
||||
import org.mian.gitnex.fragments.profile.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.profile.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.profile.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
|
|
@ -6,7 +6,12 @@ import android.content.Intent;
|
|||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
|
@ -21,10 +26,27 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|||
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.*;
|
||||
import org.mian.gitnex.fragments.BottomSheetIssuesFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetMilestonesFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetPullRequestFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetReleasesTagsFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetRepoFragment;
|
||||
import org.mian.gitnex.fragments.CollaboratorsFragment;
|
||||
import org.mian.gitnex.fragments.FilesFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.fragments.LabelsFragment;
|
||||
import org.mian.gitnex.fragments.MilestonesFragment;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
import org.mian.gitnex.fragments.WikiFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
|
|
|
@ -294,7 +294,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.markdown_switcher, menu);
|
||||
|
|
|
@ -24,7 +24,13 @@ import org.mian.gitnex.R;
|
|||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
|
|
|
@ -17,7 +17,11 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
|
|
@ -4,7 +4,11 @@ import android.content.Context;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
|
|
@ -27,7 +27,13 @@ import org.mian.gitnex.clients.PicassoService;
|
|||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.views.ReactionList;
|
||||
import org.mian.gitnex.views.ReactionSpinner;
|
||||
|
|
|
@ -26,7 +26,13 @@ import org.mian.gitnex.activities.IssueDetailActivity;
|
|||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
|
130
app/src/main/java/org/mian/gitnex/adapters/NotesAdapter.java
Normal file
130
app/src/main/java/org/mian/gitnex/adapters/NotesAdapter.java
Normal file
|
@ -0,0 +1,130 @@
|
|||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateNoteActivity;
|
||||
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.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class NotesAdapter extends RecyclerView.Adapter<NotesAdapter.NotesViewHolder> {
|
||||
|
||||
private List<Notes> notesList;
|
||||
private final Context ctx;
|
||||
private final Intent noteIntent;
|
||||
|
||||
public NotesAdapter(Context ctx, List<Notes> notesListMain) {
|
||||
this.ctx = ctx;
|
||||
this.notesList = notesListMain;
|
||||
noteIntent = new Intent(ctx, CreateNoteActivity.class);
|
||||
}
|
||||
|
||||
class NotesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Notes notes;
|
||||
|
||||
private final TextView content;
|
||||
private final TextView datetime;
|
||||
|
||||
private NotesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
content = itemView.findViewById(R.id.content);
|
||||
datetime = itemView.findViewById(R.id.datetime);
|
||||
ImageView deleteNote = itemView.findViewById(R.id.delete_note);
|
||||
|
||||
itemView.setOnClickListener(view -> {
|
||||
noteIntent.putExtra("action", "edit");
|
||||
noteIntent.putExtra("noteId", notes.getNoteId());
|
||||
ctx.startActivity(noteIntent);
|
||||
});
|
||||
|
||||
deleteNote.setOnClickListener(itemDelete -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(ctx.getString(R.string.menuDeleteText))
|
||||
.setMessage(ctx.getString(R.string.noteDeleteDialoMessage))
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> deleteNote(getBindingAdapterPosition(), notes.getNoteId())).setNeutralButton(R.string.cancelButton, null).show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteNote(int position, int noteId) {
|
||||
|
||||
NotesApi notesApi = BaseApi.getInstance(ctx, NotesApi.class);
|
||||
assert notesApi != null;
|
||||
notesApi.deleteNote(noteId);
|
||||
notesList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, notesList.size());
|
||||
Toasty.success(ctx, ctx.getResources().getQuantityString(R.plurals.noteDeleteMessage, 1));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public NotesAdapter.NotesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_notes, parent, false);
|
||||
return new NotesViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull NotesAdapter.NotesViewHolder holder, int position) {
|
||||
|
||||
Locale locale = ctx.getResources().getConfiguration().locale;
|
||||
Notes currentItem = notesList.get(position);
|
||||
holder.notes = currentItem;
|
||||
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(Objects.requireNonNull(StringUtils.substring(currentItem.getContent(), 0, 140))), holder.content);
|
||||
|
||||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
if(currentItem.getModified() != null) {
|
||||
String modifiedTime = prettyTime.format(Instant.ofEpochSecond(currentItem.getModified()));
|
||||
holder.datetime.setText(ctx.getResources().getString(R.string.noteTimeModified, modifiedTime));
|
||||
}
|
||||
else {
|
||||
String createdTime = prettyTime.format(Instant.ofEpochSecond(currentItem.getDatetime()));
|
||||
holder.datetime.setText(ctx.getResources().getString(R.string.noteDateTime, createdTime));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return notesList.size();
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void updateList(List<Notes> list) {
|
||||
|
||||
notesList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
|
@ -26,7 +26,13 @@ import org.mian.gitnex.activities.IssueDetailActivity;
|
|||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -23,7 +23,13 @@ import org.mian.gitnex.activities.RepoDetailActivity;
|
|||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentReleasesBinding;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.structs.FragmentRefreshListener;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -17,7 +17,11 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
|
|
@ -7,7 +7,11 @@ import android.graphics.Typeface;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
|
@ -15,7 +19,11 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
|
62
app/src/main/java/org/mian/gitnex/database/api/NotesApi.java
Normal file
62
app/src/main/java/org/mian/gitnex/database/api/NotesApi.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import org.mian.gitnex.database.dao.NotesDao;
|
||||
import org.mian.gitnex.database.models.Notes;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class NotesApi extends BaseApi {
|
||||
|
||||
private final NotesDao notesDao;
|
||||
|
||||
NotesApi(Context context) {
|
||||
super(context);
|
||||
notesDao = gitnexDatabase.notesDao();
|
||||
}
|
||||
|
||||
public long insertNote(String content, Integer datetime) {
|
||||
|
||||
Notes notes = new Notes();
|
||||
notes.setContent(content);
|
||||
notes.setDatetime(datetime);
|
||||
|
||||
return insertNoteAsyncTask(notes);
|
||||
}
|
||||
|
||||
public long insertNoteAsyncTask(Notes notes) {
|
||||
return notesDao.insertNote(notes);
|
||||
}
|
||||
|
||||
public LiveData<List<Notes>> fetchAllNotes() {
|
||||
return notesDao.fetchAllNotes();
|
||||
}
|
||||
|
||||
public Notes fetchNoteById(int noteId) {
|
||||
return notesDao.fetchNoteById(noteId);
|
||||
}
|
||||
|
||||
public Integer fetchNotesCount() {
|
||||
return notesDao.fetchNotesCount();
|
||||
}
|
||||
|
||||
public void updateNote(final String content, final long modified, int noteId) {
|
||||
executorService.execute(() -> notesDao.updateNote(content, modified, noteId));
|
||||
}
|
||||
|
||||
public void deleteAllNotes() {
|
||||
executorService.execute(notesDao::deleteAllNotes);
|
||||
}
|
||||
|
||||
public void deleteNote(final int noteId) {
|
||||
final Notes note = notesDao.fetchNoteById(noteId);
|
||||
|
||||
if(note != null) {
|
||||
executorService.execute(() -> notesDao.deleteNote(noteId));
|
||||
}
|
||||
}
|
||||
}
|
37
app/src/main/java/org/mian/gitnex/database/dao/NotesDao.java
Normal file
37
app/src/main/java/org/mian/gitnex/database/dao/NotesDao.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package org.mian.gitnex.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import org.mian.gitnex.database.models.Notes;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
@Dao
|
||||
public interface NotesDao {
|
||||
|
||||
@Insert
|
||||
long insertNote(Notes notes);
|
||||
|
||||
@Query("SELECT * FROM Notes ORDER BY modified DESC, noteId DESC")
|
||||
LiveData<List<Notes>> fetchAllNotes();
|
||||
|
||||
@Query("SELECT * FROM Notes WHERE noteId = :noteId")
|
||||
Notes fetchNoteById(int noteId);
|
||||
|
||||
@Query("SELECT count(noteId) FROM Notes")
|
||||
Integer fetchNotesCount();
|
||||
|
||||
@Query("UPDATE Notes SET content = :content, modified = :modified WHERE noteId = :noteId")
|
||||
void updateNote(String content, long modified, int noteId);
|
||||
|
||||
@Query("DELETE FROM Notes")
|
||||
void deleteAllNotes();
|
||||
|
||||
@Query("DELETE FROM Notes WHERE noteId = :noteId")
|
||||
void deleteNote(int noteId);
|
||||
}
|
|
@ -8,9 +8,11 @@ import androidx.room.RoomDatabase;
|
|||
import androidx.room.migration.Migration;
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
import org.mian.gitnex.database.dao.DraftsDao;
|
||||
import org.mian.gitnex.database.dao.NotesDao;
|
||||
import org.mian.gitnex.database.dao.RepositoriesDao;
|
||||
import org.mian.gitnex.database.dao.UserAccountsDao;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.Notes;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
|
||||
|
@ -18,7 +20,7 @@ import org.mian.gitnex.database.models.UserAccount;
|
|||
* @author M M Arif
|
||||
*/
|
||||
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class}, version = 6, exportSchema = false)
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class, Notes.class}, version = 7, exportSchema = false)
|
||||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
private static final String DB_NAME = "gitnex";
|
||||
|
@ -57,6 +59,13 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE 'Repositories' ADD COLUMN 'mostVisited' INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
};
|
||||
private static final Migration MIGRATION_6_7 = new Migration(6, 7) {
|
||||
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS 'Notes' ('noteId' INTEGER NOT NULL, 'content' TEXT, 'datetime' INTEGER, 'modified' INTEGER, PRIMARY KEY('noteid'))");
|
||||
}
|
||||
};
|
||||
private static volatile GitnexDatabase gitnexDatabase;
|
||||
|
||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||
|
@ -67,7 +76,7 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
|
||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||
//.fallbackToDestructiveMigration()
|
||||
.allowMainThreadQueries().addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6).build();
|
||||
.allowMainThreadQueries().addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6, MIGRATION_6_7).build();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -83,4 +92,5 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
|
||||
public abstract UserAccountsDao userAccountsDao();
|
||||
|
||||
public abstract NotesDao notesDao();
|
||||
}
|
||||
|
|
55
app/src/main/java/org/mian/gitnex/database/models/Notes.java
Normal file
55
app/src/main/java/org/mian/gitnex/database/models/Notes.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
package org.mian.gitnex.database.models;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "Notes")
|
||||
public class Notes implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int noteId;
|
||||
|
||||
@Nullable
|
||||
private String content;
|
||||
private Integer datetime;
|
||||
private Integer modified;
|
||||
|
||||
public int getNoteId() {
|
||||
return noteId;
|
||||
}
|
||||
|
||||
public void setNoteId(int noteId) {
|
||||
this.noteId = noteId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(@Nullable String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Integer getDatetime() {
|
||||
return datetime;
|
||||
}
|
||||
|
||||
public void setDatetime(Integer datetime) {
|
||||
this.datetime = datetime;
|
||||
}
|
||||
|
||||
public Integer getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void setModified(Integer modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,11 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.actions.PullRequestActions;
|
||||
import org.mian.gitnex.activities.*;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.DiffActivity;
|
||||
import org.mian.gitnex.activities.EditIssueActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.MergePullRequestActivity;
|
||||
import org.mian.gitnex.databinding.BottomSheetSingleIssueBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
|
|
|
@ -22,7 +22,13 @@ import org.mian.gitnex.adapters.DiffFilesAdapter;
|
|||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentCommitDetailsBinding;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FileDiffView;
|
||||
import org.mian.gitnex.helpers.ParseDiff;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -3,7 +3,12 @@ package org.mian.gitnex.fragments;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -5,7 +5,12 @@ import android.content.res.ColorStateList;
|
|||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -6,21 +6,26 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateNoteActivity;
|
||||
import org.mian.gitnex.activities.CreateOrganizationActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.adapters.MostVisitedReposAdapter;
|
||||
import org.mian.gitnex.adapters.NotesAdapter;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.api.NotesApi;
|
||||
import org.mian.gitnex.database.models.Notes;
|
||||
import org.mian.gitnex.databinding.FragmentNotesBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,10 +37,10 @@ public class NotesFragment extends Fragment {
|
|||
|
||||
private FragmentNotesBinding fragmentNotesBinding;
|
||||
private Context ctx;
|
||||
private MostVisitedReposAdapter adapter;
|
||||
private RepositoriesApi repositoriesApi;
|
||||
private List<Repository> notesList;
|
||||
private int currentActiveAccountId;
|
||||
private NotesAdapter adapter;
|
||||
private NotesApi notesApi;
|
||||
private List<Notes> notesList;
|
||||
private Intent noteIntent;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -47,15 +52,15 @@ public class NotesFragment extends Fragment {
|
|||
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navNotes));
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
noteIntent = new Intent(ctx, CreateNoteActivity.class);
|
||||
|
||||
fragmentNotesBinding.newNote.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(view.getContext(), CreateNoteActivity.class);
|
||||
startActivity(intent);
|
||||
noteIntent.putExtra("action", "add");
|
||||
ctx.startActivity(noteIntent);
|
||||
});
|
||||
|
||||
notesList = new ArrayList<>();
|
||||
repositoriesApi = BaseApi.getInstance(ctx, RepositoriesApi.class);
|
||||
notesApi = BaseApi.getInstance(ctx, NotesApi.class);
|
||||
|
||||
fragmentNotesBinding.recyclerView.setHasFixedSize(true);
|
||||
fragmentNotesBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
@ -63,32 +68,39 @@ public class NotesFragment extends Fragment {
|
|||
fragmentNotesBinding.recyclerView.setPadding(0, 0, 0, 220);
|
||||
fragmentNotesBinding.recyclerView.setClipToPadding(false);
|
||||
|
||||
adapter = new MostVisitedReposAdapter(ctx, notesList);
|
||||
currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
adapter = new NotesAdapter(ctx, notesList);
|
||||
|
||||
fragmentNotesBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
notesList.clear();
|
||||
fragmentNotesBinding.pullToRefresh.setRefreshing(false);
|
||||
fragmentNotesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
fetchDataAsync();
|
||||
}, 250));
|
||||
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
fetchDataAsync();
|
||||
|
||||
return fragmentNotesBinding.getRoot();
|
||||
}
|
||||
|
||||
private void fetchDataAsync(int accountId) {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
notesList.clear();
|
||||
fetchDataAsync();
|
||||
}
|
||||
|
||||
repositoriesApi.fetchAllMostVisited(accountId).observe(getViewLifecycleOwner(), mostVisitedRepos -> {
|
||||
private void fetchDataAsync() {
|
||||
|
||||
notesApi.fetchAllNotes().observe(getViewLifecycleOwner(), allNotes -> {
|
||||
|
||||
fragmentNotesBinding.pullToRefresh.setRefreshing(false);
|
||||
assert mostVisitedRepos != null;
|
||||
if(mostVisitedRepos.size() > 0) {
|
||||
assert allNotes != null;
|
||||
if(allNotes.size() > 0) {
|
||||
|
||||
notesList.clear();
|
||||
fragmentNotesBinding.noData.setVisibility(View.GONE);
|
||||
notesList.addAll(mostVisitedRepos);
|
||||
notesList.addAll(allNotes);
|
||||
adapter.notifyDataChanged();
|
||||
fragmentNotesBinding.recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
@ -100,21 +112,39 @@ public class NotesFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
|
||||
/*public void resetAllRepositoryCounter(int accountId) {
|
||||
private void filter(String text) {
|
||||
|
||||
if(mostVisitedReposList.size() > 0) {
|
||||
List<Notes> arr = new ArrayList<>();
|
||||
|
||||
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class)).resetAllRepositoryMostVisited(accountId);
|
||||
mostVisitedReposList.clear();
|
||||
for(Notes d : notesList) {
|
||||
|
||||
if(d == null || d.getContent() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(d.getContent().toLowerCase().contains(text)) {
|
||||
arr.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
adapter.updateList(arr);
|
||||
}
|
||||
|
||||
public void deleteAllNotes() {
|
||||
|
||||
if(notesList.size() > 0) {
|
||||
|
||||
notesApi.deleteAllNotes();
|
||||
notesList.clear();
|
||||
adapter.notifyDataChanged();
|
||||
Toasty.success(ctx, getResources().getString(R.string.resetMostReposCounter));
|
||||
Toasty.success(ctx, ctx.getResources().getQuantityString(R.plurals.noteDeleteMessage, 2));
|
||||
}
|
||||
else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noDataFound));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
inflater.inflate(R.menu.reset_menu, menu);
|
||||
|
@ -140,20 +170,22 @@ public class NotesFragment extends Fragment {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
if(item.getItemId() == R.id.reset_menu_item) {
|
||||
|
||||
if(mostVisitedReposList.size() == 0) {
|
||||
if(notesList.size() == 0) {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noDataFound));
|
||||
}
|
||||
else {
|
||||
new MaterialAlertDialogBuilder(ctx).setTitle(R.string.reset).setMessage(R.string.resetCounterAllDialogMessage).setPositiveButton(R.string.reset, (dialog, which) -> {
|
||||
new MaterialAlertDialogBuilder(ctx).setTitle(R.string.menuDeleteText)
|
||||
.setMessage(R.string.notesAllDeletionMessage)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
resetAllRepositoryCounter(currentActiveAccountId);
|
||||
deleteAllNotes();
|
||||
dialog.dismiss();
|
||||
}).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
@ -161,22 +193,4 @@ public class NotesFragment extends Fragment {
|
|||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<Repository> arr = new ArrayList<>();
|
||||
|
||||
for(Repository d : mostVisitedReposList) {
|
||||
|
||||
if(d == null || d.getRepositoryOwner() == null || d.getRepositoryName() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(d.getRepositoryOwner().toLowerCase().contains(text) || d.getRepositoryName().toLowerCase().contains(text)) {
|
||||
arr.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
adapter.updateList(arr);
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -3,7 +3,12 @@ package org.mian.gitnex.fragments;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -5,7 +5,12 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
|
@ -5,7 +5,12 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -16,10 +16,21 @@ import org.gitnex.tea4j.v2.models.Organization;
|
|||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.*;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentRepoInfoBinding;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -13,7 +13,15 @@ import androidx.annotation.Nullable;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.*;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.activities.SettingsAppearanceActivity;
|
||||
import org.mian.gitnex.activities.SettingsDraftsActivity;
|
||||
import org.mian.gitnex.activities.SettingsGeneralActivity;
|
||||
import org.mian.gitnex.activities.SettingsNotificationsActivity;
|
||||
import org.mian.gitnex.activities.SettingsReportsActivity;
|
||||
import org.mian.gitnex.activities.SettingsSecurityActivity;
|
||||
import org.mian.gitnex.activities.SettingsTranslationActivity;
|
||||
import org.mian.gitnex.databinding.CustomAboutDialogBinding;
|
||||
import org.mian.gitnex.databinding.FragmentSettingsBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -12,7 +12,14 @@ import org.mian.gitnex.R;
|
|||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentProfileDetailBinding;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.Locale;
|
||||
import jp.wasabeef.picasso.transformations.BlurTransformation;
|
||||
import retrofit2.Call;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -4,7 +4,12 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package org.mian.gitnex.helpers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.*;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -13,7 +17,6 @@ import android.net.Uri;
|
|||
import android.os.Build;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import androidx.annotation.ColorInt;
|
||||
|
@ -35,7 +38,14 @@ import java.net.URL;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
|
|
@ -10,7 +10,12 @@ import androidx.core.content.res.ResourcesCompat;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.commonmark.ext.gfm.tables.TableBlock;
|
||||
import org.commonmark.node.*;
|
||||
import org.commonmark.node.AbstractVisitor;
|
||||
import org.commonmark.node.FencedCodeBlock;
|
||||
import org.commonmark.node.Image;
|
||||
import org.commonmark.node.Link;
|
||||
import org.commonmark.node.Node;
|
||||
import org.commonmark.node.Text;
|
||||
import org.commonmark.parser.InlineParserFactory;
|
||||
import org.commonmark.parser.Parser;
|
||||
import org.commonmark.parser.PostProcessor;
|
||||
|
@ -55,7 +60,13 @@ import io.noties.markwon.recycler.SimpleEntry;
|
|||
import io.noties.markwon.recycler.table.TableEntry;
|
||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||
import io.noties.prism4j.Prism4j;
|
||||
import stormpot.*;
|
||||
import stormpot.Allocator;
|
||||
import stormpot.BlazePool;
|
||||
import stormpot.Config;
|
||||
import stormpot.Pool;
|
||||
import stormpot.Poolable;
|
||||
import stormpot.Slot;
|
||||
import stormpot.Timeout;
|
||||
|
||||
/**
|
||||
* @author opyale
|
||||
|
|
|
@ -6,7 +6,12 @@ import android.graphics.BitmapFactory;
|
|||
import android.util.Log;
|
||||
import com.squareup.picasso.Cache;
|
||||
import org.mian.gitnex.R;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package org.mian.gitnex.helpers;
|
||||
|
||||
import android.graphics.*;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
|
|
|
@ -5,7 +5,11 @@ import android.app.NotificationManager;
|
|||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import androidx.work.*;
|
||||
import androidx.work.Constraints;
|
||||
import androidx.work.ExistingPeriodicWorkPolicy;
|
||||
import androidx.work.NetworkType;
|
||||
import androidx.work.PeriodicWorkRequest;
|
||||
import androidx.work.WorkManager;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
|
|
|
@ -57,35 +57,28 @@
|
|||
android:orientation="vertical"
|
||||
android:padding="@dimen/dimen16dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/note_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="textCapSentences"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:hint="@string/newMilestoneTitle"
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:textSize="@dimen/dimen14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/note_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dimen480dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top|start"
|
||||
android:layout_marginTop="@dimen/dimen32dp"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:scrollbars="vertical"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:hint="Start taking notes here ..."
|
||||
android:hint="@string/newNoteContentHint"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:textSize="@dimen/dimen14sp"
|
||||
android:autofillHints="Start taking notes here ..." />
|
||||
android:textSize="@dimen/dimen16sp"
|
||||
android:autofillHints="@string/newNoteContentHint" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/markdown_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="@dimen/dimen16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -22,92 +22,54 @@
|
|||
android:padding="@dimen/dimen12dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/org_info_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dimen8dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="@dimen/dimen24dp"
|
||||
android:layout_height="@dimen/dimen24dp"
|
||||
android:layout_marginStart="@dimen/dimen0dp"
|
||||
android:layout_marginEnd="@dimen/dimen10dp"
|
||||
android:contentDescription="@string/repoContentAvatar"
|
||||
android:src="@drawable/ic_android"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/org_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen14sp"
|
||||
tools:text="@string/orgName"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repo_name"
|
||||
android:id="@+id/content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/repoName"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen16sp"
|
||||
android:textStyle="bold"/>
|
||||
android:textSize="@dimen/dimen14sp" />
|
||||
|
||||
<View
|
||||
android:id="@+id/spacer_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="@dimen/dimen8dp"/>
|
||||
android:layout_marginBottom="@dimen/dimen8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/repo_info_frame"
|
||||
android:id="@+id/note_info_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dimen18dp"
|
||||
android:layout_height="@dimen/dimen18dp"
|
||||
android:layout_marginStart="@dimen/dimen0dp"
|
||||
android:layout_marginEnd="@dimen/dimen6dp"
|
||||
android:contentDescription="@string/generalImgContentText"
|
||||
app:srcCompat="@drawable/ic_trending"
|
||||
app:tint="?attr/iconsColor"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/most_visited"
|
||||
android:id="@+id/datetime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen14sp"
|
||||
tools:text="@string/repoStars"/>
|
||||
android:textSize="@dimen/dimen12sp"
|
||||
tools:text="@string/noteDateTime" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/repo_info_end_frame"
|
||||
android:id="@+id/note_info_end_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dimen10dp"
|
||||
android:gravity="center_vertical|end"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/dimen6dp"
|
||||
android:paddingEnd="@dimen/dimen6dp">
|
||||
android:paddingEnd="@dimen/dimen0dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reset_counter"
|
||||
android:id="@+id/delete_note"
|
||||
android:layout_width="@dimen/dimen18dp"
|
||||
android:layout_height="@dimen/dimen18dp"
|
||||
android:layout_marginStart="@dimen/dimen16dp"
|
||||
android:layout_marginEnd="@dimen/dimen2dp"
|
||||
android:contentDescription="@string/generalImgContentText"
|
||||
app:srcCompat="@drawable/ic_reset"
|
||||
app:tint="?attr/iconsColor"/>
|
||||
app:srcCompat="@drawable/ic_delete"
|
||||
app:tint="?attr/iconsColor" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -794,4 +794,14 @@
|
|||
|
||||
<!-- notes -->
|
||||
<string name="newNote">New Note</string>
|
||||
<string name="editNote">Edit Note</string>
|
||||
<string name="newNoteContentHint">Start taking your notes here</string>
|
||||
<string name="noteDateTime">Created %s</string>
|
||||
<string name="noteTimeModified">Updated %s</string>
|
||||
<string name="noteDeleteDialoMessage">Do you really want to delete this note?</string>
|
||||
<plurals name="noteDeleteMessage">
|
||||
<item quantity="one">Note deleted successfully</item>
|
||||
<item quantity="other">Notes deleted successfully</item>
|
||||
</plurals>
|
||||
<string name="notesAllDeletionMessage">This will delete all of your notes. This action cannot be undone.</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue