Enhance settings screen and make it translation ready (#735)

Merge branch 'master' into enhance-settings-screen

# Conflicts:
#	app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java

Cleanup and refactor of activities

Fix bottomsheet

enhance code blocks and refactors

Move home screen to general, make it ready for translation

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/735
This commit is contained in:
M M Arif 2020-10-29 14:13:19 +01:00
parent 6a9144435e
commit f64e23dcc1
47 changed files with 879 additions and 987 deletions

View File

@ -140,14 +140,13 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
mRecyclerView.setAdapter(adapter);
noData.setVisibility(View.GONE);
mProgressBar.setVisibility(View.GONE);
}
else {
noData.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE);
}
mProgressBar.setVisibility(View.GONE);
}
private void initCloseListener() {

View File

@ -76,7 +76,6 @@ public class AddNewAccountActivity extends BaseActivity {
if(!connToInternet) {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
}
else {
@ -144,7 +143,9 @@ public class AddNewAccountActivity extends BaseActivity {
GiteaVersion version = responseVersion.body();
assert version != null;
if(!Version.valid(version.getVersion())) {
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
return;
}
@ -170,7 +171,6 @@ public class AddNewAccountActivity extends BaseActivity {
});
alertDialogBuilder.create().show();
}
else if(giteaVersion.lessOrEqual(getString(R.string.versionHigh))) {
@ -180,7 +180,6 @@ public class AddNewAccountActivity extends BaseActivity {
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
login(instanceUrl, loginToken);
}
}
@ -193,7 +192,6 @@ public class AddNewAccountActivity extends BaseActivity {
private void login(String instanceUrl, String loginToken) {
setupNewAccountWithToken(instanceUrl, loginToken);
}
@Override

View File

@ -81,9 +81,11 @@ public class AddNewTeamMemberActivity extends BaseActivity {
closeActivity.setOnClickListener(onClickListener);
if(getIntent().getStringExtra("teamId") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamId")).equals("")) {
teamId = getIntent().getStringExtra("teamId");
}
else {
teamId = "0";
}
@ -104,9 +106,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId));
loadUserSearchList(instanceUrl, instanceToken, addNewTeamMember.getText().toString(), loginUid, teamId);
}
}
@Override
@ -141,16 +141,13 @@ public class AddNewTeamMemberActivity extends BaseActivity {
dataList.addAll(response.body().getData());
mRecyclerView.setAdapter(adapter);
noData.setVisibility(View.GONE);
mProgressBar.setVisibility(View.GONE);
}
else {
noData.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE);
}
mProgressBar.setVisibility(View.GONE);
}
}

View File

@ -95,14 +95,14 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
adapter = new AdminGetUsersAdapter(ctx, usersListMain);
if(adapter.getItemCount() > 0) {
mRecyclerView.setVisibility(View.VISIBLE);
mRecyclerView.setAdapter(adapter);
noDataUsers.setVisibility(View.GONE);
searchFilter = true;
}
else {
//adapter.notifyDataSetChanged();
//mRecyclerView.setAdapter(adapter);
mRecyclerView.setVisibility(View.GONE);
noDataUsers.setVisibility(View.VISIBLE);
}
@ -140,6 +140,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
@Override
public boolean onQueryTextChange(String newText) {
adapter.getFilter().filter(newText);
return false;
}
@ -157,18 +158,21 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
int id = item.getItemId();
switch (id) {
case android.R.id.home:
finish();
return true;
case R.id.genericMenu:
BottomSheetAdminUsersFragment bottomSheet = new BottomSheetAdminUsersFragment();
bottomSheet.show(getSupportFragmentManager(), "usersBottomSheet");
return true;
default:
return super.onOptionsItemSelected(item);
}
if(id == android.R.id.home) {
finish();
return true;
}
else if(id == R.id.genericMenu) {
BottomSheetAdminUsersFragment bottomSheet = new BottomSheetAdminUsersFragment();
bottomSheet.show(getSupportFragmentManager(), "usersBottomSheet");
return true;
}
else {
return super.onOptionsItemSelected(item);
}
}
@Override

View File

@ -33,46 +33,48 @@ import static org.acra.ReportField.STACK_TRACE;
public abstract class BaseActivity extends AppCompatActivity {
private Context appCtx;
@Override
public void onCreate(Bundle savedInstanceState) {
appCtx = getApplicationContext();
Context appCtx = getApplicationContext();
final TinyDB tinyDb = new TinyDB(appCtx);
switch(tinyDb.getInt("themeId")) {
case 1:
setTheme(R.style.AppThemeLight);
break;
case 2:
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
setTheme(R.style.AppTheme);
}
else {
setTheme(R.style.AppThemeLight);
}
break;
case 3:
setTheme(R.style.AppThemeRetro);
break;
case 4:
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
setTheme(R.style.AppTheme);
}
else {
setTheme(R.style.AppThemeRetro);
}
break;
default:
setTheme(R.style.AppTheme);
break;
}
String appLocale = tinyDb.getString("locale");
@ -84,29 +86,30 @@ public abstract class BaseActivity extends AppCompatActivity {
switch(tinyDb.getInt("customFontId", -1)) {
case 0:
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
break;
case 2:
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/sourcecodeproregular.ttf");
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/sourcecodeproregular.ttf");
FontsOverride.setDefaultFont(this, "SERIF", "fonts/sourcecodeproregular.ttf");
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/sourcecodeproregular.ttf");
break;
default:
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/manroperegular.ttf");
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/manroperegular.ttf");
FontsOverride.setDefaultFont(this, "SERIF", "fonts/manroperegular.ttf");
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/manroperegular.ttf");
break;
}
if(tinyDb.getInt("pollingDelayMinutes") == 0) {
tinyDb.putInt("pollingDelayMinutes", 15);
}
@ -114,26 +117,31 @@ public abstract class BaseActivity extends AppCompatActivity {
// enabling counter badges by default
if(tinyDb.getString("enableCounterBadgesInit").isEmpty()) {
tinyDb.putBoolean("enableCounterBadges", true);
tinyDb.putString("enableCounterBadgesInit", "yes");
}
// enable crash reports by default
if(tinyDb.getString("crashReportingEnabledInit").isEmpty()) {
tinyDb.putBoolean("crashReportingEnabled", true);
tinyDb.putString("crashReportingEnabledInit", "yes");
}
// default cache setter
if(tinyDb.getString("cacheSizeStr").isEmpty()) {
tinyDb.putString("cacheSizeStr", getResources().getString(R.string.cacheSizeDataSelectionSelectedText));
}
if(tinyDb.getString("cacheSizeImagesStr").isEmpty()) {
tinyDb.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
}
// enable comment drafts by default
if(tinyDb.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
tinyDb.putString("draftsCommentsDeletionEnabledInit", "yes");
}
@ -145,7 +153,6 @@ public abstract class BaseActivity extends AppCompatActivity {
ACRABuilder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class).setReportAsFile(true).setMailTo(getResources().getString(R.string.appEmail)).setSubject(getResources().getString(R.string.crashReportEmailSubject, AppUtil.getAppBuildNo(getApplicationContext()))).setEnabled(true);
ACRABuilder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class).setEnabled(true);
ACRA.init(getApplication(), ACRABuilder);
}
}

View File

