Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readd getters for TextView #232

Merged
merged 2 commits into from
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

## 6.1.0 - 27/06/2020
* Readded getters for title & text TextView

## 6.0.0 - 27/06/2020
* Support custom sound

Expand Down
2 changes: 1 addition & 1 deletion alerter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ apply from: rootProject.file('quality.gradle')

final String GROUP_ID = "com.tapadoo.android"

final String VERSION = "6.0.0"
final String VERSION = "6.1.0"

final String DESCRIPTION = "An Android Alerting Library"
final String GITHUB_URL = "https://github.com/Tapadoo/Alerter"
Expand Down
23 changes: 19 additions & 4 deletions alerter/src/main/java/com/tapadoo/alerter/Alert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.view.animation.AnimationUtils
import android.widget.Button
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.*
import androidx.appcompat.content.res.AppCompatResources
import androidx.appcompat.view.ContextThemeWrapper
Expand Down Expand Up @@ -77,7 +78,7 @@ class Alert @JvmOverloads constructor(context: Context,
/**
* Uri to set sound
*/
private var soundUri : Uri? = null
private var soundUri: Uri? = null

/**
* Sets the Layout Gravity of the Alert
Expand Down Expand Up @@ -632,9 +633,9 @@ class Alert @JvmOverloads constructor(context: Context,
*/
fun setRightIconPosition(position: Int) {
if (position == Gravity.TOP
|| position == Gravity.CENTER
|| position == Gravity.CENTER_VERTICAL
|| position == Gravity.BOTTOM) {
|| position == Gravity.CENTER
|| position == Gravity.CENTER_VERTICAL
|| position == Gravity.BOTTOM) {
flRightIconContainer.layoutParams = (flRightIconContainer.layoutParams as LinearLayout.LayoutParams).apply {
gravity = position
}
Expand Down Expand Up @@ -780,6 +781,20 @@ class Alert @JvmOverloads constructor(context: Context,
}
}

/**
* @return the TextView for the title
*/
fun getTitle(): TextView {
return tvTitle
}

/**
* @return the TextView for the text
*/
fun getText(): TextView {
return tvText
}

override fun canDismiss(): Boolean {
return isDismissible
}
Expand Down
28 changes: 21 additions & 7 deletions app/src/main/java/com/tapadoo/alerter/demo/JavaDemoActivity.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.tapadoo.alerter.demo;

import android.graphics.Color;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

import com.tapadoo.alerter.Alert;
import com.tapadoo.alerter.Alerter;
import com.tapadoo.alerter.OnHideAlertListener;
import com.tapadoo.alerter.OnShowAlertListener;
Expand Down Expand Up @@ -72,13 +75,15 @@ public void onClick(View view) {
showAlertWithProgress();
} else if (i == com.tapadoo.alerter.demo.R.id.btnAlertWithCustomFont) {
showAlertWithCustomFont();
} else if (i == com.tapadoo.alerter.demo.R.id.btnAlertWithCustomColor) {
showAlertWithCustomColor();
} else if (i == com.tapadoo.alerter.demo.R.id.btnAlertSwipeToDismissEnabled) {
showAlertSwipeToDismissEnabled();
} else if (i == com.tapadoo.alerter.demo.R.id.btnAlertSound){
} else if (i == com.tapadoo.alerter.demo.R.id.btnAlertSound) {
showAlertSound();
}else if (i == com.tapadoo.alerter.demo.R.id.btnCenterAlert){
} else if (i == com.tapadoo.alerter.demo.R.id.btnCenterAlert) {
showAlertFromCenter();
}else if (i == com.tapadoo.alerter.demo.R.id.btnBottomAlert){
} else if (i == com.tapadoo.alerter.demo.R.id.btnBottomAlert) {
showAlertFromBottom();
} else {
showAlertDefault();
Expand Down Expand Up @@ -133,12 +138,12 @@ private void showAlertVerbose() {
Alerter.create(JavaDemoActivity.this)
.setTitle("Alert Title")
.setText("The alert scales to accommodate larger bodies of text. " +
"The alert scales to accommodate larger bodies of text. " +
"The alert scales to accommodate larger bodies of text.")
"The alert scales to accommodate larger bodies of text. " +
"The alert scales to accommodate larger bodies of text.")
.show();
}

private void showAlertCallbacks(){
private void showAlertCallbacks() {
Alerter.create(JavaDemoActivity.this)
.setTitle("Alert Title")
.setText("Alert text...")
Expand Down Expand Up @@ -186,6 +191,15 @@ private void showAlertWithCustomFont() {
.show();
}

private void showAlertWithCustomColor() {
Alert alert = Alerter.create(JavaDemoActivity.this)
.setTitle("Yellow Alert Title")
.setText("Red Alert text...")
.show();
alert.getTitle().setTextColor(Color.YELLOW);
alert.getText().setTextColor(Color.RED);
}

private void showAlertSwipeToDismissEnabled() {
Alerter.create(JavaDemoActivity.this)
.setTitle("Alert Title")
Expand Down Expand Up @@ -227,7 +241,7 @@ private void showAlertSound() {
.setTitle("Alert Title")
.setText("Alert text...")
.setBackgroundColorRes(R.color.colorAccent)
.setSound(Uri.parse("android.resource://"+getPackageName()+"/raw/ringtone"))
.setSound(Uri.parse("android.resource://" + getPackageName() + "/raw/ringtone"))
.show();
}

Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/tapadoo/alerter/demo/KotlinDemoActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tapadoo.alerter.demo

import android.graphics.Color
import android.graphics.Typeface
import android.net.Uri
import android.os.Bundle
Expand Down Expand Up @@ -122,6 +123,15 @@ class KotlinDemoActivity : AppCompatActivity() {
.show()
}

private fun showAlertWithCustomColor() {
var alert = Alerter.create(this@KotlinDemoActivity)
.setTitle("Yellow Alert Title")
.setText("Red Alert text...")
.show()
alert?.getTitle()?.setTextColor(Color.YELLOW)
alert?.getText()?.setTextColor(Color.RED)
}

private fun showAlertSwipeToDismissEnabled() {
Alerter.create(this@KotlinDemoActivity)
.setTitle("Alert Title")
Expand Down Expand Up @@ -265,6 +275,10 @@ class KotlinDemoActivity : AppCompatActivity() {
showAlertWithCustomFont()
}

btnAlertWithCustomColor.setOnClickListener {
showAlertWithCustomColor()
}

btnAlertSwipeToDismissEnabled.setOnClickListener {
showAlertSwipeToDismissEnabled()
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/content_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
android:layout_height="wrap_content"
android:text="@string/custom_font" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnAlertWithCustomColor"
style="@style/ExampleButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/custom_color" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnAlertSwipeToDismissEnabled"
style="@style/ExampleButton"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<string name="infinite_alert">Infinity Duration Alert</string>
<string name="progress_alert">Progress Alert</string>
<string name="custom_font">Custom Font</string>
<string name="custom_color">Custom Color</string>
<string name="swipe_to_dismiss">Swipe To Dismiss Alert</string>
<string name="custom_enter_exit_animations">Custom Enter/Exit Animations</string>
<string name="with_buttons">With Buttons</string>
Expand Down