Skip to content

Commit 5d650de

Browse files
author
Daniel Quah
committed
Add initial fancy announcement
1 parent 7ae0415 commit 5d650de

5 files changed

Lines changed: 57 additions & 9 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5+
<uses-permission android:name="android.permission.INTERNET" />
6+
57
<application
68
android:allowBackup="true"
79
android:dataExtractionRules="@xml/data_extraction_rules"
@@ -10,8 +12,8 @@
1012
android:label="@string/app_name"
1113
android:roundIcon="@mipmap/ic_launcher_round"
1214
android:supportsRtl="true"
13-
android:theme="@style/Theme.AndroidGuideBlocks"
1415
tools:targetApi="31">
16+
1517
</application>
1618

1719
</manifest>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.contextu.al.fancyannouncement
2+
3+
import android.app.Activity
4+
import android.content.DialogInterface
5+
import android.view.Window
6+
import androidx.appcompat.app.AlertDialog
7+
import com.contextu.al.R
8+
9+
class FancyAnnouncementGuideBlocks(private val activity: Activity) {
10+
11+
fun show(title: String, content: String, negativeText: String, negativeButtonListener: DialogInterface.OnClickListener,
12+
positiveText: String, positiveButtonListener: DialogInterface.OnClickListener, imageUrl: String){
13+
// val view = activity.layoutInflater.inflate(R.layout.fancy_annoucenment, null, true)
14+
//val viewGroup = (activity.findViewById(android.R.id.content) as ViewGroup).getChildAt(0) as ViewGroup
15+
val alertDialog = AlertDialog.Builder(activity)
16+
.setTitle(title)
17+
.setMessage(content)
18+
.setNegativeButton(negativeText, negativeButtonListener)
19+
.setPositiveButton(positiveText, positiveButtonListener)
20+
.create()
21+
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
22+
alertDialog.setContentView(R.layout.fancy_announcement)
23+
alertDialog.show()
24+
// val fancyAnnouncementImage = alertDialog.findViewById<ImageView>(R.id.announcementImage)
25+
// fancyAnnouncementImage?.let {
26+
// Glide.with(activity.baseContext).load(imageUrl).into(fancyAnnouncementImage)
27+
// }
28+
// val fancyAnnouncementTitle = alertDialog.findViewById<TextView>(R.id.fancy_announcement_title)
29+
// fancyAnnouncementTitle?.text = title
30+
// val fancyAnnouncementContent = alertDialog.findViewById<TextView>(R.id.fancy_announcement_message)
31+
// fancyAnnouncementContent?.text = content
32+
// val imageView = view.findViewById<ImageView>(R.id.fancy_announcement_imageview)
33+
// viewGroup.addView(imageView)
34+
// Glide.with(activity.baseContext).load(imageUrl).into(imageView)
35+
36+
}
37+
}

app/src/main/res/layout/fancy_annoucenment.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
xmlns:app="http://schemas.android.com/apk/res-auto">
6+
7+
<ImageView
8+
android:id="@+id/announcementImage"
9+
android:layout_width="80dp"
10+
android:layout_height="80dp"
11+
app:layout_constraintTop_toTopOf="parent"
12+
app:layout_constraintStart_toStartOf="parent"
13+
app:layout_constraintEnd_toEndOf="parent"
14+
/>
15+
16+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/themes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33

4-
<style name="Theme.AndroidGuideBlocks" parent="android:Theme.Material.Light.NoActionBar" />
4+
<style name="Theme.AndroidGuideBlocks" parent="Theme.AppCompat.Light" />
55
</resources>

0 commit comments

Comments
 (0)