Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message translation updates format improvements typo update some renaming refactors Use better naming convention remove duplicate source arrange draft titles enhance click listener area Launch drafts from reply screen and clean up Add message draft saved update repositories tasks Update user accounts repository with thread, remove async tasks remove async task in drafts update layout, change async to thread in drafts Merge branch 'master' into pull_139 # Conflicts: # app/build.gradle # app/src/main/java/org/mian/gitnex/activities/LoginActivity.java Merge branch 'master' into pull_139 # Conflicts: # app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139 # Conflicts: # app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java Merge branch 'master' into pull_139 # Conflicts: # app/src/main/java/org/mian/gitnex/activities/LoginActivity.java # app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java # app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java Merge branch 'master' into pull_139 Merge branch 'master' into pull_139 Merge branch 'master' into pull_139 and fix conflicts # Conflicts: # app/build.gradle # app/src/main/java/org/mian/gitnex/activities/LoginActivity.java # app/src/main/java/org/mian/gitnex/activities/MainActivity.java # app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java # app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java # app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java # app/src/main/res/values/strings.xml Code Format Merge branch 'master' into 15-comments-draft Merge branch 'master' into 15-comments-draft Merge branch 'master' into 15-comments-draft # Conflicts: # app/src/main/java/org/mian/gitnex/activities/MainActivity.java # app/src/main/res/values/strings.xml Go to draft, save on type and other fixes delete all drafts, added messages where needed delete draft Force logout Merge branch 'master' into 15-comments-draft Merge branch 'master' into 15-comments-draft # Conflicts: # app/src/main/java/org/mian/gitnex/activities/MainActivity.java # app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java check if account data is null, we need to log the user out for the 1st time. Merge branch 'master' into 15-comments-draft fix repo owner, name sequence Add comments for test, show drafts list Add repos to db Add account to db and other refactors to the code Merge branch 'master' into 15-comments-draft Merge branch 'master' into 15-comments-draft Merge branch 'master' into 15-comments-draft Merge branch 'master' into 15-comments-draft # Conflicts: # app/build.gradle # app/src/main/AndroidManifest.xml Merge branch 'master' into 15-comments-draft merge more queries, added dao repositories, layout update Added queries in dao some refactor. added models, dao, entities (accounts, repositories, drafts) WIP on implementing drafts, introduced Room persistence library for db. Co-authored-by: M M Arif <mmarif@swatian.com> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139 Reviewed-by: opyale <opyale@noreply.codeberg.org>
This commit is contained in:
parent
f135508745
commit
cdfc2cfb9e
@ -85,6 +85,8 @@ dependencies {
|
||||
implementation "ch.acra:acra-mail:$acra"
|
||||
implementation "ch.acra:acra-limiter:$acra"
|
||||
implementation "ch.acra:acra-notification:$acra"
|
||||
implementation "androidx.room:room-runtime:2.2.5"
|
||||
annotationProcessor "androidx.room:room-compiler:2.2.5"
|
||||
implementation "com.eightbitlab:blurview:1.6.3"
|
||||
implementation "io.mikael:urlbuilder:2.0.9"
|
||||
|
||||
|
@ -21,6 +21,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import com.tooltip.Tooltip;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.helpers.NetworkObserver;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
@ -380,6 +381,15 @@ public class LoginActivity extends BaseActivity {
|
||||
tinyDB.putString("loginUid", userDetails.getLogin());
|
||||
tinyDB.putString("userLogin", userDetails.getUsername());
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||
int checkAccount = userAccountsApi.getCount(accountName);
|
||||
|
||||
if(checkAccount == 0) {
|
||||
userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||
}
|
||||
|
||||
enableProcessButton();
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
finish();
|
||||
@ -517,6 +527,15 @@ public class LoginActivity extends BaseActivity {
|
||||
tinyDB.putString(loginUid + "-token", newToken.getSha1());
|
||||
tinyDB.putString(loginUid + "-token-last-eight", appUtil.getLastCharactersOfWord(newToken.getSha1(), 8));
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||
int checkAccount = userAccountsApi.getCount(accountName);
|
||||
|
||||
if(checkAccount == 0) {
|
||||
userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), newToken.getSha1(), "");
|
||||
}
|
||||
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
finish();
|
||||
break;
|
||||
@ -581,6 +600,16 @@ public class LoginActivity extends BaseActivity {
|
||||
assert userDetails != null;
|
||||
tinyDB.putString("userLogin", userDetails.getUsername());
|
||||
tinyDB.putBoolean("loggedInMode", true);
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||
int checkAccount = userAccountsApi.getCount(accountName);
|
||||
|
||||
if(checkAccount == 0) {
|
||||
userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), instanceToken, "");
|
||||
}
|
||||
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
finish();
|
||||
break;
|
||||
|
@ -17,6 +17,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
@ -26,7 +27,11 @@ import com.google.android.material.navigation.NavigationView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.fragments.AboutFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.ExploreRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
||||
@ -46,6 +51,7 @@ import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import eightbitlab.com.blurview.BlurView;
|
||||
import eightbitlab.com.blurview.RenderScriptBlur;
|
||||
import retrofit2.Call;
|
||||
@ -55,7 +61,7 @@ import retrofit2.Callback;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener {
|
||||
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetDraftsFragment.BottomSheetListener {
|
||||
|
||||
private DrawerLayout drawer;
|
||||
private BlurView blurView;
|
||||
@ -85,6 +91,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
//userAvatar = findViewById(R.id.userAvatar);
|
||||
|
||||
Intent mainIntent = getIntent();
|
||||
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
@ -113,6 +122,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
return;
|
||||
}
|
||||
|
||||
String accountName = loginUid + "@" + instanceUrl;
|
||||
try {
|
||||
getAccountData(accountName);
|
||||
}
|
||||
catch(ExecutionException | InterruptedException e) {
|
||||
Log.e("getAccountData", e.toString());
|
||||
}
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
|
||||
@ -159,6 +176,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
else if(fragmentById instanceof AboutFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout));
|
||||
}
|
||||
else if(fragmentById instanceof DraftsFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
}
|
||||
else if(fragmentById instanceof AdministrationFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||
}
|
||||
@ -263,6 +283,18 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
toggle.syncState();
|
||||
|
||||
if(launchFragment != null) {
|
||||
|
||||
if(launchFragment.equals("drafts")) {
|
||||
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||
mainIntent.removeExtra("launchFragment");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(savedInstanceState == null) {
|
||||
|
||||
switch(tinyDb.getInt("homeScreenId")) {
|
||||
@ -336,9 +368,55 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
}
|
||||
|
||||
public void setActionBarTitle(@NonNull String title) {
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
|
||||
if("deleteDrafts".equals(text)) {
|
||||
|
||||
if(currentActiveAccountId > 0) {
|
||||
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
DraftsFragment frag = (DraftsFragment) fm.findFragmentById(R.id.fragment_container);
|
||||
|
||||
if(frag != null) {
|
||||
|
||||
new AlertDialog.Builder(ctx).setTitle(R.string.deleteAllDrafts).setIcon(R.drawable.ic_delete).setCancelable(false).setMessage(R.string.deleteAllDraftsDialogMessage).setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
frag.deleteAllDrafts(currentActiveAccountId);
|
||||
dialog.dismiss();
|
||||
|
||||
}).setNegativeButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).show();
|
||||
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void getAccountData(String accountName) throws ExecutionException, InterruptedException {
|
||||
|
||||
UserAccountsApi accountData = new UserAccountsApi(ctx);
|
||||
UserAccount data = accountData.getAccountData(accountName);
|
||||
|
||||
if(data != null) {
|
||||
TinyDB tinyDb = new TinyDB(ctx.getApplicationContext());
|
||||
tinyDb.putInt("currentActiveAccountId", data.getAccountId());
|
||||
}
|
||||
else {
|
||||
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
}
|
||||
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -407,6 +485,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreRepositoriesFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_comments_draft:
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_administration:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AdministrationFragment()).commit();
|
||||
@ -440,6 +523,21 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == R.id.genericMenu) {
|
||||
BottomSheetDraftsFragment bottomSheet = new BottomSheetDraftsFragment();
|
||||
bottomSheet.show(getSupportFragmentManager(), "draftsBottomSheet");
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
}
|
||||
|
||||
private void giteaVersion(final String instanceUrl) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
@ -1,33 +1,42 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import com.hendraanggrian.appcompat.socialview.Mention;
|
||||
import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
|
||||
import com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -41,9 +50,11 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
private TextView draftSaved;
|
||||
private SocialAutoCompleteTextView addComment;
|
||||
private ArrayAdapter<Mention> defaultMentionAdapter;
|
||||
private Button replyButton;
|
||||
private String TAG = StaticGlobalVariables.replyToIssueActivity;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -55,12 +66,15 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
draftSaved = findViewById(R.id.draftSaved);
|
||||
addComment = findViewById(R.id.addComment);
|
||||
addComment.setShowSoftInputOnFocus(true);
|
||||
|
||||
@ -95,6 +109,12 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
if(getIntent().getStringExtra("draftTitle") != null) {
|
||||
|
||||
toolbar_title.setText(getIntent().getStringExtra("draftTitle"));
|
||||
|
||||
}
|
||||
|
||||
if(getIntent().getStringExtra("commentAction") != null && getIntent().getStringExtra("commentAction").equals("edit")) {
|
||||
|
||||
final String commentId = getIntent().getStringExtra("commentId");
|
||||
@ -102,20 +122,62 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
toolbar_title.setText(getResources().getString(R.string.editCommentTitle));
|
||||
replyButton.setText(getResources().getString(R.string.editCommentButtonText));
|
||||
|
||||
addComment.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
saveDraft(addComment.getText().toString());
|
||||
draftSaved.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
replyButton.setOnClickListener(v -> {
|
||||
|
||||
disableProcessButton();
|
||||
assert commentId != null;
|
||||
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString());
|
||||
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
addComment.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
saveDraft(addComment.getText().toString());
|
||||
draftSaved.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
replyButton.setOnClickListener(replyToIssue);
|
||||
|
||||
@ -123,6 +185,27 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void saveDraft(String draftText) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
int repositoryId = (int) tinyDb.getLong("repositoryId", 0);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int issueNumber = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(getApplicationContext());
|
||||
|
||||
int countDraft = draftsApi.checkDraft(issueNumber, repositoryId);
|
||||
|
||||
if(countDraft == 0) {
|
||||
long draftId = draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment);
|
||||
}
|
||||
else {
|
||||
DraftsApi.updateDraftByIssueIdAsyncTask(draftText, issueNumber, repositoryId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void loadCollaboratorsList() {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
@ -153,13 +236,13 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
if(!response.body().get(i).getFull_name().equals("")) {
|
||||
fullName = response.body().get(i).getFull_name();
|
||||
}
|
||||
defaultMentionAdapter.add(
|
||||
new Mention(response.body().get(i).getUsername(), fullName, response.body().get(i).getAvatar_url()));
|
||||
defaultMentionAdapter.add(new Mention(response.body().get(i).getUsername(), fullName, response.body().get(i).getAvatar_url()));
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
Log.i(TAG, String.valueOf(response.code()));
|
||||
|
||||
}
|
||||
|
||||
@ -167,26 +250,19 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.getMessage());
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private View.OnClickListener replyToIssue = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
processNewCommentReply();
|
||||
}
|
||||
};
|
||||
private View.OnClickListener replyToIssue = v -> processNewCommentReply();
|
||||
|
||||
private void processNewCommentReply() {
|
||||
|
||||
@ -268,13 +344,43 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.reply_to_issue, menu);
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch(item.getItemId()) {
|
||||
|
||||
case R.id.replyToIssueMenu:
|
||||
Intent fragmentIntent = new Intent(ReplyToIssueActivity.this, MainActivity.class);
|
||||
fragmentIntent.putExtra("launchFragment", "drafts");
|
||||
ReplyToIssueActivity.this.startActivity(fragmentIntent);
|
||||
break;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
replyButton.setEnabled(false);
|
||||
|
127
app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java
Normal file
127
app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java
Normal file
@ -0,0 +1,127 @@
|
||||
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 org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||
|
||||
private List<DraftWithRepository> draftsList;
|
||||
private Context mCtx;
|
||||
|
||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView draftText;
|
||||
private TextView repoInfo;
|
||||
private TextView repoId;
|
||||
private TextView draftId;
|
||||
private TextView issueNumber;
|
||||
private TextView issueType;
|
||||
private TextView repoOwner;
|
||||
private TextView repoName;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
draftText = itemView.findViewById(R.id.draftText);
|
||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
||||
repoId = itemView.findViewById(R.id.repoId);
|
||||
draftId = itemView.findViewById(R.id.draftId);
|
||||
issueNumber = itemView.findViewById(R.id.issueNumber);
|
||||
issueType = itemView.findViewById(R.id.issueType);
|
||||
repoOwner = itemView.findViewById(R.id.repoOwner);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
|
||||
int getDraftId = Integer.parseInt(draftId.getText().toString());
|
||||
deleteDraft(getAdapterPosition());
|
||||
DraftsApi.deleteSingleDraft(getDraftId);
|
||||
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
|
||||
Intent intent = new Intent(mCtx, ReplyToIssueActivity.class);
|
||||
intent.putExtra("commentBody", draftText.getText());
|
||||
intent.putExtra("issueNumber", issueNumber.getText());
|
||||
intent.putExtra("repositoryId", repoId.getText());
|
||||
intent.putExtra("draftTitle", repoInfo.getText());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(mCtx);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putLong("repositoryId", Long.parseLong(repoId.getText().toString()));
|
||||
//tinyDb.putString("issueType", issueType.getText().toString());
|
||||
|
||||
mCtx.startActivity(intent);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DraftsAdapter(Context mCtx, List<DraftWithRepository> draftsListMain) {
|
||||
this.mCtx = mCtx;
|
||||
this.draftsList = draftsListMain;
|
||||
}
|
||||
|
||||
private void deleteDraft(int position) {
|
||||
|
||||
draftsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, draftsList.size());
|
||||
Toasty.info(mCtx, mCtx.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DraftsAdapter.DraftsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_drafts, parent, false);
|
||||
return new DraftsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DraftsAdapter.DraftsViewHolder holder, int position) {
|
||||
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
holder.repoId.setText(String.valueOf(currentItem.getRepositoryId()));
|
||||
holder.draftId.setText(String.valueOf(currentItem.getDraftId()));
|
||||
holder.issueNumber.setText(String.valueOf(currentItem.getIssueId()));
|
||||
holder.issueType.setText(currentItem.getDraftType());
|
||||
holder.repoOwner.setText(currentItem.getRepositoryOwner());
|
||||
holder.repoName.setText(currentItem.getRepositoryName());
|
||||
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()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return draftsList.size();
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,8 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -92,12 +94,33 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
String[] parts = fullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
@ -138,6 +161,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
|
@ -13,6 +13,8 @@ import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
@ -23,6 +25,8 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -30,8 +34,6 @@ import org.mian.gitnex.models.WatchInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -60,6 +62,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
private LinearLayout archiveRepo;
|
||||
|
||||
private MyReposViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||
@ -87,12 +90,33 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
@ -111,7 +135,8 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
assert response.body() != null;
|
||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
|
||||
@ -133,6 +158,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
@ -143,8 +169,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
@ -186,9 +211,11 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MyReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
||||
|
||||
this.mCtx = mCtx;
|
||||
this.reposList = reposListMain;
|
||||
reposListFull = new ArrayList<>(reposList);
|
||||
@ -197,6 +224,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
@NonNull
|
||||
@Override
|
||||
public MyReposListAdapter.MyReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false);
|
||||
return new MyReposListAdapter.MyReposViewHolder(v);
|
||||
}
|
||||
@ -211,20 +239,13 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.fontSize(18)
|
||||
.toUpperCase()
|
||||
.width(28)
|
||||
.height(28)
|
||||
.endConfig()
|
||||
.buildRoundRect(firstCharacter, color, 3);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(currentItem.getAvatar_url() != null) {
|
||||
if(!currentItem.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.imageAvatar);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
holder.imageAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
@ -266,22 +287,27 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return reposList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
|
||||
return myReposFilter;
|
||||
}
|
||||
|
||||
private Filter myReposFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<UserRepositories> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(UserRepositories item : reposListFull) {
|
||||
@ -299,9 +325,11 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
reposList.clear();
|
||||
reposList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -90,12 +92,33 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
@ -136,6 +159,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
|
@ -23,6 +23,8 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -87,12 +89,33 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = fullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
@ -133,6 +156,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
|
@ -23,6 +23,8 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -87,12 +89,33 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = fullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
@ -133,6 +156,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
|
109
app/src/main/java/org/mian/gitnex/database/api/DraftsApi.java
Normal file
109
app/src/main/java/org/mian/gitnex/database/api/DraftsApi.java
Normal file
@ -0,0 +1,109 @@
|
||||
package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import org.mian.gitnex.database.dao.DraftsDao;
|
||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class DraftsApi {
|
||||
|
||||
private static DraftsDao draftsDao;
|
||||
private static long draftId;
|
||||
private static Integer checkDraftFlag;
|
||||
|
||||
public DraftsApi(Context context) {
|
||||
|
||||
GitnexDatabase db;
|
||||
db = GitnexDatabase.getDatabaseInstance(context);
|
||||
draftsDao = db.draftsDao();
|
||||
}
|
||||
|
||||
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType) {
|
||||
|
||||
Draft draft = new Draft();
|
||||
draft.setDraftRepositoryId(repositoryId);
|
||||
draft.setDraftAccountId(draftAccountId);
|
||||
draft.setIssueId(issueId);
|
||||
draft.setDraftText(draftText);
|
||||
draft.setDraftType(draftType);
|
||||
|
||||
return insertDraftAsyncTask(draft);
|
||||
}
|
||||
|
||||
private static long insertDraftAsyncTask(final Draft draft) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> draftId = draftsDao.insertDraft(draft));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.draftsRepository, e.toString());
|
||||
}
|
||||
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public Integer checkDraft(int issueId, int draftRepositoryId) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> checkDraftFlag = draftsDao.checkDraftDao(issueId, draftRepositoryId));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.draftsRepository, e.toString());
|
||||
}
|
||||
|
||||
return checkDraftFlag;
|
||||
}
|
||||
|
||||
public LiveData<List<DraftWithRepository>> getDrafts(int accountId) {
|
||||
|
||||
return draftsDao.fetchAllDrafts(accountId);
|
||||
}
|
||||
|
||||
public LiveData<Draft> getDraftByIssueId(int issueId) {
|
||||
|
||||
return draftsDao.fetchDraftByIssueId(issueId);
|
||||
}
|
||||
|
||||
public static void deleteSingleDraft(final int draftId) {
|
||||
|
||||
final LiveData<Draft> draft = draftsDao.fetchDraftById(draftId);
|
||||
|
||||
if(draft != null) {
|
||||
|
||||
new Thread(() -> draftsDao.deleteByDraftId(draftId)).start();
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteAllDrafts(final int accountId) {
|
||||
|
||||
new Thread(() -> draftsDao.deleteAllDrafts(accountId)).start();
|
||||
}
|
||||
|
||||
public static void updateDraft(final String draftText, final int draftId) {
|
||||
|
||||
new Thread(() -> draftsDao.updateDraft(draftText, draftId)).start();
|
||||
}
|
||||
|
||||
public static void updateDraftByIssueIdAsyncTask(final String draftText, final int issueId, final int draftRepositoryId) {
|
||||
|
||||
new Thread(() -> draftsDao.updateDraftByIssueId(draftText, issueId, draftRepositoryId)).start();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import org.mian.gitnex.database.dao.RepositoriesDao;
|
||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class RepositoriesApi {
|
||||
|
||||
private static RepositoriesDao repositoriesDao;
|
||||
private static long repositoryId;
|
||||
private static Repository repository;
|
||||
private static Integer checkRepository;
|
||||
|
||||
public RepositoriesApi(Context context) {
|
||||
|
||||
GitnexDatabase db;
|
||||
db = GitnexDatabase.getDatabaseInstance(context);
|
||||
repositoriesDao = db.repositoriesDao();
|
||||
}
|
||||
|
||||
public long insertRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||
|
||||
Repository repository = new Repository();
|
||||
repository.setRepoAccountId(repoAccountId);
|
||||
repository.setRepositoryOwner(repositoryOwner);
|
||||
repository.setRepositoryName(repositoryName);
|
||||
|
||||
return insertRepositoryAsyncTask(repository);
|
||||
}
|
||||
|
||||
public long insertRepositoryAsyncTask(Repository repository) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> repositoryId = repositoriesDao.newRepository(repository));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public Repository getRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> repository = repositoriesDao.getSingleRepositoryDao(repoAccountId, repositoryOwner, repositoryName));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public LiveData<List<Repository>> getAllRepositories() {
|
||||
|
||||
return repositoriesDao.fetchAllRepositories();
|
||||
}
|
||||
|
||||
public LiveData<List<Repository>> getAllRepositoriesByAccount(int repoAccountId) {
|
||||
|
||||
return repositoriesDao.getAllRepositoriesByAccountDao(repoAccountId);
|
||||
}
|
||||
|
||||
public Integer checkRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> checkRepository = repositoriesDao.checkRepositoryDao(repoAccountId, repositoryOwner, repositoryName));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return checkRepository;
|
||||
}
|
||||
|
||||
public Repository fetchRepositoryById(int repositoryId) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> repository = repositoriesDao.fetchRepositoryByIdDao(repositoryId));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public Repository fetchRepositoryByAccountIdByRepositoryId(int repositoryId, int repoAccountId) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> repository = repositoriesDao.fetchRepositoryByAccountIdByRepositoryIdDao(repositoryId, repoAccountId));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public static void deleteRepositoriesByAccount(final int repoAccountId) {
|
||||
|
||||
new Thread(() -> repositoriesDao.deleteRepositoriesByAccount(repoAccountId)).start();
|
||||
}
|
||||
|
||||
public static void deleteRepository(final int repositoryId) {
|
||||
|
||||
new Thread(() -> repositoriesDao.deleteRepository(repositoryId)).start();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import org.mian.gitnex.database.dao.UserAccountsDao;
|
||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class UserAccountsApi {
|
||||
|
||||
private static UserAccountsDao userAccountsDao;
|
||||
private static UserAccount userAccount;
|
||||
private static Integer checkAccount;
|
||||
|
||||
public UserAccountsApi(Context context) {
|
||||
|
||||
GitnexDatabase db;
|
||||
db = GitnexDatabase.getDatabaseInstance(context);
|
||||
userAccountsDao = db.userAccountsDao();
|
||||
}
|
||||
|
||||
public void insertNewAccount(String accountName, String instanceUrl, String userName, String token, String serverVersion) {
|
||||
|
||||
UserAccount userAccount = new UserAccount();
|
||||
userAccount.setAccountName(accountName);
|
||||
userAccount.setInstanceUrl(instanceUrl);
|
||||
userAccount.setUserName(userName);
|
||||
userAccount.setToken(token);
|
||||
userAccount.setServerVersion(serverVersion);
|
||||
|
||||
insertNewAccountAsync(userAccount);
|
||||
}
|
||||
|
||||
private static void insertNewAccountAsync(final UserAccount userAccount) {
|
||||
|
||||
new Thread(() -> userAccountsDao.newAccount(userAccount)).start();
|
||||
}
|
||||
|
||||
public static void updateServerVersion(final String serverVersion, final int accountId) {
|
||||
|
||||
new Thread(() -> userAccountsDao.updateServerVersion(serverVersion, accountId)).start();
|
||||
}
|
||||
|
||||
public static void updateToken(final int accountId, final String token) {
|
||||
|
||||
new Thread(() -> userAccountsDao.updateAccountToken(accountId, token)).start();
|
||||
}
|
||||
|
||||
public UserAccount getAccountData(String accountName) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> userAccount = userAccountsDao.fetchRowByAccount_(accountName));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
||||
}
|
||||
|
||||
return userAccount;
|
||||
}
|
||||
|
||||
public Integer getCount(String accountName) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> checkAccount = userAccountsDao.getCount(accountName));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
||||
}
|
||||
|
||||
return checkAccount;
|
||||
}
|
||||
|
||||
public LiveData<List<UserAccount>> getAllAccounts() {
|
||||
|
||||
return userAccountsDao.fetchAllAccounts();
|
||||
}
|
||||
|
||||
public static void deleteAccount(final int accountId) {
|
||||
|
||||
new Thread(() -> userAccountsDao.deleteAccount(accountId)).start();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
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.Draft;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Dao
|
||||
public interface DraftsDao {
|
||||
|
||||
@Insert
|
||||
long insertDraft(Draft drafts);
|
||||
|
||||
@Query("SELECT * FROM Drafts JOIN Repositories ON Repositories.repositoryId = Drafts.draftRepositoryId WHERE draftAccountId = :accountId" +
|
||||
" ORDER BY " +
|
||||
"draftId DESC")
|
||||
LiveData<List<DraftWithRepository>> fetchAllDrafts(int accountId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE draftAccountId = :accountId ORDER BY draftId DESC")
|
||||
LiveData<List<Draft>> fetchDrafts(int accountId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE draftAccountId = :accountId and draftRepositoryId = :repositoryId")
|
||||
LiveData<Draft> fetchSingleDraftByAccountIdAndRepositoryId(int accountId, int repositoryId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE draftId = :draftId")
|
||||
LiveData<Draft> fetchDraftById(int draftId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE issueId = :issueId")
|
||||
LiveData<Draft> fetchDraftByIssueId(int issueId);
|
||||
|
||||
@Query("SELECT count(draftId) FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
Integer checkDraftDao(int issueId, int draftRepositoryId);
|
||||
|
||||
@Query("UPDATE Drafts SET draftText= :draftText WHERE draftId = :draftId")
|
||||
void updateDraft(String draftText, int draftId);
|
||||
|
||||
@Query("UPDATE Drafts SET draftText= :draftText WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
void updateDraftByIssueId(String draftText, int issueId, int draftRepositoryId);
|
||||
|
||||
@Query("DELETE FROM Drafts WHERE draftId = :draftId")
|
||||
void deleteByDraftId(int draftId);
|
||||
|
||||
@Query("DELETE FROM Drafts WHERE draftAccountId = :accountId")
|
||||
void deleteAllDrafts(int accountId);
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
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.Repository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Dao
|
||||
public interface RepositoriesDao {
|
||||
|
||||
@Insert
|
||||
long newRepository(Repository repositories);
|
||||
|
||||
@Query("SELECT * FROM Repositories ORDER BY repositoryId ASC")
|
||||
LiveData<List<Repository>> fetchAllRepositories();
|
||||
|
||||
@Query("SELECT * FROM Repositories WHERE repoAccountId = :repoAccountId")
|
||||
LiveData<List<Repository>> getAllRepositoriesByAccountDao(int repoAccountId);
|
||||
|
||||
@Query("SELECT count(repositoryId) FROM Repositories WHERE repoAccountId = :repoAccountId AND repositoryOwner = :repositoryOwner AND repositoryName = :repositoryName")
|
||||
Integer checkRepositoryDao(int repoAccountId, String repositoryOwner, String repositoryName);
|
||||
|
||||
@Query("SELECT * FROM Repositories WHERE repoAccountId = :repoAccountId AND repositoryOwner = :repositoryOwner AND repositoryName = :repositoryName")
|
||||
Repository getSingleRepositoryDao(int repoAccountId, String repositoryOwner, String repositoryName);
|
||||
|
||||
@Query("SELECT * FROM Repositories WHERE repositoryId = :repositoryId")
|
||||
Repository fetchRepositoryByIdDao(int repositoryId);
|
||||
|
||||
@Query("SELECT * FROM Repositories WHERE repositoryId = :repositoryId AND repoAccountId = :repoAccountId")
|
||||
Repository fetchRepositoryByAccountIdByRepositoryIdDao(int repositoryId, int repoAccountId);
|
||||
|
||||
@Query("UPDATE Repositories SET repositoryOwner = :repositoryOwner, repositoryName = :repositoryName WHERE repositoryId = :repositoryId")
|
||||
void updateRepositoryOwnerAndName(String repositoryOwner, String repositoryName, int repositoryId);
|
||||
|
||||
@Query("DELETE FROM Repositories WHERE repositoryId = :repositoryId")
|
||||
void deleteRepository(int repositoryId);
|
||||
|
||||
@Query("DELETE FROM Repositories WHERE repoAccountId = :repoAccountId")
|
||||
void deleteRepositoriesByAccount(int repoAccountId);
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
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.UserAccount;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Dao
|
||||
public interface UserAccountsDao {
|
||||
|
||||
@Insert
|
||||
void newAccount(UserAccount userAccounts);
|
||||
|
||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||
LiveData<List<UserAccount>> fetchAllAccounts();
|
||||
|
||||
@Query("SELECT COUNT(accountId) FROM UserAccounts WHERE accountName = :accountName")
|
||||
Integer getCount(String accountName);
|
||||
|
||||
@Query("SELECT * FROM UserAccounts WHERE accountName = :accountName")
|
||||
UserAccount fetchRowByAccount_(String accountName);
|
||||
|
||||
@Query("SELECT * FROM UserAccounts WHERE accountId = :accountId")
|
||||
UserAccount fetchRowByAccountId(int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET serverVersion = :serverVersion WHERE accountId = :accountId")
|
||||
void updateServerVersion(String serverVersion, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET accountName = :accountName WHERE accountId = :accountId")
|
||||
void updateAccountName(String accountName, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET token = :token WHERE accountId = :accountId")
|
||||
void updateAccountToken(int accountId, String token);
|
||||
|
||||
@Query("UPDATE UserAccounts SET instanceUrl = :instanceUrl, token = :token WHERE accountId = :accountId")
|
||||
void updateHostInfo(String instanceUrl, String token, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET userName = :userName WHERE accountId = :accountId")
|
||||
void updateUserName(String userName, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET instanceUrl = :instanceUrl, token = :token, userName = :userName, serverVersion = :serverVersion WHERE accountId = :accountId")
|
||||
void updateAll(String instanceUrl, String token, String userName, String serverVersion, int accountId);
|
||||
|
||||
@Query("DELETE FROM UserAccounts WHERE accountId = :accountId")
|
||||
void deleteAccount(int accountId);
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package org.mian.gitnex.database.db;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
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.RepositoriesDao;
|
||||
import org.mian.gitnex.database.dao.UserAccountsDao;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||
version = 1, exportSchema = false)
|
||||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
private static GitnexDatabase gitnexDatabase;
|
||||
|
||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||
|
||||
if (gitnexDatabase == null) {
|
||||
String DB_NAME = "gitnex";
|
||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||
//.fallbackToDestructiveMigration()
|
||||
//.addMigrations(MIGRATION_1_2)
|
||||
.build();
|
||||
}
|
||||
|
||||
return gitnexDatabase;
|
||||
}
|
||||
|
||||
public abstract DraftsDao draftsDao();
|
||||
|
||||
public abstract RepositoriesDao repositoriesDao();
|
||||
|
||||
public abstract UserAccountsDao userAccountsDao();
|
||||
|
||||
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
|
||||
//database.execSQL("DROP TABLE Drafts");
|
||||
//database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'draftType' TEXT");
|
||||
|
||||
}
|
||||
};
|
||||
}
|
89
app/src/main/java/org/mian/gitnex/database/models/Draft.java
Normal file
89
app/src/main/java/org/mian/gitnex/database/models/Draft.java
Normal file
@ -0,0 +1,89 @@
|
||||
package org.mian.gitnex.database.models;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.ForeignKey;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
import java.io.Serializable;
|
||||
import static androidx.room.ForeignKey.CASCADE;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "Drafts", foreignKeys = @ForeignKey(entity = Repository.class, parentColumns = "repositoryId", childColumns = "draftRepositoryId", onDelete = CASCADE), indices = {@Index("draftRepositoryId")})
|
||||
public class Draft implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int draftId;
|
||||
|
||||
private int draftRepositoryId;
|
||||
private int draftAccountId;
|
||||
private int issueId;
|
||||
private String draftText;
|
||||
@Nullable
|
||||
private String draftType;
|
||||
|
||||
public int getDraftId() {
|
||||
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public void setDraftId(int draftId) {
|
||||
|
||||
this.draftId = draftId;
|
||||
}
|
||||
|
||||
public int getDraftRepositoryId() {
|
||||
|
||||
return draftRepositoryId;
|
||||
}
|
||||
|
||||
public void setDraftRepositoryId(int draftRepositoryId) {
|
||||
|
||||
this.draftRepositoryId = draftRepositoryId;
|
||||
}
|
||||
|
||||
public int getDraftAccountId() {
|
||||
|
||||
return draftAccountId;
|
||||
}
|
||||
|
||||
public void setDraftAccountId(int draftAccountId) {
|
||||
|
||||
this.draftAccountId = draftAccountId;
|
||||
}
|
||||
|
||||
public int getIssueId() {
|
||||
|
||||
return issueId;
|
||||
}
|
||||
|
||||
public void setIssueId(int issueId) {
|
||||
|
||||
this.issueId = issueId;
|
||||
}
|
||||
|
||||
public String getDraftText() {
|
||||
|
||||
return draftText;
|
||||
}
|
||||
|
||||
public void setDraftText(String draftText) {
|
||||
|
||||
this.draftText = draftText;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDraftType() {
|
||||
|
||||
return draftType;
|
||||
}
|
||||
|
||||
public void setDraftType(@Nullable String draftType) {
|
||||
|
||||
this.draftType = draftType;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package org.mian.gitnex.database.models;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class DraftWithRepository {
|
||||
|
||||
private int repositoryId;
|
||||
private int draftId;
|
||||
|
||||
private int repoAccountId;
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
private int draftRepositoryId;
|
||||
private int draftAccountId;
|
||||
private int issueId;
|
||||
private String draftText;
|
||||
private String draftType;
|
||||
|
||||
public int getRepositoryId() {
|
||||
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public void setRepositoryId(int repositoryId) {
|
||||
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public int getDraftId() {
|
||||
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public void setDraftId(int draftId) {
|
||||
|
||||
this.draftId = draftId;
|
||||
}
|
||||
|
||||
public int getRepoAccountId() {
|
||||
|
||||
return repoAccountId;
|
||||
}
|
||||
|
||||
public void setRepoAccountId(int repoAccountId) {
|
||||
|
||||
this.repoAccountId = repoAccountId;
|
||||
}
|
||||
|
||||
public String getRepositoryOwner() {
|
||||
|
||||
return repositoryOwner;
|
||||
}
|
||||
|
||||
public void setRepositoryOwner(String repositoryOwner) {
|
||||
|
||||
this.repositoryOwner = repositoryOwner;
|
||||
}
|
||||
|
||||
public String getRepositoryName() {
|
||||
|
||||
return repositoryName;
|
||||
}
|
||||
|
||||
public void setRepositoryName(String repositoryName) {
|
||||
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
|
||||
public int getDraftRepositoryId() {
|
||||
|
||||
return draftRepositoryId;
|
||||
}
|
||||
|
||||
public void setDraftRepositoryId(int draftRepositoryId) {
|
||||
|
||||
this.draftRepositoryId = draftRepositoryId;
|
||||
}
|
||||
|
||||
public int getDraftAccountId() {
|
||||
|
||||
return draftAccountId;
|
||||
}
|
||||
|
||||
public void setDraftAccountId(int draftAccountId) {
|
||||
|
||||
this.draftAccountId = draftAccountId;
|
||||
}
|
||||
|
||||
public int getIssueId() {
|
||||
|
||||
return issueId;
|
||||
}
|
||||
|
||||
public void setIssueId(int issueId) {
|
||||
|
||||
this.issueId = issueId;
|
||||
}
|
||||
|
||||
public String getDraftText() {
|
||||
|
||||
return draftText;
|
||||
}
|
||||
|
||||
public void setDraftText(String draftText) {
|
||||
|
||||
this.draftText = draftText;
|
||||
}
|
||||
|
||||
public String getDraftType() {
|
||||
|
||||
return draftType;
|
||||
}
|
||||
|
||||
public void setDraftType(String draftType) {
|
||||
|
||||
this.draftType = draftType;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package org.mian.gitnex.database.models;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.ForeignKey;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
import java.io.Serializable;
|
||||
import static androidx.room.ForeignKey.CASCADE;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "Repositories", foreignKeys = @ForeignKey(entity = UserAccount.class,
|
||||
parentColumns = "accountId",
|
||||
childColumns = "repoAccountId",
|
||||
onDelete = CASCADE),
|
||||
indices = {@Index("repoAccountId")})
|
||||
public class Repository implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int repositoryId;
|
||||
|
||||
private int repoAccountId;
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
public int getRepositoryId() {
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public void setRepositoryId(int repositoryId) {
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public int getRepoAccountId() {
|
||||
return repoAccountId;
|
||||
}
|
||||
|
||||
public void setRepoAccountId(int repoAccountId) {
|
||||
this.repoAccountId = repoAccountId;
|
||||
}
|
||||
|
||||
public String getRepositoryOwner() {
|
||||
return repositoryOwner;
|
||||
}
|
||||
|
||||
public void setRepositoryOwner(String repositoryOwner) {
|
||||
this.repositoryOwner = repositoryOwner;
|
||||
}
|
||||
|
||||
public String getRepositoryName() {
|
||||
return repositoryName;
|
||||
}
|
||||
|
||||
public void setRepositoryName(String repositoryName) {
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
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 = "userAccounts")
|
||||
public class UserAccount implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int accountId;
|
||||
|
||||
@Nullable
|
||||
private String accountName;
|
||||
private String instanceUrl;
|
||||
private String userName;
|
||||
private String token;
|
||||
@Nullable
|
||||
private String serverVersion;
|
||||
|
||||
public int getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(int accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setAccountName(@Nullable String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public String getInstanceUrl() {
|
||||
return instanceUrl;
|
||||
}
|
||||
|
||||
public void setInstanceUrl(String instanceUrl) {
|
||||
this.instanceUrl = instanceUrl;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getServerVersion() {
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
public void setServerVersion(@Nullable String serverVersion) {
|
||||
this.serverVersion = serverVersion;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class BottomSheetDraftsFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private String TAG = StaticGlobalVariables.tagDraftsBottomSheet;
|
||||
private BottomSheetDraftsFragment.BottomSheetListener bmListener;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_drafts, container, false);
|
||||
|
||||
TextView deleteAllDrafts = v.findViewById(R.id.deleteAllDrafts);
|
||||
|
||||
deleteAllDrafts.setOnClickListener(v1 -> {
|
||||
|
||||
dismiss();
|
||||
bmListener.onButtonClicked("deleteDrafts");
|
||||
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public interface BottomSheetListener {
|
||||
void onButtonClicked(String text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
bmListener = (BottomSheetDraftsFragment.BottomSheetListener) context;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
138
app/src/main/java/org/mian/gitnex/fragments/DraftsFragment.java
Normal file
138
app/src/main/java/org/mian/gitnex/fragments/DraftsFragment.java
Normal file
@ -0,0 +1,138 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.DraftsAdapter;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class DraftsFragment extends Fragment {
|
||||
|
||||
private Context ctx;
|
||||
private DraftsAdapter adapter;
|
||||
private RecyclerView mRecyclerView;
|
||||
private DraftsApi draftsApi;
|
||||
private TextView noData;
|
||||
private List<DraftWithRepository> draftsList_;
|
||||
private int currentActiveAccountId;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_drafts, container, false);
|
||||
ctx = getContext();
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
|
||||
draftsList_ = new ArrayList<>();
|
||||
draftsApi = new DraftsApi(ctx);
|
||||
|
||||
noData = v.findViewById(R.id.noData);
|
||||
mRecyclerView = v.findViewById(R.id.recyclerView);
|
||||
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
adapter = new DraftsAdapter(getContext(), draftsList_);
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||
|
||||
draftsList_.clear();
|
||||
swipeRefresh.setRefreshing(false);
|
||||
fetchDataAsync(1);
|
||||
|
||||
}, 250));
|
||||
|
||||
currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
|
||||
return v;
|
||||
|
||||
}
|
||||
|
||||
private void fetchDataAsync(int accountId) {
|
||||
|
||||
draftsApi.getDrafts(accountId).observe(getViewLifecycleOwner(), drafts -> {
|
||||
|
||||
assert drafts != null;
|
||||
if(drafts.size() > 0) {
|
||||
|
||||
draftsList_.clear();
|
||||
noData.setVisibility(View.GONE);
|
||||
draftsList_.addAll(drafts);
|
||||
adapter.notifyDataSetChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
draftsList_.clear();
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
}
|
||||
|
||||
public void deleteAllDrafts(int accountId) {
|
||||
|
||||
if(draftsList_.size() > 0) {
|
||||
|
||||
DraftsApi.deleteAllDrafts(accountId);
|
||||
draftsList_.clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
Toasty.info(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
||||
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getResources().getString(R.string.draftsListEmpty));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,29 @@ public class AlertDialogs {
|
||||
|
||||
}
|
||||
|
||||
public static void forceLogoutDialog(final Context context, String title, String message, String copyPositiveButton) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setCancelable(false)
|
||||
.setIcon(R.drawable.ic_info_outline_24dp)
|
||||
.setPositiveButton(copyPositiveButton, (dialog, which) -> {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putBoolean("loggedInMode", false);
|
||||
tinyDb.remove("basicAuthPassword");
|
||||
tinyDb.putBoolean("basicAuthFlag", false);
|
||||
|
||||
Intent intent = new Intent(context, LoginActivity.class);
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
alertDialogBuilder.create().show();
|
||||
}
|
||||
|
||||
public static void labelDeleteDialog(final Context context, final String labelTitle, final String labelId, String title, String message, String positiveButton, String negativeButton) {
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
|
@ -15,6 +15,11 @@ public interface StaticGlobalVariables {
|
||||
String tagPullRequestsList = "PullRequestsListFragment";
|
||||
String tagIssuesList = "IssuesListFragment";
|
||||
String tagMilestonesAdapter = "MilestonesAdapter";
|
||||
String draftsRepository = "DraftsRepository";
|
||||
String repositoriesRepository = "RepositoriesRepository";
|
||||
String replyToIssueActivity = "ReplyToIssueActivity";
|
||||
String tagDraftsBottomSheet = "BottomSheetDraftsFragment";
|
||||
String userAccountsRepository = "UserAccountsRepository";
|
||||
|
||||
// issues variables
|
||||
int issuesPageInit = 1;
|
||||
@ -26,4 +31,8 @@ public interface StaticGlobalVariables {
|
||||
// milestone
|
||||
int milestonesPageInit = 1;
|
||||
|
||||
// drafts
|
||||
String draftTypeComment = "comment";
|
||||
String draftTypeIssue = "issue";
|
||||
|
||||
}
|
||||
|
5
app/src/main/res/drawable/ic_drafts_24dp.xml
Normal file
5
app/src/main/res/drawable/ic_drafts_24dp.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#368F73" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M21.99,8c0,-0.72 -0.37,-1.35 -0.94,-1.7L12,1 2.95,6.3C2.38,6.65 2,7.28 2,8v10c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2l-0.01,-10zM12,13L3.74,7.84 12,3l8.26,4.84L12,13z"/>
|
||||
</vector>
|
@ -87,6 +87,16 @@
|
||||
android:textColorHighlight="?attr/primaryTextColor"
|
||||
android:inputType="textCapSentences|textMultiLine" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/draftSaved"
|
||||
android:text="@string/draftSaved"
|
||||
android:textColor="?attr/hintColor"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/replyButton"
|
||||
android:gravity="center"
|
||||
|
36
app/src/main/res/layout/bottom_sheet_drafts.xml
Normal file
36
app/src/main/res/layout/bottom_sheet_drafts.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:background="?attr/primaryBackgroundColor">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/deleteAllDrafts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/deleteAllDrafts"
|
||||
android:drawableStart="@drawable/ic_delete"
|
||||
android:drawablePadding="24dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp"
|
||||
android:padding="12dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</LinearLayout>
|
35
app/src/main/res/layout/fragment_drafts.xml
Normal file
35
app/src/main/res/layout/fragment_drafts.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/draftsFrame"
|
||||
android:background="?attr/primaryBackgroundColor">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/pullToRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:padding="4dp"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noData"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="15dp"
|
||||
android:text="@string/draftsListEmpty"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:visibility="visible" />
|
||||
|
||||
</RelativeLayout>
|
88
app/src/main/res/layout/list_drafts.xml
Normal file
88
app/src/main/res/layout/list_drafts.xml
Normal file
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/layoutDraftsFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="10dp"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
tools:context=".activities.MainActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repoId"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/draftId"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/issueNumber"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/issueType"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repoOwner"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repoName"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/frameDraftInfo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repoInfo"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight=".95"
|
||||
android:layout_gravity="start"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/deleteDraft"
|
||||
android:layout_weight=".05"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="end"
|
||||
android:src="@drawable/ic_delete"
|
||||
android:contentDescription="@string/menuDeleteText" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/draftText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/noDataFound" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -20,6 +20,9 @@
|
||||
<item android:id="@+id/nav_explore"
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/navExplore" />
|
||||
<item android:id="@+id/nav_comments_draft"
|
||||
android:icon="@drawable/ic_drafts_24dp"
|
||||
android:title="@string/titleDrafts" />
|
||||
<item android:id="@+id/nav_profile"
|
||||
android:icon="@drawable/ic_person_24dp"
|
||||
android:title="@string/navProfile" />
|
||||
|
13
app/src/main/res/menu/reply_to_issue.xml
Normal file
13
app/src/main/res/menu/reply_to_issue.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/replyToIssueMenu"
|
||||
android:icon="@drawable/ic_drafts_24dp"
|
||||
android:title="@string/titleDrafts"
|
||||
android:orderInCategory="1"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
@ -577,6 +577,7 @@
|
||||
<string name="unWatchRepository">Unwatch Repository</string>
|
||||
<string name="watchRepositorySuccess">Repository added to watch list</string>
|
||||
<string name="unWatchRepositorySuccess">Repository removed from watch list</string>
|
||||
<string name="titleDrafts">Drafts</string>
|
||||
<string name="filesBreadcrumbRoot" translatable="false">Root</string>
|
||||
|
||||
<string name="versionUnsupportedOld">Unsupported old version(%1$s) of Gitea detected. Please update to latest stable version. If you continue, the app may not function properly.</string>
|
||||
@ -666,6 +667,16 @@
|
||||
<string name="setCrashReports">Crash reports</string>
|
||||
<string name="crashMessage">You can tap the OK button to send the crash report by email. It will help to fix it :)\n\nYou can also add additional content in the email. Thank you!</string>
|
||||
|
||||
<string name="forceLogoutDialogHeader">Please sign in again</string>
|
||||
<string name="forceLogoutDialogDescription">Due to some major changes regarding the internal functioning of the app, we require you to login again. These changes allow us to make the app more flexible in the future.\n\nThank you for your patience and sorry for the inconvenience.</string>
|
||||
|
||||
<string name="deleteAllDrafts">Delete All Drafts</string>
|
||||
<string name="draftsListEmpty">No drafts found</string>
|
||||
<string name="draftsDeleteSuccess">Drafts deleted successfully</string>
|
||||
<string name="draftsSingleDeleteSuccess">Draft deleted successfully</string>
|
||||
<string name="deleteAllDraftsDialogMessage">This will delete all the drafts for this account. \n\nProceed with deletion?</string>
|
||||
<string name="draftSaved">Draft saved</string>
|
||||
|
||||
<string name="appearanceHintText">Themes, fonts, badges, code block theme</string>
|
||||
<string name="fileViewerHintText">PDF mode, source code theme</string>
|
||||
<string name="securityHintText">SSL certificates, cache</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user