Переглянути джерело

Put edit book layout into scroll view

sirekanyan 8 роки тому
батько
коміт
95d1ed9726

+ 4 - 4
app/src/main/java/me/vadik/knigopis/MainActivity.kt

@@ -25,6 +25,7 @@ import retrofit2.HttpException
 
 private const val ULOGIN_REQUEST_CODE = 0
 private const val BOOK_REQUEST_CODE = 1
+private const val MAX_VERSION_CLICK_COUNT = 12
 
 class MainActivity : AppCompatActivity(), Router {
 
@@ -130,10 +131,9 @@ class MainActivity : AppCompatActivity(), Router {
           versionView.text = BuildConfig.VERSION_NAME
           var count = 0
           versionView.setOnClickListener {
-            (++count == 12).let { enable ->
-              config.setDevMode(enable)
-              if (enable) toast("???")
-            }
+            count += 1
+            config.setDevMode(count >= MAX_VERSION_CLICK_COUNT)
+            if (count == MAX_VERSION_CLICK_COUNT) toast(R.string.dev_mode_message)
           }
           AlertDialog.Builder(this).setView(dialogView).show()
           true

+ 156 - 144
app/src/main/res/layout/book_edit.xml

@@ -1,17 +1,16 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:animateLayoutChanges="true">
+    android:orientation="vertical">
 
     <android.support.design.widget.AppBarLayout
         android:id="@+id/app_bar_layout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:theme="@style/AppBarTheme"
-        app:layout_constraintTop_toTopOf="parent">
+        android:theme="@style/AppBarTheme">
 
         <android.support.v7.widget.Toolbar
             android:id="@+id/toolbar"
@@ -21,147 +20,160 @@
 
     </android.support.design.widget.AppBarLayout>
 
-    <android.support.design.widget.TextInputLayout
-        android:id="@+id/book_title_input"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_margin="16dp"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toLeftOf="@id/cover_image_views"
-        app:layout_constraintTop_toBottomOf="@id/app_bar_layout">
-
-        <EditText
-            android:id="@+id/book_title_edit_text"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:hint="@string/book_hint_title"
-            android:inputType="textCapSentences"
-            tools:text="Два капитана" />
-
-    </android.support.design.widget.TextInputLayout>
-
-    <android.support.design.widget.TextInputLayout
-        android:id="@+id/book_author_input"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_margin="16dp"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toLeftOf="@id/cover_image_views"
-        app:layout_constraintTop_toBottomOf="@id/book_title_input">
-
-        <EditText
-            android:id="@+id/book_author_edit_text"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:hint="@string/book_hint_author"
-            android:inputType="textCapWords"
-            tools:text="Вениамин Каверин" />
-
-    </android.support.design.widget.TextInputLayout>
-
-    <android.support.v4.view.ViewPager
-        android:id="@+id/cover_image_views"
-        android:layout_width="0dp"
-        android:layout_height="0dp"
-        android:layout_marginEnd="16dp"
-        android:layout_marginStart="16dp"
-        android:visibility="gone"
-        app:layout_constraintBottom_toBottomOf="@id/book_author_input"
-        app:layout_constraintDimensionRatio="3:4"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toTopOf="@id/book_title_input"
-        tools:background="@color/colorAccent"
-        tools:visibility="visible" />
-
-    <android.support.design.widget.TextInputLayout
-        android:id="@+id/book_year_input"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_margin="16dp"
-        android:visibility="gone"
-        app:layout_constraintHorizontal_chainStyle="packed"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toLeftOf="@+id/book_month_input"
-        app:layout_constraintTop_toBottomOf="@id/book_author_input"
-        tools:visibility="visible">
-
-        <EditText
-            android:id="@+id/book_year_edit_text"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:hint="@string/book_hint_year"
-            android:inputType="number"
-            tools:text="2012" />
-
-    </android.support.design.widget.TextInputLayout>
-
-    <android.support.design.widget.TextInputLayout
-        android:id="@+id/book_month_input"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_margin="16dp"
-        android:visibility="gone"
-        app:layout_constraintLeft_toRightOf="@id/book_year_input"
-        app:layout_constraintRight_toLeftOf="@+id/book_day_input"
-        app:layout_constraintTop_toBottomOf="@id/book_author_input"
-        tools:visibility="visible">
-
-        <EditText
-            android:id="@+id/book_month_edit_text"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:hint="@string/book_hint_month"
-            android:inputType="number" />
-
-    </android.support.design.widget.TextInputLayout>
-
-    <android.support.design.widget.TextInputLayout
-        android:id="@+id/book_day_input"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_margin="16dp"
-        android:visibility="gone"
-        app:layout_constraintLeft_toRightOf="@id/book_month_input"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toBottomOf="@id/book_author_input"
-        tools:visibility="visible">
-
-        <EditText
-            android:id="@+id/book_day_edit_text"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:hint="@string/book_hint_day"
-            android:inputType="number" />
-
-    </android.support.design.widget.TextInputLayout>
-
-    <CheckBox
-        android:id="@+id/book_read_checkbox"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_margin="16dp"
-        android:paddingEnd="8dp"
-        android:paddingStart="8dp"
-        android:text="@string/book_read_checkbox"
-        android:textSize="16sp"
-        app:layout_constraintTop_toBottomOf="@id/book_year_input"
-        tools:checked="true" />
-
-    <android.support.design.widget.TextInputLayout
-        android:id="@+id/notes_text_input"
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_margin="16dp"
-        app:layout_constraintTop_toBottomOf="@id/book_read_checkbox">
+        android:layout_height="match_parent">
 
-        <EditText
-            android:id="@+id/notes_text_area"
+        <android.support.constraint.ConstraintLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:hint="@string/book_hint_notes"
-            android:inputType="textCapSentences"
-            tools:text="Неистово плюсую" />
-
-    </android.support.design.widget.TextInputLayout>
-
-</android.support.constraint.ConstraintLayout>
+            android:animateLayoutChanges="true">
+
+            <android.support.design.widget.TextInputLayout
+                android:id="@+id/book_title_input"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_margin="16dp"
+                app:layout_constraintLeft_toLeftOf="parent"
+                app:layout_constraintRight_toLeftOf="@id/cover_image_views"
+                app:layout_constraintTop_toTopOf="parent">
+
+                <EditText
+                    android:id="@+id/book_title_edit_text"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:hint="@string/book_hint_title"
+                    android:inputType="textCapSentences"
+                    tools:text="Два капитана" />
+
+            </android.support.design.widget.TextInputLayout>
+
+            <android.support.design.widget.TextInputLayout
+                android:id="@+id/book_author_input"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_margin="16dp"
+                app:layout_constraintLeft_toLeftOf="parent"
+                app:layout_constraintRight_toLeftOf="@id/cover_image_views"
+                app:layout_constraintTop_toBottomOf="@id/book_title_input">
+
+                <EditText
+                    android:id="@+id/book_author_edit_text"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:hint="@string/book_hint_author"
+                    android:inputType="textCapWords"
+                    tools:text="Вениамин Каверин" />
+
+            </android.support.design.widget.TextInputLayout>
+
+            <android.support.v4.view.ViewPager
+                android:id="@+id/cover_image_views"
+                android:layout_width="0dp"
+                android:layout_height="0dp"
+                android:layout_marginEnd="16dp"
+                android:layout_marginStart="16dp"
+                android:visibility="gone"
+                app:layout_constraintBottom_toBottomOf="@id/book_author_input"
+                app:layout_constraintDimensionRatio="3:4"
+                app:layout_constraintRight_toRightOf="parent"
+                app:layout_constraintTop_toTopOf="@id/book_title_input"
+                tools:background="@color/colorAccent"
+                tools:visibility="visible" />
+
+            <android.support.design.widget.TextInputLayout
+                android:id="@+id/book_year_input"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_margin="16dp"
+                android:visibility="gone"
+                app:layout_constraintHorizontal_chainStyle="packed"
+                app:layout_constraintLeft_toLeftOf="parent"
+                app:layout_constraintRight_toLeftOf="@+id/book_month_input"
+                app:layout_constraintTop_toBottomOf="@id/book_author_input"
+                tools:visibility="visible">
+
+                <EditText
+                    android:id="@+id/book_year_edit_text"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:hint="@string/book_hint_year"
+                    android:inputType="number"
+                    tools:text="2012" />
+
+            </android.support.design.widget.TextInputLayout>
+
+            <android.support.design.widget.TextInputLayout
+                android:id="@+id/book_month_input"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_margin="16dp"
+                android:visibility="gone"
+                app:layout_constraintLeft_toRightOf="@id/book_year_input"
+                app:layout_constraintRight_toLeftOf="@+id/book_day_input"
+                app:layout_constraintTop_toBottomOf="@id/book_author_input"
+                tools:visibility="visible">
+
+                <EditText
+                    android:id="@+id/book_month_edit_text"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:hint="@string/book_hint_month"
+                    android:inputType="number" />
+
+            </android.support.design.widget.TextInputLayout>
+
+            <android.support.design.widget.TextInputLayout
+                android:id="@+id/book_day_input"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_margin="16dp"
+                android:visibility="gone"
+                app:layout_constraintLeft_toRightOf="@id/book_month_input"
+                app:layout_constraintRight_toRightOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/book_author_input"
+                tools:visibility="visible">
+
+                <EditText
+                    android:id="@+id/book_day_edit_text"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:hint="@string/book_hint_day"
+                    android:inputType="number" />
+
+            </android.support.design.widget.TextInputLayout>
+
+            <CheckBox
+                android:id="@+id/book_read_checkbox"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="16dp"
+                android:paddingEnd="8dp"
+                android:paddingStart="8dp"
+                android:text="@string/book_read_checkbox"
+                android:textSize="16sp"
+                app:layout_constraintTop_toBottomOf="@id/book_year_input"
+                tools:checked="true" />
+
+            <android.support.design.widget.TextInputLayout
+                android:id="@+id/notes_text_input"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="16dp"
+                app:layout_constraintTop_toBottomOf="@id/book_read_checkbox">
+
+                <EditText
+                    android:id="@+id/notes_text_area"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:hint="@string/book_hint_notes"
+                    android:inputType="textCapSentences"
+                    tools:text="Неистово плюсую" />
+
+            </android.support.design.widget.TextInputLayout>
+
+        </android.support.constraint.ConstraintLayout>
+
+    </ScrollView>
+
+</LinearLayout>

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -51,4 +51,7 @@
     <string name="error_loading_books">Check your network connection.</string>
     <string name="error_no_books">You don\'t have any books.</string>
 
+    <!-- dev -->
+    <string name="dev_mode_message">НЕ ПЫТАЙТЕСБ ЧТОТ0 N3МЕНИТЬ!</string>
+
 </resources>