Skip to content

Commit

Permalink
Improve ui
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Mar 2, 2023
1 parent 4be96a1 commit f3727e3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class CustomRepositoryEditor: CustomTitlebarActivityBase() {
ok = tryReadManifest(newUrlStr)
}
valid = ok
updateUI()
}

private fun readManifest(conn: HttpsURLConnection): Boolean {
Expand Down Expand Up @@ -217,10 +218,20 @@ class CustomRepositoryEditor: CustomTitlebarActivityBase() {
finish()
}

private fun updateData() = validateManifestUrl()
private fun updateData() {
val repo = data.repository?: return
repo.packageDirectory = binding.packageDir.text.toString()
}

private fun updateUI() = binding.run {
manifestUrl.setText(data.repository?.manifestUrl)
val repo = data.repository?: return
manifestUrl.setText(repo.manifestUrl)
infoText.text = concat(
repo.name,
"\n\n",
repo.description,
)
packageDir.setText(repo.packageDirectory)
}

private fun delete() = lifecycleScope.launch(Dispatchers.Main) {
Expand Down
23 changes: 19 additions & 4 deletions app/src/main/res/layout/custom_repository_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
android:layout_height="wrap_content">

<EditText
android:id="@+id/manifest_url"
android:id="@+id/manifestUrl"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/repository_specification"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="@+id/pasteButton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand All @@ -37,9 +36,9 @@
android:id="@+id/pasteButton"
android:layout_width="48dp"
android:layout_height="43dp"
app:layout_constraintBottom_toBottomOf="@+id/manifest_url"
app:layout_constraintBottom_toBottomOf="@+id/manifestUrl"
app:layout_constraintEnd_toStartOf="@+id/okCheck"
app:layout_constraintTop_toTopOf="@+id/manifest_url"
app:layout_constraintTop_toTopOf="@+id/manifestUrl"
app:srcCompat="@drawable/baseline_content_paste_24" />

<ImageView
Expand All @@ -51,4 +50,20 @@
app:tint="@color/grey_500"
app:layout_constraintTop_toTopOf="@+id/pasteButton"
app:srcCompat="@drawable/baseline_check_24" />
<EditText
android:id="@+id/packageDir"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/packages_dir"
app:layout_constraintTop_toBottomOf="@id/manifestUrl"
android:visibility="gone"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:id="@+id/infoText"
app:layout_constraintTop_toBottomOf="@id/packageDir"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1107,4 +1107,5 @@
<string name="wiki_page">WIKI page</string>
<string name="custom_repositories_help0">You can install documents from external custom repositories by installing custom repositories.</string>
<string name="duplicate_custom_repository">Repository with name %s already exists, can\'t add another.</string>
<string name="packages_dir">Packages directory (Zip files)</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ data class CustomRepository(
val type: String,
val host: String,
val catalogDirectory: String,
val packageDirectory: String,
var packageDirectory: String,
var manifestUrl: String? = null,
) {
fun toJson(): String {
Expand Down

0 comments on commit f3727e3

Please sign in to comment.