Skip to content

Commit

Permalink
Hirak/save button (#31)
Browse files Browse the repository at this point in the history
* Add save button as fab
  • Loading branch information
Hirak20 authored and Apsaliya committed Mar 31, 2018
1 parent 3afb344 commit 857cf27
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -18,12 +18,12 @@ import com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog
import com.jakewharton.rxbinding2.widget.RxTextView
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.synthetic.main.fragment_input.etInput
import kotlinx.android.synthetic.main.fragment_input.fabSave
import kotlinx.android.synthetic.main.fragment_input.toolbar
import kotlinx.android.synthetic.main.report_folded.tvCharacters
import kotlinx.android.synthetic.main.report_folded.tvSentences
import kotlinx.android.synthetic.main.report_folded.tvWords
import kotlinx.android.synthetic.main.report_summary.foldingCell
import kotlinx.android.synthetic.main.report_summary.ibSave
import kotlinx.android.synthetic.main.report_summary.ivExpand
import kotlinx.android.synthetic.main.report_unfolded.tvCharactersContent
import kotlinx.android.synthetic.main.report_unfolded.tvParagraphsContent
Expand All @@ -38,7 +38,6 @@ import wordtextcounter.details.main.store.ReportDatabase
import java.util.concurrent.TimeUnit.MILLISECONDS



/**
* A simple [Fragment] subclass.
* Use the [InputFragment.newInstance] factory method to
Expand All @@ -52,14 +51,15 @@ class InputFragment : BaseFragment() {
private var avMoreToLess: AnimatedVectorDrawableCompat? = null
private var avLessToMore: AnimatedVectorDrawableCompat? = null
private lateinit var viewModelFactory: InputViewModelFactory

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewModelFactory = InputViewModelFactory(ReportDatabase.getInstance(activity?.applicationContext!!).reportDao())
viewModelFactory = InputViewModelFactory(
ReportDatabase.getInstance(activity?.applicationContext!!).reportDao())
viewModel = ViewModelProviders.of(this, viewModelFactory).get(InputViewModel::class.java)
avMoreToLess = AnimatedVectorDrawableCompat.create(context!!, R.drawable.avd_more_to_less)
avLessToMore = AnimatedVectorDrawableCompat.create(context!!, R.drawable.avd_less_to_more)

}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
Expand All @@ -76,14 +76,14 @@ class InputFragment : BaseFragment() {

val cView = LayoutInflater.from(activity).inflate(R.layout.report_name_edit, null)
val rName = cView.findViewById<AppCompatEditText>(R.id.rName)
ibSave.setOnClickListener {
fabSave.setOnClickListener {
MaterialStyledDialog.Builder(activity)
.setTitle("") // This is intentional. Not providing this results into weird UI.
.setDescription((activity as AppCompatActivity).getString(R.string.save_dialog_desc))
.setDescription(getString(R.string.save_dialog_desc))
.withDarkerOverlay(true)
.setPositiveText(getString(R.string.bookmark))
.setNegativeText(getString(R.string.cancel))
.setCustomView(cView, 20, 20, 20 ,20)
.setCustomView(cView, 20, 20, 20, 20)
.onPositive { _, _ ->
if (rName.text.trim().isEmpty()) {
//TODO Error message
Expand All @@ -97,6 +97,7 @@ class InputFragment : BaseFragment() {
.show()
}


foldingCell.initialize(1000, ContextCompat.getColor(context!!, R.color.folder_back_side), 0)
ivExpand.setOnClickListener {

Expand Down Expand Up @@ -131,6 +132,7 @@ class InputFragment : BaseFragment() {
outState.putString(TEXT, etInput.text.toString())
}


private fun handleViewState(viewState: ViewState) {

if (viewState.showError) {
Expand Down
59 changes: 59 additions & 0 deletions app/src/main/res/layout/fragment_input.xml
Expand Up @@ -22,11 +22,14 @@
app:titleEnabled="false"
>


<View
android:layout_width="match_parent"
android:layout_height="@dimen/_56sdp"
android:background="@color/primaryDarkColor"
/>


<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -36,8 +39,52 @@

<include layout="@layout/report_summary"/>


</android.support.v7.widget.CardView>

<!--<android.support.v7.widget.CardView-->
<!--android:layout_width="@dimen/_32sdp"-->
<!--android:layout_height="@dimen/_32sdp"-->
<!--app:cardBackgroundColor="@color/primaryDarkColor"-->
<!--&gt;-->

<!--<ImageButton-->
<!--android:id="@+id/ibClear"-->
<!--android:layout_width="@dimen/_32sdp"-->
<!--android:layout_height="@dimen/_32sdp"-->
<!--android:layout_gravity="end|top"-->
<!--android:background="@color/primaryDarkColor"-->
<!--android:contentDescription="@string/save"-->
<!--android:tint="@color/white"-->
<!--app:layout_constraintRight_toRightOf="parent"-->
<!--app:srcCompat="@drawable/ic_clear_black_24dp"-->
<!--/>-->

<!--</android.support.v7.widget.CardView>-->


<!--<android.support.v7.widget.CardView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="end|top"-->
<!--&gt;-->

<!--<ImageButton-->
<!--android:id="@+id/ibSave"-->
<!--android:layout_width="@dimen/_32sdp"-->
<!--android:layout_height="@dimen/_32sdp"-->
<!--android:layout_gravity="end|top"-->
<!--android:background="@color/primaryDarkColor"-->
<!--android:contentDescription="@string/save"-->
<!--android:tint="@color/white"-->
<!--app:layout_constraintRight_toRightOf="parent"-->
<!--app:srcCompat="@drawable/ic_save_black_32dp"-->
<!--/>-->


<!--</android.support.v7.widget.CardView>-->


<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
Expand All @@ -49,6 +96,18 @@

</android.support.design.widget.AppBarLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fabSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="@dimen/_10sdp"
android:layout_marginEnd="@dimen/_10sdp"
android:layout_marginRight="@dimen/_10sdp"
android:tint="@color/primaryTextColor"
app:srcCompat="@drawable/ic_save_black_32dp"
/>


<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/report_folded.xml
Expand Up @@ -13,9 +13,9 @@
android:layout_width="0dp"
android:layout_height="@dimen/_60sdp"
android:layout_marginBottom="@dimen/_10sdp"
android:layout_marginEnd="@dimen/_30sdp"
android:layout_marginEnd="@dimen/_20sdp"
android:layout_marginLeft="@dimen/_20sdp"
android:layout_marginRight="@dimen/_30sdp"
android:layout_marginRight="@dimen/_20sdp"
android:layout_marginStart="@dimen/_20sdp"
android:layout_marginTop="@dimen/_10sdp"
android:clipChildren="false"
Expand Down
15 changes: 1 addition & 14 deletions app/src/main/res/layout/report_summary.xml
Expand Up @@ -7,22 +7,9 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
tools:showIn="@layout/fragment_input"
>

<ImageButton
android:id="@+id/ibSave"
android:layout_width="@dimen/_32sdp"
android:layout_height="@dimen/_32sdp"
android:background="@null"
android:contentDescription="@string/save"
android:src="@drawable/ic_save_black_32dp"
android:tint="@color/secondaryTextColor"
app:layout_constraintRight_toRightOf="parent"
/>


<com.ramotion.foldingcell.FoldingCell
android:id="@+id/foldingCell"
android:layout_width="0dp"
Expand All @@ -42,9 +29,9 @@
android:id="@+id/ivExpand"
android:layout_width="@dimen/_24sdp"
android:layout_height="@dimen/_24sdp"
android:src="@drawable/ic_expand_more_black_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="@drawable/ic_expand_more_black_24dp"
/>
</android.support.constraint.ConstraintLayout>

2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Sat Dec 02 22:15:29 IST 2017
#Wed Mar 28 23:44:15 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 comments on commit 857cf27

Please sign in to comment.