@ -96,6 +96,7 @@ public class CommitsActivity extends BaseActivity {
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
}
@ -107,7 +108,6 @@ public class CommitsActivity extends BaseActivity {
swipeRefresh.setRefreshing(false);
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
adapter.notifyDataChanged();
}, 200));
adapter = new CommitsAdapter(ctx, commitsList);
@ -118,7 +118,6 @@ public class CommitsActivity extends BaseActivity {
int page = (commitsList.size() + resultLimit) / resultLimit;
loadMore(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, branchName, resultLimit);
}
}));
recyclerView.setHasFixedSize(true);
@ -127,7 +126,6 @@ public class CommitsActivity extends BaseActivity {
api = AppApiService.createService(ApiInterface.class, instanceUrl, ctx);
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
}
private void loadInitial(String token, String repoOwner, String repoName, String branchName, int resultLimit) {
@ -148,7 +146,6 @@ public class CommitsActivity extends BaseActivity {
commitsList.addAll(response.body());
adapter.notifyDataChanged();
noData.setVisibility(View.GONE);
}
else {
@ -164,7 +161,6 @@ public class CommitsActivity extends BaseActivity {
else {
Log.e(TAG, String.valueOf(response.code()));
}
progressBar.setVisibility(View.GONE);
@ -211,7 +207,6 @@ public class CommitsActivity extends BaseActivity {
else {
Log.e(TAG, String.valueOf(response.code()));
}
progressLoadMore.setVisibility(View.GONE);
@ -255,7 +250,6 @@ public class CommitsActivity extends BaseActivity {
});
return super.onCreateOptionsMenu(menu);
}
private void filter(String text) {
@ -263,7 +257,9 @@ public class CommitsActivity extends BaseActivity {
List<Commits> arr = new ArrayList<>();
for(Commits d : commitsList) {
if(d.getCommit().getMessage().toLowerCase().contains(text) || d.getSha().toLowerCase().contains(text)) {
arr.add(d);
}
}
@ -274,6 +270,7 @@ public class CommitsActivity extends BaseActivity {
private void initCloseListener() {
onClickListener = view -> {
getIntent().removeExtra("branchName");
finish();
};

View File

@ -158,7 +158,7 @@ public class CreateFileActivity extends BaseActivity {
}
private View.OnClickListener createFileListener = v -> processNewFile();
private final View.OnClickListener createFileListener = v -> processNewFile();
private void processNewFile() {
@ -170,8 +170,6 @@ public class CreateFileActivity extends BaseActivity {
String newFileBranchName_ = newFileBranchName.getText().toString();
String newFileCommitMessage_ = newFileCommitMessage.getText().toString();
//Branches currentBranch = (Branches) newFileBranchesSpinner.getSelectedItem();
if(!connToInternet) {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
@ -187,10 +185,12 @@ public class CreateFileActivity extends BaseActivity {
if(selectedBranch.equals("No branch")) {
if(newFileBranchName_.equals("")) {
Toasty.error(ctx, getString(R.string.newFileRequiredFieldNewBranchName));
return;
}
else {
if(!appUtil.checkStringsWithDash(newFileBranchName_)) {
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
@ -255,7 +255,6 @@ public class CreateFileActivity extends BaseActivity {
enableProcessButton();
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
finish();
}
else if(response.code() == 401) {
@ -264,21 +263,20 @@ public class CreateFileActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else {
if(response.code() == 404) {
enableProcessButton();
Toasty.warning(ctx, getString(R.string.apiNotFound));
}
else {
enableProcessButton();
Toasty.error(ctx, getString(R.string.orgCreatedError));
}
}
}
@Override
@ -295,6 +293,7 @@ public class CreateFileActivity extends BaseActivity {
String branchName;
DeleteFile deleteFileJsonStr;
if(currentBranch.equals("No branch")) {
branchName = fileBranchName;
@ -345,9 +344,7 @@ public class CreateFileActivity extends BaseActivity {
enableProcessButton();
Toasty.info(ctx, getString(R.string.genericError));
}
}
}
@Override
@ -364,6 +361,7 @@ public class CreateFileActivity extends BaseActivity {
String branchName;
EditFile editFileJsonStr;
if(currentBranch.equals("No branch")) {
branchName = fileBranchName;
@ -415,9 +413,7 @@ public class CreateFileActivity extends BaseActivity {
enableProcessButton();
Toasty.info(ctx, getString(R.string.genericError));
}
}
}
@Override
@ -443,20 +439,20 @@ public class CreateFileActivity extends BaseActivity {
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
if(response.isSuccessful()) {
if(response.code() == 200) {
List<Branches> branchesList_ = response.body();
branchesList.add(new Branches("No branch"));
assert branchesList_ != null;
if(branchesList_.size() > 0) {
for (int i = 0; i < branchesList_.size(); i++) {
Branches data = new Branches(
branchesList_.get(i).getName()
);
Branches data = new Branches(branchesList_.get(i).getName());
branchesList.add(data);
}
}
@ -483,10 +479,8 @@ public class CreateFileActivity extends BaseActivity {
}
});
}
}
}
@Override

View File

@ -127,13 +127,9 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
disableProcessButton();
viewBinding.newIssueLabels.setOnClickListener(newIssueLabels ->
showLabels()
);
viewBinding.newIssueLabels.setOnClickListener(newIssueLabels -> showLabels());
viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList ->
showAssignees()
);
viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList -> showAssignees());
if(!connToInternet) {
@ -181,9 +177,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
View view = assigneesBinding.getRoot();
dialogAssignees.setContentView(view);
assigneesBinding.cancel.setOnClickListener(assigneesBinding_ ->
dialogAssignees.dismiss()
);
assigneesBinding.cancel.setOnClickListener(assigneesBinding_ -> dialogAssignees.dismiss());
dialogAssignees.show();
AssigneesActions.getRepositoryAssignees(ctx, instanceUrl, instanceToken, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
@ -203,9 +197,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
View view = labelsBinding.getRoot();
dialogLabels.setContentView(view);
labelsBinding.cancel.setOnClickListener(labelsBinding_ ->
dialogLabels.dismiss()
);
labelsBinding.cancel.setOnClickListener(labelsBinding_ -> dialogLabels.dismiss());
dialogLabels.show();
LabelsActions.getRepositoryLabels(ctx, instanceUrl, instanceToken, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
@ -223,7 +215,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if (newIssueTitleForm.equals("")) {
@ -243,7 +234,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
disableProcessButton();
createNewIssueFunc(instanceUrl, instanceToken, repoOwner, repoName, loginUid, newIssueDescriptionForm, newIssueDueDateForm, milestoneId, newIssueTitleForm);
}
private void createNewIssueFunc(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String loginUid, String newIssueDescriptionForm, String newIssueDueDateForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
@ -316,13 +306,16 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response) {
if(response.isSuccessful()) {
if(response.code() == 200) {
List<Milestones> milestonesList_ = response.body();
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
assert milestonesList_ != null;
if(milestonesList_.size() > 0) {
for (int i = 0; i < milestonesList_.size(); i++) {
//Don't translate "open" is a enum
@ -333,7 +326,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
);
milestonesList.add(data);
}
}
}
@ -377,9 +369,9 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
datePickerDialog.show();
}
else if(v == viewBinding.createNewIssueButton) {
processNewIssue();
}
}
private void disableProcessButton() {

View File

@ -87,22 +87,14 @@ public class CreateLabelActivity extends BaseActivity {
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
colorPicker.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
cp.show();
}
});
colorPicker.setOnClickListener(v -> cp.show());
cp.setCallback(new ColorPickerCallback() {
@Override
public void onColorChosen(@ColorInt int color) {
cp.setCallback(color -> {
//Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
colorPicker.setBackgroundColor(color);
tinyDb.putString("labelColor", String.format("#%06X", (0xFFFFFF & color)));
cp.dismiss();
}
//Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
colorPicker.setBackgroundColor(color);
tinyDb.putString("labelColor", String.format("#%06X", (0xFFFFFF & color)));
cp.dismiss();
});
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
@ -131,9 +123,9 @@ public class CreateLabelActivity extends BaseActivity {
}
private View.OnClickListener createLabelListener = v -> processCreateLabel();
private final View.OnClickListener createLabelListener = v -> processCreateLabel();
private View.OnClickListener updateLabelListener = v -> processUpdateLabel();
private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
private void processUpdateLabel() {
@ -152,9 +144,11 @@ public class CreateLabelActivity extends BaseActivity {
String updateLabelColor;
if(tinyDb.getString("labelColor").isEmpty()) {
updateLabelColor = tinyDb.getString("labelColorDefault");
}
else {
updateLabelColor = tinyDb.getString("labelColor");
}
@ -162,21 +156,18 @@ public class CreateLabelActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if(updateLabelName.equals("")) {
Toasty.error(ctx, getString(R.string.labelEmptyError));
return;
}
if(!appUtil.checkStrings(updateLabelName)) {
Toasty.error(ctx, getString(R.string.labelNameError));
return;
}
disableProcessButton();
@ -200,10 +191,13 @@ public class CreateLabelActivity extends BaseActivity {
String newLabelName = labelName.getText().toString();
String newLabelColor;
if(tinyDb.getString("labelColor").isEmpty()) {
newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
}
else {
newLabelColor = tinyDb.getString("labelColor");
}
@ -211,26 +205,22 @@ public class CreateLabelActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if(newLabelName.equals("")) {
Toasty.error(ctx, getString(R.string.labelEmptyError));
return;
}
if(!appUtil.checkStrings(newLabelName)) {
Toasty.error(ctx, getString(R.string.labelNameError));
return;
}
disableProcessButton();
createNewLabel(instanceUrl, instanceToken, repoOwner, repoName, newLabelName, newLabelColor, loginUid);
}
private void createNewLabel(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String newLabelName, String newLabelColor, String loginUid) {
@ -256,7 +246,6 @@ public class CreateLabelActivity extends BaseActivity {
tinyDb.putString("labelColor", "");
tinyDb.putBoolean("labelsRefresh", true);
finish();
}
else if(response.code() == 401) {
@ -265,16 +254,13 @@ public class CreateLabelActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else {
enableProcessButton();
tinyDb.putString("labelColor", "");
Toasty.error(ctx, getString(R.string.labelGeneralError));
}
}
@Override
@ -306,6 +292,7 @@ public class CreateLabelActivity extends BaseActivity {
public void onResponse(@NonNull Call<CreateLabel> call, @NonNull retrofit2.Response<CreateLabel> response) {
if(response.isSuccessful()) {
if(response.code() == 200) {
Toasty.success(ctx, getString(R.string.labelUpdated));
@ -317,7 +304,6 @@ public class CreateLabelActivity extends BaseActivity {
getIntent().removeExtra("labelTitle");
getIntent().removeExtra("labelColor");
finish();
}
}
else if(response.code() == 401) {
@ -327,7 +313,6 @@ public class CreateLabelActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else {
@ -335,9 +320,7 @@ public class CreateLabelActivity extends BaseActivity {
tinyDb.putString("labelColor", "");
tinyDb.putString("labelColorDefault", "");
Toasty.error(ctx, getString(R.string.labelGeneralError));
}
}
@Override
@ -353,15 +336,14 @@ public class CreateLabelActivity extends BaseActivity {
}
private void initCloseListener() {
onClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
getIntent().removeExtra("labelAction");
getIntent().removeExtra("labelId");
getIntent().removeExtra("labelTitle");
getIntent().removeExtra("labelColor");
finish();
}
onClickListener = view -> {
getIntent().removeExtra("labelAction");
getIntent().removeExtra("labelId");
getIntent().removeExtra("labelTitle");
getIntent().removeExtra("labelColor");
finish();
};
}
@ -380,13 +362,13 @@ public class CreateLabelActivity extends BaseActivity {
public void onResponse(@NonNull Call<Labels> call, @NonNull retrofit2.Response<Labels> response) {
if(response.isSuccessful()) {
if(response.code() == 204) {
Toasty.success(ctx, getString(R.string.labelDeleteText));
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName, ctx);
getIntent().removeExtra("labelAction");
getIntent().removeExtra("labelId");
}
}
else if(response.code() == 401) {
@ -395,14 +377,11 @@ public class CreateLabelActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else {
Toasty.error(ctx, getString(R.string.labelDeleteErrorText));
}
}
@Override

View File

@ -78,7 +78,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
}
private View.OnClickListener createMilestoneListener = v -> processNewMilestone();
private final View.OnClickListener createMilestoneListener = v -> processNewMilestone();
private void processNewMilestone() {
@ -92,7 +92,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
final String instanceUrl = tinyDb.getString("instanceUrl");
final String loginUid = tinyDb.getString("loginUid");
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
//String appLocale = tinyDb.getString("locale");
String newMilestoneTitle = milestoneTitle.getText().toString();
String newMilestoneDescription = milestoneDescription.getText().toString();
@ -102,26 +101,25 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if(newMilestoneTitle.equals("")) {
Toasty.error(ctx, getString(R.string.milestoneNameErrorEmpty));
return;
}
if(!newMilestoneDescription.equals("")) {
if (appUtil.charactersLength(newMilestoneDescription) > 255) {
Toasty.warning(ctx, getString(R.string.milestoneDescError));
return;
}
}
String finalMilestoneDueDate = null;
if(!newMilestoneDueDate.isEmpty()) {
finalMilestoneDueDate = (AppUtil.customDateCombine(AppUtil.customDateFormat(newMilestoneDueDate)));
@ -135,7 +133,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
disableProcessButton();
createNewMilestone(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
}
private void createNewMilestone(final String instanceUrl, final String token, String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription, String newMilestoneDueDate) {
@ -155,6 +152,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
public void onResponse(@NonNull Call<Milestones> call, @NonNull retrofit2.Response<Milestones> response) {
if(response.isSuccessful()) {
if(response.code() == 201) {
TinyDB tinyDb = new TinyDB(appCtx);
@ -162,7 +160,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
Toasty.success(ctx, getString(R.string.milestoneCreated));
enableProcessButton();
finish();
}
}
else if(response.code() == 401) {
@ -172,19 +169,17 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else {
enableProcessButton();
Toasty.error(ctx, getString(R.string.milestoneCreatedError));
}
}
@Override
public void onFailure(@NonNull Call<Milestones> call, @NonNull Throwable t) {
Log.e("onFailure", t.toString());
enableProcessButton();
}
@ -203,16 +198,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
final int mDay = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
milestoneDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
}
}, mYear, mMonth, mDay);
(view, year, monthOfYear, dayOfMonth) -> milestoneDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
datePickerDialog.show();
}

View File

@ -73,7 +73,6 @@ public class CreateNewUserActivity extends BaseActivity {
createUserButton.setOnClickListener(createNewUserListener);
}
}
private void processCreateNewUser() {
@ -94,40 +93,34 @@ public class CreateNewUserActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if(newFullName.equals("") || newUserName.equals("") | newUserEmail.equals("") || newUserPassword.equals("")) {
Toasty.error(ctx, getString(R.string.emptyFields));
return;
}
if(!appUtil.checkStrings(newFullName)) {
Toasty.error(ctx, getString(R.string.userInvalidFullName));
return;
}
if(!appUtil.checkStringsWithAlphaNumeric(newUserName)) {
Toasty.error(ctx, getString(R.string.userInvalidUserName));
return;
}
if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
Toasty.error(ctx, getString(R.string.userInvalidEmail));
return;
}
disableProcessButton();
createNewUser(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newFullName, newUserName, newUserEmail, newUserPassword);
}
private void createNewUser(final String instanceUrl, final String instanceToken, String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
@ -151,7 +144,6 @@ public class CreateNewUserActivity extends BaseActivity {
Toasty.success(ctx, getString(R.string.userCreatedText));
enableProcessButton();
finish();
}
else if(response.code() == 401) {
@ -160,33 +152,27 @@ public class CreateNewUserActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else if(response.code() == 403) {
enableProcessButton();
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
}
else if(response.code() == 404) {
enableProcessButton();
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
}
else if(response.code() == 422) {
enableProcessButton();
Toasty.warning(ctx, ctx.getString(R.string.userExistsError));
}
else {
enableProcessButton();
Toasty.error(ctx, getString(R.string.genericError));
}
}
@Override
@ -199,7 +185,7 @@ public class CreateNewUserActivity extends BaseActivity {
}
private View.OnClickListener createNewUserListener = v -> processCreateNewUser();
private final View.OnClickListener createNewUserListener = v -> processCreateNewUser();
private void initCloseListener() {

View File

@ -75,19 +75,11 @@ public class CreateOrganizationActivity extends BaseActivity {
}
private void initCloseListener() {
onClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
};
onClickListener = view -> finish();
}
private View.OnClickListener createOrgListener = new View.OnClickListener() {
public void onClick(View v) {
processNewOrganization();
}
};
private final View.OnClickListener createOrgListener = v -> processNewOrganization();
private void processNewOrganization() {
@ -105,33 +97,29 @@ public class CreateOrganizationActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if(!newOrgDesc.equals("")) {
if (appUtil.charactersLength(newOrgDesc) > 255) {
Toasty.warning(ctx, getString(R.string.orgDescError));
return;
}
}
if(newOrgName.equals("")) {
Toasty.error(ctx, getString(R.string.orgNameErrorEmpty));
}
else if(!appUtil.checkStrings(newOrgName)) {
Toasty.warning(ctx, getString(R.string.orgNameErrorInvalid));
}
else {
disableProcessButton();
createNewOrganization(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newOrgName, newOrgDesc);
}
}
@ -157,7 +145,6 @@ public class CreateOrganizationActivity extends BaseActivity {
enableProcessButton();
Toasty.success(ctx, getString(R.string.orgCreated));
finish();
}
else if(response.code() == 401) {
@ -166,37 +153,35 @@ public class CreateOrganizationActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else if(response.code() == 409) {
enableProcessButton();
Toasty.warning(ctx, getString(R.string.orgExistsError));
}
else if(response.code() == 422) {
enableProcessButton();
Toasty.warning(ctx, getString(R.string.orgExistsError));
}
else {
if(response.code() == 404) {
enableProcessButton();
Toasty.warning(ctx, getString(R.string.apiNotFound));
}
else {
enableProcessButton();
Toasty.error(ctx, getString(R.string.orgCreatedError));
}
}
}
@Override
public void onFailure(@NonNull Call<UserOrganizations> call, @NonNull Throwable t) {
Log.e("onFailure", t.toString());
enableProcessButton();
}

View File

@ -94,6 +94,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
// require gitea 1.12 or higher
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
}
@ -113,13 +114,9 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
viewBinding.prLabels.setOnClickListener(prLabels ->
showLabels()
);
viewBinding.prLabels.setOnClickListener(prLabels -> showLabels());
viewBinding.createPr.setOnClickListener(createPr ->
processPullRequest()
);
viewBinding.createPr.setOnClickListener(createPr -> processPullRequest());
}
private void processPullRequest() {
@ -133,13 +130,16 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
assignees.add("");
if (labelsIds.size() == 0) {
labelsIds.add(0);
}
if (dueDate.matches("")) {
dueDate = null;
}
else {
dueDate = AppUtil.customDateCombine(AppUtil.customDateFormat(dueDate));
}
@ -160,9 +160,9 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
Toasty.error(ctx, getString(R.string.sameBranchesError));
}
else {
createPullRequest(prTitle, prDescription, mergeInto, pullFrom, milestoneId, dueDate, assignees);
}
//Log.e("processPullRequest", String.valueOf(milestoneId));
}
private void createPullRequest(String prTitle, String prDescription, String mergeInto, String pullFrom, int milestoneId, String dueDate, List<String> assignees) {
@ -201,7 +201,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
enableProcessButton();
Toasty.error(ctx, getString(R.string.genericError));
}
}
@Override
@ -231,6 +230,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
dialogLabels = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
if (dialogLabels.getWindow() != null) {
dialogLabels.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
@ -239,9 +239,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
View view = labelsBinding.getRoot();
dialogLabels.setContentView(view);
labelsBinding.cancel.setOnClickListener(editProperties ->
dialogLabels.dismiss()
);
labelsBinding.cancel.setOnClickListener(editProperties -> dialogLabels.dismiss());
dialogLabels.show();
LabelsActions.getRepositoryLabels(ctx, instanceUrl, instanceToken, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
@ -260,19 +258,18 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
if(response.isSuccessful()) {
if(response.code() == 200) {
List<Branches> branchesList_ = response.body();
assert branchesList_ != null;
if(branchesList_.size() > 0) {
for (int i = 0; i < branchesList_.size(); i++) {
Branches data = new Branches(
branchesList_.get(i).getName()
);
Branches data = new Branches(branchesList_.get(i).getName());
branchesList.add(data);
}
}
@ -316,7 +313,9 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
assert milestonesList_ != null;
if(milestonesList_.size() > 0) {
for (int i = 0; i < milestonesList_.size(); i++) {
//Don't translate "open" is a enum
@ -327,7 +326,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
);
milestonesList.add(data);
}
}
}

View File

@ -109,7 +109,7 @@ public class CreateReleaseActivity extends BaseActivity {
}
private View.OnClickListener createReleaseListener = v -> processNewRelease();
private final View.OnClickListener createReleaseListener = v -> processNewRelease();
private void processNewRelease() {
@ -126,7 +126,6 @@ public class CreateReleaseActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if(newReleaseTitle.equals("")) {
@ -149,7 +148,6 @@ public class CreateReleaseActivity extends BaseActivity {
disableProcessButton();
createNewReleaseFunc(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
}
private void createNewReleaseFunc(final String instanceUrl, final String token, String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String selectedBranch, boolean newReleaseType, boolean newReleaseDraft) {
@ -182,27 +180,22 @@ public class CreateReleaseActivity extends BaseActivity {
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else if(response.code() == 403) {
enableProcessButton();
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
}
else if(response.code() == 404) {
enableProcessButton();
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
}
else {
enableProcessButton();
Toasty.error(ctx, ctx.getString(R.string.genericError));
}
}
@Override
@ -228,6 +221,7 @@ public class CreateReleaseActivity extends BaseActivity {
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
if(response.isSuccessful()) {
if(response.code() == 200) {
List<Branches> branchesList_ = response.body();
@ -256,7 +250,6 @@ public class CreateReleaseActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
}

View File

@ -109,7 +109,7 @@ public class CreateRepoActivity extends BaseActivity {
}
}
private View.OnClickListener createRepoListener = v -> processNewRepo();
private final View.OnClickListener createRepoListener = v -> processNewRepo();
private void processNewRepo() {
@ -127,6 +127,7 @@ public class CreateRepoActivity extends BaseActivity {
}
if(!newRepoDesc.equals("")) {
if (appUtil.charactersLength(newRepoDesc) > 255) {
Toasty.warning(ctx, getString(R.string.repoDescError));
@ -212,7 +213,6 @@ public class CreateRepoActivity extends BaseActivity {
enableProcessButton();
Toasty.error(ctx, getString(R.string.repoCreatedError));
}
}
@Override
@ -244,6 +244,7 @@ public class CreateRepoActivity extends BaseActivity {
organizationsList.add(new OrgOwner(userLogin));
assert organizationsList_ != null;
if(organizationsList_.size() > 0) {
for(int i = 0; i < organizationsList_.size(); i++) {
@ -257,7 +258,6 @@ public class CreateRepoActivity extends BaseActivity {
OrgOwner data = new OrgOwner(organizationsList_.get(i).getUsername());
organizationsList.add(data);
}
}

View File

@ -41,7 +41,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
private TextView teamAccessControls;
private TextView teamAccessControlsArray;
private Button createTeamButton;
private String[] permissionList = {"Read", "Write", "Admin"};
private final String[] permissionList = {"Read", "Write", "Admin"};
public int permissionSelectedChoice = -1;
@Override
@ -49,7 +49,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
return R.layout.activity_create_team_by_org;
}
private String[] accessControlsList = new String[] {
private final String[] accessControlsList = new String[] {
"Code",
"Issues",
"Pull Request",
@ -61,7 +61,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
private List<String> pushAccessList;
private boolean[] selectedAccessControlsTrueFalse = new boolean[]{
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{
false,
false,
false,
@ -102,12 +102,8 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
pBuilder.setTitle(R.string.newTeamPermission);
if(permissionSelectedChoice != -1) {
pBuilder.setCancelable(true);
}
else {
pBuilder.setCancelable(false);
}
pBuilder.setCancelable(permissionSelectedChoice != -1);
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
permissionSelectedChoice = i;
@ -136,15 +132,12 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
}
dialogInterface.dismiss();
});
AlertDialog pDialog = pBuilder.create();
pDialog.show();
});
teamAccessControls.setOnClickListener(v -> {
teamAccessControls.setText("");
@ -189,6 +182,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
}
if(value){
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
}
@ -198,15 +192,16 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
String data = String.valueOf(teamAccessControls.getText());
if(!data.equals("")) {
teamAccessControls.setText(data.substring(0, data.length() - 2));
}
String dataArray = String.valueOf(teamAccessControlsArray.getText());
if(!dataArray.equals("")) {
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
}
//Log.i("orgName", String.valueOf(teamAccessControlsArray.getText()));
});
AlertDialog aDialog = aDialogBuilder.create();
@ -222,14 +217,12 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
shape.setCornerRadius( 8 );
shape.setColor(getResources().getColor(R.color.hintColor));
createTeamButton.setBackground(shape);
} else {
}
else {
createTeamButton.setEnabled(true);
createTeamButton.setOnClickListener(this);
}
}
private void processCreateTeam() {
@ -251,52 +244,49 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if (newTeamName.equals("")) {
Toasty.error(ctx, getString(R.string.teamNameEmpty));
return;
}
if(!appUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
Toasty.warning(ctx, getString(R.string.teamNameError));
return;
}
if(!newTeamDesc.equals("")) {
if(!appUtil.checkStrings(newTeamDesc)) {
Toasty.warning(ctx, getString(R.string.teamDescError));
return;
}
if(newTeamDesc.length() > 100) {
Toasty.warning(ctx, getString(R.string.teamDescLimit));
return;
}
}
if (newTeamPermission.equals("")) {
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
return;
}
List<String> newTeamAccessControls_ = new ArrayList<>(Arrays.asList(newTeamAccessControls.split(",")));
for (int i = 0; i < newTeamAccessControls_.size(); i++) {
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
}
createNewTeamCall(instanceUrl, instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, loginUid);
}
private void createNewTeamCall(final String instanceUrl, final String instanceToken, String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls, String loginUid) {
@ -316,6 +306,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
public void onResponse(@NonNull Call<Teams> call, @NonNull retrofit2.Response<Teams> response2) {
if(response2.isSuccessful()) {
if(response2.code() == 201) {
TinyDB tinyDb = new TinyDB(appCtx);
@ -324,7 +315,6 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
Toasty.success(ctx, getString(R.string.teamCreated));
finish();
}
}
else if(response2.code() == 404) {
@ -341,7 +331,6 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
Toasty.error(ctx, getString(R.string.teamCreatedError));
}
}
@Override
@ -356,6 +345,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
public void onClick(View v) {
if(v == createTeamButton) {
processCreateTeam();
}
}

View File

@ -229,7 +229,6 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.repository.setOnClickListener(repository -> {
tinyDb.putInt("defaultScreenId", 1);
tinyDb.putString("defaultScreenStr", getResources().getString(R.string.navRepos));
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
ctx.startActivity(mainIntent);
finish();
@ -238,7 +237,6 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.organization.setOnClickListener(organization -> {
tinyDb.putInt("defaultScreenId", 2);
tinyDb.putString("defaultScreenStr", getResources().getString(R.string.navOrgs));
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
ctx.startActivity(mainIntent);
finish();
@ -247,7 +245,6 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.notification.setOnClickListener(notification -> {
tinyDb.putInt("defaultScreenId", 3);
tinyDb.putString("defaultScreenStr", getResources().getString(R.string.pageTitleNotifications));
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
ctx.startActivity(mainIntent);
finish();
@ -256,7 +253,6 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.explore.setOnClickListener(explore -> {
tinyDb.putInt("defaultScreenId", 4);
tinyDb.putString("defaultScreenStr", getResources().getString(R.string.navExplore));
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
ctx.startActivity(mainIntent);
finish();
@ -265,7 +261,6 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.launchApp2.setOnClickListener(launchApp2 -> {
tinyDb.putInt("defaultScreenId", 0);
tinyDb.putString("defaultScreenStr", getResources().getString(R.string.generalDeepLinkSelectedText));
ctx.startActivity(mainIntent);
finish();
});

View File

@ -99,6 +99,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
// if gitea is 1.12 or higher use the new limit
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
}
@ -117,9 +118,11 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
if(!tinyDb.getString("issueNumber").isEmpty()) {
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issueIndex)));
}
else {
toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issueIndex)));
}
}
@ -145,25 +148,25 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if (editIssueTitleForm.equals("")) {
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
return;
}
if (editIssueDueDateForm.equals("")) {
editIssueDueDateForm = null;
} else {
}
else {
editIssueDueDateForm = (AppUtil.customDateCombine(AppUtil.customDateFormat(editIssueDueDateForm)));
}
disableProcessButton();
editIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid, editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm, milestoneId);
}
private void editIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid, String title, String description, String dueDate, int milestoneId) {
@ -194,7 +197,6 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
tinyDb.putBoolean("issueEdited", true);
tinyDb.putBoolean("resumeIssues", true);
finish();
}
else if(response.code() == 401) {
@ -203,19 +205,17 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else {
enableProcessButton();
Toasty.error(ctx, getString(R.string.genericError));
}
}
@Override
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
Log.e("onFailure", t.toString());
enableProcessButton();
}
@ -236,9 +236,9 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
(view, year, monthOfYear, dayOfMonth) -> editIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
datePickerDialog.show();
}
else if(v == editIssueButton) {
processEditIssue();
}
@ -319,9 +319,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
}, 500);
enableProcessButton();
}
}
@Override
@ -354,7 +352,6 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
Toasty.error(ctx, getString(R.string.genericError));
}
}
@Override

View File

@ -88,16 +88,17 @@ public class FileDiffActivity extends BaseActivity {
}
getPullDiffContent(instanceUrl, repoOwner, repoName, pullIndex, instanceToken, apiCall);
}
private void getPullDiffContent(String instanceUrl, String owner, String repo, String pullIndex, String token, boolean apiCall) {
Call<ResponseBody> call;
if(apiCall) {
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getPullDiffContent(token, owner, repo, pullIndex);
}
else {
call = RetrofitClient.getInstance(instanceUrl, ctx).getWebInterface().getPullDiffContent(owner, repo, pullIndex);
}
@ -109,16 +110,18 @@ public class FileDiffActivity extends BaseActivity {
if(response.code() == 200) {
try {
assert response.body() != null;
AppUtil appUtil = new AppUtil();
List<FileDiffView> fileContentsArray = ParseDiff.getFileDiffViewArray(response.body().string());
int filesCount = fileContentsArray.size();
if(filesCount > 1) {
toolbarTitle.setText(getResources().getString(R.string.fileDiffViewHeader, Integer.toString(filesCount)));
}
else {
toolbarTitle.setText(getResources().getString(R.string.fileDiffViewHeaderSingle, Integer.toString(filesCount)));
}
@ -126,34 +129,28 @@ public class FileDiffActivity extends BaseActivity {
mListView.setAdapter(adapter);
mProgressBar.setVisibility(View.GONE);
}
catch(IOException e) {
e.printStackTrace();
}
}
else if(response.code() == 401) {
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else if(response.code() == 403) {
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
}
else if(response.code() == 404) {
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
}
else {
Toasty.error(ctx, getString(R.string.labelGeneralError));
}
}
@Override
@ -174,5 +171,4 @@ public class FileDiffActivity extends BaseActivity {
};
}
}

View File

@ -28,6 +28,7 @@ import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import com.github.barteksc.pdfviewer.PDFView;
import com.github.barteksc.pdfviewer.util.FitPolicy;
import com.github.chrisbanes.photoview.PhotoView;
@ -144,18 +145,15 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
singleFileName = URLDecoder.decode(singleFileName, "UTF-8");
singleFileName = singleFileName.replaceAll("//", "/");
singleFileName = singleFileName.startsWith("/") ? singleFileName.substring(1) : singleFileName;
}
catch(UnsupportedEncodingException e) {
Log.i("singleFileName", singleFileName);
}
toolbar_title.setText(singleFileName);
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
}
@Override
@ -173,6 +171,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
if(tinyDb.getBoolean("fileModified")) {
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
tinyDb.putBoolean("fileModified", false);
}
@ -213,7 +212,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
imageData = Base64.decode(response.body().getContent(), Base64.DEFAULT);
Drawable imageDrawable = new BitmapDrawable(getResources(), BitmapFactory.decodeByteArray(imageData, 0, imageData.length));
imageView.setImageDrawable(imageDrawable);
}
else if(appUtil.sourceCodeExtension(fileExtension)) { // file is sourcecode
@ -223,27 +221,33 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
singleCodeContents.setVisibility(View.VISIBLE);
switch(tinyDb.getInt("fileviewerSourceCodeThemeId")) {
case 1:
singleCodeContents.setTheme(Theme.ARDUINO_LIGHT);
break;
case 2:
singleCodeContents.setTheme(Theme.GITHUB);
break;
case 3:
singleCodeContents.setTheme(Theme.FAR);
break;
case 4:
singleCodeContents.setTheme(Theme.IR_BLACK);
break;
case 5:
singleCodeContents.setTheme(Theme.ANDROID_STUDIO);
break;
default:
singleCodeContents.setTheme(Theme.MONOKAI_SUBLIME);
}
singleCodeContents.setSource(appUtil.decodeBase64(response.body().getContent()));
}
else if(appUtil.pdfExtension(fileExtension)) { // file is pdf
@ -268,7 +272,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
singleFileContents.setText(getResources().getString(R.string.excludeFilesInFileviewer));
singleFileContents.setGravity(Gravity.CENTER);
singleFileContents.setTypeface(null, Typeface.BOLD);
}
else { // file type not known - plain text view
@ -278,37 +281,30 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
singleFileContentsFrame.setVisibility(View.VISIBLE);
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));
}
}
else {
singleFileContents.setText("");
mProgressBar.setVisibility(View.GONE);
}
}
else if(response.code() == 401) {
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else if(response.code() == 403) {
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
}
else if(response.code() == 404) {
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
}
else {
Toasty.error(ctx, getString(R.string.labelGeneralError));
}
}
@Override
@ -328,7 +324,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
inflater.inflate(R.menu.files_view_menu, menu);
String fileExtension = FileUtils.getExtension(singleFileName);
if(!fileExtension.equalsIgnoreCase("md")) {
menu.getItem(0).setVisible(false);
}
@ -340,89 +338,90 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
int id = item.getItemId();
switch(id) {
case android.R.id.home:
if(id == android.R.id.home) {
finish();
return true;
case R.id.genericMenu:
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
bottomSheet.show(getSupportFragmentManager(), "fileViewerBottomSheet");
return true;
case R.id.markdown:
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
.usePlugin(ImagesPlugin.create(plugin -> {
plugin.addSchemeHandler(new SchemeHandler() {
@NonNull
@Override
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
final int resourceId = ctx.getResources().getIdentifier(
raw.substring("drawable://".length()),
"drawable",
ctx.getPackageName());
final Drawable drawable = ctx.getDrawable(resourceId);
assert drawable != null;
return ImageItem.withResult(drawable);
}
@NonNull
@Override
public Collection<String> supportedSchemes() {
return Collections.singleton("drawable");
}
});
plugin.placeholderProvider(drawable -> null);
plugin.addMediaDecoder(GifMediaDecoder.create(false));
plugin.addMediaDecoder(SvgMediaDecoder.create(ctx.getResources()));
plugin.addMediaDecoder(SvgMediaDecoder.create());
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(ctx.getResources()));
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
}))
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
.linkColor(getResources().getColor(R.color.lightBlue));
}
})
.usePlugin(TablePlugin.create(ctx))
.usePlugin(TaskListPlugin.create(ctx))
.usePlugin(HtmlPlugin.create())
.usePlugin(StrikethroughPlugin.create())
.usePlugin(LinkifyPlugin.create())
.build();
if(!tinyDb.getBoolean("enableMarkdownInFileView")) {
singleCodeContents.setVisibility(View.GONE);
singleFileContentsFrame.setVisibility(View.VISIBLE);
singleFileContents.setVisibility(View.VISIBLE);
Spanned bodyWithMD = markwon.toMarkdown(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
markwon.setParsedMarkdown(singleFileContents, bodyWithMD);
tinyDb.putBoolean("enableMarkdownInFileView", true);
}
else {
singleCodeContents.setVisibility(View.VISIBLE);
singleFileContentsFrame.setVisibility(View.GONE);
singleFileContents.setVisibility(View.GONE);
singleCodeContents.setSource(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
tinyDb.putBoolean("enableMarkdownInFileView", false);
}
return true;
default:
return super.onOptionsItemSelected(item);
finish();
return true;
}
else if(id == R.id.genericMenu) {
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
bottomSheet.show(getSupportFragmentManager(), "fileViewerBottomSheet");
return true;
}
else if(id == R.id.markdown) {
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
.usePlugin(ImagesPlugin.create(plugin -> {
plugin.addSchemeHandler(new SchemeHandler() {
@NonNull
@Override
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
final int resourceId = ctx.getResources().getIdentifier(
raw.substring("drawable://".length()),
"drawable",
ctx.getPackageName());
final Drawable drawable = ContextCompat.getDrawable(ctx, resourceId);
assert drawable != null;
return ImageItem.withResult(drawable);
}
@NonNull
@Override
public Collection<String> supportedSchemes() {
return Collections.singleton("drawable");
}
});
plugin.placeholderProvider(drawable -> null);
plugin.addMediaDecoder(GifMediaDecoder.create(false));
plugin.addMediaDecoder(SvgMediaDecoder.create(ctx.getResources()));
plugin.addMediaDecoder(SvgMediaDecoder.create());
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(ctx.getResources()));
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
}))
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
.linkColor(getResources().getColor(R.color.lightBlue));
}
})
.usePlugin(TablePlugin.create(ctx))
.usePlugin(TaskListPlugin.create(ctx))
.usePlugin(HtmlPlugin.create())
.usePlugin(StrikethroughPlugin.create())
.usePlugin(LinkifyPlugin.create())
.build();
if(!tinyDb.getBoolean("enableMarkdownInFileView")) {
singleCodeContents.setVisibility(View.GONE);
singleFileContentsFrame.setVisibility(View.VISIBLE);
singleFileContents.setVisibility(View.VISIBLE);
Spanned bodyWithMD = markwon.toMarkdown(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
markwon.setParsedMarkdown(singleFileContents, bodyWithMD);
tinyDb.putBoolean("enableMarkdownInFileView", true);
}
else {
singleCodeContents.setVisibility(View.VISIBLE);
singleFileContentsFrame.setVisibility(View.GONE);
singleFileContents.setVisibility(View.GONE);
singleCodeContents.setSource(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
tinyDb.putBoolean("enableMarkdownInFileView", false);
}
return true;
}
else {
return super.onOptionsItemSelected(item);
}
}
@Override
@ -441,10 +440,13 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
intent.putExtra("fileAction", 1);
intent.putExtra("filePath", singleFileName);
intent.putExtra("fileSha", fileSha);
if(!appUtil.imageExtension(fileExtension)) {
intent.putExtra("fileContents", data);
}
else {
intent.putExtra("fileContents", "");
}
@ -459,10 +461,13 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
intent.putExtra("fileAction", 2);
intent.putExtra("filePath", singleFileName);
intent.putExtra("fileSha", fileSha);
if(!appUtil.imageExtension(fileExtension)) {
intent.putExtra("fileContents", data);
}
else {
intent.putExtra("fileContents", "");
}

