Skip to content

Commit

Permalink
(#284) add flip preference dialog design
Browse files Browse the repository at this point in the history
  • Loading branch information
zuevval committed Oct 17, 2020
1 parent fc8e555 commit 206cabe
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.github.braillesystems.learnbraille.ui

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.data.entities.*
import com.github.braillesystems.learnbraille.res.inputMarkerPrintRules
Expand All @@ -10,6 +15,7 @@ import com.github.braillesystems.learnbraille.res.showMarkerPrintRules
import com.github.braillesystems.learnbraille.res.showSymbolPrintRules
import com.github.braillesystems.learnbraille.ui.views.BrailleDotsViewMode
import com.github.braillesystems.learnbraille.utils.*
import kotlinx.android.synthetic.main.fragment_flip_dialog.view.*

fun Fragment.showCorrectToast() = toast(getString(R.string.input_correct))

Expand Down Expand Up @@ -63,3 +69,19 @@ fun Context.showPrint(data: MaterialData): String =

fun Fragment.showPrint(data: MaterialData): String =
contextNotNull.showPrint(data)

fun FragmentActivity.showFlipPreferenceDialog() {
val viewGroup: ViewGroup = findViewById(android.R.id.content)
val dialogView: View =
LayoutInflater.from(this).inflate(R.layout.fragment_flip_dialog, viewGroup, false)
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.setView(dialogView)
builder.setTitle(getString(R.string.fragment_flip_dialog_title))
val alertDialog: AlertDialog = builder.create()
alertDialog.show()
dialogView.btnOK.setOnClickListener {
val flipPreferenceOn = dialogView.radioButtonFlip.isChecked
// TODO save preference & never ask again
alertDialog.hide()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import com.github.braillesystems.learnbraille.data.db.LearnBrailleDatabase
import com.github.braillesystems.learnbraille.databinding.FragmentMenuBinding
import com.github.braillesystems.learnbraille.ui.screens.AbstractFragmentWithHelp
import com.github.braillesystems.learnbraille.ui.screens.theory.toLastCourseStep
import com.github.braillesystems.learnbraille.ui.showFlipPreferenceDialog
import com.github.braillesystems.learnbraille.utils.*
import com.google.android.material.button.MaterialButton
import org.koin.android.ext.android.inject
import timber.log.Timber


class MenuFragment : AbstractFragmentWithHelp(R.string.menu_help) {

private val db: LearnBrailleDatabase by inject()
Expand Down Expand Up @@ -97,6 +99,7 @@ class MenuFragment : AbstractFragmentWithHelp(R.string.menu_help) {
}

colorButtons(buttons)
activity?.showFlipPreferenceDialog() // TODO ask in practice and theory

}.root

Expand Down
54 changes: 54 additions & 0 deletions app/src/main/res/layout/fragment_flip_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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"
android:id="@+id/fragment_flip_dialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- TODO reduce hardcode -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/fragment_flip_dialog_msg"
android:layout_margin="10dp"
android:textSize="@dimen/lessons_info_text_size"/>

<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">

<RadioButton
android:id="@+id/radioButtonNoFlip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/radio_btn_no_flip"
android:checked="true"
android:textAlignment="center" />

<RadioButton
android:id="@+id/radioButtonFlip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/radio_btn_flip"
android:textAlignment="center" />
</RadioGroup>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:text="@string/fragment_flip_dialog_msg2"
android:textSize="@dimen/lessons_info_text_size"/>

<Button
android:id="@+id/btnOK"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:text="@string/dialog_ok" />
</LinearLayout>
12 changes: 12 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,16 @@
<string name="stats_section_7days">За последние 7 дней</string>
<string name="stats_section_30days">За последние 30 дней</string>
<string name="flip_card">Шеститочие: письмо/чтение</string>

<string name="fragment_flip_dialog_title">Выберите порядок столбцов в шеститочии</string>
<string name="fragment_flip_dialog_msg">
Выберите удобный Вам вариант расположения точек <b>при вводе</b>.
</string>
<string name="fragment_flip_dialog_msg2">
Вы всегда сможете изменить это значение в разделе \"Настройки\"/
\"Порядок столбцов при вводе\"
</string>
<string name="dialog_ok">OK</string>
<string name="radio_btn_flip">Точки 1, 2, 3 справа (как при письме на брайлевском приборе)</string>
<string name="radio_btn_no_flip">Точки 1, 2, 3 слева (как при чтении)</string>
</resources>

0 comments on commit 206cabe

Please sign in to comment.