Skip to content

Commit

Permalink
Fix: update layout
Browse files Browse the repository at this point in the history
  • Loading branch information
therajanmaurya committed Nov 27, 2020
1 parent de71905 commit ffc2d21
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class SweetPlayAppUpdaterBottomSheet(
private val title: String,
private val description: String,
private val headerImage: Int,
private val typeface: Typeface? = null
private val typeface: Typeface? = null,
private val background: Int
) : BottomSheetDialogFragment(), InstallStateUpdatedListener {

private lateinit var appUpdateManager: AppUpdateManager
Expand All @@ -35,8 +36,10 @@ class SweetPlayAppUpdaterBottomSheet(
fun newInstant(
title: String,
description: String,
headerImage: Int
) = SweetPlayAppUpdaterBottomSheet(title, description, headerImage)
headerImage: Int,
typeface: Typeface?,
background: Int
) = SweetPlayAppUpdaterBottomSheet(title, description, headerImage, typeface, background)

const val REQUEST_CODE_FLEXIBLE_UPDATE = 17363
}
Expand All @@ -57,8 +60,9 @@ class SweetPlayAppUpdaterBottomSheet(
title = this@SweetPlayAppUpdaterBottomSheet.title
description = this@SweetPlayAppUpdaterBottomSheet.description
headerImage = this@SweetPlayAppUpdaterBottomSheet.headerImage
bsBackground = this@SweetPlayAppUpdaterBottomSheet.background

typeface?.let {
/*typeface?.let {
tvUpdateAvailable.typeface = it
tvUpdateAvailableMessage.typeface = it
tvUpdateProgress.typeface = it
Expand All @@ -68,7 +72,7 @@ class SweetPlayAppUpdaterBottomSheet(
btnDownloadInstall.typeface = it
btnCancel.typeface = it
btnOk.typeface = it
}
}*/
}
return binding.root
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<data>

<import type="androidx.core.content.ContextCompat" />

<variable
name="fragment"
type="com.github.sweet.play.update.SweetPlayAppUpdaterBottomSheet" />
Expand All @@ -21,6 +23,10 @@
name="description"
type="String" />

<variable
name="bsBackground"
type="Integer" />

</data>

<androidx.constraintlayout.widget.ConstraintLayout
Expand All @@ -33,10 +39,11 @@
android:id="@+id/ivBackground"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/shp_header_background"
android:background="@{ContextCompat.getDrawable(context, bsBackground)}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:background="@color/blue_start" />

<ImageView
android:id="@+id/imageView3"
Expand Down Expand Up @@ -107,16 +114,25 @@
app:layout_constraintTop_toBottomOf="@+id/tvUpdateAvailable"
tools:text="@string/sweet_app_update_available_message" />

<View
android:id="@+id/view"
android:layout_width="wrap_content"
android:layout_height="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvUpdateAvailableMessage" />

<LinearLayout
android:id="@+id/llUpdateAction"
android:layout_width="match_parent"
android:layout_height="0dp"
android:animateLayoutChanges="true"
android:gravity="center"
android:paddingBottom="24dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvUpdateAvailableMessage">
app:layout_constraintTop_toBottomOf="@+id/view">

<com.google.android.material.button.MaterialButton
android:id="@+id/btnLater"
Expand All @@ -143,6 +159,7 @@
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="24dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -174,8 +191,8 @@
android:layout_gravity="center"
android:animateLayoutChanges="true"
android:gravity="center"
android:paddingBottom="24dp"
android:orientation="vertical"
android:paddingBottom="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/llUpdateDownloadProgress">
Expand All @@ -200,19 +217,19 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_padding_16dp"
android:layout_weight="1"
android:text="@string/checking_for_update"/>
android:text="@string/checking_for_update" />

</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/btnCancel"
style="@style/SweetButtonStyle.BorderedOutlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color"
style="@style/MaterialButtonStyle.Bordered"
android:onClick="@{() -> fragment.dismiss()}"
android:text="@string/cancel"
android:textAllCaps="false" />
android:textAllCaps="false"
android:textColor="@color/text_color" />

</LinearLayout>

Expand All @@ -223,21 +240,21 @@
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
android:paddingBottom="24dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/llCheckingUpdate">

<com.google.android.material.button.MaterialButton
android:id="@+id/btnOk"
style="@style/SweetButtonStyle.BorderedOutlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_padding_8dp"
android:textColor="@color/text_color"
style="@style/MaterialButtonStyle.Bordered"
android:onClick="@{() -> fragment.dismiss()}"
android:text="@string/ok"
android:textAllCaps="false" />
android:textAllCaps="false"
android:textColor="@color/text_color" />

</LinearLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<item name="cornerSize">50%</item>
</style>

<style name="MaterialButtonStyle.Bordered" parent="Widget.MaterialComponents.Button.OutlinedButton">
<style name="SweetButtonStyle.BorderedOutlined" parent="Widget.MaterialComponents.Button.OutlinedButton">
<item name="android:layout_height">48dp</item>
<item name="android:insetTop">0dp</item>
<item name="android:insetBottom">0dp</item>
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.github.sweet.play.update.demo"
minSdkVersion 19
targetSdkVersion 30
versionCode 34
versionName "1.34"
versionCode 2
versionName "1.1"

vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class MainActivity : AppCompatActivity() {
SweetPlayAppUpdaterBottomSheet.newInstant(
"App Update Available",
"We have fixed some issues and added some cool feature in this update",
R.drawable.ic_android_black_24dp
R.drawable.ic_android_black_24dp,
null,
R.drawable.shp_header_background
).apply { isCancelable = false }
.show(supportFragmentManager, "Check Update")
}
Expand Down

0 comments on commit ffc2d21

Please sign in to comment.