Fix crash on creating new file (#819)

Allow multi line text in desc inputs

Minor improvements.

Improving the selection of branches.

Default to first branch in spinner.

Minor improvements.

fix crash on creating new file

Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: opyale <opyale@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/819
Reviewed-by: opyale <opyale@noreply.codeberg.org>
Co-Authored-By: M M Arif <mmarif@noreply.codeberg.org>
Co-Committed-By: M M Arif <mmarif@noreply.codeberg.org>
This commit is contained in:
M M Arif 2021-02-01 19:13:48 +01:00 committed by opyale
parent 3c381f372e
commit cb241d80f3
15 changed files with 134 additions and 244 deletions

View File

@ -21,6 +21,7 @@ import org.mian.gitnex.databinding.ActivityCreateFileBinding;
import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.NetworkStatusObserver;
import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.models.Branches; import org.mian.gitnex.models.Branches;
import org.mian.gitnex.models.DeleteFile; import org.mian.gitnex.models.DeleteFile;
@ -43,21 +44,21 @@ public class CreateFileActivity extends BaseActivity {
private EditText newFileName; private EditText newFileName;
private EditText newFileContent; private EditText newFileContent;
private EditText newFileBranchName;
private EditText newFileCommitMessage; private EditText newFileCommitMessage;
private AutoCompleteTextView newFileBranchesSpinner; private AutoCompleteTextView newFileBranches;
private String filePath; private String filePath;
private String fileSha; private String fileSha;
private int fileAction = 0; // 0 = create, 1 = delete, 2 = edit
List<Branches> branchesList = new ArrayList<>(); public static final int FILE_ACTION_CREATE = 0;
public static final int FILE_ACTION_DELETE = 1;
public static final int FILE_ACTION_EDIT = 2;
private int fileAction = FILE_ACTION_CREATE;
private final List<String> branches = new ArrayList<>();
private String loginUid;
private String repoOwner; private String repoOwner;
private String repoName; private String repoName;
private String instanceToken;
private String selectedBranch;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
@ -68,21 +69,16 @@ public class CreateFileActivity extends BaseActivity {
ActivityCreateFileBinding activityCreateFileBinding = ActivityCreateFileBinding.inflate(getLayoutInflater()); ActivityCreateFileBinding activityCreateFileBinding = ActivityCreateFileBinding.inflate(getLayoutInflater());
setContentView(activityCreateFileBinding.getRoot()); setContentView(activityCreateFileBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
loginUid = tinyDB.getString("loginUid");
String repoFullName = tinyDB.getString("repoFullName"); String repoFullName = tinyDB.getString("repoFullName");
String[] parts = repoFullName.split("/"); String[] parts = repoFullName.split("/");
repoOwner = parts[0]; repoOwner = parts[0];
repoName = parts[1]; repoName = parts[1];
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
closeActivity = activityCreateFileBinding.close; closeActivity = activityCreateFileBinding.close;
newFileName = activityCreateFileBinding.newFileName; newFileName = activityCreateFileBinding.newFileName;
newFileContent = activityCreateFileBinding.newFileContent; newFileContent = activityCreateFileBinding.newFileContent;
newFileBranchName = activityCreateFileBinding.newFileBranchName;
newFileCommitMessage = activityCreateFileBinding.newFileCommitMessage; newFileCommitMessage = activityCreateFileBinding.newFileCommitMessage;
TextView toolbarTitle = activityCreateFileBinding.toolbarTitle; TextView toolbarTitle = activityCreateFileBinding.toolbarTitle;
@ -91,10 +87,10 @@ public class CreateFileActivity extends BaseActivity {
imm.showSoftInput(newFileName, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(newFileName, InputMethodManager.SHOW_IMPLICIT);
initCloseListener(); initCloseListener();
closeActivity.setOnClickListener(onClickListener); closeActivity.setOnClickListener(onClickListener);
newFileCreate = activityCreateFileBinding.newFileCreate; newFileCreate = activityCreateFileBinding.newFileCreate;
newFileContent.setOnTouchListener((touchView, motionEvent) -> { newFileContent.setOnTouchListener((touchView, motionEvent) -> {
touchView.getParent().requestDisallowInterceptTouchEvent(true); touchView.getParent().requestDisallowInterceptTouchEvent(true);
@ -106,9 +102,9 @@ public class CreateFileActivity extends BaseActivity {
return false; return false;
}); });
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", 1) == 1) { if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE) == FILE_ACTION_DELETE) {
fileAction = getIntent().getIntExtra("fileAction", 1); fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE);
filePath = getIntent().getStringExtra("filePath"); filePath = getIntent().getStringExtra("filePath");
String fileContents = getIntent().getStringExtra("fileContents"); String fileContents = getIntent().getStringExtra("fileContents");
@ -124,11 +120,12 @@ public class CreateFileActivity extends BaseActivity {
newFileContent.setText(fileContents); newFileContent.setText(fileContents);
newFileContent.setEnabled(false); newFileContent.setEnabled(false);
newFileContent.setFocusable(false); newFileContent.setFocusable(false);
} }
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", 2) == 2) { if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT) == FILE_ACTION_EDIT) {
fileAction = getIntent().getIntExtra("fileAction", 2); fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT);
filePath = getIntent().getStringExtra("filePath"); filePath = getIntent().getStringExtra("filePath");
String fileContents = getIntent().getStringExtra("fileContents"); String fileContents = getIntent().getStringExtra("fileContents");
@ -142,24 +139,21 @@ public class CreateFileActivity extends BaseActivity {
newFileName.setFocusable(false); newFileName.setFocusable(false);
newFileContent.setText(fileContents); newFileContent.setText(fileContents);
} }
initCloseListener(); initCloseListener();
closeActivity.setOnClickListener(onClickListener); closeActivity.setOnClickListener(onClickListener);
newFileBranchesSpinner = activityCreateFileBinding.newFileBranchesSpinner; newFileBranches = activityCreateFileBinding.newFileBranches;
getBranches(instanceToken, repoOwner, repoName, loginUid); getBranches(repoOwner, repoName);
disableProcessButton(); disableProcessButton();
if(!connToInternet) { NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.get(ctx);
networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> newFileCreate.setEnabled(hasNetworkConnection));
newFileCreate.setEnabled(false); newFileCreate.setOnClickListener(createFileListener);
}
else {
newFileCreate.setOnClickListener(createFileListener);
}
} }
@ -172,7 +166,7 @@ public class CreateFileActivity extends BaseActivity {
String newFileName_ = newFileName.getText().toString(); String newFileName_ = newFileName.getText().toString();
String newFileContent_ = newFileContent.getText().toString(); String newFileContent_ = newFileContent.getText().toString();
String newFileBranchName_ = newFileBranchName.getText().toString(); String newFileBranchName_ = newFileBranches.getText().toString();
String newFileCommitMessage_ = newFileCommitMessage.getText().toString(); String newFileCommitMessage_ = newFileCommitMessage.getText().toString();
if(!connToInternet) { if(!connToInternet) {
@ -187,25 +181,13 @@ public class CreateFileActivity extends BaseActivity {
return; return;
} }
if(selectedBranch.equals("No branch")) { if(!appUtil.checkStringsWithDash(newFileBranchName_)) {
if(newFileBranchName_.equals("")) { Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
return;
}
Toasty.error(ctx, getString(R.string.newFileRequiredFieldNewBranchName)); if(newFileCommitMessage_.length() > 255) {
return;
}
else {
if(!appUtil.checkStringsWithDash(newFileBranchName_)) {
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
return;
}
}
}
if(appUtil.charactersLength(newFileCommitMessage_) > 255) {
Toasty.warning(ctx, getString(R.string.newFileCommitMessageError)); Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
} }
@ -213,37 +195,30 @@ public class CreateFileActivity extends BaseActivity {
disableProcessButton(); disableProcessButton();
if(fileAction == 1) { switch(fileAction) {
case FILE_ACTION_CREATE:
createNewFile(Authorization.get(ctx), repoOwner, repoName, newFileName_, appUtil.encodeBase64(newFileContent_), newFileCommitMessage_, newFileBranchName_);
break;
case FILE_ACTION_DELETE:
deleteFile(Authorization.get(ctx), repoOwner, repoName, filePath, newFileCommitMessage_, newFileBranchName_, fileSha);
break;
case FILE_ACTION_EDIT:
editFile(Authorization.get(ctx), repoOwner, repoName, filePath,
appUtil.encodeBase64(newFileContent_), newFileCommitMessage_, newFileBranchName_, fileSha);
break;
deleteFile(Authorization.get(ctx), repoOwner, repoName, filePath,
newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
} }
else if(fileAction == 2) {
editFile(Authorization.get(ctx), repoOwner, repoName, filePath,
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
}
else {
createNewFile(Authorization.get(ctx), repoOwner, repoName, newFileName_,
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, selectedBranch);
}
} }
} }
private void createNewFile(final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch) { private void createNewFile(final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName) {
NewFile createNewFileJsonStr; NewFile createNewFileJsonStr = branches.contains(branchName) ?
if(currentBranch.equals("No branch")) { new NewFile(branchName, fileContent, fileCommitMessage, "") :
new NewFile("", fileContent, fileCommitMessage, branchName);
createNewFileJsonStr = new NewFile("", fileContent, fileCommitMessage, fileBranchName);
}
else {
createNewFileJsonStr = new NewFile(currentBranch, fileContent, fileCommitMessage, "");
}
Call<JsonElement> call = RetrofitClient Call<JsonElement> call = RetrofitClient
.getApiInterface(ctx) .getApiInterface(ctx)
@ -254,33 +229,33 @@ public class CreateFileActivity extends BaseActivity {
@Override @Override
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) { public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
if(response.code() == 201) { switch(response.code()) {
enableProcessButton(); case 201:
Toasty.success(ctx, getString(R.string.newFileSuccessMessage)); enableProcessButton();
finish(); Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
} finish();
else if(response.code() == 401) { break;
enableProcessButton(); case 401:
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), enableProcessButton();
getResources().getString(R.string.alertDialogTokenRevokedMessage), AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
} getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
else { break;
if(response.code() == 404) { case 404:
enableProcessButton();
Toasty.warning(ctx, getString(R.string.apiNotFound));
break;
enableProcessButton(); default:
Toasty.warning(ctx, getString(R.string.apiNotFound)); enableProcessButton();
} Toasty.error(ctx, getString(R.string.orgCreatedError));
else { break;
enableProcessButton(); }
Toasty.error(ctx, getString(R.string.orgCreatedError));
}
}
} }
@Override @Override
@ -288,26 +263,17 @@ public class CreateFileActivity extends BaseActivity {
Log.e("onFailure", t.toString()); Log.e("onFailure", t.toString());
enableProcessButton(); enableProcessButton();
} }
}); });
} }
private void deleteFile(final String token, String repoOwner, String repoName, String fileName, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) { private void deleteFile(final String token, String repoOwner, String repoName, String fileName, String fileCommitMessage, String branchName, String fileSha) {
String branchName; DeleteFile deleteFileJsonStr = branches.contains(branchName) ?
DeleteFile deleteFileJsonStr; new DeleteFile(branchName, fileCommitMessage, "", fileSha) :
new DeleteFile("", fileCommitMessage, branchName, fileSha);
if(currentBranch.equals("No branch")) {
branchName = fileBranchName;
deleteFileJsonStr = new DeleteFile("", fileCommitMessage, fileBranchName, fileSha);
}
else {
branchName = currentBranch;
deleteFileJsonStr = new DeleteFile(currentBranch, fileCommitMessage, "", fileSha);
}
Call<JsonElement> call = RetrofitClient Call<JsonElement> call = RetrofitClient
.getApiInterface(ctx) .getApiInterface(ctx)
@ -321,7 +287,7 @@ public class CreateFileActivity extends BaseActivity {
if(response.code() == 200) { if(response.code() == 200) {
enableProcessButton(); enableProcessButton();
Toasty.info(ctx, getString(R.string.deleteFileMessage, branchName)); Toasty.info(ctx, getString(R.string.deleteFileMessage, tinyDB.getString("repoBranch")));
getIntent().removeExtra("filePath"); getIntent().removeExtra("filePath");
getIntent().removeExtra("fileSha"); getIntent().removeExtra("fileSha");
getIntent().removeExtra("fileContents"); getIntent().removeExtra("fileContents");
@ -360,21 +326,11 @@ public class CreateFileActivity extends BaseActivity {
} }
private void editFile(final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) { private void editFile(final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName, String fileSha) {
String branchName; EditFile editFileJsonStr = branches.contains(branchName) ?
EditFile editFileJsonStr; new EditFile(branchName, fileCommitMessage, "", fileSha, fileContent) :
new EditFile("", fileCommitMessage, branchName, fileSha, fileContent);
if(currentBranch.equals("No branch")) {
branchName = fileBranchName;
editFileJsonStr = new EditFile("", fileCommitMessage, fileBranchName, fileSha, fileContent);
}
else {
branchName = currentBranch;
editFileJsonStr = new EditFile(currentBranch, fileCommitMessage, "", fileSha, fileContent);
}
Call<JsonElement> call = RetrofitClient Call<JsonElement> call = RetrofitClient
.getApiInterface(ctx) .getApiInterface(ctx)
@ -385,36 +341,36 @@ public class CreateFileActivity extends BaseActivity {
@Override @Override
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) { public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
if(response.code() == 200) { switch(response.code()) {
enableProcessButton(); case 200:
Toasty.info(ctx, getString(R.string.editFileMessage, branchName)); enableProcessButton();
getIntent().removeExtra("filePath"); Toasty.info(ctx, getString(R.string.editFileMessage, branchName));
getIntent().removeExtra("fileSha"); getIntent().removeExtra("filePath");
getIntent().removeExtra("fileContents"); getIntent().removeExtra("fileSha");
tinyDB.putBoolean("fileModified", true); getIntent().removeExtra("fileContents");
finish(); tinyDB.putBoolean("fileModified", true);
} finish();
else if(response.code() == 401) { break;
enableProcessButton(); case 401:
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), enableProcessButton();
getResources().getString(R.string.alertDialogTokenRevokedMessage), AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
} getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
else { break;
if(response.code() == 404) {
case 404:
enableProcessButton(); enableProcessButton();
Toasty.info(ctx, getString(R.string.apiNotFound)); Toasty.info(ctx, getString(R.string.apiNotFound));
} break;
else {
default:
enableProcessButton(); enableProcessButton();
Toasty.info(ctx, getString(R.string.genericError)); Toasty.info(ctx, getString(R.string.genericError));
} break;
} }
} }
@ -423,12 +379,13 @@ public class CreateFileActivity extends BaseActivity {
Log.e("onFailure", t.toString()); Log.e("onFailure", t.toString());
enableProcessButton(); enableProcessButton();
} }
}); });
} }
private void getBranches(String instanceToken, String repoOwner, String repoName, String loginUid) { private void getBranches(String repoOwner, String repoName) {
Call<List<Branches>> call = RetrofitClient Call<List<Branches>> call = RetrofitClient
.getApiInterface(ctx) .getApiInterface(ctx)
@ -439,48 +396,18 @@ public class CreateFileActivity extends BaseActivity {
@Override @Override
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) { public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
if(response.isSuccessful()) { if(response.code() == 200) {
if(response.code() == 200) { assert response.body() != null;
for(Branches branch : response.body()) branches.add(branch.getName());
List<Branches> branchesList_ = response.body(); ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateFileActivity.this, R.layout.list_spinner_items, branches);
branchesList.add(new Branches("No branch")); newFileBranches.setAdapter(adapter);
assert branchesList_ != null; newFileBranches.setText(tinyDB.getString("repoBranch"), false);
if(branchesList_.size() > 0) { enableProcessButton();
for (int i = 0; i < branchesList_.size(); i++) {
Branches data = new Branches(branchesList_.get(i).getName());
branchesList.add(data);
}
}
ArrayAdapter<Branches> adapter = new ArrayAdapter<>(CreateFileActivity.this,
R.layout.list_spinner_items, branchesList);
newFileBranchesSpinner.setAdapter(adapter);
enableProcessButton();
newFileBranchesSpinner.setOnItemClickListener ((parent, view, position, id) -> {
selectedBranch = branchesList.get(position).getName();
if(selectedBranch.equals("No branch")) {
newFileBranchName.setEnabled(true);
newFileBranchName.setVisibility(View.VISIBLE);
}
else {
newFileBranchName.setEnabled(false);
newFileBranchName.setVisibility(View.GONE);
newFileBranchName.setText("");
}
});
}
} }
} }