View File

@ -26,6 +26,7 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -460,18 +461,21 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
int id = item.getItemId();
switch(id) {
case android.R.id.home:
finish();
return true;
case R.id.genericMenu:
BottomSheetSingleIssueFragment bottomSheet = new BottomSheetSingleIssueFragment();
bottomSheet.show(getSupportFragmentManager(), "singleIssueBottomSheet");
return true;
default:
return super.onOptionsItemSelected(item);
}
if(id == android.R.id.home) {
finish();
return true;
}
else if(id == R.id.genericMenu) {
BottomSheetSingleIssueFragment bottomSheet = new BottomSheetSingleIssueFragment();
bottomSheet.show(getSupportFragmentManager(), "singleIssueBottomSheet");
return true;
}
else {
return super.onOptionsItemSelected(item);
}
}
@Override
@ -480,6 +484,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
super.onResume();
if(tinyDb.getBoolean("commentPosted")) {
viewBinding.scrollViewComments.post(() -> {
IssueCommentsViewModel
@ -489,18 +494,17 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN), 1000);
tinyDb.putBoolean("commentPosted", false);
});
}
if(tinyDb.getBoolean("commentEdited")) {
viewBinding.scrollViewComments.post(() -> {
IssueCommentsViewModel
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
ctx);
tinyDb.putBoolean("commentEdited", false);
});
}
@ -514,7 +518,6 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
tinyDb.putBoolean("singleIssueUpdate", false);
}, 500);
}
if(tinyDb.getBoolean("issueEdited")) {
@ -527,9 +530,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
tinyDb.putBoolean("issueEdited", false);
}, 500);
}
}
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo, int index, String loginUid) {
@ -542,14 +543,13 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
assert issueCommentsMain != null;
if(issueCommentsMain.size() > 0) {
viewBinding.divider.setVisibility(View.VISIBLE);
}
adapter = new IssueCommentsAdapter(ctx, getSupportFragmentManager(), issueCommentsMain);
viewBinding.recyclerView.setAdapter(adapter);
});
}
private void getSingleIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid) {
@ -569,6 +569,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
assert singleIssue != null;
viewBinding.issuePrState.setVisibility(View.VISIBLE);
if(singleIssue.getPull_request() != null) {
if(singleIssue.getPull_request().isMerged()) { // merged
@ -600,7 +601,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
final int resourceId = ctx.getResources()
.getIdentifier(raw.substring("drawable://".length()), "drawable", ctx.getPackageName());
final Drawable drawable = ctx.getDrawable(resourceId);
final Drawable drawable = ContextCompat.getDrawable(ctx, resourceId);
assert drawable != null;
return ImageItem.withResult(drawable);
@ -653,7 +654,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
params1.setMargins(15, 0, 0, 0);
if(singleIssue.getAssignees() != null) {
viewBinding.assigneesScrollView.setVisibility(View.VISIBLE);
for(int i = 0; i < singleIssue.getAssignees().size(); i++) {
ImageView assigneesView = new ImageView(ctx);
@ -665,17 +668,19 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
viewBinding.frameAssignees.addView(assigneesView);
assigneesView.setLayoutParams(params1);
if(!singleIssue.getAssignees().get(i).getFull_name().equals("")) {
assigneesView.setOnClickListener(
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getFull_name()), ctx));
}
else {
assigneesView.setOnClickListener(
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getLogin()), ctx));
}
}
}
else {
viewBinding.assigneesScrollView.setVisibility(View.GONE);
}
@ -684,6 +689,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
params.setMargins(0, 0, 15, 0);
if(singleIssue.getLabels() != null) {
viewBinding.labelsScrollView.setVisibility(View.VISIBLE);
for(int i = 0; i < singleIssue.getLabels().size(); i++) {
@ -707,16 +713,17 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
labelsView.setImageDrawable(drawable);
viewBinding.frameLabels.addView(labelsView);
}
}
else {
viewBinding.labelsScrollView.setVisibility(View.GONE);
}
if(singleIssue.getDue_date() != null) {
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
String dueDate = formatter.format(singleIssue.getDue_date());
viewBinding.issueDueDate.setText(dueDate);
@ -724,11 +731,11 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getDue_date()), ctx));
}
else if(timeFormat.equals("normal1")) {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
String dueDate = formatter.format(singleIssue.getDue_date());
viewBinding.issueDueDate.setText(dueDate);
}
}
else {
@ -738,6 +745,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
String edited;
if(!singleIssue.getUpdated_at().equals(singleIssue.getCreated_at())) {
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
viewBinding.issueModified.setVisibility(View.VISIBLE);
viewBinding.issueModified.setText(edited);
@ -745,22 +753,27 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getUpdated_at()), ctx));
}
else {
viewBinding.issueModified.setVisibility(View.INVISIBLE);
}
if((singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) && singleIssue.getAssignees() != null) {
paramsDesc.setMargins(0, 35, 0, 0);
viewBinding.issueDescription.setLayoutParams(paramsDesc);
}
else if(singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) {
paramsDesc.setMargins(0, 55, 0, 0);
viewBinding.issueDescription.setLayoutParams(paramsDesc);
}
else if(singleIssue.getAssignees() == null) {
paramsDesc.setMargins(0, 35, 0, 0);
viewBinding.issueDescription.setLayoutParams(paramsDesc);
}
else {
paramsDesc.setMargins(0, 15, 0, 0);
viewBinding.issueDescription.setLayoutParams(paramsDesc);
}
@ -769,29 +782,33 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
viewBinding.issueCreatedTime.setVisibility(View.VISIBLE);
if(timeFormat.equals("pretty")) {
viewBinding.issueCreatedTime
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), ctx));
}
if(singleIssue.getMilestone() != null) {
viewBinding.issueMilestone.setVisibility(View.VISIBLE);
viewBinding.issueMilestone.setText(getString(R.string.issueMilestone, singleIssue.getMilestone().getTitle()));
}
else {
viewBinding.issueMilestone.setVisibility(View.GONE);
}
if(!singleIssue.getUser().getFull_name().equals("")) {
viewBinding.assigneeAvatar.setOnClickListener(
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getFull_name(), ctx));
}
else {
viewBinding.assigneeAvatar.setOnClickListener(
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getLogin(), ctx));
}
viewBinding.progressBar.setVisibility(View.GONE);
}
else if(response.code() == 401) {
@ -815,9 +832,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
Intent mainIntent = new Intent(ctx, MainActivity.class);
ctx.startActivity(mainIntent);
finish();
}
}
@Override
@ -842,21 +857,17 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
assert response.body() != null;
tinyDb.putBoolean("issueSubscribed", response.body().getSubscribed());
}
else {
tinyDb.putBoolean("issueSubscribed", false);
}
}
@Override
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
tinyDb.putBoolean("issueSubscribed", false);
}
});

