Skip to content

Commit

Permalink
Fix #196.
Browse files Browse the repository at this point in the history
  • Loading branch information
therealbluepandabear committed Aug 9, 2022
1 parent 9f48c45 commit 3dc4f8c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.graphics.Color
import android.view.MenuItem
import android.view.ViewGroup
import android.widget.RadioGroup
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.widget.doAfterTextChanged
import com.android.volley.Request
Expand Down Expand Up @@ -78,22 +77,16 @@ fun CanvasActivity.onMenuItemSelected(item: MenuItem): Boolean {
val fileNameTextInputLayout =
exportRootLayout.findViewById<TextInputLayout>(R.id.exportProjectDialogLayout_fileNameTextInputLayout)

val fileTypeTextView = exportRootLayout.findViewById<TextView>(R.id.textView2)
val defaultFileTypeTextViewTopMargin = (fileTypeTextView.layoutParams as ViewGroup.MarginLayoutParams).topMargin

exportRootLayout.post {
// We do this so that there is no default top margin, which I personally find it ugly
(exportRootLayout.layoutParams as ViewGroup.MarginLayoutParams).topMargin = 0

fileNameTextInputEditText.setText(projectTitle)
fileNameTextInputEditText.doAfterTextChanged {
if (it.toString().isNotBlank()) {
fileNameTextInputLayout.error = ""
(fileNameTextInputLayout.layoutParams as ViewGroup.MarginLayoutParams).bottomMargin = 0
(fileTypeTextView.layoutParams as ViewGroup.MarginLayoutParams).topMargin = 0
fileNameTextInputLayout.isErrorEnabled = false
} else {
fileNameTextInputLayout.error = getString(R.string.exception_invalid_file_name)
(fileTypeTextView.layoutParams as ViewGroup.MarginLayoutParams).topMargin = defaultFileTypeTextViewTopMargin
}
}
}
Expand Down Expand Up @@ -164,7 +157,6 @@ fun CanvasActivity.onMenuItemSelected(item: MenuItem): Boolean {
alertDialog.cancel()
} else {
fileNameTextInputLayout.error = getString(R.string.exception_invalid_file_name)
(fileTypeTextView.layoutParams as ViewGroup.MarginLayoutParams).topMargin = defaultFileTypeTextViewTopMargin
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NewColorPaletteFragment : Fragment(), ActivityFragment {

binding.fragmentNewColorPaletteColorPaletteNameTextInputEditText.doAfterTextChanged {
if (binding.fragmentNewColorPaletteColorPaletteNameTextInputEditText.text.toString().isNotBlank()) {
binding.fragmentNewColorPaletteColorPaletteNameTextInputLayout.error = null
binding.fragmentNewColorPaletteColorPaletteNameTextInputLayout.isErrorEnabled = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private fun NewProjectFragment.checkForTitleError() {
binding.fragmentNewCanvasProjectTitleTextInputLayout.error = getString(R.string.exception_invalid_project_name)
invalidTitle = true
} else {
binding.fragmentNewCanvasProjectTitleTextInputLayout.error = null
binding.fragmentNewCanvasProjectTitleTextInputLayout.isErrorEnabled = false
invalidTitle = false
}
}
Expand All @@ -39,7 +39,7 @@ private fun NewProjectFragment.checkForWidthError() {
}

else -> {
binding.fragmentNewCanvasWidthTextInputLayout.error = null
binding.fragmentNewCanvasWidthTextInputLayout.isErrorEnabled = false
invalidWidth = false
}
}
Expand All @@ -58,7 +58,7 @@ private fun NewProjectFragment.checkForHeightError() {
}

else -> {
binding.fragmentNewCanvasHeightTextInputLayout.error = null
binding.fragmentNewCanvasHeightTextInputLayout.isErrorEnabled = false
invalidHeight = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private fun SprayToolSettingsFragment.checkForRadiusError() {
}

else -> {
binding.fragmentSprayToolSettingsRadiusTextInputLayout.error = null
binding.fragmentSprayToolSettingsRadiusTextInputLayout.isErrorEnabled = false
invalidRadius = false
}
}
Expand All @@ -40,7 +40,7 @@ private fun SprayToolSettingsFragment.checkForStrengthError() {
}

else -> {
binding.fragmentSprayToolSettingsStrengthTextInputLayout.error = null
binding.fragmentSprayToolSettingsStrengthTextInputLayout.isErrorEnabled = false
invalidStrength = false
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/export_project_dialog_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:hint="File Name"
android:hint="@string/exportProjectDialogLayout_file_name_str"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
Expand All @@ -27,7 +27,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="File Type"
android:text="@string/exportProjectDialogLayout_file_type_str"
app:layout_constraintStart_toStartOf="@+id/exportProjectDialogLayout_fileNameTextInputLayout"
app:layout_constraintTop_toBottomOf="@+id/exportProjectDialogLayout_fileNameTextInputLayout" />

Expand Down Expand Up @@ -114,7 +114,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="Resolution"
android:text="@string/exportProjectDialogLayout_resolution_str"
app:layout_constraintStart_toStartOf="@+id/exportProjectDialogLayout_fileNameTextInputLayout"
app:layout_constraintTop_toBottomOf="@+id/horizontalScrollView" />

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<string name="projectDetailsAlertBox_created">Created</string>
<string name="projectDetailsAlertBox_colors">Colors</string>

<string name="exportProjectDialogLayout_file_name_str">File Name</string>
<string name="exportProjectDialogLayout_file_type_str">File Type</string>
<string name="exportProjectDialogLayout_resolution_str">File Type</string>

<!--Other strings-->
<string name="recentCreationsLayout_subtitle" translatable="false">%1$dx%2$d</string>

Expand Down

0 comments on commit 3dc4f8c

Please sign in to comment.