View File

@ -117,7 +117,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
if(!newMilestoneDescription.equals("")) { if(!newMilestoneDescription.equals("")) {
if (appUtil.charactersLength(newMilestoneDescription) > 255) { if (newMilestoneDescription.length() > 255) {
Toasty.warning(ctx, getString(R.string.milestoneDescError)); Toasty.warning(ctx, getString(R.string.milestoneDescError));
return; return;

View File

@ -108,7 +108,7 @@ public class CreateOrganizationActivity extends BaseActivity {
if(!newOrgDesc.equals("")) { if(!newOrgDesc.equals("")) {
if (appUtil.charactersLength(newOrgDesc) > 255) { if (newOrgDesc.length() > 255) {
Toasty.warning(ctx, getString(R.string.orgDescError)); Toasty.warning(ctx, getString(R.string.orgDescError));
return; return;

View File

@ -118,7 +118,7 @@ public class CreateRepoActivity extends BaseActivity {
if(!newRepoDesc.equals("")) { if(!newRepoDesc.equals("")) {
if (appUtil.charactersLength(newRepoDesc) > 255) { if (newRepoDesc.length() > 255) {
Toasty.warning(ctx, getString(R.string.repoDescError)); Toasty.warning(ctx, getString(R.string.repoDescError));
return; return;

View File

@ -361,7 +361,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
String fileExtension = FileUtils.getExtension(singleFileName); String fileExtension = FileUtils.getExtension(singleFileName);
String data = appUtil.decodeBase64(tinyDB.getString("downloadFileContents")); String data = appUtil.decodeBase64(tinyDB.getString("downloadFileContents"));
Intent intent = new Intent(ctx, CreateFileActivity.class); Intent intent = new Intent(ctx, CreateFileActivity.class);
intent.putExtra("fileAction", 1); intent.putExtra("fileAction", CreateFileActivity.FILE_ACTION_DELETE);
intent.putExtra("filePath", singleFileName); intent.putExtra("filePath", singleFileName);
intent.putExtra("fileSha", fileSha); intent.putExtra("fileSha", fileSha);
@ -382,7 +382,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
String fileExtension = FileUtils.getExtension(singleFileName); String fileExtension = FileUtils.getExtension(singleFileName);
String data = appUtil.decodeBase64(tinyDB.getString("downloadFileContents")); String data = appUtil.decodeBase64(tinyDB.getString("downloadFileContents"));
Intent intent = new Intent(ctx, CreateFileActivity.class); Intent intent = new Intent(ctx, CreateFileActivity.class);
intent.putExtra("fileAction", 2); intent.putExtra("fileAction", CreateFileActivity.FILE_ACTION_EDIT);
intent.putExtra("filePath", singleFileName); intent.putExtra("filePath", singleFileName);
intent.putExtra("fileSha", fileSha); intent.putExtra("fileSha", fileSha);

View File

@ -26,11 +26,6 @@ import java.util.Locale;
public class AppUtil { public class AppUtil {
public static String strReplace(String str, String original, String replace) {
return str.replace(original, replace);
}
public static boolean hasNetworkConnection(Context context) { public static boolean hasNetworkConnection(Context context) {
return NetworkStatusObserver.get(context).hasNetworkConnection(); return NetworkStatusObserver.get(context).hasNetworkConnection();
@ -62,11 +57,6 @@ public class AppUtil {
return context.getPackageName().equals("org.mian.gitnex.pro"); return context.getPackageName().equals("org.mian.gitnex.pro");
} }
public int charactersLength(String str) {
return str.length();
}
public Boolean checkStringsWithAlphaNumeric(String str) { // [a-zA-Z0-9] public Boolean checkStringsWithAlphaNumeric(String str) { // [a-zA-Z0-9]
return str.matches("^[\\w]+$"); return str.matches("^[\\w]+$");
} }

View File

@ -100,18 +100,18 @@
android:id="@+id/newFileContent" android:id="@+id/newFileContent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="140dp" android:layout_height="140dp"
android:gravity="top|start"
android:inputType="textMultiLine|textCapSentences"
android:scrollbars="vertical"
android:textColor="?attr/inputTextColor" android:textColor="?attr/inputTextColor"
android:textColorHighlight="?attr/hintColor" android:textColorHighlight="?attr/hintColor"
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:gravity="top|start"
android:scrollbars="vertical"
android:inputType="textCapSentences"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:id="@+id/newFileBranchesSpinnerLayout" android:id="@+id/newFileBranchesLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:boxBackgroundColor="?attr/inputBackgroundColor" app:boxBackgroundColor="?attr/inputBackgroundColor"
@ -119,48 +119,22 @@
app:hintTextColor="?attr/hintColor" app:hintTextColor="?attr/hintColor"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:hint="@string/newFileOldBranches" android:hint="@string/newFileBranches"
app:endIconTint="?attr/iconsColor" app:endIconTint="?attr/iconsColor"
app:helperTextEnabled="true" app:helperTextEnabled="true"
app:helperText="@string/newFileCurrentBranchMessage" app:helperText="@string/newFileEmptyBranchMessage"
app:helperTextTextColor="?attr/inputTextColor" app:helperTextTextColor="?attr/inputTextColor"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"> style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu">
<AutoCompleteTextView <AutoCompleteTextView
android:id="@+id/newFileBranchesSpinner" android:id="@+id/new_file_branches"
style="@style/Widget.MaterialComponents.AutoCompleteTextView.FilledBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="none" android:inputType="textCapSentences"
android:labelFor="@id/new_file_branches"
android:singleLine="true"
android:textColor="?attr/inputTextColor" android:textColor="?attr/inputTextColor"
android:labelFor="@+id/newFileBranchesSpinner"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/newFileBranchNameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundColor="?attr/inputBackgroundColor"
android:textColorHint="?attr/hintColor"
app:hintTextColor="?attr/hintColor"
app:boxStrokeErrorColor="@color/darkRed"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:endIconMode="clear_text"
app:endIconTint="?attr/iconsColor"
app:helperTextEnabled="true"
app:helperText="@string/newFileNewBranchMessage"
app:helperTextTextColor="?attr/inputTextColor"
android:hint="@string/newFileBranchTintCopy">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/newFileBranchName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/inputTextColor"
android:textColorHighlight="?attr/hintColor"
android:textColorHint="?attr/hintColor"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
@ -186,10 +160,10 @@
android:id="@+id/newFileCommitMessage" android:id="@+id/newFileCommitMessage"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textMultiLine|textCapSentences"
android:textColor="?attr/inputTextColor" android:textColor="?attr/inputTextColor"
android:textColorHighlight="?attr/hintColor" android:textColorHighlight="?attr/hintColor"
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:inputType="textCapSentences"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -105,7 +105,7 @@
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:gravity="top|start" android:gravity="top|start"
android:scrollbars="vertical" android:scrollbars="vertical"
android:inputType="textCapSentences" android:inputType="textCapSentences|textMultiLine"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -105,7 +105,7 @@
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:gravity="top|start" android:gravity="top|start"
android:scrollbars="vertical" android:scrollbars="vertical"
android:inputType="textCapSentences" android:inputType="textCapSentences|textMultiLine"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -105,7 +105,7 @@
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:gravity="top|start" android:gravity="top|start"
android:scrollbars="vertical" android:scrollbars="vertical"
android:inputType="textCapSentences" android:inputType="textCapSentences|textMultiLine"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -105,7 +105,7 @@
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:gravity="top|start" android:gravity="top|start"
android:scrollbars="vertical" android:scrollbars="vertical"
android:inputType="textCapSentences" android:inputType="textCapSentences|textMultiLine"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -74,7 +74,7 @@
android:textColor="?attr/inputTextColor" android:textColor="?attr/inputTextColor"
android:textColorHighlight="?attr/hintColor" android:textColorHighlight="?attr/hintColor"
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:inputType="textCapSentences" android:inputType="textCapSentences|textMultiLine"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -128,7 +128,7 @@
android:textColorHighlight="?attr/hintColor" android:textColorHighlight="?attr/hintColor"
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:gravity="top|start" android:gravity="top|start"
android:inputType="textCapSentences" android:inputType="textCapSentences|textMultiLine"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -102,7 +102,7 @@
android:textColorHint="?attr/hintColor" android:textColorHint="?attr/hintColor"
android:gravity="top|start" android:gravity="top|start"
android:scrollbars="vertical" android:scrollbars="vertical"
android:inputType="textCapSentences" android:inputType="textCapSentences|textMultiLine"
android:textSize="16sp" /> android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -471,10 +471,9 @@
<string name="newFileInvalidBranchName">Invalid branch name, may only contain &#8211;, a&#8211;z, 0&#8211;9</string> <string name="newFileInvalidBranchName">Invalid branch name, may only contain &#8211;, a&#8211;z, 0&#8211;9</string>
<string name="newFileCommitMessageError">Commit message is too long</string> <string name="newFileCommitMessageError">Commit message is too long</string>
<string name="newFileSuccessMessage">New file created</string> <string name="newFileSuccessMessage">New file created</string>
<string name="newFileOldBranches">Current Branches</string> <string name="newFileBranches">Select or create a branch</string>
<string name="newFileRequiredFields">Fields like filename, content and commit message are required</string> <string name="newFileRequiredFields">Fields like filename, content and commit message are required</string>
<string name="newFileCurrentBranchMessage">Selecting current branch will disable new branch</string> <string name="newFileEmptyBranchMessage">Leave blank to push to the default branch</string>
<string name="newFileNewBranchMessage">e.g: new-branch</string>
<string name="newFileRequiredFieldNewBranchName">New branch name cannot be empty if current branch is not selected</string> <string name="newFileRequiredFieldNewBranchName">New branch name cannot be empty if current branch is not selected</string>
<string name="strFilter">Filter</string> <string name="strFilter">Filter</string>