From 9d182821d237154f9da02b6c28be0938233927bc Mon Sep 17 00:00:00 2001 From: M M Arif Date: Tue, 28 Apr 2020 02:08:12 +0000 Subject: [PATCH] Hide new branch when current is selected (#451) Hide is best approach here Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/451 Reviewed-by: opyale Reviewed-by: 6543 <6543@noreply.gitea.io> --- .../gitnex/activities/CreateFileActivity.java | 23 +++++++++---------- app/src/main/res/layout/activity_new_file.xml | 2 ++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateFileActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateFileActivity.java index ce0ac546..742f537f 100644 --- a/app/src/main/java/org/mian/gitnex/activities/CreateFileActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/CreateFileActivity.java @@ -13,6 +13,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Spinner; +import android.widget.TextView; import androidx.annotation.NonNull; import com.google.gson.JsonElement; import org.mian.gitnex.R; @@ -76,6 +77,8 @@ public class CreateFileActivity extends BaseActivity { newFileContent = findViewById(R.id.newFileContent); newFileBranchName = findViewById(R.id.newFileBranchName); newFileCommitMessage = findViewById(R.id.newFileCommitMessage); + TextView branchNameId = findViewById(R.id.branchNameId); + TextView branchNameHintText = findViewById(R.id.branchNameHintText); newFileName.requestFocus(); assert imm != null; @@ -99,13 +102,18 @@ public class CreateFileActivity extends BaseActivity { View arg1, int arg2, long arg3) { Branches bModelValue = (Branches) newFileBranchesSpinner.getSelectedItem(); - Log.i("bModelSelected", bModelValue.toString()); if(bModelValue.toString().equals("No branch")) { newFileBranchName.setEnabled(true); + newFileBranchName.setVisibility(View.VISIBLE); + branchNameId.setVisibility(View.VISIBLE); + branchNameHintText.setVisibility(View.VISIBLE); } else { newFileBranchName.setEnabled(false); + newFileBranchName.setVisibility(View.GONE); + branchNameId.setVisibility(View.GONE); + branchNameHintText.setVisibility(View.GONE); newFileBranchName.setText(""); } @@ -132,11 +140,7 @@ public class CreateFileActivity extends BaseActivity { } - private View.OnClickListener createFileListener = new View.OnClickListener() { - public void onClick(View v) { - processNewFile(); - } - }; + private View.OnClickListener createFileListener = v -> processNewFile(); private void processNewFile() { @@ -314,12 +318,7 @@ public class CreateFileActivity extends BaseActivity { } private void initCloseListener() { - onClickListener = new View.OnClickListener() { - @Override - public void onClick(View view) { - finish(); - } - }; + onClickListener = view -> finish(); } private void disableProcessButton() { diff --git a/app/src/main/res/layout/activity_new_file.xml b/app/src/main/res/layout/activity_new_file.xml index 5e7bed36..0aae7677 100644 --- a/app/src/main/res/layout/activity_new_file.xml +++ b/app/src/main/res/layout/activity_new_file.xml @@ -155,6 +155,7 @@ android:gravity="end" />