-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display release notes in new update dialog
- Loading branch information
1 parent
00ad05f
commit 21106fa
Showing
8 changed files
with
253 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/src/main/java/tk/therealsuji/vtopchennai/fragments/dialogs/UpdateDialogFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package tk.therealsuji.vtopchennai.fragments.dialogs; | ||
|
||
import android.app.Dialog; | ||
import android.os.Bundle; | ||
import android.text.Html; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.Window; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.fragment.app.DialogFragment; | ||
|
||
import io.noties.markwon.Markwon; | ||
import tk.therealsuji.vtopchennai.R; | ||
import tk.therealsuji.vtopchennai.helpers.SettingsRepository; | ||
|
||
public class UpdateDialogFragment extends DialogFragment { | ||
String versionName, releaseNotes; | ||
|
||
public UpdateDialogFragment() { | ||
// Required empty public constructor | ||
} | ||
|
||
public UpdateDialogFragment(String versionName, String releaseNotes) { | ||
this.versionName = versionName; | ||
this.releaseNotes = releaseNotes; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
View dialogFragment = inflater.inflate(R.layout.layout_dialog_update, container, false); | ||
|
||
TextView description = dialogFragment.findViewById(R.id.text_view_description); | ||
description.setText(Html.fromHtml(this.requireContext().getString(R.string.update_message, this.versionName), Html.FROM_HTML_MODE_LEGACY)); | ||
|
||
TextView releaseNotes = dialogFragment.findViewById(R.id.text_view_release_notes); | ||
Markwon markwon = Markwon.create(this.requireContext()); | ||
markwon.setMarkdown(releaseNotes, this.releaseNotes); | ||
|
||
dialogFragment.findViewById(R.id.button_cancel).setOnClickListener(view -> this.dismiss()); | ||
dialogFragment.findViewById(R.id.button_update).setOnClickListener(view -> SettingsRepository.openDownloadPage(this.requireContext())); | ||
|
||
return dialogFragment; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { | ||
Dialog dialog = super.onCreateDialog(savedInstanceState); | ||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
return dialog; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="#000000" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M23,12l-2.44,-2.78 0.34,-3.68 -3.61,-0.82 -1.89,-3.18L12,3 8.6,1.54 6.71,4.72l-3.61,0.81 0.34,3.68L1,12l2.44,2.78 -0.34,3.69 3.61,0.82 1.89,3.18L12,21l3.4,1.46 1.89,-3.18 3.61,-0.82 -0.34,-3.68L23,12zM18.49,14.11l0.26,2.79 -2.74,0.62 -1.43,2.41L12,18.82l-2.58,1.11 -1.43,-2.41 -2.74,-0.62 0.26,-2.8L3.66,12l1.85,-2.12 -0.26,-2.78 2.74,-0.61 1.43,-2.41L12,5.18l2.58,-1.11 1.43,2.41 2.74,0.62 -0.26,2.79L20.34,12l-1.85,2.11zM11,15h2v2h-2zM11,7h2v6h-2z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="?android:colorBackground" | ||
android:fitsSystemWindows="true"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_margin="20dp" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/text_view_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:drawablePadding="10dp" | ||
android:text="@string/update_title" | ||
android:textSize="25sp" | ||
android:textStyle="bold" | ||
app:drawableStartCompat="@drawable/ic_update_available" | ||
app:drawableTint="?attr/colorPrimary" /> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_marginVertical="20dp" | ||
android:layout_weight="1"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/text_view_description" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/update_message" | ||
android:textSize="16sp" /> | ||
|
||
<TextView | ||
android:id="@+id/text_view_release_notes" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="20dp" | ||
android:textSize="16sp" /> | ||
</LinearLayout> | ||
</ScrollView> | ||
|
||
<Button | ||
android:id="@+id/button_update" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingVertical="15dp" | ||
android:text="@string/download_update" /> | ||
|
||
<Button | ||
android:id="@+id/button_cancel" | ||
style="@style/Widget.Material3.Button.OutlinedButton" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="5dp" | ||
android:paddingVertical="15dp" | ||
android:text="@string/cancel_update" /> | ||
</LinearLayout> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters