mirror of https://codeberg.org/gitnex/GitNex.git
Refactor file create/edit screen
This commit is contained in:
parent
a23c60907e
commit
f07b2e40bd
|
@ -2,15 +2,13 @@ package org.mian.gitnex.activities;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -29,8 +27,7 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||
import org.mian.gitnex.databinding.ActivityCreateFileBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.NetworkStatusObserver;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
@ -72,16 +69,14 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
TextView toolbarTitle = binding.toolbarTitle;
|
||||
binding.topAppBar.setNavigationOnClickListener(v -> finish());
|
||||
|
||||
binding.newFileName.requestFocus();
|
||||
MenuItem create = binding.topAppBar.getMenu().getItem(0);
|
||||
MenuItem update = binding.topAppBar.getMenu().getItem(1);
|
||||
MenuItem delete = binding.topAppBar.getMenu().getItem(2);
|
||||
update.setVisible(false);
|
||||
delete.setVisible(false);
|
||||
|
||||
InputMethodManager inputMethodManager =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
assert inputMethodManager != null;
|
||||
inputMethodManager.showSoftInput(binding.newFileName, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
binding.close.setOnClickListener(view -> finish());
|
||||
binding.newFileContent.setOnTouchListener(
|
||||
(touchView, motionEvent) -> {
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
@ -103,12 +98,13 @@ public class CreateFileActivity extends BaseActivity {
|
|||
filePath = getIntent().getStringExtra("filePath");
|
||||
fileSha = getIntent().getStringExtra("fileSha");
|
||||
|
||||
toolbarTitle.setText(getString(R.string.deleteGenericTitle, filePath));
|
||||
|
||||
binding.newFileCreate.setText(R.string.deleteFile);
|
||||
binding.topAppBar.setTitle(getString(R.string.deleteGenericTitle, filePath));
|
||||
|
||||
binding.newFileNameLayout.setVisibility(View.GONE);
|
||||
binding.newFileContentLayout.setVisibility(View.GONE);
|
||||
delete.setVisible(true);
|
||||
create.setVisible(false);
|
||||
update.setVisible(false);
|
||||
}
|
||||
|
||||
if (getIntent().getStringExtra("filePath") != null
|
||||
|
@ -118,20 +114,20 @@ public class CreateFileActivity extends BaseActivity {
|
|||
filePath = getIntent().getStringExtra("filePath");
|
||||
fileSha = getIntent().getStringExtra("fileSha");
|
||||
|
||||
toolbarTitle.setText(getString(R.string.editFileText, filePath));
|
||||
binding.topAppBar.setTitle(getString(R.string.editFileText, filePath));
|
||||
|
||||
binding.newFileCreate.setText(R.string.editFile);
|
||||
binding.newFileName.setText(filePath);
|
||||
binding.newFileName.setEnabled(false);
|
||||
binding.newFileName.setFocusable(false);
|
||||
|
||||
binding.newFileContent.setText(getIntent().getStringExtra("fileContents"));
|
||||
update.setVisible(true);
|
||||
create.setVisible(false);
|
||||
delete.setVisible(false);
|
||||
}
|
||||
|
||||
getBranches(repository.getOwner(), repository.getName());
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
binding.openCodeEditor.setOnClickListener(
|
||||
v ->
|
||||
launchCodeEditorActivityForResult(
|
||||
|
@ -139,13 +135,23 @@ public class CreateFileActivity extends BaseActivity {
|
|||
FilenameUtils.getExtension(
|
||||
String.valueOf(binding.newFileName.getText()))));
|
||||
|
||||
NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.getInstance(ctx);
|
||||
networkStatusObserver.registerNetworkStatusListener(
|
||||
hasNetworkConnection ->
|
||||
runOnUiThread(
|
||||
() -> binding.newFileCreate.setEnabled(hasNetworkConnection)));
|
||||
binding.topAppBar.setOnMenuItemClickListener(
|
||||
menuItem -> {
|
||||
int id = menuItem.getItemId();
|
||||
|
||||
binding.newFileCreate.setOnClickListener(v -> processNewFile());
|
||||
if (id == R.id.create) {
|
||||
processNewFile();
|
||||
return true;
|
||||
} else if (id == R.id.update) {
|
||||
processNewFile();
|
||||
return true;
|
||||
} else if (id == R.id.delete) {
|
||||
processNewFile();
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(menuItem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void launchCodeEditorActivityForResult(String fileContent, String fileExtension) {
|
||||
|
@ -175,29 +181,39 @@ public class CreateFileActivity extends BaseActivity {
|
|||
: "";
|
||||
|
||||
if (!AppUtil.hasNetworkConnection(appCtx)) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if (((newFileName.isEmpty() || newFileContent.isEmpty())
|
||||
&& fileAction != FILE_ACTION_DELETE)
|
||||
|| newFileCommitMessage.isEmpty()) {
|
||||
Toasty.error(ctx, getString(R.string.newFileRequiredFields));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.newFileRequiredFields));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AppUtil.checkStringsWithDash(newFileBranchName)) {
|
||||
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.newFileInvalidBranchName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newFileCommitMessage.length() > 255) {
|
||||
Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.newFileCommitMessageError));
|
||||
return;
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
switch (fileAction) {
|
||||
case FILE_ACTION_CREATE:
|
||||
createNewFile(
|
||||
|
@ -264,39 +280,40 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
switch (response.code()) {
|
||||
case 201:
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.newFileSuccessMessage));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
result.putExtra("fileAction", fileAction);
|
||||
setResult(200, result);
|
||||
RepoDetailActivity.updateFABActions = true;
|
||||
finish();
|
||||
new Handler().postDelayed(() -> finish(), 3000);
|
||||
break;
|
||||
|
||||
case 401:
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
|
||||
case 404:
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.genericError));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<FileResponse> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
public void onFailure(@NonNull Call<FileResponse> call, @NonNull Throwable t) {}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -332,9 +349,9 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
switch (response.code()) {
|
||||
case 200:
|
||||
enableProcessButton();
|
||||
Toasty.info(
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(
|
||||
R.string.deleteFileMessage,
|
||||
repository.getBranchRef()));
|
||||
|
@ -342,33 +359,32 @@ public class CreateFileActivity extends BaseActivity {
|
|||
result.putExtra("fileModified", true);
|
||||
result.putExtra("fileAction", fileAction);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
new Handler().postDelayed(() -> finish(), 3000);
|
||||
break;
|
||||
|
||||
case 401:
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
|
||||
case 404:
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.genericError));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<FileDeleteResponse> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
@NonNull Call<FileDeleteResponse> call, @NonNull Throwable t) {}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -406,38 +422,39 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
switch (response.code()) {
|
||||
case 200:
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.editFileMessage, branchName));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.editFileMessage, branchName));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
result.putExtra("fileAction", fileAction);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
new Handler().postDelayed(() -> finish(), 3000);
|
||||
break;
|
||||
|
||||
case 401:
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
|
||||
case 404:
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.genericError));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<FileResponse> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
public void onFailure(@NonNull Call<FileResponse> call, @NonNull Throwable t) {}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -468,27 +485,14 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
binding.newFileBranches.setAdapter(adapter);
|
||||
binding.newFileBranches.setText(repository.getBranchRef(), false);
|
||||
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {}
|
||||
});
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
binding.newFileCreate.setEnabled(false);
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
binding.newFileCreate.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
|
@ -12,8 +12,8 @@ import org.mian.gitnex.databinding.ActivitySettingsAppearanceBinding;
|
|||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FontsOverride;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
|
@ -106,7 +106,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
activitySettingsAppearanceBinding.switchCounterBadge.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
tinyDB.putBoolean("enableCounterBadges", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
activitySettingsAppearanceBinding.counterBadgeFrame.setOnClickListener(
|
||||
v ->
|
||||
|
@ -120,7 +123,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
activitySettingsAppearanceBinding.switchLabelsInListBadge.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
tinyDB.putBoolean("showLabelsInList", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
activitySettingsAppearanceBinding.labelsInListFrame.setOnClickListener(
|
||||
v ->
|
||||
|
@ -147,10 +153,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
@ -184,10 +190,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceCustomFont.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
appCtx.getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
@ -216,10 +222,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceCustomFont.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
appCtx.getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
@ -255,10 +261,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
SettingsFragment.refreshParent = true;
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterface.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
this.recreate();
|
||||
});
|
||||
|
||||
|
@ -282,7 +288,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
db.putInt("lightThemeTimeMinute", materialTimePicker.getMinute());
|
||||
SettingsFragment.refreshParent = true;
|
||||
overridePendingTransition(0, 0);
|
||||
Toasty.success(ctx, getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
recreate();
|
||||
});
|
||||
|
||||
|
@ -305,7 +314,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
db.putInt("darkThemeTimeMinute", materialTimePicker.getMinute());
|
||||
SettingsFragment.refreshParent = true;
|
||||
overridePendingTransition(0, 0);
|
||||
Toasty.success(ctx, getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
recreate();
|
||||
});
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivitySettingsCodeEditorBinding;
|
||||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
|
@ -54,10 +54,10 @@ public class SettingsCodeEditorActivity extends BaseActivity {
|
|||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
@ -88,10 +88,10 @@ public class SettingsCodeEditorActivity extends BaseActivity {
|
|||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
@ -130,10 +130,10 @@ public class SettingsCodeEditorActivity extends BaseActivity {
|
|||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivitySettingsGeneralBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
|
@ -115,10 +115,10 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
tinyDB.putInt("homeScreenId", i);
|
||||
|
||||
dialogInterfaceHomeScreen.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
@ -153,10 +153,10 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
tinyDB.putInt("defaultScreenId", i);
|
||||
|
||||
dialogInterfaceHomeScreen.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
@ -168,7 +168,10 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
viewBinding.switchTabs.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
tinyDB.putBoolean("useCustomTabs", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
viewBinding.customTabsFrame.setOnClickListener(
|
||||
v -> viewBinding.switchTabs.setChecked(!viewBinding.switchTabs.isChecked()));
|
||||
|
@ -182,7 +185,10 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
viewBinding.commentsDeletionSwitch.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
tinyDB.putBoolean("draftsCommentsDeletionEnabled", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
viewBinding.enableDraftsCommentsDeletion.setOnClickListener(
|
||||
v ->
|
||||
|
@ -194,7 +200,10 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
viewBinding.crashReportsSwitch.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
tinyDB.putBoolean("crashReportingEnabled", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
viewBinding.enableSendReports.setOnClickListener(
|
||||
v ->
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.mian.gitnex.R;
|
|||
import org.mian.gitnex.databinding.ActivitySettingsNotificationsBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.notifications.Notifications;
|
||||
|
||||
/**
|
||||
|
@ -82,7 +82,10 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
viewBinding.pollingDelayFrame);
|
||||
}
|
||||
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
viewBinding.enableNotificationsFrame.setOnClickListener(
|
||||
v ->
|
||||
|
@ -124,10 +127,10 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
R.string
|
||||
.pollingDelaySelectedText),
|
||||
numberPicker.getValue()));
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.setView(numberPicker);
|
||||
|
@ -144,7 +147,10 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
tinyDB.putBoolean("notificationsEnableLights", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
viewBinding.enableLightsFrame.setOnClickListener(
|
||||
v ->
|
||||
|
@ -182,7 +188,10 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
viewBinding.enableVibrationMode.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
tinyDB.putBoolean("notificationsEnableVibration", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
viewBinding.enableVibrationFrame.setOnClickListener(
|
||||
v ->
|
||||
|
|
|
@ -6,7 +6,6 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI
|
|||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import androidx.biometric.BiometricManager;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import java.io.File;
|
||||
|
@ -15,7 +14,7 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivitySettingsSecurityBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
|
||||
/**
|
||||
|
@ -78,9 +77,10 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
BIOMETRIC_STRONG | DEVICE_CREDENTIAL)) {
|
||||
case BiometricManager.BIOMETRIC_SUCCESS:
|
||||
tinyDB.putBoolean("biometricStatus", true);
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
break;
|
||||
case BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE:
|
||||
case BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED:
|
||||
|
@ -89,38 +89,45 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
tinyDB.putBoolean("biometricStatus", false);
|
||||
activitySettingsSecurityBinding.switchBiometric.setChecked(
|
||||
false);
|
||||
Toasty.error(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.biometricNotSupported));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.biometricNotSupported));
|
||||
break;
|
||||
case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
|
||||
tinyDB.putBoolean("biometricStatus", false);
|
||||
activitySettingsSecurityBinding.switchBiometric.setChecked(
|
||||
false);
|
||||
Toasty.error(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.biometricNotAvailable));
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.biometricNotAvailable));
|
||||
break;
|
||||
case BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED:
|
||||
tinyDB.putBoolean("biometricStatus", false);
|
||||
activitySettingsSecurityBinding.switchBiometric.setChecked(
|
||||
false);
|
||||
Toasty.info(
|
||||
appCtx,
|
||||
getResources().getString(R.string.enrollBiometric));
|
||||
SnackBar.info(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.enrollBiometric));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
tinyDB.putBoolean("biometricStatus", true);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
}
|
||||
} else {
|
||||
|
||||
tinyDB.putBoolean("biometricStatus", false);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -157,7 +164,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
this.overridePendingTransition(0, 0);
|
||||
} catch (IOException e) {
|
||||
|
||||
Log.e("SettingsSecurity", e.toString());
|
||||
// Log.e("SettingsSecurity", e.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -185,10 +192,10 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
tinyDB.putInt("cacheSizeImagesId", i);
|
||||
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
@ -214,10 +221,10 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
tinyDB.putInt("cacheSizeId", i);
|
||||
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
|
|
@ -1,55 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:orientation="vertical">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/Widget.AppCompat.SearchView"
|
||||
app:elevation="@dimen/dimen0dp">
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
style="?attr/collapsingToolbarLayoutLargeStyle"
|
||||
android:layout_width="match_parent"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
app:contentScrim="?attr/primaryBackgroundColor"
|
||||
android:layout_height="?attr/collapsingToolbarLayoutLargeSize">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:id="@+id/topAppBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/primaryBackgroundColor">
|
||||
android:elevation="0dp"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:title="@string/pageTitleNewFile"
|
||||
app:layout_collapseMode="pin"
|
||||
app:menu="@menu/file_create_edit_menu"
|
||||
app:navigationIcon="@drawable/ic_close" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close"
|
||||
android:layout_width="@dimen/dimen26dp"
|
||||
android:layout_height="@dimen/dimen26dp"
|
||||
android:layout_marginStart="@dimen/dimen16dp"
|
||||
android:layout_marginEnd="@dimen/dimen16dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/close"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:src="@drawable/ic_close"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbarTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/pageTitleNewFile"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen20sp"/>
|
||||
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<ScrollView
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/primaryBackgroundColor">
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -65,7 +54,6 @@
|
|||
android:layout_marginBottom="@dimen/dimen8dp"
|
||||
android:hint="@string/newFileNameTintCopy"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
app:boxStrokeErrorColor="@color/darkRed"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="?attr/iconsColor"
|
||||
|
@ -95,7 +83,6 @@
|
|||
android:layout_marginBottom="@dimen/dimen8dp"
|
||||
android:hint="@string/newFileContentTintCopy"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
app:boxStrokeErrorColor="@color/darkRed"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="?attr/iconsColor"
|
||||
|
@ -135,7 +122,6 @@
|
|||
android:layout_marginBottom="@dimen/dimen8dp"
|
||||
android:hint="@string/newFileBranches"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
app:endIconTint="?attr/iconsColor"
|
||||
app:helperText="@string/newFileEmptyBranchMessage"
|
||||
app:helperTextEnabled="true"
|
||||
|
@ -164,7 +150,6 @@
|
|||
android:layout_marginBottom="@dimen/dimen8dp"
|
||||
android:hint="@string/newFileMessageTintCopy"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
app:boxStrokeErrorColor="@color/darkRed"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="255"
|
||||
|
@ -186,17 +171,8 @@
|
|||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/newFileCreate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dimen54dp"
|
||||
android:layout_marginTop="@dimen/dimen8dp"
|
||||
android:text="@string/newFileButtonCopy"
|
||||
android:textColor="?attr/materialCardBackgroundColor"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
@ -124,7 +124,6 @@
|
|||
android:layout_marginBottom="@dimen/dimen8dp"
|
||||
android:hint="@string/newIssueTitle"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
app:boxStrokeErrorColor="@color/darkRed"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="?attr/iconsColor"
|
||||
|
@ -151,7 +150,6 @@
|
|||
android:layout_marginTop="@dimen/dimen8dp"
|
||||
android:layout_marginBottom="@dimen/dimen8dp"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
app:boxStrokeErrorColor="@color/darkRed"
|
||||
app:hintTextColor="?attr/hintColor">
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/create"
|
||||
android:title="@string/newCreateButtonCopy"
|
||||
android:orderInCategory="0"
|
||||
android:contentDescription="@string/newCreateButtonCopy"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/update"
|
||||
android:title="@string/menuEditText"
|
||||
android:orderInCategory="1"
|
||||
android:contentDescription="@string/newCreateButtonCopy"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/delete"
|
||||
android:title="@string/menuDeleteText"
|
||||
android:orderInCategory="2"
|
||||
android:contentDescription="@string/menuDeleteText"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
Loading…
Reference in New Issue