View File

@ -92,6 +92,7 @@ public class LoginActivity extends BaseActivity {
selectedProtocol = String.valueOf(parent.getItemAtPosition(position));
if(selectedProtocol.equals(String.valueOf(Protocol.HTTP))) {
Toasty.warning(ctx, getResources().getString(R.string.protocolError));
}
});
@ -141,9 +142,7 @@ public class LoginActivity extends BaseActivity {
disableProcessButton();
login();
});
}
private void login() {
@ -221,11 +220,9 @@ public class LoginActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.loginTokenError));
enableProcessButton();
return;
}
versionCheck(instanceUrl.toString(), loginUid, loginPass, 123, loginToken, loginType);
}
}
@ -234,7 +231,6 @@ public class LoginActivity extends BaseActivity {
Log.e("onFailure-login", e.toString());
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
enableProcessButton();
}
}
@ -254,7 +250,6 @@ public class LoginActivity extends BaseActivity {
callVersion =
(loginOTP != 0) ? RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithOTP(credential, loginOTP) :
RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithBasic(credential);
}
callVersion.enqueue(new Callback<GiteaVersion>() {
@ -265,9 +260,10 @@ public class LoginActivity extends BaseActivity {
if(responseVersion.code() == 200) {
GiteaVersion version = responseVersion.body();
assert version != null;
if(!Version.valid(version.getVersion())) {
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
enableProcessButton();
return;
@ -321,9 +317,11 @@ public class LoginActivity extends BaseActivity {
// the setup methods then can better handle all different cases
if(loginType == LoginType.BASIC) {
setup(instanceUrl, loginUid, loginPass, loginOTP);
}
else if(loginType == LoginType.TOKEN) { // Token
setupUsingExistingToken(instanceUrl, loginToken);
}
}
@ -352,6 +350,7 @@ public class LoginActivity extends BaseActivity {
switch(response.code()) {
case 200:
assert userDetails != null;
tinyDB.putBoolean("loggedInMode", true);
tinyDB.putString(userDetails.getLogin() + "-token", loginToken);
@ -380,18 +379,16 @@ public class LoginActivity extends BaseActivity {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
break;
case 401:
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
enableProcessButton();
break;
default:
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
enableProcessButton();
}
}
@Override
@ -400,7 +397,6 @@ public class LoginActivity extends BaseActivity {
Log.e("onFailure", t.toString());
Toasty.error(ctx, getResources().getString(R.string.genericError));
enableProcessButton();
}
});
@ -431,7 +427,9 @@ public class LoginActivity extends BaseActivity {
if(response.code() == 200) {
assert userTokens != null;
for(UserTokens t : userTokens) {
if(t.getName().equals(tokenName)) {
// this app had created an token on this instance before
@ -447,6 +445,7 @@ public class LoginActivity extends BaseActivity {
delcall = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().deleteToken(credential, loginUid, t.getId());
}
delcall.enqueue(new Callback<Void>() {
@Override
@ -460,7 +459,6 @@ public class LoginActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
enableProcessButton();
}
}
@ -470,7 +468,6 @@ public class LoginActivity extends BaseActivity {
Log.e("onFailure-login", t.toString());
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
enableProcessButton();
}
});
return;
@ -483,7 +480,6 @@ public class LoginActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
enableProcessButton();
}
}
@ -493,7 +489,6 @@ public class LoginActivity extends BaseActivity {
Log.e("onFailure-login", t.toString());
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
enableProcessButton();
}
});
@ -541,6 +536,7 @@ public class LoginActivity extends BaseActivity {
switch(response.code()) {
case 200:
assert userDetails != null;
tinyDB.remove("loginPass");
tinyDB.putBoolean("loggedInMode", true);
@ -570,18 +566,16 @@ public class LoginActivity extends BaseActivity {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
break;
case 401:
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
enableProcessButton();
break;
default:
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
enableProcessButton();
}
}
@Override
@ -590,7 +584,6 @@ public class LoginActivity extends BaseActivity {
Log.e("onFailure", t.toString());
Toasty.error(ctx, getResources().getString(R.string.genericError));
enableProcessButton();
}
});
}
@ -599,7 +592,6 @@ public class LoginActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + responseCreate.code());
enableProcessButton();
}
}
@ -615,17 +607,21 @@ public class LoginActivity extends BaseActivity {
private void loadDefaults() {
if(tinyDB.getString("loginType").equals(LoginType.BASIC.name().toLowerCase())) {
loginMethod.check(R.id.loginUsernamePassword);
}
else {
loginMethod.check(R.id.loginToken);
}
if(!tinyDB.getString("instanceUrlRaw").equals("")) {
instanceUrlET.setText(tinyDB.getString("instanceUrlRaw"));
}
if(!tinyDB.getString("loginUid").equals("")) {
loginUidET.setText(tinyDB.getString("loginUid"));
}
@ -636,9 +632,11 @@ public class LoginActivity extends BaseActivity {
}
if(!tinyDB.getString("uniqueAppId").isEmpty()) {
device_id = tinyDB.getString("uniqueAppId");
}
else {
device_id = UUID.randomUUID().toString();
tinyDB.putString("uniqueAppId", device_id);
}

View File

@ -113,30 +113,37 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
if(tinyDb.getString("dateFormat").isEmpty()) {
tinyDb.putString("dateFormat", "pretty");
}
if(tinyDb.getString("codeBlockStr").isEmpty()) {
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
}
if(tinyDb.getString("enableCounterIssueBadgeInit").isEmpty()) {
tinyDb.putBoolean("enableCounterIssueBadge", true);
}
if(tinyDb.getString("homeScreenStr").isEmpty()) {
tinyDb.putString("homeScreenStr", "yes");
tinyDb.putInt("homeScreenId", 0);
}
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
if(!tinyDb.getBoolean("loggedInMode")) {
logout(this, ctx);
return;
}
if(tinyDb.getInt("currentActiveAccountId") <= 0) {
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
@ -146,17 +153,17 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
switch(tinyDb.getInt("customFontId", -1)) {
case 0:
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
break;
case 2:
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodeproregular.ttf");
break;
default:
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/manroperegular.ttf");
break;
}
toolbarTitle.setTypeface(myTypeface);
@ -166,33 +173,43 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
Fragment fragmentById = fm.findFragmentById(R.id.fragment_container);
if(fragmentById instanceof SettingsFragment) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
}
else if(fragmentById instanceof MyRepositoriesFragment) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
}
else if(fragmentById instanceof StarredRepositoriesFragment) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
}
else if(fragmentById instanceof OrganizationsFragment) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
}
else if(fragmentById instanceof ExploreFragment) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
}
else if(fragmentById instanceof NotificationsFragment) {
toolbarTitle.setText(R.string.pageTitleNotifications);
}
else if(fragmentById instanceof ProfileFragment) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
}
else if(fragmentById instanceof DraftsFragment) {
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
}
else if(fragmentById instanceof AdministrationFragment) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
}
else if(fragmentById instanceof UserAccountsFragment) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
}
@ -221,6 +238,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
if(tinyDb.getBoolean("noConnection")) {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
tinyDb.putBoolean("noConnection", false);
}
@ -253,17 +271,18 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
userAccountsList.addAll(userAccounts);
navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts);
}
});
userEmail.setTypeface(myTypeface);
userFullName.setTypeface(myTypeface);
if(!userEmailNav.equals("")) {
userEmail.setText(userEmailNav);
}
if(!userFullNameNav.equals("")) {
userFullName.setText(userFullNameNav);
}
@ -292,14 +311,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
.setBlurAlgorithm(new RenderScriptBlur(ctx))
.setBlurRadius(5)
.setHasFixedTransformationMatrix(false);
}
@Override
public void onError(Exception e) {}
});
}
userAvatar.setOnClickListener(v -> {
@ -334,17 +350,17 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
switch(launchFragment) {
case "drafts":
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
navigationView.setCheckedItem(R.id.nav_comments_draft);
return;
case "notifications":
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
navigationView.setCheckedItem(R.id.nav_notifications);
return;
}
}
@ -357,21 +373,22 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
switch(launchFragmentByHandler) {
case "repos":
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
navigationView.setCheckedItem(R.id.nav_repositories);
return;
case "org":
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
navigationView.setCheckedItem(R.id.nav_organizations);
return;
case "notification":
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
navigationView.setCheckedItem(R.id.nav_notifications);
return;
case "explore":
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
navigationView.setCheckedItem(R.id.nav_explore);
return;
@ -391,71 +408,70 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
switch(tinyDb.getInt("homeScreenId")) {
case 1:
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
navigationView.setCheckedItem(R.id.nav_starred_repos);
break;
case 2:
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
navigationView.setCheckedItem(R.id.nav_organizations);
break;
case 3:
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
navigationView.setCheckedItem(R.id.nav_repositories);
break;
case 4:
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
navigationView.setCheckedItem(R.id.nav_profile);
break;
case 5:
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
navigationView.setCheckedItem(R.id.nav_explore);
break;
case 6:
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
navigationView.setCheckedItem(R.id.nav_comments_draft);
break;
case 7:
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
navigationView.setCheckedItem(R.id.nav_notifications);
break;
default:
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
navigationView.setCheckedItem(R.id.nav_home);
break;
}
}
if(!connToInternet) {
if(!tinyDb.getBoolean("noConnection")) {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
}
tinyDb.putBoolean("noConnection", true);
}
else {
loadUserInfo(instanceUrl, instanceToken, loginUid);
giteaVersion(instanceUrl);
tinyDb.putBoolean("noConnection", false);
}
// Changelog popup
@ -513,14 +529,15 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
})
.setNeutralButton(R.string.cancelButton, null).show();
}
else {
Toasty.error(ctx, getResources().getString(R.string.genericError));
}
}
else {
Toasty.error(ctx, getResources().getString(R.string.genericError));
}
@ -532,74 +549,74 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
public void onBackPressed() {
if(drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
}
else {
super.onBackPressed();
}
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch(menuItem.getItemId()) {
int id = menuItem.getItemId();
case R.id.nav_home:
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
break;
if(id == R.id.nav_home) {
case R.id.nav_organizations:
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
break;
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
}
else if(id == R.id.nav_organizations) {
case R.id.nav_profile:
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
break;
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
}
else if(id == R.id.nav_profile) {
case R.id.nav_repositories:
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
break;
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
}
else if(id == R.id.nav_repositories) {
case R.id.nav_settings:
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
break;
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
}
else if(id == R.id.nav_settings) {
case R.id.nav_logout:
logout(this, ctx);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
}
else if(id == R.id.nav_logout) {
case R.id.nav_starred_repos:
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
break;
logout(this, ctx);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
else if(id == R.id.nav_starred_repos) {
case R.id.nav_explore:
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
break;
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
}
else if(id == R.id.nav_explore) {
case R.id.nav_notifications:
toolbarTitle.setText(R.string.pageTitleNotifications);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
break;
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
}
else if(id == R.id.nav_notifications) {
case R.id.nav_comments_draft:
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
break;
toolbarTitle.setText(R.string.pageTitleNotifications);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
}
else if(id == R.id.nav_comments_draft) {
case R.id.nav_administration:
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AdministrationFragment()).commit();
break;
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
}
else if(id == R.id.nav_administration) {
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AdministrationFragment()).commit();
}
drawer.closeDrawer(GravityCompat.START);
@ -614,7 +631,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
//tinyDb.clear();
activity.finish();
ctx.startActivity(new Intent(ctx, LoginActivity.class));
}
@Override
@ -623,13 +639,13 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
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) {
@ -651,7 +667,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
assert version != null;
tinyDb.putString("giteaVersion", version.getVersion());
}
}
@ -660,9 +675,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
Log.e("onFailure-version", t.toString());
}
});
}
private void loadUserInfo(String instanceUrl, String token, String loginUid) {
@ -685,6 +698,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
assert userDetails != null;
if(userDetails.getIs_admin() != null) {
tinyDb.putBoolean("userIsAdmin", userDetails.getIs_admin());
}
@ -692,9 +706,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
tinyDb.putInt("userId", userDetails.getId());
if(!userDetails.getFullname().equals("")) {
tinyDb.putString("userFullname", userDetails.getFullname());
}
else {
tinyDb.putString("userFullname", userDetails.getLogin());
}
@ -702,9 +718,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
tinyDb.putString("userAvatar", userDetails.getAvatar());
if(userDetails.getLang() != null) {
tinyDb.putString("userLang", userDetails.getLang());
}
else {
tinyDb.putString("userLang", "");
}
}
@ -712,15 +730,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
else if(response.code() == 401) {
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else {
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
Toasty.error(ctx, toastError);
}
}
@Override

View File

@ -96,21 +96,26 @@ public class MergePullRequestActivity extends BaseActivity {
// if gitea version is greater/equal(1.12.0) than user installed version (installed.higherOrEqual(compareVer))
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
viewBinding.deleteBranch.setVisibility(View.VISIBLE);
}
if(tinyDb.getString("prMergeable").equals("false")) {
disableProcessButton();
viewBinding.mergeInfoDisabledMessage.setVisibility(View.VISIBLE);
}
else {
viewBinding.mergeInfoDisabledMessage.setVisibility(View.GONE);
}
if(tinyDb.getString("prIsFork").equals("true")) {
viewBinding.deleteBranchForkInfo.setVisibility(View.VISIBLE);
}
else {
viewBinding.deleteBranchForkInfo.setVisibility(View.GONE);
}
@ -134,6 +139,7 @@ public class MergePullRequestActivity extends BaseActivity {
mergeList.add(new MergePullRequestSpinner("rebase-merge", getResources().getString(R.string.mergeOptionRebaseCommit)));
// squash merge works only on gitea > v1.11.4 due to a bug
if(new Version(tinyDb.getString("giteaVersion")).higher("1.11.4")) {
mergeList.add(new MergePullRequestSpinner("squash", getResources().getString(R.string.mergeOptionSquash)));
}
@ -152,7 +158,7 @@ public class MergePullRequestActivity extends BaseActivity {
onClickListener = view -> finish();
}
private View.OnClickListener mergePullRequest = v -> processMergePullRequest();
private final View.OnClickListener mergePullRequest = v -> processMergePullRequest();
private void processMergePullRequest() {
@ -280,7 +286,6 @@ public class MergePullRequestActivity extends BaseActivity {
Log.i("deleteBranch", "Branch deleted successfully");
}
}
@Override

View File

@ -46,9 +46,9 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
}
catch(URISyntaxException e) {
Toasty.error(appCtx, getString(R.string.genericError));
}
}
}

View File

@ -74,17 +74,17 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
switch(tinyDb.getInt("customFontId", -1)) {
case 0:
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf");
break;
case 2:
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf");
break;
default:
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/manroperegular.ttf");
break;
}
toolbarTitle.setTypeface(myTypeface);
@ -92,12 +92,18 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
int tabsCount = vg.getChildCount();
for (int j = 0; j < tabsCount; j++) {
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
int tabChildCount = vgTab.getChildCount();
for (int i = 0; i < tabChildCount; i++) {
View tabViewChild = vgTab.getChildAt(i);
if (tabViewChild instanceof TextView) {
((TextView) tabViewChild).setTypeface(myTypeface);
}
}
@ -105,7 +111,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
}
@ -122,18 +127,21 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
int id = item.getItemId();
switch (id) {
case android.R.id.home:
finish();
return true;
case R.id.repoMenu:
BottomSheetOrganizationFragment bottomSheet = new BottomSheetOrganizationFragment();
bottomSheet.show(getSupportFragmentManager(), "orgBottomSheet");
return true;
default:
return super.onOptionsItemSelected(item);
}
if(id == android.R.id.home) {
finish();
return true;
}
else if(id == R.id.repoMenu) {
BottomSheetOrganizationFragment bottomSheet = new BottomSheetOrganizationFragment();
bottomSheet.show(getSupportFragmentManager(), "orgBottomSheet");
return true;
}
else {
return super.onOptionsItemSelected(item);
}
}
@Override
@ -175,25 +183,31 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
String orgName;
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
orgName = getIntent().getStringExtra("orgName");
}
else {
orgName = tinyDb.getString("orgName");
}
Fragment fragment = null;
switch (position) {
case 0: // info
return OrganizationInfoFragment.newInstance(orgName);
case 1: // repos
return RepositoriesByOrgFragment.newInstance(orgName);
case 2: // teams
return TeamsByOrgFragment.newInstance(orgName);
case 3: // members
return MembersByOrgFragment.newInstance(orgName);
}
return fragment;
}
@Override

View File

@ -15,6 +15,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.lifecycle.ViewModelProvider;
import org.mian.gitnex.R;
import org.mian.gitnex.adapters.TeamMembersByOrgAdapter;
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
import org.mian.gitnex.fragments.BottomSheetOrganizationTeamsFragment;
import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.TinyDB;
@ -66,22 +67,25 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
closeActivity.setOnClickListener(onClickListener);
if(getIntent().getStringExtra("teamTitle") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamTitle")).equals("")) {
toolbarTitle.setText(getIntent().getStringExtra("teamTitle"));
toolbarTitle.setText(getIntent().getStringExtra("teamTitle"));
}
else {
toolbarTitle.setText(R.string.orgTeamMembers);
toolbarTitle.setText(R.string.orgTeamMembers);
}
if(getIntent().getStringExtra("teamId") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamId")).equals("")){
teamId = getIntent().getStringExtra("teamId");
teamId = getIntent().getStringExtra("teamId");
}
else {
teamId = "0";
teamId = "0";
}
assert teamId != null;
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), Integer.parseInt(teamId));
}
@Override
@ -94,10 +98,10 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
if(tinyDb.getBoolean("teamActionFlag")) {
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), Integer.parseInt(teamId));
tinyDb.putBoolean("teamActionFlag", false);
}
}
private void fetchDataAsync(String instanceUrl, String instanceToken, int teamId) {
@ -107,11 +111,14 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId, ctx).observe(this, teamMembersListMain -> {
adapter = new TeamMembersByOrgAdapter(ctx, teamMembersListMain);
if(adapter.getCount() > 0) {
mGridView.setAdapter(adapter);
noDataMembers.setVisibility(View.GONE);
}
else {
adapter.notifyDataSetChanged();
mGridView.setAdapter(adapter);
noDataMembers.setVisibility(View.VISIBLE);
@ -119,7 +126,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
progressBar.setVisibility(View.GONE);
});
}
@Override
@ -128,7 +134,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
return true;
}
@Override
@ -136,31 +141,32 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
int id = item.getItemId();
switch(id) {
case android.R.id.home:
finish();
return true;
case R.id.genericMenu:
BottomSheetOrganizationTeamsFragment bottomSheet = new BottomSheetOrganizationTeamsFragment();
bottomSheet.show(getSupportFragmentManager(), "orgTeamsBottomSheet");
return true;
default:
return super.onOptionsItemSelected(item);
}
if(id == android.R.id.home) {
finish();
return true;
}
else if(id == R.id.genericMenu) {
BottomSheetOrganizationTeamsFragment bottomSheet = new BottomSheetOrganizationTeamsFragment();
bottomSheet.show(getSupportFragmentManager(), "orgTeamsBottomSheet");
return true;
}
else {
return super.onOptionsItemSelected(item);
}
}
@Override
public void onButtonClicked(String text) {
TinyDB tinyDb = new TinyDB(appCtx);
if("newMember".equals(text)) {
Intent intent = new Intent(OrganizationTeamMembersActivity.this, AddNewTeamMemberActivity.class);
intent.putExtra("teamId", teamId);
startActivity(intent);
}
}
private void initCloseListener() {

View File

@ -73,11 +73,7 @@ public class ProfileEmailActivity extends BaseActivity {
}
private View.OnClickListener addEmailListener = new View.OnClickListener() {
public void onClick(View v) {
processAddNewEmail();
}
};
private final View.OnClickListener addEmailListener = v -> processAddNewEmail();
private void processAddNewEmail() {
@ -93,27 +89,23 @@ public class ProfileEmailActivity extends BaseActivity {
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
return;
}
if(newUserEmail.equals("")) {
Toasty.error(ctx, getString(R.string.emailErrorEmpty));
return;
}
else if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
Toasty.warning(ctx, getString(R.string.emailErrorInvalid));
return;
}
List<String> newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
disableProcessButton();
addNewEmail(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newEmailList);
}
private void addNewEmail(final String instanceUrl, final String token, List<String> newUserEmail) {
@ -139,7 +131,6 @@ public class ProfileEmailActivity extends BaseActivity {
tinyDb.putBoolean("emailsRefresh", true);
enableProcessButton();
finish();
}
else if(response.code() == 401) {
@ -148,37 +139,32 @@ public class ProfileEmailActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else if(response.code() == 403) {
enableProcessButton();
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
}
else if(response.code() == 404) {
enableProcessButton();
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
}
else if(response.code() == 422) {
enableProcessButton();
Toasty.warning(ctx, ctx.getString(R.string.emailErrorInUse));
}
else {
enableProcessButton();
Toasty.error(ctx, getString(R.string.labelGeneralError));
}
}
@Override
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
Log.e("onFailure", t.toString());
enableProcessButton();
}

View File

@ -80,6 +80,7 @@ public class ReplyToIssueActivity extends BaseActivity {
imm.showSoftInput(addComment, InputMethodManager.SHOW_IMPLICIT);
if(!tinyDb.getString("issueTitle").isEmpty()) {
toolbar_title.setText(tinyDb.getString("issueTitle"));
}
@ -93,9 +94,11 @@ public class ReplyToIssueActivity extends BaseActivity {
else {
if(getIntent().getStringExtra("commentBody") != null) {
draftIdOnCreate = returnDraftId(getIntent().getStringExtra("commentBody"));
}
else {
draftIdOnCreate = returnDraftId("");
}
}
@ -107,6 +110,7 @@ public class ReplyToIssueActivity extends BaseActivity {
addComment.setText(getIntent().getStringExtra("commentBody"));
if(getIntent().getBooleanExtra("cursorToEnd", false)) {
addComment.setSelection(addComment.length());
}
}
@ -126,7 +130,6 @@ public class ReplyToIssueActivity extends BaseActivity {
addComment.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -148,7 +151,6 @@ public class ReplyToIssueActivity extends BaseActivity {
});
return;
}
addComment.addTextChangedListener(new TextWatcher() {
@ -217,7 +219,7 @@ public class ReplyToIssueActivity extends BaseActivity {
onClickListener = view -> finish();
}
private View.OnClickListener replyToIssue = v -> processNewCommentReply();
private final View.OnClickListener replyToIssue = v -> processNewCommentReply();
private void processNewCommentReply() {
@ -239,7 +241,6 @@ public class ReplyToIssueActivity extends BaseActivity {
disableProcessButton();
replyComment(newReplyDT);
}
}
private void replyComment(String newReplyDT) {
@ -282,7 +283,6 @@ public class ReplyToIssueActivity extends BaseActivity {
}
finish();
}
else if(response.code() == 401) {
@ -291,15 +291,12 @@ public class ReplyToIssueActivity extends BaseActivity {
getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
}
else {
enableProcessButton();
Toasty.error(ctx, getString(R.string.commentError));
}
}
@Override
@ -319,26 +316,24 @@ public class ReplyToIssueActivity extends BaseActivity {
inflater.inflate(R.menu.reply_to_issue, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
int id = 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);
if(id == R.id.replyToIssueMenu) {
Intent fragmentIntent = new Intent(ReplyToIssueActivity.this, MainActivity.class);
fragmentIntent.putExtra("launchFragment", "drafts");
ReplyToIssueActivity.this.startActivity(fragmentIntent);
return true;
}
else {
return true;
return super.onOptionsItemSelected(item);
}
}
private void disableProcessButton() {

View File

@ -126,17 +126,17 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
switch(tinyDB.getInt("customFontId", -1)) {
case 0:
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf");
break;
case 2:
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf");
break;
default:
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/manroperegular.ttf");
break;
}
toolbarTitle.setTypeface(myTypeface);
@ -156,6 +156,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
View tabViewChild = vgTab.getChildAt(i);
if(tabViewChild instanceof TextView) {
((TextView) tabViewChild).setTypeface(myTypeface);
}
}
@ -172,7 +173,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
tabsCount--;
collaboratorTab.setVisibility(View.GONE);
}
mViewPager = findViewById(R.id.container);
@ -209,7 +209,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
assert tabOpenIssues != null; // FIXME This should be cleaned up
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
openIssueTabView.setTextColor(textColor);
}
// Pull request count
@ -220,7 +219,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
assert tabOpenPulls != null; // FIXME This should be cleaned up
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
openPullTabView.setTextColor(textColor);
}
// Release count
@ -233,7 +231,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
assert tabOpenRelease != null; // FIXME This should be cleaned up
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
openReleaseTabView.setTextColor(textColor);
}
}
}
@ -259,7 +256,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
checkRepositoryWatchStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
}
@Override
@ -271,7 +267,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
}
}
@Override
@ -280,7 +275,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.repo_dotted_menu, menu);
return true;
}
@Override
@ -337,100 +331,105 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
switch(text) {
case "label":
startActivity(new Intent(RepoDetailActivity.this, CreateLabelActivity.class));
break;
case "newIssue":
startActivity(new Intent(RepoDetailActivity.this, CreateIssueActivity.class));
break;
case "newMilestone":
startActivity(new Intent(RepoDetailActivity.this, CreateMilestoneActivity.class));
break;
case "addCollaborator":
startActivity(new Intent(RepoDetailActivity.this, AddCollaboratorToRepositoryActivity.class));
break;
case "chooseBranch":
chooseBranch();
break;
case "createRelease":
startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
break;
case "openWebRepo":
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(tinyDB.getString("repoHtmlUrl")));
startActivity(i);
break;
case "shareRepo":
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, tinyDB.getString("repoHtmlUrl"));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDB.getString("repoHtmlUrl"));
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
break;
case "copyRepoUrl":
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", tinyDB.getString("repoHtmlUrl"));
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
break;
case "newFile":
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
break;
case "openIssues":
if(getFragmentRefreshListener() != null) {
getFragmentRefreshListener().onRefresh("open");
}
break;
case "closedIssues":
if(getFragmentRefreshListener() != null) {
getFragmentRefreshListener().onRefresh("closed");
}
break;
case "openPr":
if(getFragmentRefreshListenerPr() != null) {
getFragmentRefreshListenerPr().onRefresh("open");
}
break;
case "closedPr":
if(getFragmentRefreshListenerPr() != null) {
getFragmentRefreshListenerPr().onRefresh("closed");
}
break;
case "openMilestone":
if(getFragmentRefreshListenerMilestone() != null) {
getFragmentRefreshListenerMilestone().onRefresh("open");
}
break;
case "closedMilestone":
if(getFragmentRefreshListenerMilestone() != null) {
getFragmentRefreshListenerMilestone().onRefresh("closed");
}
break;
case "repoSettings":
startActivity(new Intent(RepoDetailActivity.this, RepositorySettingsActivity.class));
break;
case "newPullRequest":
startActivity(new Intent(RepoDetailActivity.this, CreatePullRequestActivity.class));
break;
}
}
private void chooseBranch() {
@ -470,7 +469,9 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
public void onClick(DialogInterface dialogInterface, int i) {
tinyDB.putString("repoBranch", branchesList.get(i));
if(getFragmentRefreshListenerFiles() != null) {
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
}
dialogInterface.dismiss();
@ -479,9 +480,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
pBuilder.setNeutralButton(R.string.cancelButton, null);
pBuilder.create().show();
}
}
@Override
@ -509,37 +508,36 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
switch(position) {
case 0: // Repository details
return RepoInfoFragment.newInstance(repositoryOwner, repositoryName);
case 1: // Files
return FilesFragment.newInstance(repositoryOwner, repositoryName, tinyDB.getString("repoBranch"));
return FilesFragment.newInstance(repositoryOwner, repositoryName, tinyDB.getString("repoBranch"));
case 2: // Issues
fragment = new IssuesFragment();
break;
case 3: // Pull requests
fragment = new PullRequestsFragment();
break;
case 4: // Releases
return ReleasesFragment.newInstance(repositoryOwner, repositoryName);
return ReleasesFragment.newInstance(repositoryOwner, repositoryName);
case 5: // Milestones
fragment = new MilestonesFragment();
break;
case 6: // Labels
return LabelsFragment.newInstance(repositoryOwner, repositoryName);
case 7: // Collaborators
return CollaboratorsFragment.newInstance(repositoryOwner, repositoryName);
return CollaboratorsFragment.newInstance(repositoryOwner, repositoryName);
}
assert fragment != null;
return fragment;
}
@Override
@ -547,7 +545,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
return tabsCount;
}
}
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
@ -563,6 +560,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
if(response.code() == 200) {
if(tinyDB.getBoolean("enableCounterBadges")) {
assert repoInfo != null;
if(repoInfo.getOpen_issues_count() != null) {
@ -589,7 +587,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
Log.e("onFailure", String.valueOf(response.code()));
}
}
@Override
@ -611,7 +608,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
tinyDB.putInt("repositoryStarStatus", response.code());
}
@Override
@ -638,15 +634,14 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
assert response.body() != null;
if(response.body().getSubscribed()) {
tinyDB.putBoolean("repositoryWatchStatus", true);
}
}
else {
tinyDB.putBoolean("repositoryWatchStatus", false);
}
}
@Override

View File

@ -97,6 +97,7 @@ public class RepoForksActivity extends BaseActivity {
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
}
@ -122,9 +123,7 @@ public class RepoForksActivity extends BaseActivity {
int page = (forksList.size() + resultLimit) / resultLimit;
loadMore(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, resultLimit);
}
}));
recyclerView.setHasFixedSize(true);
@ -132,7 +131,6 @@ public class RepoForksActivity extends BaseActivity {
recyclerView.setAdapter(adapter);
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
}
private void loadInitial(String instanceUrl, String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
@ -150,29 +148,27 @@ public class RepoForksActivity extends BaseActivity {
if(response.isSuccessful()) {
assert response.body() != null;
if(response.body().size() > 0) {
forksList.clear();
forksList.addAll(response.body());
adapter.notifyDataChanged();
noData.setVisibility(View.GONE);
}
else {
forksList.clear();
adapter.notifyDataChanged();
noData.setVisibility(View.VISIBLE);
}
progressBar.setVisibility(View.GONE);
}
else {
Log.e(TAG, String.valueOf(response.code()));
}
}
@Override
@ -180,7 +176,6 @@ public class RepoForksActivity extends BaseActivity {
Log.e(TAG, t.toString());
}
});
}
@ -205,37 +200,31 @@ public class RepoForksActivity extends BaseActivity {
forksList.remove(forksList.size() - 1);
List<UserRepositories> result = response.body();
assert result != null;
if(result.size() > 0) {
pageSize = result.size();
forksList.addAll(result);
}
else {
adapter.setMoreDataAvailable(false);
}
adapter.notifyDataChanged();
progressLoadMore.setVisibility(View.GONE);
}
else {
Log.e(TAG, String.valueOf(response.code()));
}
}
@Override
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
Log.e(TAG, t.toString());
}
});
@ -270,7 +259,6 @@ public class RepoForksActivity extends BaseActivity {
});
return super.onCreateOptionsMenu(menu);
}
private void filter(String text) {
@ -278,7 +266,9 @@ public class RepoForksActivity extends BaseActivity {
List<UserRepositories> arr = new ArrayList<>();
for(UserRepositories d : forksList) {
if(d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) {
arr.add(d);
}
}
@ -289,6 +279,7 @@ public class RepoForksActivity extends BaseActivity {
private void initCloseListener() {
onClickListener = view -> {
getIntent().removeExtra("repoFullNameForForks");
finish();
};

View File

@ -7,16 +7,12 @@ import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import org.mian.gitnex.R;
import org.mian.gitnex.adapters.RepoStargazersAdapter;
import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.models.UserInfo;
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
import java.util.List;
/**
* Author M M Arif
@ -66,28 +62,29 @@ public class RepoStargazersActivity extends BaseActivity {
toolbarTitle.setText(R.string.repoStargazersInMenu);
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
}
private void fetchDataAsync(String instanceUrl, String instanceToken, String repoOwner, String repoName) {
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName, ctx).observe(this, new Observer<List<UserInfo>>() {
@Override
public void onChanged(@Nullable List<UserInfo> stargazersListMain) {
adapter = new RepoStargazersAdapter(ctx, stargazersListMain);
if(adapter.getCount() > 0) {
mGridView.setAdapter(adapter);
noDataStargazers.setVisibility(View.GONE);
}
else {
adapter.notifyDataSetChanged();
mGridView.setAdapter(adapter);
noDataStargazers.setVisibility(View.VISIBLE);
}
mProgressBar.setVisibility(View.GONE);
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName, ctx).observe(this, stargazersListMain -> {
adapter = new RepoStargazersAdapter(ctx, stargazersListMain);
if(adapter.getCount() > 0) {
mGridView.setAdapter(adapter);
noDataStargazers.setVisibility(View.GONE);
}
else {
adapter.notifyDataSetChanged();
mGridView.setAdapter(adapter);
noDataStargazers.setVisibility(View.VISIBLE);
}
mProgressBar.setVisibility(View.GONE);
});
}

View File

@ -7,16 +7,12 @@ import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import org.mian.gitnex.R;
import org.mian.gitnex.adapters.RepoWatchersAdapter;
import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.models.UserInfo;
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
import java.util.List;
/**
* Author M M Arif
@ -66,28 +62,29 @@ public class RepoWatchersActivity extends BaseActivity {
toolbarTitle.setText(R.string.repoWatchersInMenu);
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
}
private void fetchDataAsync(String instanceUrl, String instanceToken, String repoOwner, String repoName) {
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName, ctx).observe(this, new Observer<List<UserInfo>>() {
@Override
public void onChanged(@Nullable List<UserInfo> watchersListMain) {
adapter = new RepoWatchersAdapter(ctx, watchersListMain);
if(adapter.getCount() > 0) {
mGridView.setAdapter(adapter);
noDataWatchers.setVisibility(View.GONE);
}
else {
adapter.notifyDataSetChanged();
mGridView.setAdapter(adapter);
noDataWatchers.setVisibility(View.VISIBLE);
}
mProgressBar.setVisibility(View.GONE);
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName, ctx).observe(this, watchersListMain -> {
adapter = new RepoWatchersAdapter(ctx, watchersListMain);
if(adapter.getCount() > 0) {
mGridView.setAdapter(adapter);
noDataWatchers.setVisibility(View.GONE);
}
else {
adapter.notifyDataSetChanged();
mGridView.setAdapter(adapter);
noDataWatchers.setVisibility(View.VISIBLE);
}
mProgressBar.setVisibility(View.GONE);
});
}

View File

@ -82,22 +82,15 @@ public class RepositorySettingsActivity extends BaseActivity {
// require gitea 1.12 or higher
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
viewBinding.transferOwnerFrame.setVisibility(View.VISIBLE);
}
viewBinding.editProperties.setOnClickListener(editProperties -> {
showRepositoryProperties();
});
viewBinding.editProperties.setOnClickListener(editProperties -> showRepositoryProperties());
viewBinding.deleteRepository.setOnClickListener(deleteRepository -> {
showDeleteRepository();
});
viewBinding.transferOwnerFrame.setOnClickListener(transferRepositoryOwnership -> {
showTransferRepository();
});
viewBinding.deleteRepository.setOnClickListener(deleteRepository -> showDeleteRepository());
viewBinding.transferOwnerFrame.setOnClickListener(transferRepositoryOwnership -> showTransferRepository());
}
private void showTransferRepository() {
@ -114,9 +107,7 @@ public class RepositorySettingsActivity extends BaseActivity {
View view = transferRepoBinding.getRoot();
dialogTransferRepository.setContentView(view);
transferRepoBinding.cancel.setOnClickListener(editProperties -> {
dialogTransferRepository.dismiss();
});
transferRepoBinding.cancel.setOnClickListener(editProperties -> dialogTransferRepository.dismiss());
transferRepoBinding.transfer.setOnClickListener(deleteRepo -> {
@ -197,6 +188,7 @@ public class RepositorySettingsActivity extends BaseActivity {
dialogDeleteRepository = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
if (dialogDeleteRepository.getWindow() != null) {
dialogDeleteRepository.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
@ -205,9 +197,7 @@ public class RepositorySettingsActivity extends BaseActivity {
View view = deleteRepoBinding.getRoot();
dialogDeleteRepository.setContentView(view);
deleteRepoBinding.cancel.setOnClickListener(editProperties -> {
dialogDeleteRepository.dismiss();
});
deleteRepoBinding.cancel.setOnClickListener(editProperties -> dialogDeleteRepository.dismiss());
deleteRepoBinding.delete.setOnClickListener(deleteRepo -> {
@ -273,6 +263,7 @@ public class RepositorySettingsActivity extends BaseActivity {
dialogProp = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
if (dialogProp.getWindow() != null) {
dialogProp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
@ -281,9 +272,7 @@ public class RepositorySettingsActivity extends BaseActivity {
View view = propBinding.getRoot();
dialogProp.setContentView(view);
propBinding.cancel.setOnClickListener(editProperties -> {
dialogProp.dismiss();
});
propBinding.cancel.setOnClickListener(editProperties -> dialogProp.dismiss());
Call<UserRepositories> call = RetrofitClient
.getInstance(instanceUrl, ctx)
@ -314,19 +303,24 @@ public class RepositorySettingsActivity extends BaseActivity {
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
}
else {
propBinding.repoEnableTimer.setVisibility(View.GONE);
}
});
if(repoInfo.getInternal_tracker() != null) {
propBinding.repoEnableTimer.setChecked(repoInfo.getInternal_tracker().isEnable_time_tracker());
}
else {
propBinding.repoEnableTimer.setVisibility(View.GONE);
}
propBinding.repoEnableWiki.setChecked(repoInfo.isHas_wiki());
propBinding.repoEnablePr.setChecked(repoInfo.isHas_pull_requests());
propBinding.repoEnableMerge.setChecked(repoInfo.isAllow_merge_commits());
@ -359,7 +353,6 @@ public class RepositorySettingsActivity extends BaseActivity {
propBinding.repoEnableSquash.isChecked(), propBinding.repoEnableForceMerge.isChecked()));
dialogProp.show();
}
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription,
@ -370,11 +363,14 @@ public class RepositorySettingsActivity extends BaseActivity {
UserRepositories.internalTimeTrackerObject repoPropsTimeTracker = new UserRepositories.internalTimeTrackerObject(repoEnableTimer);
UserRepositories repoProps;
if(!repoEnableIssues) {
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoEnableMerge,
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
}
else {
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoPropsTimeTracker, repoEnableMerge,
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
}
@ -406,7 +402,6 @@ public class RepositorySettingsActivity extends BaseActivity {
RepositoriesApi.updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDb.getLong("repositoryId", 0));
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
RepositorySettingsActivity.this.startActivity(intent);
}
}
else {
@ -415,7 +410,6 @@ public class RepositorySettingsActivity extends BaseActivity {
propBinding.processingRequest.setVisibility(View.GONE);
Toasty.error(ctx, getString(R.string.genericError));
}
}
@Override

View File

@ -5,13 +5,15 @@ import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import com.google.android.material.switchmaterial.SwitchMaterial;
import org.mian.gitnex.R;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.helpers.Version;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Author M M Arif
@ -22,20 +24,16 @@ public class SettingsAppearanceActivity extends BaseActivity {
private Context appCtx;
private View.OnClickListener onClickListener;
private static String[] timeList = {"Pretty", "Normal"};
private static final String[] timeList = {"Pretty", "Normal"};
private static int timeSelectedChoice = 0;
private static String[] codeBlockList = {"Green - Black", "White - Black", "Grey - Black", "White - Grey", "Dark - White"};
private List<String> codeBlockList;
private static int codeBlockSelectedChoice = 0;
private static String[] homeScreenList = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile", "Explore", "Drafts"};
private static String[] homeScreenListNew = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile", "Explore", "Drafts", "Notifications"};
private static int homeScreenSelectedChoice = 0;
private static String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
private static final String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
private static int customFontSelectedChoice = 0;
private static String[] themeList = {"Dark", "Light", "Auto (Light / Dark)", "Retro", "Auto (Retro / Dark)"};
private static final String[] themeList = {"Dark", "Light", "Auto (Light / Dark)", "Retro", "Auto (Retro / Dark)"};
private static int themeSelectedChoice = 0;
@Override
@ -56,85 +54,138 @@ public class SettingsAppearanceActivity extends BaseActivity {
final TextView tvDateTimeSelected = findViewById(R.id.tvDateTimeSelected); // setter for time
final TextView codeBlockSelected = findViewById(R.id.codeBlockSelected); // setter for code block
final TextView homeScreenSelected = findViewById(R.id.homeScreenSelected); // setter for home screen
final TextView customFontSelected = findViewById(R.id.customFontSelected); // setter for custom font
final TextView themeSelected = findViewById(R.id.themeSelected); // setter for theme
LinearLayout timeFrame = findViewById(R.id.timeFrame);
LinearLayout codeBlockFrame = findViewById(R.id.codeBlockFrame);
LinearLayout homeScreenFrame = findViewById(R.id.homeScreenFrame);
LinearLayout customFontFrame = findViewById(R.id.customFontFrame);
LinearLayout themeFrame = findViewById(R.id.themeSelectionFrame);
Switch counterBadgesSwitch = findViewById(R.id.switchCounterBadge);
SwitchMaterial counterBadgesSwitch = findViewById(R.id.switchCounterBadge);
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
// code block
String[] codeBlockList_ = {getResources().getString(R.string.codeBlockGreenOnBlack), getResources().getString(R.string.codeBlockWhiteOnBlack),
getResources().getString(R.string.codeBlockGreyOnBlack), getResources().getString(R.string.codeBlockWhiteOnGrey),
getResources().getString(R.string.codeBlockDarkOnWhite)};
homeScreenList = homeScreenListNew;
codeBlockList = new ArrayList<>(Arrays.asList(codeBlockList_));
String[] codeBlockArray = new String[codeBlockList.size()];
codeBlockList.toArray(codeBlockArray);
if(codeBlockSelectedChoice == 0) {
codeBlockSelectedChoice = tinyDb.getInt("codeBlockId");
codeBlockSelected.setText(getResources().getString(R.string.codeBlockGreenOnBlack));
}
if(codeBlockSelectedChoice == 1) {
codeBlockSelected.setText(getResources().getString(R.string.codeBlockWhiteOnBlack));
}
else if(codeBlockSelectedChoice == 2) {
codeBlockSelected.setText(getResources().getString(R.string.codeBlockGreyOnBlack));
}
else if(codeBlockSelectedChoice == 3) {
codeBlockSelected.setText(getResources().getString(R.string.codeBlockWhiteOnGrey));
}
else if(codeBlockSelectedChoice == 4) {
codeBlockSelected.setText(getResources().getString(R.string.codeBlockDarkOnWhite));
}
codeBlockFrame.setOnClickListener(codeBlock -> {
AlertDialog.Builder cBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
cBuilder.setTitle(R.string.settingsCodeBlockSelectorDialogTitle);
cBuilder.setCancelable(codeBlockSelectedChoice != -1);
cBuilder.setSingleChoiceItems(codeBlockList_, codeBlockSelectedChoice, (dialogInterfaceCodeBlock, i) -> {
codeBlockSelectedChoice = i;
codeBlockSelected.setText(codeBlockList_[i]);
tinyDb.putInt("codeBlockId", i);
switch(i) {
case 1: // white on black
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
break;
case 2: // grey on black
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorAccent));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
break;
case 3: // white on grey
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorAccent));
break;
case 4: // dark on white
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorPrimary));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorWhite));
break;
default: // green on black
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
break;
}
dialogInterfaceCodeBlock.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
AlertDialog cDialog = cBuilder.create();
cDialog.show();
});
// code block
if(!tinyDb.getString("timeStr").isEmpty()) {
tvDateTimeSelected.setText(tinyDb.getString("timeStr"));
}
if(!tinyDb.getString("codeBlockStr").isEmpty()) {
codeBlockSelected.setText(tinyDb.getString("codeBlockStr"));
}
if(!tinyDb.getString("homeScreenStr").isEmpty()) {
homeScreenSelected.setText(tinyDb.getString("homeScreenStr"));
}
if(!tinyDb.getString("customFontStr").isEmpty()) {
customFontSelected.setText(tinyDb.getString("customFontStr"));
}
if(!tinyDb.getString("themeStr").isEmpty()) {
themeSelected.setText(tinyDb.getString("themeStr"));
}
if(timeSelectedChoice == 0) {
timeSelectedChoice = tinyDb.getInt("timeId");
}
if(codeBlockSelectedChoice == 0) {
codeBlockSelectedChoice = tinyDb.getInt("codeBlockId");
}
if(homeScreenSelectedChoice == 0) {
homeScreenSelectedChoice = tinyDb.getInt("homeScreenId");
}
if(customFontSelectedChoice == 0) {
customFontSelectedChoice = tinyDb.getInt("customFontId", 1);
}
if(themeSelectedChoice == 0) {
themeSelectedChoice = tinyDb.getInt("themeId");
}
if(tinyDb.getBoolean("enableCounterBadges")) {
counterBadgesSwitch.setChecked(true);
}
else {
counterBadgesSwitch.setChecked(false);
}
counterBadgesSwitch.setChecked(tinyDb.getBoolean("enableCounterBadges"));
// counter badge switcher
counterBadgesSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
tinyDb.putBoolean("enableCounterBadges", true);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
}
else {
tinyDb.putBoolean("enableCounterBadges", false);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
}
tinyDb.putBoolean("enableCounterBadges", isChecked);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
// theme selection dialog
@ -143,12 +194,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
tsBuilder.setTitle(getResources().getString(R.string.themeSelectorDialogTitle));
if(themeSelectedChoice != -1) {
tsBuilder.setCancelable(true);
}
else {
tsBuilder.setCancelable(false);
}
tsBuilder.setCancelable(themeSelectedChoice != -1);
tsBuilder.setSingleChoiceItems(themeList, themeSelectedChoice, (dialogInterfaceTheme, i) -> {
@ -162,12 +208,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
this.overridePendingTransition(0, 0);
dialogInterfaceTheme.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
AlertDialog cfDialog = tsBuilder.create();
cfDialog.show();
});
// custom font dialog
@ -176,12 +220,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
AlertDialog.Builder cfBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
cfBuilder.setTitle(R.string.settingsCustomFontSelectorDialogTitle);
if(customFontSelectedChoice != -1) {
cfBuilder.setCancelable(true);
}
else {
cfBuilder.setCancelable(false);
}
cfBuilder.setCancelable(customFontSelectedChoice != -1);
cfBuilder.setSingleChoiceItems(customFontList, customFontSelectedChoice, (dialogInterfaceCustomFont, i) -> {
@ -195,95 +234,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
this.overridePendingTransition(0, 0);
dialogInterfaceCustomFont.dismiss();
Toasty.success(appCtx, appCtx.getResources().getString(R.string.settingsSave));
});
AlertDialog cfDialog = cfBuilder.create();
cfDialog.show();
});
// home screen dialog
homeScreenFrame.setOnClickListener(view -> {
AlertDialog.Builder hsBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
hsBuilder.setTitle(R.string.settingsHomeScreenSelectorDialogTitle);
if(homeScreenSelectedChoice != -1) {
hsBuilder.setCancelable(true);
}
else {
hsBuilder.setCancelable(false);
}
hsBuilder.setSingleChoiceItems(homeScreenList, homeScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
homeScreenSelectedChoice = i;
homeScreenSelected.setText(homeScreenList[i]);
tinyDb.putString("homeScreenStr", homeScreenList[i]);
tinyDb.putInt("homeScreenId", i);
dialogInterfaceHomeScreen.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
AlertDialog hsDialog = hsBuilder.create();
hsDialog.show();
});
// code block dialog
codeBlockFrame.setOnClickListener(view -> {
AlertDialog.Builder cBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
cBuilder.setTitle(R.string.settingsCodeBlockSelectorDialogTitle);
if(codeBlockSelectedChoice != -1) {
cBuilder.setCancelable(true);
}
else {
cBuilder.setCancelable(false);
}
cBuilder.setSingleChoiceItems(codeBlockList, codeBlockSelectedChoice, (dialogInterfaceCodeBlock, i) -> {
codeBlockSelectedChoice = i;
codeBlockSelected.setText(codeBlockList[i]);
tinyDb.putString("codeBlockStr", codeBlockList[i]);
tinyDb.putInt("codeBlockId", i);
switch(codeBlockList[i]) {
case "White - Black":
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
break;
case "Grey - Black":
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorAccent));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
break;
case "White - Grey":
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorAccent));
break;
case "Dark - White":
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorPrimary));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorWhite));
break;
default:
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
break;
}
dialogInterfaceCodeBlock.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
AlertDialog cDialog = cBuilder.create();
cDialog.show();
});
// time and date dialog
@ -292,12 +246,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
AlertDialog.Builder tBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
tBuilder.setTitle(R.string.settingsTimeSelectorDialogTitle);
if(timeSelectedChoice != -1) {
tBuilder.setCancelable(true);
}
else {
tBuilder.setCancelable(false);
}
tBuilder.setCancelable(timeSelectedChoice != -1);
tBuilder.setSingleChoiceItems(timeList, timeSelectedChoice, (dialogInterfaceTime, i) -> {
@ -307,21 +256,20 @@ public class SettingsAppearanceActivity extends BaseActivity {
tinyDb.putInt("timeId", i);
if("Normal".equals(timeList[i])) {
tinyDb.putString("dateFormat", "normal");
}
else {
tinyDb.putString("dateFormat", "pretty");
}
dialogInterfaceTime.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
AlertDialog tDialog = tBuilder.create();
tDialog.show();
});
}

View File

@ -4,10 +4,10 @@ import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Switch;
import com.google.android.material.switchmaterial.SwitchMaterial;
import org.mian.gitnex.R;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty;
/**
* Author M M Arif
@ -37,27 +37,15 @@ public class SettingsDraftsActivity extends BaseActivity {
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
Switch commentsDeletionSwitch = findViewById(R.id.commentsDeletionSwitch);
SwitchMaterial commentsDeletionSwitch = findViewById(R.id.commentsDeletionSwitch);
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
commentsDeletionSwitch.setChecked(true);
}
else {
commentsDeletionSwitch.setChecked(false);
}
commentsDeletionSwitch.setChecked(tinyDb.getBoolean("draftsCommentsDeletionEnabled"));
// delete comments on submit switcher
commentsDeletionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if(isChecked) {
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
}
else {
tinyDb.putBoolean("draftsCommentsDeletionEnabled", false);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
}
tinyDb.putBoolean("draftsCommentsDeletionEnabled", isChecked);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
}

View File

@ -5,9 +5,9 @@ import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import com.google.android.material.switchmaterial.SwitchMaterial;
import org.mian.gitnex.R;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty;
@ -21,7 +21,7 @@ public class SettingsFileViewerActivity extends BaseActivity {
private Context appCtx;
private View.OnClickListener onClickListener;
private static String[] fileViewerSourceCodeThemesList = {"Sublime", "Arduino Light", "Github", "Far ", "Ir Black", "Android Studio"};
private static final String[] fileViewerSourceCodeThemesList = {"Sublime", "Arduino Light", "Github", "Far ", "Ir Black", "Android Studio"};
private static int fileViewerSourceCodeThemesSelectedChoice = 0;
@Override
@ -47,7 +47,7 @@ public class SettingsFileViewerActivity extends BaseActivity {
LinearLayout sourceCodeThemeFrame = findViewById(R.id.sourceCodeThemeFrame);
Switch pdfModeSwitch = findViewById(R.id.switchPdfMode);
SwitchMaterial pdfModeSwitch = findViewById(R.id.switchPdfMode);
if(!tinyDb.getString("fileviewerSourceCodeThemeStr").isEmpty()) {
fileViewerSourceCodeThemesSelected.setText(tinyDb.getString("fileviewerSourceCodeThemeStr"));
@ -57,12 +57,7 @@ public class SettingsFileViewerActivity extends BaseActivity {
fileViewerSourceCodeThemesSelectedChoice = tinyDb.getInt("fileviewerThemeId");
}
if(tinyDb.getBoolean("enablePdfMode")) {
pdfModeSwitch.setChecked(true);
}
else {
pdfModeSwitch.setChecked(false);
}
pdfModeSwitch.setChecked(tinyDb.getBoolean("enablePdfMode"));
// fileviewer srouce code theme selection dialog
sourceCodeThemeFrame.setOnClickListener(view -> {
@ -70,12 +65,7 @@ public class SettingsFileViewerActivity extends BaseActivity {
AlertDialog.Builder fvtsBuilder = new AlertDialog.Builder(SettingsFileViewerActivity.this);
fvtsBuilder.setTitle(R.string.fileviewerSourceCodeThemeSelectorDialogTitle);
if(fileViewerSourceCodeThemesSelectedChoice != -1) {
fvtsBuilder.setCancelable(true);
}
else {
fvtsBuilder.setCancelable(false);
}
fvtsBuilder.setCancelable(fileViewerSourceCodeThemesSelectedChoice != -1);
fvtsBuilder.setSingleChoiceItems(fileViewerSourceCodeThemesList, fileViewerSourceCodeThemesSelectedChoice, (dialogInterfaceTheme, i) -> {
@ -91,25 +81,15 @@ public class SettingsFileViewerActivity extends BaseActivity {
AlertDialog cfDialog = fvtsBuilder.create();
cfDialog.show();
});
// pdf night mode switcher
pdfModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if(isChecked) {
tinyDb.putBoolean("enablePdfMode", true);
tinyDb.putString("enablePdfModeInit", "yes");
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
}
else {
tinyDb.putBoolean("enablePdfMode", false);
tinyDb.putString("enablePdfModeInit", "yes");
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
}
tinyDb.putBoolean("enablePdfMode", isChecked);
tinyDb.putString("enablePdfModeInit", "yes");
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
}
private void initCloseListener() {

View File

@ -8,6 +8,7 @@ import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivitySettingsGeneralBinding;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.helpers.Version;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -22,8 +23,11 @@ public class SettingsGeneralActivity extends BaseActivity {
private Context appCtx;
private View.OnClickListener onClickListener;
private List<String> homeScreenList;
private static int homeScreenSelectedChoice = 0;
private List<String> defaultScreen;
private static int defaultScreenSelectedChoice = 0;
private static int defaultLinkHandlerScreenSelectedChoice = 0;
@Override
protected int getLayoutResourceId() {
@ -46,18 +50,109 @@ public class SettingsGeneralActivity extends BaseActivity {
initCloseListener();
viewBinding.close.setOnClickListener(onClickListener);
// home screen
String[] homeDefaultScreen_ = {getResources().getString(R.string.pageTitleMyRepos), getResources().getString(R.string.pageTitleStarredRepos), getResources().getString(R.string.pageTitleOrganizations),
getResources().getString(R.string.pageTitleRepositories), getResources().getString(R.string.pageTitleProfile), getResources().getString(R.string.pageTitleExplore),
getResources().getString(R.string.titleDrafts)};
String[] homeDefaultScreenNew = {getResources().getString(R.string.pageTitleMyRepos), getResources().getString(R.string.pageTitleStarredRepos), getResources().getString(R.string.pageTitleOrganizations),
getResources().getString(R.string.pageTitleRepositories), getResources().getString(R.string.pageTitleProfile), getResources().getString(R.string.pageTitleExplore),
getResources().getString(R.string.titleDrafts), getResources().getString(R.string.pageTitleNotifications)};
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
homeDefaultScreen_ = homeDefaultScreenNew;
}
homeScreenList = new ArrayList<>(Arrays.asList(homeDefaultScreen_));
String[] homeScreenArray = new String[homeScreenList.size()];
homeScreenList.toArray(homeScreenArray);
if(homeScreenSelectedChoice == 0) {
homeScreenSelectedChoice = tinyDb.getInt("homeScreenId");
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleMyRepos));
}
if(homeScreenSelectedChoice == 1) {
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleStarredRepos));
}
else if(homeScreenSelectedChoice == 2) {
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleOrganizations));
}
else if(homeScreenSelectedChoice == 3) {
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleRepositories));
}
else if(homeScreenSelectedChoice == 4) {
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleProfile));
}
else if(homeScreenSelectedChoice == 5) {
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleExplore));
}
else if(homeScreenSelectedChoice == 6) {
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.titleDrafts));
}
else if(homeScreenSelectedChoice == 7) {
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleNotifications));
}
viewBinding.homeScreenFrame.setOnClickListener(setDefaultHomeScreen -> {
AlertDialog.Builder hsBuilder = new AlertDialog.Builder(SettingsGeneralActivity.this);
hsBuilder.setTitle(R.string.settingsHomeScreenSelectorDialogTitle);
hsBuilder.setCancelable(homeScreenSelectedChoice != -1);
hsBuilder.setSingleChoiceItems(homeScreenArray, homeScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
homeScreenSelectedChoice = i;
viewBinding.homeScreenSelected.setText(homeScreenArray[i]);
tinyDb.putInt("homeScreenId", i);
dialogInterfaceHomeScreen.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
AlertDialog hsDialog = hsBuilder.create();
hsDialog.show();
});
// home screen
// link handler
String[] defaultScreen_ = {getResources().getString(R.string.generalDeepLinkSelectedText), getResources().getString(R.string.navRepos), getResources().getString(R.string.navOrgs), getResources().getString(R.string.pageTitleNotifications), getResources().getString(R.string.navExplore)};
defaultScreen = new ArrayList<>(Arrays.asList(defaultScreen_));
String[] linksArray = new String[defaultScreen.size()];
defaultScreen.toArray(linksArray);
if(!tinyDb.getString("defaultScreenStr").isEmpty()) {
viewBinding.generalDeepLinkSelected.setText(tinyDb.getString("defaultScreenStr"));
if(defaultLinkHandlerScreenSelectedChoice == 0) {
defaultLinkHandlerScreenSelectedChoice = tinyDb.getInt("defaultScreenId");
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.generalDeepLinkSelectedText));
}
if(defaultScreenSelectedChoice == 0) {
defaultScreenSelectedChoice = tinyDb.getInt("defaultScreenId");
if(defaultLinkHandlerScreenSelectedChoice == 1) {
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navRepos));
}
else if(defaultLinkHandlerScreenSelectedChoice == 2) {
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navOrgs));
}
else if(defaultLinkHandlerScreenSelectedChoice == 3) {
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.pageTitleNotifications));
}
else if(defaultLinkHandlerScreenSelectedChoice == 4) {
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navExplore));
}
viewBinding.setDefaultLinkHandler.setOnClickListener(setDefaultLinkHandler -> {
@ -65,18 +160,12 @@ public class SettingsGeneralActivity extends BaseActivity {
AlertDialog.Builder dlBuilder = new AlertDialog.Builder(SettingsGeneralActivity.this);
dlBuilder.setTitle(R.string.linkSelectorDialogTitle);
if(defaultScreenSelectedChoice != -1) {
dlBuilder.setCancelable(true);
}
else {
dlBuilder.setCancelable(false);
}
dlBuilder.setCancelable(defaultLinkHandlerScreenSelectedChoice != -1);
dlBuilder.setSingleChoiceItems(linksArray, defaultScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
dlBuilder.setSingleChoiceItems(linksArray, defaultLinkHandlerScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
defaultScreenSelectedChoice = i;
defaultLinkHandlerScreenSelectedChoice = i;
viewBinding.generalDeepLinkSelected.setText(linksArray[i]);
tinyDb.putString("defaultScreenStr", linksArray[i]);
tinyDb.putInt("defaultScreenId", i);
dialogInterfaceHomeScreen.dismiss();
@ -85,9 +174,8 @@ public class SettingsGeneralActivity extends BaseActivity {
AlertDialog dlDialog = dlBuilder.create();
dlDialog.show();
});
// link handler
}
private void initCloseListener() { onClickListener = view -> finish(); }

View File

@ -4,7 +4,7 @@ import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Switch;
import com.google.android.material.switchmaterial.SwitchMaterial;
import org.mian.gitnex.R;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty;
@ -37,29 +37,16 @@ public class SettingsReportsActivity extends BaseActivity {
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
Switch crashReportsSwitch = findViewById(R.id.crashReportsSwitch);
SwitchMaterial crashReportsSwitch = findViewById(R.id.crashReportsSwitch);
if(tinyDb.getBoolean("crashReportingEnabled")) {
crashReportsSwitch.setChecked(true);
}
else {
crashReportsSwitch.setChecked(false);
}
crashReportsSwitch.setChecked(tinyDb.getBoolean("crashReportingEnabled"));
// crash reports switcher
crashReportsSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if(isChecked) {
tinyDb.putBoolean("crashReportingEnabled", true);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
}
else {
tinyDb.putBoolean("crashReportingEnabled", false);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
}
tinyDb.putBoolean("crashReportingEnabled", isChecked);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
}
private void initCloseListener() {

View File

@ -73,22 +73,27 @@ public class SettingsSecurityActivity extends BaseActivity {
LinearLayout clearCacheFrame = findViewById(R.id.clearCacheSelectionFrame);
if(!tinyDb.getString("cacheSizeStr").isEmpty()) {
cacheSizeDataSelected.setText(tinyDb.getString("cacheSizeStr"));
}
if(!tinyDb.getString("cacheSizeImagesStr").isEmpty()) {
cacheSizeImagesSelected.setText(tinyDb.getString("cacheSizeImagesStr"));
}
if(cacheSizeDataSelectedChoice == 0) {
cacheSizeDataSelectedChoice = tinyDb.getInt("cacheSizeId");
}
if(cacheSizeImagesSelectedChoice == 0) {
cacheSizeImagesSelectedChoice = tinyDb.getInt("cacheSizeImagesId");
}
if(new Version(currentVersion).less("1.12.3")) {
pollingDelayFrame.setVisibility(View.GONE);
}
@ -113,14 +118,11 @@ public class SettingsSecurityActivity extends BaseActivity {
FileUtils.mkdir(cacheDir.getAbsolutePath());
this.recreate();
this.overridePendingTransition(0, 0);
}
catch (IOException e) {
Log.e("SettingsSecurity", e.toString());
}
});
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
@ -134,12 +136,7 @@ public class SettingsSecurityActivity extends BaseActivity {
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsSecurityActivity.this);
tsBuilder.setTitle(getResources().getString(R.string.cacheSizeImagesDialogHeader));
if(cacheSizeImagesSelectedChoice != -1) {
tsBuilder.setCancelable(true);
}
else {
tsBuilder.setCancelable(false);
}
tsBuilder.setCancelable(cacheSizeImagesSelectedChoice != -1);
tsBuilder.setSingleChoiceItems(cacheSizeImagesList, cacheSizeImagesSelectedChoice, (dialogInterfaceTheme, i) -> {
@ -150,12 +147,10 @@ public class SettingsSecurityActivity extends BaseActivity {
dialogInterfaceTheme.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
AlertDialog cfDialog = tsBuilder.create();
cfDialog.show();
});
// cache size data selection dialog
@ -164,12 +159,7 @@ public class SettingsSecurityActivity extends BaseActivity {
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsSecurityActivity.this);
tsBuilder.setTitle(getResources().getString(R.string.cacheSizeDataDialogHeader));
if(cacheSizeDataSelectedChoice != -1) {
tsBuilder.setCancelable(true);
}
else {
tsBuilder.setCancelable(false);
}
tsBuilder.setCancelable(cacheSizeDataSelectedChoice != -1);
tsBuilder.setSingleChoiceItems(cacheSizeDataList, cacheSizeDataSelectedChoice, (dialogInterfaceTheme, i) -> {
@ -180,12 +170,10 @@ public class SettingsSecurityActivity extends BaseActivity {
dialogInterfaceTheme.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
AlertDialog cfDialog = tsBuilder.create();
cfDialog.show();
});
// certs deletion
@ -206,12 +194,10 @@ public class SettingsSecurityActivity extends BaseActivity {
Intent loginActivityIntent = new Intent().setClass(appCtx, LoginActivity.class);
loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
appCtx.startActivity(loginActivityIntent);
});
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
builder.create().show();
});
// polling delay
@ -237,15 +223,12 @@ public class SettingsSecurityActivity extends BaseActivity {
pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), numberPicker.getValue()));
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
builder.setNeutralButton(R.string.cancelButton, null);
builder.setView(numberPicker);
builder.create().show();
});
}
private void initCloseListener() {

View File

@ -61,10 +61,12 @@ public class SettingsTranslationActivity extends BaseActivity {
});
if(!tinyDb.getString("localeStr").isEmpty()) {
tvLanguageSelected.setText(tinyDb.getString("localeStr"));
}
if(langSelectedChoice == 0) {
langSelectedChoice = tinyDb.getInt("langId");
}
@ -74,12 +76,7 @@ public class SettingsTranslationActivity extends BaseActivity {
AlertDialog.Builder lBuilder = new AlertDialog.Builder(SettingsTranslationActivity.this);
lBuilder.setTitle(R.string.settingsLanguageSelectorDialogTitle);
if(langSelectedChoice != -1) {
lBuilder.setCancelable(true);
}
else {
lBuilder.setCancelable(false);
}
lBuilder.setCancelable(langSelectedChoice != -1);
lBuilder.setSingleChoiceItems(langList, langSelectedChoice, (dialogInterface, i) -> {
@ -90,54 +87,71 @@ public class SettingsTranslationActivity extends BaseActivity {
switch(langList[i]) {
case "Arabic":
tinyDb.putString("locale", "ar");
break;
case "Chinese":
tinyDb.putString("locale", "zh");
break;
case "Czech":
tinyDb.putString("locale", "cs");
break;
case "Finnish":
tinyDb.putString("locale", "fi");
break;
case "French":
tinyDb.putString("locale", "fr");
break;
case "German":
tinyDb.putString("locale", "de");
break;
case "Italian":
tinyDb.putString("locale", "it");
break;
case "Latvian":
tinyDb.putString("locale", "lv");
break;
case "Persian":
tinyDb.putString("locale", "fa");
break;
case "Polish":
tinyDb.putString("locale", "pl");
break;
case "Portuguese/Brazilian":
tinyDb.putString("locale", "pt");
break;
case "Russian":
tinyDb.putString("locale", "ru");
break;
case "Serbian":
tinyDb.putString("locale", "sr");
break;
case "Spanish":
tinyDb.putString("locale", "es");
break;
case "Turkish":
tinyDb.putString("locale", "tr");
break;
case "Ukrainian":
tinyDb.putString("locale", "uk");
break;
default:
tinyDb.putString("locale", "en");
break;
}
@ -147,16 +161,13 @@ public class SettingsTranslationActivity extends BaseActivity {
this.overridePendingTransition(0, 0);
dialogInterface.dismiss();
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
lBuilder.setNeutralButton(getString(R.string.cancelButton), null);
AlertDialog lDialog = lBuilder.create();
lDialog.show();
});
}
private void initCloseListener() {

View File

@ -150,11 +150,11 @@
android:text="@string/settingsCounterBadges"
android:textColor="?attr/primaryTextColor"/>
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switchCounterBadge"
android:layout_toEndOf="@+id/tvCounterBadgeHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="24dp"
android:switchMinWidth="56dp"
android:paddingStart="0dp"
android:paddingEnd="24dp"
@ -194,34 +194,4 @@
</LinearLayout>
<LinearLayout
android:id="@+id/homeScreenFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical">
<TextView
android:id="@+id/homeScreenHeaderSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginTop="10dp"
android:layout_marginStart="44dp"
android:layout_marginEnd="24dp"
android:text="@string/settingsHomeScreenHeaderText"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:id="@+id/homeScreenSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginStart="44dp"
android:layout_marginEnd="24dp"
android:text="@string/settingsHomeScreenSelectedText"
android:textColor="?attr/selectedTextColor"/>
</LinearLayout>
</LinearLayout>

View File

@ -61,11 +61,11 @@
android:text="@string/settingsEnableCommentsDeletionText"
android:textColor="?attr/primaryTextColor" />
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/commentsDeletionSwitch"
android:layout_toEndOf="@+id/enableCommentsDeletionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="24dp"
android:switchMinWidth="56dp"
android:layout_alignParentEnd="true"
android:paddingStart="0dp"

View File

@ -91,11 +91,11 @@
android:text="@string/settingsPdfModeHeaderText"
android:textColor="?attr/primaryTextColor"/>
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switchPdfMode"
android:layout_toEndOf="@+id/pdfModeHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="24dp"
android:switchMinWidth="56dp"
android:paddingStart="0dp"
android:paddingEnd="25dp"

View File

@ -85,4 +85,34 @@
</LinearLayout>
<LinearLayout
android:id="@+id/homeScreenFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical">
<TextView
android:id="@+id/homeScreenHeaderSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginTop="10dp"
android:layout_marginStart="44dp"
android:layout_marginEnd="24dp"
android:text="@string/settingsHomeScreenHeaderText"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:id="@+id/homeScreenSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginStart="44dp"
android:layout_marginEnd="24dp"
android:text="@string/settingsHomeScreenSelectedText"
android:textColor="?attr/selectedTextColor"/>
</LinearLayout>
</LinearLayout>

View File

@ -60,11 +60,11 @@
android:text="@string/settingsEnableReportsText"
android:textColor="?attr/primaryTextColor" />
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/crashReportsSwitch"
android:layout_toEndOf="@+id/enableReportsHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="24dp"
android:switchMinWidth="56dp"
android:layout_alignParentEnd="true"
android:paddingStart="0dp"

View File

@ -271,11 +271,11 @@
<string name="settingsEnableCommentsDeletionText">Enable Drafts Deletion</string>
<string name="settingsEnableCommentsDeletionHintText">Delete comment draft when comment is posted</string>
<string name="settingsGeneralHeader">General</string>
<string name="generalHintText">Default actions</string>
<string name="generalHintText">Home screen, default link handler</string>
<string name="generalDeepLinkDefaultScreen">Default Link Handler</string>
<string name="generalDeepLinkDefaultScreenHintText">Choose what screen should be loaded if the app cannot handle external links. It will redirect you automatically.</string>
<string name="generalDeepLinkSelectedText">N/A</string>
<string name="linkSelectorDialogTitle">Select Default Screen</string>
<string name="linkSelectorDialogTitle">Select Default Link Handler Screen</string>
<!-- settings -->
<string name="noMoreData">No more data available</string>
@ -726,4 +726,9 @@
<string name="launchApp">Go to App</string>
<string name="noActionText">GitNex cannot handle the requested resource, you can open an issue at the project repository as an improvement with providing details of the work. Just launch a default screen for now from the buttons below, it can be changed from settings.</string>
<string name="codeBlockGreenOnBlack">Green on Black</string>
<string name="codeBlockWhiteOnBlack">White on Black</string>
<string name="codeBlockGreyOnBlack">Grey on Black</string>
<string name="codeBlockWhiteOnGrey">White on Grey</string>
<string name="codeBlockDarkOnWhite">Dark on White</string>
</resources>