Remove module

This commit is contained in:
Nezumi
2023-05-17 16:46:08 +07:00
parent 8fa9e1c759
commit 95e6f35543
239 changed files with 18 additions and 9190 deletions
-3
View File
@@ -11,10 +11,7 @@
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/SJDialog" />
<option value="$PROJECT_DIR$/aestheticdialogs" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/popupDialog" />
</set>
</option>
</GradleProjectSettings>
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.6.20" />
</component>
</project>
+1
View File
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
-1
View File
@@ -1 +0,0 @@
/build
-147
View File
@@ -1,147 +0,0 @@
# BasicDialog Documentation
Create dialog example
```java
BasicDialog dialog = new BasicDialog();
dialog.Builder(context)
.setTitle("Title")
.setLeftButtonText("button1")
.setRightButtonText("button2")
.onButtonClick(() -> {
// Do something
})
.show();
```
![BasicDialog example](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/BasicDialog%20example%201.png)
## Builder
Apply the default theme to a dialog
```java
dialog.Builder(context)
```
![BasicDialog day-night](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/BasicDialog%20day-night.png)
Apply the app theme to a dialog **(only works with material3 theme)**
```java
dialog.Builder(context,true)
```
Apply the custom theme to a dialog **(only works with material3 theme)**
```java
dialog.Builder(context,theme)
```
## Old Dialog theme
By default dialog colors will be set to material3 dynamic colors. With this method you can set the dialog color for the background and buttons to the older non-dynamic colors
```java
dialog.setOldTheme();
```
![BasicDialog oldTheme](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/BasicDialog%20oldTheme.png)
## Add onClick Listener
onClickListener for right button. The left button is for dismissing dialog
```java
dialog.onButtonClick(new DialogButtonEvent() {
@Override
public void onButtonClick() {
// Do something
}
});
//or
dialog.onButtonClick(() -> {
// Do something
});
```
onClickListener for left and right button
```java
dialog.onButtonClick(new DialogButtonEvents() {
@Override
public void onLeftButtonClick() {
// Do something
}
@Override
public void onRightButtonClick() {
// Do something
}
});
```
## All BasicDialog Methods
```java
//Create dialog
dialog.Builder(context);
//Usin the old dialog theme
dialog.setOldTheme();
//Set title
dialog.setTitle("Title");
//Set message
dialog.setMessage("Message");
//Set title text alignment
dialog.setTitleAlignment(TextAlignment);
//Set message text alignment
dialog.setMessageAlignment(TextAlignment);
//Set left button text
dialog.setLeftButtonText("Text");
//Set right button text
dialog.setRightButtonText("Text");
//Set text color
dialog.setTextColor(color);
//Set title text color
dialog.setTitleTextColor(color);
//Set message text color
dialog.setMessageTextColor(color);
//Set buttons color
dialog.setButtonsColor(color);
//Set left button color
dialog.setLeftButtonColor(color);
//Set right button color
dialog.setRightButtonColor(color);
//Set buttons text color
dialog.setButtonsTextColor(color);
//Set text color for left button
dialog.setLeftButtonTextColor(color);
//Set text color for right button
dialog.setRightButtonTextColor(color);
//Set buttons background resource
dialog.setButtonsBackgroundResource(drawable);
//Set left button background resource
dialog.setLeftButtonBackgroundResource(drawable);
//Set right button background resource
dialog.setRightButtonBackgroundResource(drawable);
//Set dialog color
dialog.setDialogBackgroundColor(color);
//Set dialog background resource
dialog.setDialogBackgroundResource(drawable);
//Set maximum dialog width. Default is 600dp
dialog.setMaxDialogWidth(width);
//Get maximum dialog width
int dialogWidth = dialog.getMaxDialogWidth();
//Get left button
Button leftButton = dialog.getLeftButton();
//Get right button
Button rightButton = dialog.getRightButton();
//Set dialog animations
dialog.setDialogAnimations(styleRes);
//Enable or disable swipe down to dismiss dialog.
//By default is set to true
dialog.swipeToDismiss(boolean);
//Set dialog onTouchListener.
//This method will overide swipe down to dismiss action
dialog.setOnTouchListener(onTouchListener);
//Shew dialog
dialog.show();
//Dismiss dialog
dialog.dismiss();
```
-200
View File
@@ -1,200 +0,0 @@
# CustomViewDialog Documentation
## Examples
#### Add button example
```java
Button button1 = new Button(this);
button1.setText("Button");
CustomViewDialog customViewDialog = new CustomViewDialog();
customViewDialog.Builder(this)
.setTitle("Title")
.addCustomView(button1)
.show();
```
![CustomViewDialog example 1](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/CustomViewDialog%20example%201.png)
#### Add EditText example
```java
EditText editText = new EditText(this);
editText.setHint("add text");
CustomViewDialog customViewDialog = new CustomViewDialog();
customViewDialog.Builder(this)
.setTitle("Title")
.dialogWithTwoButtons()
.addCustomView(editText)
.onButtonClick(() -> {
String text = editText.getText().toString();
// Do something
})
.show();
```
![CustomViewDialog example 2](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/CustomViewDialog%20example%202.png)
#### Add custom xml layout example
```java
View view = LayoutInflater.from(this).inflate(R.layout.custon_layout,null);
CustomViewDialog customViewDialog = new CustomViewDialog();
customViewDialog.Builder(this)
.setTitle("Title")
.dialogWithTwoButtons()
.addCustomView(view)
.show();
```
![CustomViewDialog example 3](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/CustomViewDialog%20example%203.png)
## Builder
Apply the default theme to a dialog
```java
customViewDialog.Builder(context)
```
![CustomViewDialog day-night](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/CustomViewDialog%20day-night.png)
Apply the app theme to a dialog **(only works with material3 theme)**
```java
customViewDialog.Builder(context,true)
```
Apply the custom theme to a dialog **(only works with material3 theme)**
```java
customViewDialog.Builder(context,theme)
```
## Dialog with two buttons
```java
customViewDialog.dialogWithTwoButtons();
```
## Old Dialog theme
By default dialog colors will be set to material3 dynamic colors. With this method you can set the dialog color for the background and buttons to the older non-dynamic colors
```java
customViewDialog.setOldTheme();
```
![CustomViewDialog oldTheme](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/CustomViewDialog%20oldTheme.png)
## Add View
```java
customViewDialog.addCustomView(view);
```
## Add onClick Listener
onClickListener for the right button if the dialog has [two buttons](#dialog-with-two-buttons), the left button is for dismissing dialog. If the dialog has only one button, onClickListener will be set to that button.
```java
customViewDialog.onButtonClick(new DialogButtonEvent() {
@Override
public void onButtonClick() {
// Do something
}
});
//or
customViewDialog.onButtonClick(() -> {
// Do something
});
```
onClickListener for left and right button (only works when dialog has [two buttons](#dialog-with-two-buttons))
```java
customViewDialog.onButtonClick(new DialogButtonEvents() {
@Override
public void onLeftButtonClick() {
// Do something
}
@Override
public void onRightButtonClick() {
// Do something
}
});
```
## All CustomViewDialog Methods
```java
//Create dialog
customViewDialog.Builder(context);
//Create dialog width two buttons
customViewDialog.dialogWithTwoButtons();
//Usin the old dialog theme
customViewDialog.setOldTheme();
//Set title
customViewDialog.setTitle("Title");
//Set message
customViewDialog.setMessage("Message");
//Set title text alignment
customViewDialog.setTitleAlignment(TextAlignment);
//Set message text alignment
customViewDialog.setMessageAlignment(TextAlignment);
//Set text color
customViewDialog.setTextColor(color);
//Set title text color
customViewDialog.setTitleTextColor(color);
//Set message text color
customViewDialog.setMessageTextColor(color);
//Set button text (one button dialog)
customViewDialog.setButtonText("Text");
//Set left button text
customViewDialog.setLeftButtonText("Text");
//Set right button text
customViewDialog.setRightButtonText("Text");
//Set buttons color
customViewDialog.setButtonsColor(color);
//Set button color (one button dialog)
customViewDialog.setButtonColor(color);
//Set left button color
customViewDialog.setLeftButtonColor(color);
//Set right button color
customViewDialog.setRightButtonColor(color);
//Set buttons text color
customViewDialog.setButtonsTextColor(color);
//Set text color a button (one button dialog)
customViewDialog.setButtonTextColor(color);
//Set text color for left button
customViewDialog.setLeftButtonTextColor(color);
//Set text color for right button
customViewDialog.setRightButtonTextColor(color);
//Set buttons background resource
customViewDialog.setButtonsBackgroundResource(drawable);
//Set button background resource (one button dialog)
customViewDialog.setButtonBackgroundResource(drawable);
//Set left button background resource
customViewDialog.setLeftButtonBackgroundResource(drawable);
//Set right button background resource
customViewDialog.setRightButtonBackgroundResource(drawable);
//Set dialog color
customViewDialog.setDialogBackgroundColor(color);
//Set dialog background resource
customViewDialog.setDialogBackgroundResource(drawable);
//Add Custom view
customViewDialog.addCustomView(view);
//Set maximum dialog width. Default is 600dp
customViewDialog.setMaxDialogWidth(width);
//Get maximum dialog width
int dialogWidth = customViewDialog.getMaxDialogWidth();
//Get left button
Button leftButton = customViewDialog.getLeftButton();
//Get right button
Button rightButton = customViewDialog.getRightButton();
//Set dialog animations
customViewDialog.setDialogAnimations(styleRes);
//Enable or disable swipe down to dismiss dialog.
//By default is set to true
dialog.swipeToDismiss(boolean);
//Set dialog onTouchListener.
//This method will overide swipe down to dismiss action
dialog.setOnTouchListener(onTouchListener);
//Shew dialog
customViewDialog.show();
//Dismiss dialog
customViewDialog.dismiss();
```
-428
View File
@@ -1,428 +0,0 @@
# ListDialog Documentation
## Examples
#### List of String array
```java
String[] strings = {"item1","item2","item3"};
ListDialog listDialog = new ListDialog();
listDialog.Builder(this)
.setItems(strings,(position, value) -> {
// Do something
})
.show();
```
![ListDialog example 1](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/ListDialog%20example%201.png)
#### List of Objects
```java
class ExampleObject{
String value;
public ExampleObject(String value) {
this.value = value;
}
}
```
```java
ExampleObject[] objects = {new ExampleObject("object1"),new ExampleObject("object2"),new ExampleObject("object3")};
ListDialog listDialog = new ListDialog();
listDialog.Builder(this)
.setItems(
objects,
obj -> obj.value, // get value from object
(position, value) -> {
// Do something
})
.show();
```
![ListDialog example 2](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/ListDialog%20example%202.png)
#### ArrayList of Objects with two values
```java
class ExampleObject{
String value1;
String value2;
public ExampleObject(String value1, String value2) {
this.value1 = value1;
this.value2 = value2;
}
}
```
```java
ArrayList<ExampleObject> arrayList = new ArrayList<>();
arrayList.add(new ExampleObject("object1","value1"));
arrayList.add(new ExampleObject("object2","value2"));
arrayList.add(new ExampleObject("object3","value3"));
ListDialog listDialog = new ListDialog();
listDialog.Builder(this)
.setItems(
arrayList,
new ListItemValues<ExampleObject>() {
@Override
public String getValue1(ExampleObject obj) {
return obj.value1;
}
@Override
public String getValue2(ExampleObject obj) {
return obj.value2;
}
},
(position, value) -> {
// Do something
})
.show();
```
![ListDialog example 3](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/ListDialog%20example%203.png)
#### Selecting multiple items in a list
```java
ArrayList<String> stringArrayList = new ArrayList<>();
stringArrayList.add("item1");
stringArrayList.add("item2");
stringArrayList.add("item3");
ListDialog listDialog = new ListDialog();
listDialog.Builder(this)
.dialogWithTwoButtons()
.setSelectableList()
.setItems(stringArrayList,obj -> obj)
.onButtonClick(() -> {
ArrayList<ExampleObject> selectedItems = listDialog.getSelectedItems();
// Do something
})
.show();
```
![ListDialog example 4](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/ListDialog%20example%204.png)
## Builder
Apply the default theme to a dialog
```java
listDialog.Builder(context)
```
![ListDialog day-night](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/ListDialog%20day-night.png)
Apply the app theme to a dialog **(only works with material3 theme)**
```java
listDialog.Builder(context,true)
```
Apply the custom theme to a dialog **(only works with material3 theme)**
```java
listDialog.Builder(context,theme)
```
## Dialog with two buttons
```java
listDialog.dialogWithTwoButtons();
```
## Old Dialog theme
By default dialog colors will be set to material3 dynamic colors. With this method you can set the dialog color for the background and buttons to the older non-dynamic colors
```java
listDialog.setOldTheme();
```
![ListDialog oldTheme](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/ListDialog%20oldTheme.png)
## Select multiple items in a list
```java
listDialog.setSelectableList();
```
## Add items in a list
You can add item in a list by setting [ReciclerView Adapter](#set-reciclerview-adapter), using [setItems()](#setitems) method or using [setImageItems()](#setimageitems) method for list with icons.
### Set ReciclerView Adapter
```java
listDialog.setAdapter(recyclerViewAdapter);
```
### setItems
This method uses [DefaultListAdapter](/SJDialog/src/main/java/com/sjapps/library/customdialog/adapter/DefaultListAdapter.java) for array of Strings or [DefaultListAdapterGeneric](/SJDialog/src/main/java/com/sjapps/library/customdialog/adapter/DefaultListAdapterGeneric.java) for array of Objects or ArrayList.
#### Array of Strings
You need to use [setSelectableList()](#select-multiple-items-in-a-list) firstly or add [onListItemClick](#array-of-strings-and-onlistitemclick)
```java
listDialog.setItems(strings);
```
#### Array of Strings and onListItemClick
```java
listDialog.setItems(strings,(position, value) -> {
// Do something
});
```
#### Array of Objects
You need to use [setSelectableList()](#select-multiple-items-in-a-list) firstly or add [onListItemClick](#array-of-objects-and-onlistitemclick)
```java
listDialog.setItems(objects, new ListItemValue<ExampleObject>() {
@Override
public String getValue(ExampleObject obj) {
return obj.value; // get value of an Object
}
});
//or
listDialog.setItems(objects,obj -> obj.value);
```
#### Array of Objects and onListItemClick
```java
listDialog.setItems(objects,obj -> obj.value,(position, obj) -> {
// Do something
});
```
#### Array of Objects with two values
You need to use [setSelectableList()](#select-multiple-items-in-a-list) firstly or add [onListItemClick](#array-of-objects-with-two-values-and-onlistitemclick)
```java
listDialog.setItems(objects, new ListItemValues<ExampleObject>() {
@Override
public String getValue1(ExampleObject obj) {
return obj.value1;
}
@Override
public String getValue2(ExampleObject obj) {
return obj.value2;
}
});
```
#### Array of Objects with two values and onListItemClick
```java
listDialog.setItems(objects, new ListItemValues<ExampleObject>() {
@Override
public String getValue1(ExampleObject obj) {
return obj.value1;
}
@Override
public String getValue2(ExampleObject obj) {
return obj.value2;
}
},(position, obj) -> {
// Do something
});
```
#### ArrayList
You need to use [setSelectableList()](#select-multiple-items-in-a-list) firstly or add [onListItemClick](#arraylist-and-onlistitemclick)
```java
listDialog.setItems(arrayList,obj -> obj.value);
```
#### ArrayList and onListItemClick
```java
listDialog.setItems(arrayList,obj -> obj.value,(position, obj) -> {
// Do something
});
```
#### ArrayList with two values
You need to use [setSelectableList()](#select-multiple-items-in-a-list) firstly or add [onListItemClick](#arraylist-with-two-values-and-onlistitemclick)
```java
listDialog.setItems(arrayList, new ListItemValues<ExampleObject>() {
@Override
public String getValue1(ExampleObject obj) {
return obj.value1;
}
@Override
public String getValue2(ExampleObject obj) {
return obj.value2;
}
});
```
#### ArrayList with two values and onListItemClick
```java
listDialog.setItems(arrayList, new ListItemValues<ExampleObject>() {
@Override
public String getValue1(ExampleObject obj) {
return obj.value1;
}
@Override
public String getValue2(ExampleObject obj) {
return obj.value2;
}
},(position, obj) -> {
// Do something
});
```
### setImageItems
Creating ArrayList of [ImageListItem](/SJDialog/src/main/java/com/sjapps/library/customdialog/ImageListItem.java)
```java
ArrayList<ImageListItem> listItems = new ArrayList<>();
listItems.add(new ImageListItem("item1", drawable1));
// or adding data of type Object
listItems.add(new ImageListItem("item2", drawable2,data));
```
#### ArrayList of ImageListItem
You need to use [setSelectableList()](#select-multiple-items-in-a-list) firstly or add [onListItemClick](#arraylist-of-two-imagelistitem-and-onlistitemclick)
```java
listDialog.setImageItems(listItems);
```
#### ArrayList of ImageListItem and onListItemClick
```java
listDialog.setImageItems(listItems, (position, obj) -> {
// Do something
});
```
## Set RecyclerView LayoutManager
```java
listDialog.setLayoutManager(layoutManager);
```
## Add onClick Listener
onClickListener for the right button if the dialog has [two buttons](#dialog-with-two-buttons), the left button is for dismissing dialog. If the dialog has only one button, onClickListener will be set to that button.
```java
listDialog.onButtonClick(new DialogButtonEvent() {
@Override
public void onButtonClick() {
// Do something
}
});
//or
listDialog.onButtonClick(() -> {
// Do something
});
```
onClickListener for left and right button (only works when dialog has [two buttons](#dialog-with-two-buttons))
```java
listDialog.onButtonClick(new DialogButtonEvents() {
@Override
public void onLeftButtonClick() {
// Do something
}
@Override
public void onRightButtonClick() {
// Do something
}
});
```
## All ListDialog Methods
```java
//Create dialog
listDialog.Builder(context);
//Create dialog width two buttons
listDialog.dialogWithTwoButtons();
//Usin the old dialog theme
listDialog.setOldTheme();
//Set title
listDialog.setTitle("Title");
//Set message
listDialog.setMessage("Message");
//Set title text alignment
listDialog.setTitleAlignment(TextAlignment);
//Set message text alignment
listDialog.setMessageAlignment(TextAlignment);
//Set text color
listDialog.setTextColor(color);
//Set title text color
listDialog.setTitleTextColor(color);
//Set message text color
listDialog.setMessageTextColor(color);
//Set button text (one button dialog)
listDialog.setButtonText("Text");
//Set left button text
listDialog.setLeftButtonText("Text");
//Set right button text
listDialog.setRightButtonText("Text");
//Set buttons color
listDialog.setButtonsColor(color);
//Set button color (one button dialog)
listDialog.setButtonColor(color);
//Set left button color
listDialog.setLeftButtonColor(color);
//Set right button color
listDialog.setRightButtonColor(color);
//Set buttons text color
listDialog.setButtonsTextColor(color);
//Set text color a button (one button dialog)
listDialog.setButtonTextColor(color);
//Set text color for left button
listDialog.setLeftButtonTextColor(color);
//Set text color for right button
listDialog.setRightButtonTextColor(color);
//Set buttons background resource
listDialog.setButtonsBackgroundResource(drawable);
//Set button background resource (one button dialog)
listDialog.setButtonBackgroundResource(drawable);
//Set left button background resource
listDialog.setLeftButtonBackgroundResource(drawable);
//Set right button background resource
listDialog.setRightButtonBackgroundResource(drawable);
//Set dialog color
listDialog.setDialogBackgroundColor(color);
//Set dialog background resource
listDialog.setDialogBackgroundResource(drawable);
//Selecting multiple items in a list
listDialog.setSelectableList();
//Set text color of an items in a list
listDialog.setListItemTextColor(color);
//Set a background resource for items in a list
listDialog.setListItemBackgroundResource(drawable);
//Set a background resource for selected items in a list
listDialog.setListItemSelectedBackgroundResource(drawable);
//Set a background resource of a list
listDialog.setListBackgroundResource(drawable);
//Get list item background resource
int ItemBgRes = listDialog.getListItemBgRes();
//Get list item selected background resource
int ItemBgResSelected = listDialog.getListItemBgResSelected();
//set RecyclerView Adapter
listDialog.setAdapter(recyclerViewAdapter);
//Set Layout Manager
listDialog.setLayoutManager(layoutManager);
//Add items in a list
listDialog.setItems(strings);
listDialog.setItems(strings, listItemClick);
listDialog.setItems(objects, listItemValue);
listDialog.setItems(objects, listItemValue, listItemClickObj);
listDialog.setItems(objects, listItemValues);
listDialog.setItems(objects, listItemValues, listItemClickObj);
listDialog.setItems(arrayList, listItemValue);
listDialog.setItems(arrayList, listItemValue, listItemClickObj);
listDialog.setItems(arrayList, listItemValues);
listDialog.setItems(arrayList, listItemValues, listItemClickObj);
listDialog.setImageItems(listItems);
listDialog.setImageItems(listItems, listItemClickObj);
//Hide 'List is empty' text
listDialog.hideEmptyListText();
//Change empty list text
listDialog.setEmptyListText("text");
//Set maximum dialog width. Default is 600dp
listDialog.setMaxDialogWidth(width);
//Get maximum dialog width
int dialogWidth = listDialog.getMaxDialogWidth();
//Get left button
Button leftButton = listDialog.getLeftButton();
//Get right button
Button rightButton = listDialog.getRightButton();
//Set dialog animations
listDialog.setDialogAnimations(styleRes);
//Enable or disable swipe down to dismiss dialog.
//By default is set to true
dialog.swipeToDismiss(boolean);
//Set dialog onTouchListener.
//This method will overide swipe down to dismiss action
dialog.setOnTouchListener(onTouchListener);
//Shew dialog
listDialog.show();
//Dismiss dialog
listDialog.dismiss();
```
-112
View File
@@ -1,112 +0,0 @@
# MessageDialog Documentation
Message dialog example
```java
MessageDialog messageDialog = new MessageDialog();
messageDialog.Builder(context)
.setTitle("Title")
.setMessage("Message")
.show();
```
![MessageDialog example](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/MessageDialog%20example.png)
## Builder
Apply the default theme to a dialog
```java
messageDialog.Builder(context)
```
![MessageDialog day-night](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/MessageDialog%20day-night.png)
Apply the app theme to a dialog **(only works with material3 theme)**
```java
messageDialog.Builder(context,true)
```
Apply the custom theme to a dialog **(only works with material3 theme)**
```java
messageDialog.Builder(context,theme)
```
## Old Dialog theme
By default dialog colors will be set to material3 dynamic colors. With this method you can set the dialog color for the background and buttons to the older non-dynamic colors
```java
messageDialog.setOldTheme();
```
![MessageDialog oldTheme](https://raw.githubusercontent.com/SlaVcE14/SJ-Dialog/master/SJDialog/images/MessageDialog%20oldTheme.png)
## Add onClick Listener
```java
messageDialog.onButtonClick(new DialogButtonEvent() {
@Override
public void onButtonClick() {
// Do something
}
});
//or
messageDialog.onButtonClick(() -> {
// Do something
});
```
## All MessageDialog Methods
```java
//Create dialog
messageDialog.Builder(context);
//Usin the old dialog theme
messageDialog.setOldTheme();
//Set title
messageDialog.setTitle("Title");
//Set message
messageDialog.setMessage("Message");
//Set title text alignment
messageDialog.setTitleAlignment(TextAlignment);
//Set message text alignment
messageDialog.setMessageAlignment(TextAlignment);
//Set button text
messageDialog.setButtonText("Text");
//Set text color
messageDialog.setTextColor(color);
//Set title text color
messageDialog.setTitleTextColor(color);
//Set message text color
messageDialog.setMessageTextColor(color);
//Set button color
messageDialog.setButtonColor(color);
//Set button text color
messageDialog.setButtonTextColor(color);
//Set button background resource
messageDialog.setButtonBackgroundResource(drawable);
//Set dialog color
messageDialog.setDialogBackgroundColor(color);
//Set dialog background resource
messageDialog.setDialogBackgroundResource(drawable);
//Set maximum dialog width. Default is 600dp
messageDialog.setMaxDialogWidth(width);
//Get maximum dialog width
int dialogWidth = messageDialog.getMaxDialogWidth();
//Get button
Button Button = messageDialog.getButton();
//Set dialog animations
messageDialog.setDialogAnimations(styleRes);
//Enable or disable swipe down to dismiss dialog.
//By default is set to true
dialog.swipeToDismiss(boolean);
//Set dialog onTouchListener.
//This method will overide swipe down to dismiss action
dialog.setOnTouchListener(onTouchListener);
//Shew dialog
messageDialog.show();
//Dismiss dialog
messageDialog.dismiss();
```
-39
View File
@@ -1,39 +0,0 @@
plugins {
id 'com.android.library'
}
android {
compileSdk 31
defaultConfig {
minSdk 23
versionCode 20
versionName "1.6"
buildConfigField 'int', 'VERSION_CODE', "${versionCode}"
buildConfigField 'String', 'VERSION_NAME', "\"${versionName}\""
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_9
targetCompatibility JavaVersion.VERSION_1_9
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

-21
View File
@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -1,26 +0,0 @@
package com.sjapps.library;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.sjapps.library.test", appContext.getPackageName());
}
}
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sjapps.library">
</manifest>
@@ -1,437 +0,0 @@
package com.sjapps.library.customdialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.StyleRes;
import com.sjapps.library.R;
/**@since 1.6*/
@SuppressWarnings("unused")
public class BasicDialog extends SJDialog{
@Deprecated
public static final String LONG_TYPE = "long";
@Deprecated
public static final String SHORT_TYPE = "short";
private boolean isDeleteDialog;
public BasicDialog(){
twoButtons = true;
}
/** @since 1.4*/
public BasicDialog Short(Context context, String Title){
return Short(context,Title,null);
}
/** @since 1.0*/
public BasicDialog Short(Context context, String Title, String Btn1Txt, String Btn2Txt){
return Builder(context,Title,null,Btn1Txt,Btn2Txt);
}
/** @since 1.0*/
public BasicDialog Short(Context context, String Title, String Btn2Txt){
return Short(context,Title,null,Btn2Txt);
}
/** @since 1.4*/
public BasicDialog Long(Context context, String Title, String Message){
return Long(context,Title,Message,null);
}
/** @since 1.0*/
public BasicDialog Long(Context context, String Title, String Text, String Btn1Txt, String Btn2Txt){
return Builder(context,Title,Text,Btn1Txt,Btn2Txt);
}
/** @since 1.0*/
public BasicDialog Long(Context context, String Title, String Text, String Btn2Txt){
return Long(context,Title,Text,null,Btn2Txt);
}
/** @since 1.0*/
public BasicDialog Delete(Context context, String Title){
return Builder(context,Title,null,null,null).deleteAttributes();
}
/** @since 1.0*/
public BasicDialog Delete(Context context){
return Builder(context).deleteAttributes();
}
public BasicDialog Delete(Context context, int theme){
return Builder(context,theme).deleteAttributes();
}
public BasicDialog Delete(Context context, boolean useAppTheme){
return Builder(context,useAppTheme).deleteAttributes();
}
private BasicDialog deleteAttributes(){
isDeleteDialog = true;
return setTitle("Delete?")
.setRightButtonColor(MATERIAL3_RED_BUTTON)
.setRightButtonText("Delete");
}
/**
* @deprecated Use {@link BasicDialog#Builder(Context)}
* */
@Deprecated(since = "1.6")
public BasicDialog DialogBuilder(Context context){
return Builder(context);
}
/**
* @deprecated Use {@link BasicDialog#Builder(Context, boolean)}
* @since 1.6
*/
@Deprecated
public BasicDialog DialogBuilder(Context context, boolean useAppTheme){
return Builder(context, useAppTheme);
}
/**
* @deprecated Use {@link BasicDialog#Builder(Context, int)}
*/
@Deprecated(since = "1.6")
public BasicDialog DialogBuilder(Context context, int theme){
return Builder(context,theme);
}
/**
* @deprecated Dialog type is automatic. Use {@link BasicDialog#Builder(Context)}
* @since 1.3
*/
@Deprecated(since = "1.4")
public BasicDialog DialogBuilder(Context context, String dialogType){
return Builder(context);
}
/**
* @deprecated Use {@link BasicDialog#Builder(Context, String, String, String, String)}
* @since 1.0
*/
@Deprecated(since = "1.6")
public BasicDialog DialogBuilder(Context context, String Title, String Text, String Btn1Txt, String Btn2Txt){
return Builder(context,Title,Text,Btn1Txt,Btn2Txt);
}
public BasicDialog Builder(Context context){
super.Builder(context,R.layout.basic_dialog);
return this;
}
public BasicDialog Builder(Context context, boolean useAppTheme){
super.Builder(context,R.layout.basic_dialog,useAppTheme);
return this;
}
public BasicDialog Builder(Context context,@StyleRes int theme){
super.Builder(context,R.layout.basic_dialog,theme,false);
return this;
}
public BasicDialog Builder(Context context, String Title, String Text, String Btn1Txt, String Btn2Txt){
super.Builder(context,R.layout.basic_dialog);
TextView TitleTv = dialog.findViewById(R.id.titleText);
if (Btn1Txt == null) {
button1.setOnClickListener(v -> dialog.dismiss());
}else button1.setText(Btn1Txt);
if (Btn2Txt != null) {
button2.setText(Btn2Txt);
}
if (Text != null){
setMessage(Text);
}
if (Title == null){
return this;
}
TitleTv.setText(Title);
return this;
}
/**
* Set a dialog type.
* @param dialogType type of a dialog. Supported types: {@link #SHORT_TYPE} and {@link #LONG_TYPE}
* @return current class
* @deprecated Old method, not in use. Remove this.
* @since 1.4
* */
@Deprecated
public BasicDialog setDialogType(String dialogType){
//Nothing here!!
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public BasicDialog setOldTheme(){
super.setOldTheme();
if (isDeleteDialog)
super.setRightButtonColor(RED_BUTTON);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public BasicDialog setTitle(String title){
super.setTitle(title);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public BasicDialog setMessage(String message){
super.setMessage(message);
return this;
}
/**
* {@inheritDoc}
* @since 1.6
* */
@Override
public BasicDialog setTitleAlignment(int textAlignment) {
super.setTitleAlignment(textAlignment);
return this;
}
/**
* {@inheritDoc}
* @since 1.6
* */
@Override
public BasicDialog setMessageAlignment(int textAlignment) {
super.setMessageAlignment(textAlignment);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public BasicDialog setTextColor(int color) {
super.setTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public BasicDialog setTitleTextColor(int color) {
super.setTitleTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public BasicDialog setMessageTextColor(int color) {
super.setMessageTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setLeftButtonText(String text){
super.setLeftButtonText(text);
return this;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setRightButtonText(String text){
super.setRightButtonText(text);
return this;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setButtonsTextColor(@ColorInt int color){
super.setButtonsTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setLeftButtonTextColor(@ColorInt int color){
super.setLeftButtonTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setRightButtonTextColor(@ColorInt int color){
super.setRightButtonTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setButtonsColor(@ColorInt int color){
super.setButtonsColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setLeftButtonColor(@ColorInt int color){
super.setLeftButtonColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setRightButtonColor(@ColorInt int color){
super.setRightButtonColor(color);
return this;
}
@Override
public BasicDialog setButtonsColor(@ButtonColor String color){
super.setButtonsColor(color);
return this;
}
@Override
public BasicDialog setLeftButtonColor(@ButtonColor String color){
super.setLeftButtonColor(color);
return this;
}
@Override
public BasicDialog setRightButtonColor(@ButtonColor String color){
super.setRightButtonColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public BasicDialog setDialogBackgroundColor(int color) {
super.setDialogBackgroundColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public BasicDialog setDialogBackgroundResource(@DrawableRes int drawable){
super.setDialogBackgroundResource(drawable);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public BasicDialog setButtonsBackgroundResource(@DrawableRes int drawable){
super.setButtonsBackgroundResource(drawable);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public BasicDialog setLeftButtonBackgroundResource(@DrawableRes int drawable){
super.setLeftButtonBackgroundResource(drawable);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public BasicDialog setRightButtonBackgroundResource(@DrawableRes int drawable){
super.setRightButtonBackgroundResource(drawable);
return this;
}
/**{@inheritDoc}
* @since 1.0*/
@Override
public BasicDialog onButtonClick(DialogButtonEvent dialogButtonEvent){
super.onButtonClick(dialogButtonEvent);
return this;
}
/**{@inheritDoc}
* @since 1.0*/
@Override
public BasicDialog onButtonClick(DialogButtonEvents dialogButtonEvents) {
super.onButtonClick(dialogButtonEvents);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public BasicDialog show() {
super.show();
return this;
}
@Override
protected int setButtonsRootLayoutID() {
return R.id.buttons;
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public BasicDialog setMaxDialogWidth(int maxDialogWidth) {
super.setMaxDialogWidth(maxDialogWidth);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public BasicDialog setOnTouchListener(View.OnTouchListener onTouchListener) {
super.setOnTouchListener(onTouchListener);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public BasicDialog swipeToDismiss(boolean isSwipeToDismiss) {
super.swipeToDismiss(isSwipeToDismiss);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public BasicDialog setDialogAnimations(int styleRes) {
super.setDialogAnimations(styleRes);
return this;
}
@Override
protected void setButtons() {
setButton1(R.id.btn1);
setButton2(R.id.btn2);
}
@Override
public Button getLeftButton() {
return super.getLeftButton();
}
@Override
public Button getRightButton() {
return super.getRightButton();
}
/**@since 1.6*/
@Override
public TextView getTitleTextView() {
return super.getTitleTextView();
}
/**@since 1.6*/
@Override
public TextView getMessageTextView() {
return super.getMessageTextView();
}
}
@@ -1,393 +0,0 @@
package com.sjapps.library.customdialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.StyleRes;
import com.sjapps.library.R;
/**@since 1.5*/
@SuppressWarnings("unused")
public class CustomViewDialog extends SJDialog{
private LinearLayout rootView;
public CustomViewDialog(){
}
public CustomViewDialog Builder(Context context){
return Builder(context,false);
}
public CustomViewDialog Builder(Context context,@StyleRes int theme){
super.Builder(context,R.layout.custom_view_dialog,theme, false);
rootView = dialog.findViewById(R.id.customViewRoot);
onLeftButtonClick(dialog::dismiss);
return this;
}
public CustomViewDialog Builder(Context context,boolean useAppTheme){
super.Builder(context,R.layout.custom_view_dialog,useAppTheme);
rootView = dialog.findViewById(R.id.customViewRoot);
onLeftButtonClick(dialog::dismiss);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setOldTheme(){
super.setOldTheme();
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setTitle(String title){
super.setTitle(title);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setMessage(String message) {
super.setMessage(message);
return this;
}
/**
* {@inheritDoc}
* @since 1.6
* */
@Override
public CustomViewDialog setTitleAlignment(int textAlignment) {
super.setTitleAlignment(textAlignment);
return this;
}
/**
* {@inheritDoc}
* @since 1.6
* */
@Override
public CustomViewDialog setMessageAlignment(int textAlignment) {
super.setMessageAlignment(textAlignment);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setTextColor(int color) {
super.setTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public CustomViewDialog setTitleTextColor(int color) {
super.setTitleTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public CustomViewDialog setMessageTextColor(int color) {
super.setMessageTextColor(color);
return this;
}
/**
* Set a button text.
* @param text button text
* @return current class
* @since 1.5
* */
public CustomViewDialog setButtonText(String text){
return setLeftButtonText(text);
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setLeftButtonText(String text){
super.setLeftButtonText(text);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setRightButtonText(String text){
super.setRightButtonText(text);
return this;
}
/**
* Set button text color.
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.5
* */
public CustomViewDialog setButtonTextColor(@ColorInt int color){
return setLeftButtonTextColor(color);
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setButtonsTextColor(@ColorInt int color){
super.setButtonsTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setLeftButtonTextColor(@ColorInt int color){
super.setLeftButtonTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setRightButtonTextColor(@ColorInt int color){
super.setRightButtonTextColor(color);
return this;
}
/**
* Set button color.
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.5
* */
public CustomViewDialog setButtonColor(@ColorInt int color){
return setLeftButtonColor(color);
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setButtonsColor(@ColorInt int color){
super.setButtonsColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setLeftButtonColor(@ColorInt int color){
super.setLeftButtonColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setRightButtonColor(@ColorInt int color){
super.setRightButtonColor(color);
return this;
}
@Override
public CustomViewDialog setButtonColor(@ButtonColor String color) {
super.setButtonColor(color);
return this;
}
@Override
public CustomViewDialog setButtonsColor(@ButtonColor String color){
super.setButtonsColor(color);
return this;
}
@Override
public CustomViewDialog setLeftButtonColor(@ButtonColor String color){
super.setLeftButtonColor(color);
return this;
}
@Override
public CustomViewDialog setRightButtonColor(@ButtonColor String color){
super.setRightButtonColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public CustomViewDialog setDialogBackgroundColor(int color) {
super.setDialogBackgroundColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setDialogBackgroundResource(@DrawableRes int drawable){
super.setDialogBackgroundResource(drawable);
return this;
}
/**
* Set background resource for button.
* @param drawable resource id
* @return current class
* @since 1.5
* */
public CustomViewDialog setButtonBackgroundResource(@DrawableRes int drawable){
return setLeftButtonBackgroundResource(drawable);
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setButtonsBackgroundResource(@DrawableRes int drawable){
super.setButtonsBackgroundResource(drawable);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setLeftButtonBackgroundResource(@DrawableRes int drawable){
super.setLeftButtonBackgroundResource(drawable);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setRightButtonBackgroundResource(@DrawableRes int drawable){
super.setRightButtonBackgroundResource(drawable);
return this;
}
/**
* Set onClick listener for a button
*
* @param dialogButtonEvent dialog button event
* @return current class
* @since 1.5
*/
@Override
public CustomViewDialog onButtonClick(DialogButtonEvent dialogButtonEvent){
if (twoButtons)
super.onButtonClick(dialogButtonEvent);
else
super.onLeftButtonClick(dialogButtonEvent);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog onButtonClick(DialogButtonEvents dialogButtonEvents) {
super.onButtonClick(dialogButtonEvents);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog show() {
super.show();
return this;
}
@Override
protected int setButtonsRootLayoutID() {
return R.id.buttons;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setMaxDialogWidth(int maxDialogWidth) {
super.setMaxDialogWidth(maxDialogWidth);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog setDialogAnimations(int styleRes) {
super.setDialogAnimations(styleRes);
return this;
}
@Override
protected void setButtons() {
setButton1(R.id.btn1);
setButton2(R.id.btn2);
}
@Override
public Button getLeftButton() {
return super.getLeftButton();
}
@Override
public Button getRightButton() {
return super.getRightButton();
}
/**@since 1.6*/
@Override
public TextView getTitleTextView() {
return super.getTitleTextView();
}
/**@since 1.6*/
@Override
public TextView getMessageTextView() {
return super.getMessageTextView();
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public CustomViewDialog dialogWithTwoButtons() {
super.dialogWithTwoButtons();
setButton2Visibility(View.VISIBLE);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public CustomViewDialog setOnTouchListener(View.OnTouchListener onTouchListener) {
super.setOnTouchListener(onTouchListener);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public CustomViewDialog swipeToDismiss(boolean isSwipeToDismiss) {
super.swipeToDismiss(isSwipeToDismiss);
return this;
}
@Override
public void setButton2Visibility(int visibility) {
super.setButton2Visibility(visibility);
}
public CustomViewDialog addCustomView(View view){
rootView.addView(view);
return this;
}
}
@@ -1,5 +0,0 @@
package com.sjapps.library.customdialog;
public interface DialogButtonEvent {
void onButtonClick();
}
@@ -1,7 +0,0 @@
package com.sjapps.library.customdialog;
public interface DialogButtonEvents {
void onLeftButtonClick();
void onRightButtonClick();
}
@@ -1,57 +0,0 @@
package com.sjapps.library.customdialog;
import android.graphics.drawable.Drawable;
public class ImageListItem {
private String name;
private Drawable image;
private Object data;
public ImageListItem() {
}
public ImageListItem(String name, Drawable image) {
this.name = name;
this.image = image;
}
public ImageListItem(String name, Drawable image, Object data) {
this.name = name;
this.image = image;
this.data = data;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Drawable getImage() {
return image;
}
public void setImage(Drawable image) {
this.image = image;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
@Override
public String toString() {
return "ImageListItem{" +
"name='" + name + '\'' +
", image=" + image +
", data=" + data +
'}';
}
}
@@ -1,931 +0,0 @@
package com.sjapps.library.customdialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.sjapps.library.R;
import com.sjapps.library.customdialog.adapter.DefaultImageListAdapter;
import com.sjapps.library.customdialog.adapter.DefaultListAdapter;
import com.sjapps.library.customdialog.adapter.DefaultListAdapterGeneric;
import com.sjapps.library.customdialog.list.events.ListItemClick;
import com.sjapps.library.customdialog.list.events.ListItemClickObj;
import java.util.ArrayList;
/**@since 1.5*/
@SuppressWarnings({"unused", "unchecked","UnusedReturnValue"})
public class ListDialog extends SJDialog {
RecyclerView listRV;
boolean isSelectableList = false;
boolean hideEmptyListTxt = false;
boolean hasAdapter = false;
boolean waitForLayoutManager = false;
private @DrawableRes int listItemBgRes = R.drawable.ripple_list;
private @DrawableRes int listItemBgResSelected = R.drawable.ripple_list_selected;
private @ColorInt int listItemBgColor = -1;
private @ColorInt int listItemBgColorSelected = -1;
private int listItemTextColor = 1;
private RecyclerView.LayoutManager layoutManager = null;
RecyclerView.Adapter<?> adapter;
ArrayList<?> selectedItems = new ArrayList<>();
TextView emptyListTxt;
public ListDialog() {
}
public ListDialog Builder(Context context) {
return Builder(context, false);
}
public ListDialog Builder(Context context, @StyleRes int theme) {
super.Builder(context, R.layout.list_dialog, theme, false);
listRV = dialog.findViewById(R.id.list);
onLeftButtonClick(dialog::dismiss);
emptyListTxt = dialog.findViewById(R.id.emptyListTxt);
return this;
}
public ListDialog Builder(Context context, boolean useAppTheme) {
super.Builder(context, R.layout.list_dialog, useAppTheme);
listRV = dialog.findViewById(R.id.list);
onLeftButtonClick(dialog::dismiss);
emptyListTxt = dialog.findViewById(R.id.emptyListTxt);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setOldTheme() {
super.setOldTheme();
setListOldColor();
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setTitle(String title) {
super.setTitle(title);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setMessage(String message) {
super.setMessage(message);
return this;
}
/**
* {@inheritDoc}
* @since 1.6
* */
@Override
public ListDialog setTitleAlignment(int textAlignment) {
super.setTitleAlignment(textAlignment);
return this;
}
/**
* {@inheritDoc}
* @since 1.6
* */
@Override
public ListDialog setMessageAlignment(int textAlignment) {
super.setMessageAlignment(textAlignment);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public ListDialog setTextColor(int color) {
super.setTextColor(color);
setListItemTextColor(color);
setEmptyListTxtColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public ListDialog setTitleTextColor(int color) {
super.setTitleTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public ListDialog setMessageTextColor(int color) {
super.setMessageTextColor(color);
return this;
}
/**
* Set a button text.
*
* @param text button text
* @return current class
* @since 1.5
*/
public ListDialog setButtonText(String text) {
return setLeftButtonText(text);
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setLeftButtonText(String text) {
super.setLeftButtonText(text);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setRightButtonText(String text) {
super.setRightButtonText(text);
return this;
}
/**
* Set button text color.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.5
*/
public ListDialog setButtonTextColor(@ColorInt int color) {
return setLeftButtonTextColor(color);
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setButtonsTextColor(@ColorInt int color) {
super.setButtonsTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setLeftButtonTextColor(@ColorInt int color) {
super.setLeftButtonTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setRightButtonTextColor(@ColorInt int color) {
super.setRightButtonTextColor(color);
return this;
}
/**
* Set button color.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.5
*/
public ListDialog setButtonColor(@ColorInt int color) {
return setLeftButtonColor(color);
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setButtonsColor(@ColorInt int color) {
super.setButtonsColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setLeftButtonColor(@ColorInt int color) {
super.setLeftButtonColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setRightButtonColor(@ColorInt int color) {
super.setRightButtonColor(color);
return this;
}
@Override
public ListDialog setButtonColor(@ButtonColor String color) {
super.setButtonColor(color);
return this;
}
@Override
public ListDialog setButtonsColor(@ButtonColor String color) {
super.setButtonsColor(color);
return this;
}
@Override
public ListDialog setLeftButtonColor(@ButtonColor String color) {
super.setLeftButtonColor(color);
return this;
}
@Override
public ListDialog setRightButtonColor(@ButtonColor String color) {
super.setRightButtonColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public ListDialog setDialogBackgroundColor(int color) {
super.setDialogBackgroundColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setDialogBackgroundResource(@DrawableRes int drawable) {
super.setDialogBackgroundResource(drawable);
return this;
}
/**
* Set background resource for button.
*
* @param drawable resource id
* @return current class
* @since 1.5
*/
public ListDialog setButtonBackgroundResource(@DrawableRes int drawable) {
return setLeftButtonBackgroundResource(drawable);
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setButtonsBackgroundResource(@DrawableRes int drawable) {
super.setButtonsBackgroundResource(drawable);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setLeftButtonBackgroundResource(@DrawableRes int drawable) {
super.setLeftButtonBackgroundResource(drawable);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setRightButtonBackgroundResource(@DrawableRes int drawable) {
super.setRightButtonBackgroundResource(drawable);
return this;
}
/**
* Set onClick listener for a button
*
* @param dialogButtonEvent dialog button event
* @return current class
* @since 1.5
*/
@Override
public ListDialog onButtonClick(DialogButtonEvent dialogButtonEvent) {
if (twoButtons)
super.onButtonClick(dialogButtonEvent);
else
super.onLeftButtonClick(dialogButtonEvent);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog onButtonClick(DialogButtonEvents dialogButtonEvents) {
super.onButtonClick(dialogButtonEvents);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog show() {
if (layoutManager == null)
layoutManager = new LinearLayoutManager(context);
if (!waitForLayoutManager)
listRV.setLayoutManager(layoutManager);
listRV.setAdapter(adapter);
if (adapter == null)
checkListsSize(0);
super.show();
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setMaxDialogWidth(int maxDialogWidth) {
super.setMaxDialogWidth(maxDialogWidth);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog setDialogAnimations(int styleRes) {
super.setDialogAnimations(styleRes);
return this;
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public ListDialog dialogWithTwoButtons() {
super.dialogWithTwoButtons();
setButton2Visibility(View.VISIBLE);
return this;
}
@Override
public void setButton2Visibility(int visibility) {
super.setButton2Visibility(visibility);
}
private void setListOldColor() {
listItemBgRes = R.drawable.ripple_list_old;
listItemBgResSelected = R.drawable.ripple_list_selected_old;
}
/**
* Set background resource for a list
*
* @param drawable drawable resource
* @return current class
* @since 1.5
*/
public ListDialog setListBackgroundResource(@DrawableRes int drawable) {
listRV.setBackgroundResource(drawable);
return this;
}
/**
* Set background resource for a item in a list
*
* @param drawable drawable resource
* @return current class
* @since 1.5
*/
public ListDialog setListItemBackgroundResource(@DrawableRes int drawable) {
listItemBgRes = drawable;
return this;
}
/**
* Set background resource for a selected item in a list
*
* @param drawable drawable resource
* @return current class
* @since 1.5
*/
public ListDialog setListItemSelectedBackgroundResource(@DrawableRes int drawable) {
listItemBgResSelected = drawable;
return this;
}
/**
* Set background color for a item in a list
*
* @param color {@link ColorInt}
* @return current class
* @since 1.6
*/
public ListDialog setListItemBackgroundColor(@ColorInt int color) {
listItemBgColor = color;
return this;
}
/**
* Set background color for a selected item in a list
*
* @param color {@link ColorInt}
* @return current class
* @since 1.6
*/
public ListDialog setListItemSelectedBackgroundColor(@ColorInt int color) {
listItemBgColorSelected = color;
return this;
}
/**
* Set text color for item in a list
*
* @param listItemTextColor color for a text
* @return current class
* @since 1.6
*/
public ListDialog setListItemTextColor(int listItemTextColor) {
this.listItemTextColor = listItemTextColor;
return this;
}
private void setEmptyListTxtColor(int color) {
emptyListTxt.setTextColor(color);
}
/**
* Hide {@link #emptyListTxt} when list is empty
* @since 1.6
* @return current class
*/
public ListDialog hideEmptyListText() {
hideEmptyListTxt = true;
return this;
}
/**
* Set text to display when list is empty
* @param text Text
* @since 1.6
* @return current class
*/
public ListDialog setEmptyListText(String text){
emptyListTxt.setText(text);
return this;
}
/**
* Get a dialog list
*
* @return dialog list
* @since 1.5
*/
public RecyclerView getRecycleView() {
return listRV;
}
@Override
protected int setButtonsRootLayoutID() {
return R.id.buttons;
}
@Override
protected void setButtons() {
setButton1(R.id.btn1);
setButton2(R.id.btn2);
}
@Override
public Button getLeftButton() {
return super.getLeftButton();
}
@Override
public Button getRightButton() {
return super.getRightButton();
}
/**@since 1.6*/
@Override
public TextView getTitleTextView() {
return super.getTitleTextView();
}
/**@since 1.6*/
@Override
public TextView getMessageTextView() {
return super.getMessageTextView();
}
/**
* Set items for a list
*
* @param listOfItems Array of {@link String}
* @return current class
* @since 1.5
*/
public ListDialog setItems(String[] listOfItems) {
return setItems(listOfItems, (ListItemClick) null);
}
/**
* Set items for a list and ListItemClick event
*
* @param listOfItems Array of {@link String}
* @param itemClick ListItemClick event
* @return current class
* @since 1.5
*/
public ListDialog setItems(String[] listOfItems, @Nullable ListItemClick itemClick) {
if (hasAdapter)
throw tooManyAdapters;
if (!isSelectableList && itemClick == null)
throw nullListItemClick(ListItemClick.class);
checkListsSize(listOfItems.length);
adapter = new DefaultListAdapter(listOfItems,
isSelectableList,
itemClick,
(ArrayList<String>) selectedItems,
listItemBgRes,
listItemBgResSelected,
listItemTextColor,
listItemBgColor,
listItemBgColorSelected);
hasAdapter = true;
return this;
}
/**
* Set items for a list and String value of an object for use in a list
*
* @param objArray Array of {@link Object}
* @param value {@link ListItemValue} for getting String value of an object
* @param <T> Type of an Object
* @return current class
* @since 1.5
*/
public <T> ListDialog setItems(T[] objArray, ListItemValue<T> value) {
return setItems(objArray, value, null);
}
/**
* Set items for a list and String values of an object for use in a list
*
* @param objArray Array of {@link Object}
* @param values {@link ListItemValues} for getting String values of an object. {@link ListItemValues#getValue1(Object)}
* for first value and {@link ListItemValues#getValue1(Object)} for second value
* @param <T> Type of an Object
* @return current class
* @since 1.5
*/
public <T> ListDialog setItems(T[] objArray, ListItemValues<T> values) {
return setItems(objArray, values, null);
}
/**
* Set items for a list and String value of an object for use in a list
*
* @param arrayList {@link ArrayList} of {@link Object}
* @param value {@link ListItemValue} for getting String value of an object
* @param <T> Type of an Object
* @return current class
* @since 1.5
*/
public <T> ListDialog setItems(ArrayList<T> arrayList, ListItemValue<T> value) {
return setItems(arrayList, value, null);
}
/**
* Set items for a list and String values of an object for use in a list
*
* @param arrayList {@link ArrayList} of {@link Object}
* @param values {@link ListItemValues} for getting String values of an object. {@link ListItemValues#getValue1(Object)}
* for first value and {@link ListItemValues#getValue1(Object)} for second value
* @param <T> Type of an Object
* @return current class
* @since 1.5
*/
public <T> ListDialog setItems(ArrayList<T> arrayList, ListItemValues<T> values) {
return setItems(arrayList, values, null);
}
/**
* Set items for a list, String value of an object for use in a list and ListItemClick event
*
* @param objArray Array of {@link Object}
* @param value {@link ListItemValue} for getting String value of an object
* @param itemClick ListItemClick event
* @param <T> Type of an Object
* @return current class
* @since 1.5
*/
public <T> ListDialog setItems(T[] objArray, ListItemValue<T> value, @Nullable ListItemClickObj<T> itemClick) {
if (hasAdapter)
throw tooManyAdapters;
if (!isSelectableList && itemClick == null)
throw nullListItemClick(ListItemClickObj.class);
checkListsSize(objArray.length);
adapter = new DefaultListAdapterGeneric<>(objArray,
value,
isSelectableList,
itemClick,
(ArrayList<T>) selectedItems,
listItemBgRes,
listItemBgResSelected,
listItemTextColor,
listItemBgColor,
listItemBgColorSelected);
hasAdapter = true;
return this;
}
/**
* Set items for a list, String values of an object for use in a list and ListItemClick event
*
* @param objArray Array of {@link Object}
* @param values {@link ListItemValues} for getting String values of an object. {@link ListItemValues#getValue1(Object)}
* for first value and {@link ListItemValues#getValue1(Object)} for second value
* @param itemClick ListItemClick event
* @param <T> Type of an Object
* @return current class
* @since 1.5
*/
public <T> ListDialog setItems(T[] objArray, ListItemValues<T> values, @Nullable ListItemClickObj<T> itemClick) {
if (hasAdapter)
throw tooManyAdapters;
if (!isSelectableList && itemClick == null)
throw nullListItemClick(ListItemClickObj.class);
checkListsSize(objArray.length);
adapter = new DefaultListAdapterGeneric<>(objArray,
values,
isSelectableList,
itemClick,
(ArrayList<T>) selectedItems,
listItemBgRes,
listItemBgResSelected,
listItemTextColor,
listItemBgColor,
listItemBgColorSelected);
hasAdapter = true;
return this;
}
/**
* Set items for a list, String value of an object for use in a list and ListItemClick event
*
* @param arrayList {@link ArrayList} of {@link Object}
* @param value {@link ListItemValue} for getting String value of an object
* @param itemClick ListItemClick event
* @param <T> Type of an Object
* @return current class
* @since 1.5
*/
public <T> ListDialog setItems(ArrayList<T> arrayList, ListItemValue<T> value, @Nullable ListItemClickObj<T> itemClick) {
if (hasAdapter)
throw tooManyAdapters;
if (!isSelectableList && itemClick == null)
throw nullListItemClick(ListItemClickObj.class);
checkListsSize(arrayList.size());
adapter = new DefaultListAdapterGeneric<>(arrayList,
value,
isSelectableList,
itemClick,
(ArrayList<T>) selectedItems,
listItemBgRes,
listItemBgResSelected,
listItemTextColor,
listItemBgColor,
listItemBgColorSelected);
hasAdapter = true;
return this;
}
/**
* Set items for a list, String values of an object for use in a list and ListItemClick event
*
* @param arrayList {@link ArrayList} of {@link Object}
* @param values {@link ListItemValues} for getting String values of an object. {@link ListItemValues#getValue1(Object)}
* for first value and {@link ListItemValues#getValue1(Object)} for second value
* @param itemClick ListItemClick event
* @param <T> Type of an Object
* @return current class
* @since 1.5
*/
public <T> ListDialog setItems(ArrayList<T> arrayList, ListItemValues<T> values, @Nullable ListItemClickObj<T> itemClick) {
if (hasAdapter)
throw tooManyAdapters;
if (!isSelectableList && itemClick == null)
throw nullListItemClick(ListItemClickObj.class);
checkListsSize(arrayList.size());
adapter = new DefaultListAdapterGeneric<>(arrayList,
values,
isSelectableList,
itemClick,
(ArrayList<T>) selectedItems,
listItemBgRes,
listItemBgResSelected,
listItemTextColor,
listItemBgColor,
listItemBgColorSelected);
hasAdapter = true;
return this;
}
/**
* Set image items for a list
* @param arrayList {@link ArrayList} of {@link ImageListItem}
* @return current class
* @since 1.6
*/
public ListDialog setImageItems(ArrayList<ImageListItem> arrayList) {
return setImageItems(arrayList, null);
}
/**
* Set image items for a list and ListItemClick event
* @param arrayList {@link ArrayList} of {@link ImageListItem}
* @param itemClick ListItemClick event
* @return current class
* @since 1.6
*/
public ListDialog setImageItems(ArrayList<ImageListItem> arrayList, @Nullable ListItemClickObj<ImageListItem> itemClick) {
if (hasAdapter)
throw tooManyAdapters;
if (!isSelectableList && itemClick == null)
throw nullListItemClick(ListItemClickObj.class);
checkListsSize(arrayList.size());
adapter = new DefaultImageListAdapter(arrayList,
isSelectableList,
itemClick,
(ArrayList<ImageListItem>) selectedItems,
listItemBgRes,
listItemBgResSelected,
listItemTextColor,
listItemBgColor,
listItemBgColorSelected);
hasAdapter = true;
waitForLayoutManager = true;
listRV.post(() -> {
int maxItemCount = listRV.getWidth() / functions.dpToPixels(context,80);
if (maxItemCount == 0)
maxItemCount = 1;
setLayoutManager(new GridLayoutManager(context, arrayList.size()!=0 ? Math.min(maxItemCount, arrayList.size()):1));
listRV.setLayoutManager(layoutManager);
waitForLayoutManager = false;
});
return this;
}
/**
* Set a list adapter
*
* @param adapter RecycleView {@link RecyclerView.Adapter adapter}
* @return current class
* @since 1.5
*/
public ListDialog setAdapter(RecyclerView.Adapter<?> adapter) {
if (hasAdapter)
throw tooManyAdapters;
this.adapter = adapter;
hasAdapter = true;
return this;
}
/**
* @param layoutManager {@link RecyclerView.LayoutManager LayoutManager }
* @return current class
* @since 1.6
*/
public ListDialog setLayoutManager(RecyclerView.LayoutManager layoutManager) {
this.layoutManager = layoutManager;
return this;
}
/**
* Get a list adapter
*
* @return current class
* @since 1.5
*/
public RecyclerView.Adapter<?> getListAdapter() {
return adapter;
}
/**
* @return Background resource for views in RecycleView
* @since 1.5
*/
public int getListItemBgRes() {
return listItemBgRes;
}
/**
* @return Background resource for selected views in RecycleView
* @since 1.5
*/
public int getListItemBgResSelected() {
return listItemBgResSelected;
}
/**
* Create list with multi selectable items. Use {@link #getSelectedItems()} fet getting selected items
*
* @return current class
* @since 1.5
*/
public ListDialog setSelectableList() {
isSelectableList = true;
return this;
}
public boolean isSelectableList() {
return isSelectableList;
}
@Override
public ListDialog setOnTouchListener(View.OnTouchListener onTouchListener) {
super.setOnTouchListener(onTouchListener);
return this;
}
@Override
public ListDialog swipeToDismiss(boolean isSwipeToDismiss) {
super.swipeToDismiss(isSwipeToDismiss);
return this;
}
/**
* Get selected items in a list
*
* @return ArrayList of selected items in a list
* @since 1.5
*/
public <T> ArrayList<T> getSelectedItems() {
return (ArrayList<T>) selectedItems;
}
void checkListsSize(int size) {
if (hideEmptyListTxt) {
emptyListTxt.setVisibility(View.GONE);
return;
}
emptyListTxt.setVisibility((size > 0) ? View.GONE : View.VISIBLE);
}
@SuppressWarnings("rawtypes")
private NullPointerException nullListItemClick(Class className) {
return new NullPointerException(
String.format("%s is null. Set %s event or use setSelectableList() for selecting multiple item in a list",
className.getSimpleName(),
className.getSimpleName())
);
}
private final UnsupportedOperationException tooManyAdapters = new UnsupportedOperationException("Too many Adapters for RecyclerView");
}
@@ -1,19 +0,0 @@
package com.sjapps.library.customdialog;
import android.graphics.drawable.Drawable;
public interface ListItemImageValue<T> {
/**
* Get String value of an Object for using in a list
* @param obj Current Object for getting first String value of it
* @return String value
*/
String getTitle(T obj);
/**
* Get Drawable value of an Object for use in a list item
* @param obj Current Object for getting second String value of it
* @return Drawable
*/
Drawable getImage(T obj);
}
@@ -1,10 +0,0 @@
package com.sjapps.library.customdialog;
public interface ListItemValue<T> {
/**
* Get String value of an Object for using in a list
* @param obj Current Object for getting String value of it
* @return String value
*/
String getValue(T obj);
}
@@ -1,17 +0,0 @@
package com.sjapps.library.customdialog;
public interface ListItemValues<T> {
/**
* Get String value of an Object for use in the first value of a list item
* @param obj Current Object for getting first String value of it
* @return String value
*/
String getValue1(T obj);
/**
* Get String value of an Object for use in the second value of a list item
* @param obj Current Object for getting second String value of it
* @return String value
*/
String getValue2(T obj);
}
@@ -1,270 +0,0 @@
package com.sjapps.library.customdialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.StyleRes;
import com.sjapps.library.R;
/**@since 1.3*/
@SuppressWarnings("unused")
public class MessageDialog extends SJDialog{
private boolean isErrorDialog;
public MessageDialog(){
onlyOneButton = true;
}
public MessageDialog Builder(Context context){
super.Builder(context,R.layout.message_dialog);
onButtonClick(() -> dialog.dismiss());
return this;
}
public MessageDialog Builder(Context context,@StyleRes int theme){
super.Builder(context,R.layout.message_dialog,theme, false);
onButtonClick(() -> dialog.dismiss());
return this;
}
public MessageDialog Builder(Context context,boolean useAppTheme){
super.Builder(context,R.layout.message_dialog,useAppTheme);
onButtonClick(() -> dialog.dismiss());
return this;
}
public MessageDialog ErrorDialogBuilder(Context context){
return Builder(context).errorDialogAttributes();
}
public MessageDialog ErrorDialogBuilder(Context context,@StyleRes int theme){
return Builder(context,theme).errorDialogAttributes();
}
public MessageDialog ErrorDialogBuilder(Context context,boolean useAppTheme){
return Builder(context,useAppTheme).errorDialogAttributes();
}
private MessageDialog errorDialogAttributes(){
isErrorDialog = true;
return setDialogBackgroundResource(R.drawable.dialog_background_material3_red)
.setTextColor(context.getResources().getColor(R.color.SJDialog_ErrorTextColor, context.getTheme()))
.setButtonColor(MATERIAL3_RED_BUTTON)
.setTitle("Error");
}
/**{@inheritDoc}
* @since 1.5*/
@Override
public MessageDialog setOldTheme(){
super.setOldTheme();
if (isErrorDialog) {
setDialogBackgroundResource(R.drawable.dialog_background_red);
setTextColor(defaultOldColorWhite);
setButtonColor(defaultOldColorWhite);
setButtonTextColor(defaultOldColorBlack);
}
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public MessageDialog setTitle(String title){
super.setTitle(title);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public MessageDialog setMessage(String message) {
super.setMessage(message);
return this;
}
/**
* {@inheritDoc}
* @since 1.6
* */
@Override
public MessageDialog setTitleAlignment(int textAlignment) {
super.setTitleAlignment(textAlignment);
return this;
}
/**
* {@inheritDoc}
* @since 1.6
* */
@Override
public MessageDialog setMessageAlignment(int textAlignment) {
super.setMessageAlignment(textAlignment);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public MessageDialog setTextColor(int color) {
super.setTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public MessageDialog setTitleTextColor(int color) {
super.setTitleTextColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public MessageDialog setMessageTextColor(int color) {
super.setMessageTextColor(color);
return this;
}
/**
* Set a button text.
* @param text button text
* @return current class
* @since 1.4
* */
public MessageDialog setButtonText(String text){
super.setLeftButtonText(text);
return this;
}
/**
* Set button text color.
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.4
* */
public MessageDialog setButtonTextColor(@ColorInt int color){
super.setLeftButtonTextColor(color);
return this;
}
/**
* Set button color.
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.4
* */
public MessageDialog setButtonColor(@ColorInt int color){
super.setLeftButtonColor(color);
return this;
}
@Override
public MessageDialog setButtonColor(@ButtonColor String color){
super.setButtonColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public MessageDialog setDialogBackgroundColor(int color) {
super.setDialogBackgroundColor(color);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public MessageDialog setDialogBackgroundResource(@DrawableRes int drawable){
super.setDialogBackgroundResource(drawable);
return this;
}
/**
* Set background resource for button.
* @param drawable resource id
* @return current class
* @since 1.3
* */
public MessageDialog setButtonBackgroundResource(@DrawableRes int drawable){
super.setLeftButtonBackgroundResource(drawable);
return this;
}
/**
* Set onClick listener for a button
* @param dialogButtonEvent dialog button events
* @return current class
* */
@Override
public MessageDialog onButtonClick(DialogButtonEvent dialogButtonEvent){
super.onLeftButtonClick(dialogButtonEvent);
return this;
}
@Override
protected void setButtons() {
setButton1(R.id.btn);
}
public Button getButton() {
return super.getLeftButton();
}
/**@since 1.6*/
@Override
public TextView getTitleTextView() {
return super.getTitleTextView();
}
/**@since 1.6*/
@Override
public TextView getMessageTextView() {
return super.getMessageTextView();
}
/**{@inheritDoc}
* @since 1.4*/
@Override
public MessageDialog setMaxDialogWidth(int maxDialogWidth){
super.setMaxDialogWidth(maxDialogWidth);
return this;
}
@Override
public MessageDialog setDialogAnimations(int styleRes) {
super.setDialogAnimations(styleRes);
return this;
}
/**{@inheritDoc}
* @since 1.3*/
@Override
public MessageDialog show(){
super.show();
return this;
}
@Override
protected int setButtonsRootLayoutID() {
return R.id.buttonRoot;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public MessageDialog setOnTouchListener(View.OnTouchListener onTouchListener) {
super.setOnTouchListener(onTouchListener);
return this;
}
/**{@inheritDoc}
* @since 1.6*/
@Override
public MessageDialog swipeToDismiss(boolean isSwipeToDismiss) {
super.swipeToDismiss(isSwipeToDismiss);
return this;
}
}
@@ -1,744 +0,0 @@
package com.sjapps.library.customdialog;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.IdRes;
import androidx.annotation.IntDef;
import androidx.annotation.LayoutRes;
import androidx.annotation.StringDef;
import androidx.annotation.StyleRes;
import com.sjapps.library.R;
@SuppressWarnings({"unused", "UnusedReturnValue"})
public abstract class SJDialog {
public static final String RED_BUTTON = "RedBtn";
public static final String MATERIAL3_RED_BUTTON = "Material3RedBtn";
public static final String OLD_BUTTON_COLOR = "OldBtnColor";
/** Sets text alignment to {@link View#TEXT_ALIGNMENT_VIEW_START}
* @since 1.6
* */
public static final int TEXT_ALIGNMENT_LEFT = View.TEXT_ALIGNMENT_VIEW_START;
/** Sets text alignment to {@link View#TEXT_ALIGNMENT_VIEW_END}
* @since 1.6
* */
public static final int TEXT_ALIGNMENT_RIGHT = View.TEXT_ALIGNMENT_VIEW_END;
/** Sets text alignment to {@link View#TEXT_ALIGNMENT_CENTER}
* @since 1.6
* */
public static final int TEXT_ALIGNMENT_CENTER = View.TEXT_ALIGNMENT_CENTER;
private @LayoutRes int Btn1Resource = R.layout.button_template;
private @LayoutRes int Btn2Resource = R.layout.button_template;
@ColorInt int defaultOldThemeTextColor;
@ColorInt int defaultOldColorWhite = 0xFFE5E5E5;
@ColorInt int defaultOldColorBlack = 0xFF333333;
private final int defaultTheme = R.style.Theme_SJDialog;
private int newTheme = -1;
private boolean usesDefaultTheme = true;
private boolean isSwipeToDismiss = true;
private boolean isDefaultOnTouchListener = true;
private View.OnTouchListener dialogOnTouchListener = null;
public Dialog dialog;
protected Button button1, button2;
private LinearLayout background;
private int maxDialogWidth = 600;
Context context;
DialogButtonEvent dialogButtonEvent;
DialogButtonEvents dialogButtonEvents;
@StringDef({RED_BUTTON, MATERIAL3_RED_BUTTON, OLD_BUTTON_COLOR})
public @interface ButtonColor {
}
@IntDef({TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER})
public @interface TextAlignment {
}
protected boolean onlyOneButton = false;
protected boolean twoButtons = false;
private boolean leftBtnOnClick = false;
protected SJDialog Builder(Context context, @LayoutRes int layoutResID) {
Builder(context, layoutResID, defaultTheme, false);
return this;
}
protected SJDialog Builder(Context context, @LayoutRes int layoutResID, boolean useAppTheme) {
Builder(context, layoutResID, defaultTheme, useAppTheme);
return this;
}
protected SJDialog Builder(Context context, @LayoutRes int layoutResID, @StyleRes int theme, boolean useAppTheme) {
this.context = context;
defaultOldThemeTextColor = context.getResources().getColor(R.color.SJDialog_OldThemeTextColor, context.getTheme());
dialog = useAppTheme ?
new Dialog(new ContextThemeWrapper(context, context.getTheme())) :
new Dialog(new ContextThemeWrapper(context, theme));
setContentView(layoutResID);
setDialogSize();
dialog.getWindow().getAttributes().gravity = Gravity.BOTTOM;
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.getWindow().getAttributes().windowAnimations = R.style.SJDialogAnimation;
background = dialog.findViewById(R.id.dialogBackground);
setButtons();
if (theme != defaultTheme || useAppTheme) {
usesDefaultTheme = false;
newTheme = !useAppTheme ? theme : -1;
regenerateButtons();
}
return this;
}
protected void setDialogSize() {
if (context == null)
throw new NullPointerException("context is null");
if (dialog == null) {
throw new NullPointerException("dialog is null");
}
functions.SetDialogSize(context, dialog, maxDialogWidth);
}
/**
* By default dialog colors will be set to material3 dynamic colors.
* With this method you can set the dialog color for the background
* and buttons to the older non-dynamic colors
*
* @return current class
* @since 1.5
*/
protected SJDialog setOldTheme() {
setButtonsColor(OLD_BUTTON_COLOR);
setDialogBackgroundResource(R.drawable.dialog_background_old);
setTextColor(defaultOldThemeTextColor);
return this;
}
/**
* Set a dialog title.
*
* @param title title of a dialog
* @return current class
* @since 1.3
*/
protected SJDialog setTitle(String title) {
TextView TitleTv = getTitleTextView();
TitleTv.setText(title);
return this;
}
/**
* Set a dialog message.
*
* @param message message of a dialog
* @return current class
* @since 1.3
*/
protected SJDialog setMessage(String message) {
TextView msg = getMessageTextView();
msg.setText(message);
msg.setVisibility(View.VISIBLE);
return this;
}
/**
* Set the text alignment for Title TextView. Default is set to {@link SJDialog#TEXT_ALIGNMENT_CENTER}
* @param textAlignment The text alignment to set. Supported types: {@link SJDialog#TEXT_ALIGNMENT_LEFT}, {@link SJDialog#TEXT_ALIGNMENT_RIGHT} and {@link SJDialog#TEXT_ALIGNMENT_CENTER}
* @return current class
* @since 1.6
* */
protected SJDialog setTitleAlignment(@TextAlignment int textAlignment){
TextView title = getTitleTextView();
title.setGravity(Gravity.RIGHT);
title.setTextAlignment(textAlignment);
return this;
}
/**
* Set the text alignment for Message TextView. Default is set to {@link SJDialog#TEXT_ALIGNMENT_LEFT}
* @param textAlignment The text alignment to set. Supported types: {@link SJDialog#TEXT_ALIGNMENT_LEFT}, {@link SJDialog#TEXT_ALIGNMENT_RIGHT} and {@link SJDialog#TEXT_ALIGNMENT_CENTER}
* @return current class
* @since 1.6
* */
protected SJDialog setMessageAlignment(@TextAlignment int textAlignment){
TextView msg = getMessageTextView();
msg.setTextAlignment(textAlignment);
return this;
}
/**
* Set text color.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.6
*/
protected SJDialog setTextColor(@ColorInt int color) {
setTitleTextColor(color);
setMessageTextColor(color);
return this;
}
/**
* Set title text color.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.6
*/
protected SJDialog setTitleTextColor(@ColorInt int color) {
getTitleTextView().setTextColor(color);
return this;
}
/**
* Set message text color.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.6
*/
protected SJDialog setMessageTextColor(@ColorInt int color) {
getMessageTextView().setTextColor(color);
return this;
}
/**
* Set a text to left button.
*
* @param text button text
* @return current class
* @since 1.4
*/
protected SJDialog setLeftButtonText(String text) {
button1.setText(text);
return this;
}
/**
* Set a text to right button.
*
* @param text button text
* @return current class
* @since 1.4
*/
protected SJDialog setRightButtonText(String text) {
if (!twoButtons)
throw OneButtonException();
button2.setText(text);
return this;
}
/**
* Set text color for all buttons.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.4
*/
protected SJDialog setButtonsTextColor(@ColorInt int color) {
button1.setTextColor(color);
if (twoButtons)
button2.setTextColor(color);
return this;
}
/**
* Set text color for left button.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.4
*/
protected SJDialog setLeftButtonTextColor(@ColorInt int color) {
button1.setTextColor(color);
return this;
}
/**
* Set text color for right button.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.4
*/
protected SJDialog setRightButtonTextColor(@ColorInt int color) {
if (!twoButtons)
throw OneButtonException();
button2.setTextColor(color);
return this;
}
/**
* Set background color for all buttons.
*
* @param color Color to use for tinting buttons
* @return current class
* @since 1.4
*/
protected SJDialog setButtonsColor(@ColorInt int color) {
checkButtonResource(0);
button1.getBackground().setTint(color);
if (twoButtons) {
checkButtonResource(1);
button2.getBackground().setTint(color);
}
return this;
}
/**
* Set background color for left button.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.4
*/
protected SJDialog setLeftButtonColor(@ColorInt int color) {
checkButtonResource(0);
button1.getBackground().setTint(color);
return this;
}
/**
* Set background color for right button.
*
* @param color Color to use for tinting this drawable
* @return current class
* @since 1.4
*/
protected SJDialog setRightButtonColor(@ColorInt int color) {
if (!twoButtons)
throw OneButtonException();
checkButtonResource(1);
button2.getBackground().setTint(color);
return this;
}
protected SJDialog setButtonColor(@ButtonColor String color) {
checkButtonResource(0);
setLeftButtonColor(color);
return this;
}
protected SJDialog setButtonsColor(@ButtonColor String color) {
setLeftButtonColor(color);
if (twoButtons)
setRightButtonColor(color);
return this;
}
protected SJDialog setLeftButtonColor(@ButtonColor String color) {
checkButtonResource(0);
switch (color) {
case RED_BUTTON:
setLeftButtonBackgroundResource(R.drawable.ripple_button_red);
setLeftButtonTextColor(Color.WHITE);
break;
case MATERIAL3_RED_BUTTON:
setLeftButtonBackgroundResource(R.drawable.ripple_button_material3_red);
setLeftButtonTextColor(context.getResources().getColor(R.color.md_theme_onError, context.getTheme()));
break;
case OLD_BUTTON_COLOR:
setLeftButtonBackgroundResource(R.drawable.ripple_button_old);
setLeftButtonTextColor(Color.WHITE);
break;
default:
throw new IllegalArgumentException(color + " is not a valid argument");
}
return this;
}
protected SJDialog setRightButtonColor(@ButtonColor String color) {
if (!twoButtons)
throw OneButtonException();
checkButtonResource(1);
switch (color) {
case RED_BUTTON:
setRightButtonBackgroundResource(R.drawable.ripple_button_red);
setRightButtonTextColor(Color.WHITE);
break;
case MATERIAL3_RED_BUTTON:
setRightButtonBackgroundResource(R.drawable.ripple_button_material3_red);
setRightButtonTextColor(context.getResources().getColor(R.color.md_theme_onError, context.getTheme()));
break;
case OLD_BUTTON_COLOR:
setRightButtonBackgroundResource(R.drawable.ripple_button_old);
setRightButtonTextColor(Color.WHITE);
break;
default:
throw new IllegalArgumentException(color + " is not a valid argument");
}
return this;
}
/**
* Change dialog color
* @param color {@link ColorInt}
* @return current class
* @since 1.6
*/
protected SJDialog setDialogBackgroundColor(@ColorInt int color){
background.getBackground().mutate().setTint(color);
return this;
}
/**
* Set background resource for dialog.
*
* @param drawable resource id
* @return current class
* @since 1.3
*/
protected SJDialog setDialogBackgroundResource(@DrawableRes int drawable) {
background.setBackgroundResource(drawable);
return this;
}
/**
* Set background resource for all buttons.
*
* @param drawable resource id
* @return current class
* @since 1.3
*/
protected SJDialog setButtonsBackgroundResource(@DrawableRes int drawable) {
checkButtonResource(0);
button1.setBackgroundResource(drawable);
if (twoButtons) {
checkButtonResource(1);
button2.setBackgroundResource(drawable);
}
return this;
}
/**
* Set background resource for left button.
*
* @param drawable resource id
* @return current class
* @since 1.3
*/
protected SJDialog setLeftButtonBackgroundResource(@DrawableRes int drawable) {
checkButtonResource(0);
button1.setBackgroundResource(drawable);
return this;
}
/**
* Set background resource for right button.
*
* @param drawable resource id
* @return current class
* @since 1.3
*/
protected SJDialog setRightButtonBackgroundResource(@DrawableRes int drawable) {
if (!twoButtons)
throw OneButtonException();
checkButtonResource(1);
button2.setBackgroundResource(drawable);
return this;
}
/**
* Set onClick listener for right button
*
* @param dialogButtonEvent dialog button events
* @return current class
* @since 1.0
*/
protected SJDialog onButtonClick(DialogButtonEvent dialogButtonEvent) {
leftBtnOnClick = false;
this.dialogButtonEvent = dialogButtonEvent;
return this;
}
/**
* Set onClick listener for both buttons
*
* @param dialogButtonEvents dialog button events
* @return current class
* @since 1.0
*/
protected SJDialog onButtonClick(DialogButtonEvents dialogButtonEvents) {
this.dialogButtonEvents = dialogButtonEvents;
return this;
}
/**
* Set onClick listener for left button
*
* @param dialogButtonEvent dialog button event
* @return current class
*/
protected SJDialog onLeftButtonClick(DialogButtonEvent dialogButtonEvent) {
leftBtnOnClick = true;
this.dialogButtonEvent = dialogButtonEvent;
return this;
}
/**
* Creating dialog with two buttons. Use this method before changing buttons attributes
* @since 1.5
*/
protected SJDialog dialogWithTwoButtons() {
twoButtons = true;
return this;
}
/**
* show dialog
* @since 1.3
*/
protected SJDialog show() {
setDialogTouchListener();
addOnClickListener();
dialog.show();
return this;
}
private void addOnClickListener() {
if (dialogButtonEvents == null && dialogButtonEvent == null)
return;
if (dialogButtonEvents != null) {
button1.setOnClickListener(v -> dialogButtonEvents.onLeftButtonClick());
button2.setOnClickListener(v -> dialogButtonEvents.onRightButtonClick());
return;
}
if (!twoButtons) {
button1.setOnClickListener(v -> dialogButtonEvent.onButtonClick());
return;
}
if (leftBtnOnClick) {
button1.setOnClickListener(v -> dialogButtonEvent.onButtonClick());
return;
}
button1.setOnClickListener(v -> dismiss());
button2.setOnClickListener(v -> dialogButtonEvent.onButtonClick());
}
/**
* dismiss dialog
* @since 1.3
*/
public void dismiss() {
dialog.dismiss();
}
private void setContentView(@LayoutRes int layoutResID) {
dialog.setContentView(layoutResID);
}
protected void setButton1(@IdRes int id) {
this.button1 = dialog.findViewById(id);
}
protected void setButton2(@IdRes int id) {
this.button2 = dialog.findViewById(id);
}
protected abstract @IdRes int setButtonsRootLayoutID();
protected abstract void setButtons();
private void regenerateButtons() {
LinearLayout buttons = dialog.findViewById(setButtonsRootLayoutID());
regenerateLeftBtn(buttons);
if (onlyOneButton) {
return;
}
regenerateRightBtn(buttons);
}
@SuppressLint("SetTextI18n")
private void regenerateLeftBtn(LinearLayout buttons) {
if (buttons == null)
buttons = dialog.findViewById(setButtonsRootLayoutID());
String txt = button1.getText().toString();
buttons.removeView(button1);
button1 = (Button) LayoutInflater
.from(newTheme != -1 ? new ContextThemeWrapper(context, newTheme) : context)
.inflate(Btn1Resource,buttons,false);
button1.setText(txt);
buttons.addView(button1, 0);
}
@SuppressLint("SetTextI18n")
private void regenerateRightBtn(LinearLayout buttons) {
if (buttons == null)
buttons = dialog.findViewById(setButtonsRootLayoutID());
int btn2Visibility = button2.getVisibility();
String txt = button2.getText().toString();
buttons.removeView(button2);
button2 = (Button) LayoutInflater
.from(newTheme != -1 ? new ContextThemeWrapper(context, newTheme) : context)
.inflate(Btn2Resource,buttons,false);
button2.setVisibility(btn2Visibility);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button2.getLayoutParams();
params.setMarginStart(functions.dpToPixels(context,10));
button2.setLayoutParams(params);
button2.setText(txt);
buttons.addView(button2, 1);
}
private void checkButtonResource(int i) {
if (usesDefaultTheme)
return;
if (i == 0) {
if (Btn1Resource == R.layout.button_template) {
Btn1Resource = R.layout.button_template_1;
regenerateLeftBtn(null);
}
return;
}
if (i == 1) {
if (Btn2Resource == R.layout.button_template) {
Btn2Resource = R.layout.button_template_1;
regenerateRightBtn(null);
}
}
}
protected void setButton2Visibility(int visibility) {
button2.setVisibility(visibility);
}
protected TextView getTitleTextView() {
return dialog.findViewById(R.id.titleText);
}
protected TextView getMessageTextView() {
return dialog.findViewById(R.id.messageTxt);
}
protected Button getLeftButton() {
return button1;
}
protected Button getRightButton() {
return button2;
}
public int getMaxDialogWidth() {
return this.maxDialogWidth;
}
/**
* Set the maximum width for dialog
*
* @param maxDialogWidth set value for {@link #maxDialogWidth}. Default is 600dp
* @return current class
* @since 1.4
*/
protected SJDialog setMaxDialogWidth(int maxDialogWidth) {
this.maxDialogWidth = maxDialogWidth;
setDialogSize();
return this;
}
/**
* Set animation for a dialog
*
* @param styleRes style resource
* @return current class
* @since 1.5
*/
protected SJDialog setDialogAnimations(@StyleRes int styleRes) {
dialog.getWindow().getAttributes().windowAnimations = styleRes;
return this;
}
/**
* Enable or disable swipe down to dismiss dialog. Default is set to true
*
* @param isSwipeToDismiss Enable or disable swipe action
* @return current class
* @since 1.6
*/
protected SJDialog swipeToDismiss(boolean isSwipeToDismiss){
this.isSwipeToDismiss = isSwipeToDismiss;
return this;
}
/**
* Set dialog OnTouchListener. by default is set to {@link SwipeDismissTouchListener}.
* If this method is used, swipe to dismiss will not work.
*
* @param onTouchListener onTouchListener for dialog view
* @return current class
* @since 1.6
*/
protected SJDialog setOnTouchListener(View.OnTouchListener onTouchListener) {
dialogOnTouchListener = onTouchListener;
isDefaultOnTouchListener = false;
return this;
}
private void setDialogTouchListener() {
if (isDefaultOnTouchListener)
dialogOnTouchListener = new SwipeDismissTouchListener(
dialog.getWindow().getDecorView(),
new SwipeDismissTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss() {
return isSwipeToDismiss;
}
@Override
public void onDismiss(View view) {
dialog.dismiss();
}
}
);
dialog.getWindow().getDecorView().setOnTouchListener(dialogOnTouchListener);
}
private OneButtonException OneButtonException() {
return new OneButtonException("Trying to access right button when dialog has only one button. Use 'dialogWithTwoButtons()' to fix the problem.");
}
}
class OneButtonException extends RuntimeException {
public OneButtonException(String message) {
super(message);
}
}
@@ -1,9 +0,0 @@
package com.sjapps.library.customdialog;
/**
* by SlaVcE
* Setting up custom dialog.
* @deprecated SetupDialog is renamed to BasicDialog. Use {@link BasicDialog} instead.
* @since 1.0
*/
@Deprecated(since = "1.6")
public class SetupDialog extends BasicDialog{ }
@@ -1,216 +0,0 @@
package com.sjapps.library.customdialog;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
public class SwipeDismissTouchListener implements View.OnTouchListener {
private final int mSlop;
private final long mAnimationTime;
// Fixed properties
private final View mView;
private final DismissCallbacks mCallbacks;
private int mViewHeight = 1; // 1 and not 0 to prevent dividing by zero
// Transient properties
private float mDownX;
private float mDownY;
private boolean mSwiping;
private int mSwipingSlop;
private VelocityTracker mVelocityTracker;
private float mTranslationY;
/**
* The callback interface used by {@link SwipeDismissTouchListener} to inform its client
* about a successful dismissal of the view for which it was created.
*/
public interface DismissCallbacks {
/**
* Called to determine whether the view can be dismissed.
*/
boolean canDismiss();
/**
* Called when the user has indicated they she would like to dismiss the view.
*
* @param view The originating {@link android.view.View} to be dismissed.
*/
void onDismiss(View view);
}
/**
* Constructs a new swipe-to-dismiss touch listener for the given view.
*
* @param view The view to make dismissable.
* @param callbacks The callback to trigger when the user has indicated that would like to
* dismiss this view.
*/
public SwipeDismissTouchListener(View view, DismissCallbacks callbacks) {
ViewConfiguration vc = ViewConfiguration.get(view.getContext());
mSlop = vc.getScaledTouchSlop();
mAnimationTime = view.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime);
mView = view;
mCallbacks = callbacks;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// offset because the view is translated during swipe
motionEvent.offsetLocation(0, mTranslationY);
boolean returnTrue = false;
if (mViewHeight < 2) {
mViewHeight = mView.getHeight();
}
switch (motionEvent.getActionMasked()) {
case MotionEvent.ACTION_DOWN: {
// TODO: ensure this is a finger, and set a flag
mDownX = motionEvent.getRawX();
mDownY = motionEvent.getRawY();
if (mCallbacks.canDismiss()) {
mVelocityTracker = VelocityTracker.obtain();
mVelocityTracker.addMovement(motionEvent);
}
return true;
}
case MotionEvent.ACTION_UP: {
if (mVelocityTracker == null) {
break;
}
float deltaY = motionEvent.getRawY() - mDownY;
mVelocityTracker.addMovement(motionEvent);
mVelocityTracker.computeCurrentVelocity(1000);
boolean dismiss = false;
boolean dismissDown = false;
if (deltaY > (float) mViewHeight / 2 && mSwiping) {
dismiss = true;
dismissDown = deltaY > 0;
returnTrue = true;
} else if (Math.abs(deltaY) > 0){
returnTrue = true;
}
if (dismiss) {
// dismiss
mView.animate()
.translationY(dismissDown ? mViewHeight : 0)
.alpha(0)
.setDuration(mAnimationTime)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
performDismiss();
}
});
} else if (mSwiping) {
// cancel
mView.animate()
.translationY(0)
.alpha(1)
.setDuration(mAnimationTime)
.setListener(null);
}
mVelocityTracker.recycle();
mVelocityTracker = null;
mTranslationY = 0;
mDownX = 0;
mDownY = 0;
mSwiping = false;
break;
}
case MotionEvent.ACTION_CANCEL: {
if (mVelocityTracker == null) {
break;
}
mView.animate()
.translationY(0)
.alpha(1)
.setDuration(mAnimationTime)
.setListener(null);
mVelocityTracker.recycle();
mVelocityTracker = null;
mTranslationY = 0;
mDownX = 0;
mDownY = 0;
mSwiping = false;
break;
}
case MotionEvent.ACTION_MOVE: {
if (mVelocityTracker == null) {
break;
}
mVelocityTracker.addMovement(motionEvent);
float deltaX = motionEvent.getRawX() - mDownX;
float deltaY = motionEvent.getRawY() - mDownY;
if (Math.abs(deltaY) > mSlop && Math.abs(deltaX) < Math.abs(deltaY) / 2) {
mSwiping = true;
mSwipingSlop = (deltaY > 0 ? mSlop : 0);
mView.getParent().requestDisallowInterceptTouchEvent(true);
MotionEvent cancelEvent = MotionEvent.obtain(motionEvent);
cancelEvent.setAction(MotionEvent.ACTION_CANCEL | (motionEvent.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
mView.onTouchEvent(cancelEvent);
cancelEvent.recycle();
}
if (mSwiping) {
mTranslationY = deltaY;
if (deltaY - mSwipingSlop < 0)
mView.setTranslationY(0);
else mView.setTranslationY(deltaY - mSwipingSlop);
return true;
}
break;
}
}
return returnTrue;
}
private void performDismiss() {
// Animate the dismissed view to zero-height and then fire the dismiss callback.
// This triggers layout on each animation frame; in the future we may want to do something
// smarter and more performant.
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
final int originalHeight = mView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCallbacks.onDismiss(mView);
// Reset view presentation
mView.setAlpha(1f);
mView.setTranslationX(0);
lp.height = originalHeight;
mView.setLayoutParams(lp);
}
});
animator.addUpdateListener(valueAnimator -> {
lp.height = (Integer) valueAnimator.getAnimatedValue();
mView.setLayoutParams(lp);
});
animator.start();
}
}
@@ -1,162 +0,0 @@
package com.sjapps.library.customdialog.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.sjapps.library.R;
import com.sjapps.library.customdialog.ImageListItem;
import com.sjapps.library.customdialog.list.events.ListItemClickObj;
import java.util.ArrayList;
public class DefaultImageListAdapter extends RecyclerView.Adapter<DefaultImageListAdapter.ViewHolder> {
public ArrayList<ImageListItem> arrayListItems;
boolean isSelectable;
int itemBgRes;
int itemBgResSelected;
int listItemBgColor;
int listItemBgColorSelected;
int textColor;
ListItemClickObj<ImageListItem> itemClick;
ArrayList<ImageListItem> selectedItems;
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView valTxt;
ImageView imageView;
public ViewHolder(@NonNull View itemView) {
super(itemView);
valTxt = itemView.findViewById(R.id.value1Txt);
imageView = itemView.findViewById(R.id.imageView);
}
public TextView getTxt() {
return valTxt;
}
public ImageView getImageView() {
return imageView;
}
public View getView() {
return itemView.findViewById(R.id.layoutItem);
}
}
public DefaultImageListAdapter(ArrayList<ImageListItem> arrayList,
boolean isSelectable,
@Nullable ListItemClickObj<ImageListItem> itemClick,
ArrayList<ImageListItem> selectedItems,
int itemBgRes,
int itemBgResSelected,
int textColor,
int listItemBgColor,
int listItemBgColorSelected) {
this.itemClick = itemClick;
this.isSelectable = isSelectable;
this.selectedItems = selectedItems;
this.itemBgRes = itemBgRes;
this.itemBgResSelected = itemBgResSelected;
this.textColor = textColor;
this.arrayListItems = arrayList;
this.listItemBgColor = listItemBgColor;
this.listItemBgColorSelected = listItemBgColorSelected;
}
@NonNull
@Override
public DefaultImageListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.default_image_list_item, parent, false);
return new DefaultImageListAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
setValues(holder, position);
setBackground(holder, position);
if (textColor != 1) {
holder.getTxt().setTextColor(textColor);
}
if (isSelectable) {
holder.getView().setOnClickListener(v ->
checkSelected(holder, arrayListItems.get(position))
);
return;
}
holder.getView().setOnClickListener(v -> itemClick.onClick(position, arrayListItems.get(position)));
}
private void setBackground(@NonNull ViewHolder holder, int position) {
if (!isSelectable) {
setItemResource(holder, itemBgRes);
return;
}
if (selectedItems.contains(arrayListItems.get(position))) {
setItemResource(holder, itemBgResSelected);
setItemColor(holder,listItemBgColorSelected);
}
else {
setItemResource(holder, itemBgRes);
setItemColor(holder,listItemBgColor);
}
}
private void setValues(@NonNull ViewHolder holder, int position) {
holder.getTxt().setText(arrayListItems.get(position).getName());
holder.getImageView().setImageDrawable(arrayListItems.get(position).getImage());
}
private void checkSelected(@NonNull ViewHolder holder,ImageListItem obj) {
if (!selectedItems.contains(obj))
selectItem(holder, obj);
else deselectItem(holder, obj);
}
private void selectItem(@NonNull ViewHolder holder,ImageListItem obj) {
selectedItems.add(obj);
setItemResource(holder, itemBgResSelected);
setItemColor(holder,listItemBgColorSelected);
}
private void deselectItem(@NonNull ViewHolder holder,ImageListItem obj) {
selectedItems.remove(obj);
setItemResource(holder, itemBgRes);
setItemColor(holder,listItemBgColor);
}
private void setItemResource(@NonNull ViewHolder holder, int drawable) {
holder.getView().setBackgroundResource(drawable);
}
private void setItemColor(@NonNull ViewHolder holder, int color){
if (color == -1)
return;
holder.getView().getBackground().mutate().setTint(color);
}
@Override
public int getItemCount() {
return arrayListItems.size();
}
}
@@ -1,112 +0,0 @@
package com.sjapps.library.customdialog.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.sjapps.library.R;
import com.sjapps.library.customdialog.list.events.ListItemClick;
import java.util.ArrayList;
public class DefaultListAdapter extends RecyclerView.Adapter<DefaultListAdapterGeneric.ViewHolder> {
String[] items;
boolean isSelectable;
ListItemClick itemClick;
ArrayList<String> selectedItems;
int itemBgRes;
int itemBgResSelected;
int listItemBgColor;
int listItemBgColorSelected;
int textColor;
public DefaultListAdapter(String[] items,
boolean isSelectable,
ListItemClick itemClick,
ArrayList<String> selectedItems,
int itemBgRes,
int itemBgResSelected,
int textColor,
int listItemBgColor,
int listItemBgColorSelected) {
this.items = items;
this.isSelectable = isSelectable;
this.itemClick = itemClick;
this.selectedItems = selectedItems;
this.itemBgRes = itemBgRes;
this.itemBgResSelected = itemBgResSelected;
this.textColor = textColor;
this.listItemBgColor = listItemBgColor;
this.listItemBgColorSelected = listItemBgColorSelected;
}
@NonNull
@Override
public DefaultListAdapterGeneric.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.default_list_item,parent,false);
return new DefaultListAdapterGeneric.ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int position) {
holder.getVal1Txt().setText(items[position]);
if (selectedItems.contains(items[position])) {
setItemResource(holder, itemBgResSelected);
setItemColor(holder,listItemBgColorSelected);
}
else {
setItemResource(holder, itemBgRes);
setItemColor(holder,listItemBgColor);
}
if (textColor != 1)
holder.getVal1Txt().setTextColor(textColor);
if (isSelectable) {
holder.getView().setOnClickListener(v -> {
if (!selectedItems.contains(items[position]))
selectItem(holder,position);
else deselectItem(holder, position);
});
return;
}
holder.getView().setOnClickListener(v -> itemClick.onClick(position,items[position]));
}
private void selectItem(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int position){
selectedItems.add(items[position]);
setItemResource(holder,itemBgResSelected);
setItemColor(holder,listItemBgColorSelected);
}
private void deselectItem(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int position){
selectedItems.remove(items[position]);
setItemResource(holder,itemBgRes);
setItemColor(holder,listItemBgColor);
}
private void setItemResource(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int drawable){
holder.getView().setBackgroundResource(drawable);
}
private void setItemColor(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int color){
if (color == -1)
return;
holder.getView().getBackground().mutate().setTint(color);
}
@Override
public int getItemCount() {
return items.length;
}
}
@@ -1,290 +0,0 @@
package com.sjapps.library.customdialog.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.sjapps.library.R;
import com.sjapps.library.customdialog.ListItemValue;
import com.sjapps.library.customdialog.ListItemValues;
import com.sjapps.library.customdialog.list.events.ListItemClickObj;
import java.util.ArrayList;
public class DefaultListAdapterGeneric<T> extends RecyclerView.Adapter<DefaultListAdapterGeneric.ViewHolder> {
public ArrayList<T> arrayListItems;
public T[] listObj;
private ListItemValue<T> value;
private ListItemValues<T> values;
boolean isArrList;
boolean isObjArr;
boolean hasTwoVal;
boolean isSelectable;
int itemBgRes;
int itemBgResSelected;
int listItemBgColor;
int listItemBgColorSelected;
int textColor;
ListItemClickObj<T> itemClick;
ArrayList<T> selectedItems;
public static class ViewHolder extends RecyclerView.ViewHolder{
TextView val1Txt;
TextView val2Txt;
public ViewHolder(@NonNull View itemView) {
super(itemView);
val1Txt = itemView.findViewById(R.id.value1Txt);
val2Txt = itemView.findViewById(R.id.value2Txt);
}
public TextView getVal1Txt() {
return val1Txt;
}
public TextView getVal2Txt() {
return val2Txt;
}
public View getView(){
return itemView.findViewById(R.id.layoutItem);
}
}
public DefaultListAdapterGeneric(T[] objArray,
ListItemValue<T> value,
boolean isSelectable,
@Nullable ListItemClickObj<T> itemClick,
ArrayList<T> selectedItems,
int itemBgRes,
int itemBgResSelected,
int textColor,
int listItemBgColor,
int listItemBgColorSelected){
this.value = value;
this.itemClick = itemClick;
this.isSelectable = isSelectable;
this.selectedItems = selectedItems;
this.itemBgRes = itemBgRes;
this.itemBgResSelected = itemBgResSelected;
this.textColor = textColor;
this.listItemBgColor = listItemBgColor;
this.listItemBgColorSelected = listItemBgColorSelected;
ObjArrayAdapter(objArray);
}
public DefaultListAdapterGeneric(T[] objArray,
ListItemValues<T> values,
boolean isSelectable,
@Nullable ListItemClickObj<T> itemClick,
ArrayList<T> selectedItems,
int itemBgRes,
int itemBgResSelected,
int textColor,
int listItemBgColor,
int listItemBgColorSelected){
this.values = values;
this.itemClick = itemClick;
hasTwoVal = true;
this.isSelectable = isSelectable;
this.selectedItems = selectedItems;
this.itemBgRes = itemBgRes;
this.itemBgResSelected = itemBgResSelected;
this.textColor = textColor;
this.listItemBgColor = listItemBgColor;
this.listItemBgColorSelected = listItemBgColorSelected;
ObjArrayAdapter(objArray);
}
public DefaultListAdapterGeneric(ArrayList<T> arrayList,
ListItemValue<T> value,
boolean isSelectable,
@Nullable ListItemClickObj<T> itemClick,
ArrayList<T> selectedItems,
int itemBgRes,
int itemBgResSelected,
int textColor,
int listItemBgColor,
int listItemBgColorSelected){
this.value = value;
this.itemClick = itemClick;
this.isSelectable = isSelectable;
this.selectedItems = selectedItems;
this.itemBgRes = itemBgRes;
this.itemBgResSelected = itemBgResSelected;
this.textColor = textColor;
this.listItemBgColor = listItemBgColor;
this.listItemBgColorSelected = listItemBgColorSelected;
ArrayListAdapter(arrayList);
}
public DefaultListAdapterGeneric(ArrayList<T> arrayList,
ListItemValues<T> values,
boolean isSelectable,
@Nullable ListItemClickObj<T> itemClick,
ArrayList<T> selectedItems,
int itemBgRes,
int itemBgResSelected,
int textColor,
int listItemBgColor,
int listItemBgColorSelected){
this.values = values;
this.itemClick = itemClick;
hasTwoVal = true;
this.isSelectable = isSelectable;
this.selectedItems = selectedItems;
this.itemBgRes = itemBgRes;
this.itemBgResSelected = itemBgResSelected;
this.textColor = textColor;
this.listItemBgColor = listItemBgColor;
this.listItemBgColorSelected = listItemBgColorSelected;
ArrayListAdapter(arrayList);
}
private void ObjArrayAdapter(T[] objArray){
this.listObj = objArray;
isObjArr = true;
}
private void ArrayListAdapter(ArrayList<T> arrayList){
this.arrayListItems = arrayList;
isArrList = true;
}
@NonNull
@Override
public DefaultListAdapterGeneric.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.default_list_item,parent,false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int position) {
setValues(holder,position);
setBackground(holder,position);
if (textColor != 1){
holder.getVal1Txt().setTextColor(textColor);
holder.getVal2Txt().setTextColor(textColor);
}
if (isSelectable){
holder.getView().setOnClickListener(v -> {
if (isArrList)
checkSelected(holder, arrayListItems.get(position));
else if (isObjArr)
checkSelected(holder, listObj[position]);
});
return;
}
if (isArrList)
holder.getView().setOnClickListener(v -> itemClick.onClick(position,arrayListItems.get(position)));
if (isObjArr)
holder.getView().setOnClickListener(v -> itemClick.onClick(position,listObj[position]));
}
private void setBackground(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int position) {
if (!isSelectable) {
setItemResource(holder,itemBgRes);
return;
}
if (isArrList) {
if (selectedItems.contains(arrayListItems.get(position))) {
setItemResource(holder, itemBgResSelected);
setItemColor(holder,listItemBgColorSelected);
}
else {
setItemResource(holder, itemBgRes);
setItemColor(holder,listItemBgColor);
}
return;
}
if (isObjArr)
if (selectedItems.contains(listObj[position])) {
setItemResource(holder, itemBgResSelected);
setItemColor(holder,listItemBgColorSelected);
}
else {
setItemResource(holder, itemBgRes);
setItemColor(holder,listItemBgColor);
}
}
private void setValues(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int position){
if (isArrList){
if (!hasTwoVal) {
holder.getVal1Txt().setText(value.getValue(arrayListItems.get(position)));
return;
}
holder.getVal1Txt().setText(values.getValue1(arrayListItems.get(position)));
holder.getVal2Txt().setText(values.getValue2(arrayListItems.get(position)));
holder.getVal2Txt().setVisibility(View.VISIBLE);
return;
}
if (isObjArr) {
if (!hasTwoVal) {
holder.getVal1Txt().setText(value.getValue(listObj[position]));
return;
}
holder.getVal1Txt().setText(values.getValue1(listObj[position]));
holder.getVal2Txt().setText(values.getValue2(listObj[position]));
holder.getVal2Txt().setVisibility(View.VISIBLE);
}
}
private void checkSelected(@NonNull DefaultListAdapterGeneric.ViewHolder holder, T obj){
if (!selectedItems.contains(obj))
selectItem(holder,obj);
else deselectItem(holder,obj);
}
private void selectItem(@NonNull DefaultListAdapterGeneric.ViewHolder holder, T obj){
selectedItems.add(obj);
setItemResource(holder, itemBgResSelected);
setItemColor(holder,listItemBgColorSelected);
}
private void deselectItem(@NonNull DefaultListAdapterGeneric.ViewHolder holder, T obj){
selectedItems.remove(obj);
setItemResource(holder,itemBgRes);
setItemColor(holder,listItemBgColor);
}
private void setItemResource(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int drawable){
holder.getView().setBackgroundResource(drawable);
}
private void setItemColor(@NonNull DefaultListAdapterGeneric.ViewHolder holder, int color){
if (color == -1)
return;
holder.getView().getBackground().mutate().setTint(color);
}
@Override
public int getItemCount() {
if (isArrList)
return arrayListItems.size();
if (isObjArr)
return listObj.length;
return 0;
}
}
@@ -1,31 +0,0 @@
package com.sjapps.library.customdialog;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.Log;
import android.util.TypedValue;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.sjapps.library.R;
public class functions {
public static void SetDialogSize(@NonNull Context context, Dialog dialog, int maxWidth){
Configuration configuration = context.getResources().getConfiguration();
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
if (configuration.screenWidthDp > maxWidth)
width = dpToPixels(context,maxWidth);
dialog.getWindow().setLayout(width, height);
}
public static int dpToPixels(@NonNull Context context, float dp) {
Resources r = context.getResources();
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
}
}
@@ -1,5 +0,0 @@
package com.sjapps.library.customdialog.list.events;
public interface ListItemClick {
void onClick(int position, String value);
}
@@ -1,5 +0,0 @@
package com.sjapps.library.customdialog.list.events;
public interface ListItemClickObj<T> {
void onClick(int position, T obj);
}
-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
>
<alpha
android:duration="200"
android:fromAlpha="0"
android:toAlpha="1"
/>
<translate
android:duration="300"
android:fromYDelta="5%"
android:toYDelta="0"
/>
</set>
-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
>
<alpha
android:duration="200"
android:fromAlpha="1"
android:toAlpha="0"
/>
<translate
android:duration="300"
android:fromYDelta="0"
android:toYDelta="5%"
/>
</set>
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?colorSecondaryContainer"/>
<corners android:radius="30dp"/>
</shape>
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?colorErrorContainer"/>
<corners android:radius="30dp"/>
</shape>
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/SJDialog_oldBackground"/>
<corners android:radius="30dp"/>
</shape>
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/SJDialog_OldThemeErrorDialog"/>
<corners android:radius="30dp"/>
</shape>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffffff">
<item android:id="@+id/mask">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?colorPrimary"/>
<corners android:radius="60dp"/>
</shape>
</item>
</ripple>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffffff">
<item android:id="@+id/mask">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?colorError"/>
<corners android:radius="60dp"/>
</shape>
</item>
</ripple>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffffff">
<item android:id="@+id/mask">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/SJDialog_oldButton"/>
<corners android:radius="60dp"/>
</shape>
</item>
</ripple>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffffff">
<item android:id="@+id/mask">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/SJDialog_red"/>
<corners android:radius="60dp"/>
</shape>
</item>
</ripple>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorPrimary">
<item android:id="@+id/mask">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?colorSecondaryContainer"/>
<corners android:radius="20dp"/>
</shape>
</item>
</ripple>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffffff">
<item android:id="@+id/mask">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/SJDialog_oldBackground"/>
<corners android:radius="20dp"/>
</shape>
</item>
</ripple>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorPrimary">
<item android:id="@+id/mask">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?colorPrimaryInverse"/>
<corners android:radius="20dp"/>
</shape>
</item>
</ripple>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffffff">
<item android:id="@+id/mask">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/SJDialog_oldBackground2"/>
<corners android:radius="20dp"/>
</shape>
</item>
</ripple>
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,92 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
>
<LinearLayout
android:id="@+id/dialogBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:background="@drawable/dialog_background"
android:gravity="bottom"
android:orientation="vertical">
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="10dp"
android:fontFamily="@font/koho_bold"
android:layout_marginTop="20dp"
android:textColor="?colorOnSecondaryContainer"
android:layout_weight="1"
android:text="Title"
android:textAlignment="center"
android:textSize="25dp" />
<TextView
android:id="@+id/messageTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:textAlignment="viewStart"
android:layout_gravity="center"
android:textSize="20dp"
android:textColor="?colorOnSecondaryContainer"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="10dp"
android:visibility="gone"
/>
<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn1"
style="@style/SJDialog.ButtonStyle"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="0.5"
android:fontFamily="@font/koho_bold"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:visibility="visible"
android:text="Cancel" />
<Button
android:id="@+id/btn2"
style="@style/SJDialog.ButtonStyle"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_marginStart="10dp"
android:layout_weight="0.5"
android:fontFamily="@font/koho_bold"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:visibility="visible"
android:text="Ok" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/SJDialog.ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_weight="1"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:text="Btn"
/>
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/SJDialog.ButtonStyle"
android:theme="@style/Theme.SJDialog"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_weight="1"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:text="Btn"
/>
@@ -1,107 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingVertical="10dp"
>
<LinearLayout
android:id="@+id/dialogBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:background="@drawable/dialog_background"
android:gravity="bottom"
android:orientation="vertical">
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:textColor="?colorOnSecondaryContainer"
android:text="Title"
android:textAlignment="center"
android:textSize="25dp" />
<TextView
android:id="@+id/messageTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:textAlignment="viewStart"
android:layout_gravity="center"
android:textSize="20dp"
android:textColor="?colorOnSecondaryContainer"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="10dp"
android:visibility="gone"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="20dp"
android:layout_marginHorizontal="10dp"
>
<LinearLayout
android:id="@+id/customViewRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
/>
</ScrollView>
<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn1"
style="@style/SJDialog.ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_weight="1"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:text="Cancel" />
<Button
android:id="@+id/btn2"
style="@style/SJDialog.ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:visibility="gone"
android:text="Ok" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
@@ -1,50 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:minHeight="70dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/layoutItem"
android:background="@drawable/ripple_list"
android:clipChildren="true"
android:layout_width="80dp"
android:layout_margin="5dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingVertical="5dp"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/imageView"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
/>
<TextView
android:id="@+id/value1Txt"
android:layout_width="match_parent"
android:layout_height="30dp"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="5dp"
android:autoSizeMaxTextSize="10dp"
android:autoSizeStepGranularity="1dp"
android:textSize="10dp"
android:textColor="?colorOnSecondaryContainer"
android:layout_weight="1"
android:maxLines="2"
android:textAlignment="center"
android:gravity="center"
android:textStyle="bold"
android:layout_marginHorizontal="10dp"
android:text="Value"
/>
</LinearLayout>
</LinearLayout>
@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:minHeight="70dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/layoutItem"
android:background="@drawable/ripple_list"
android:clipChildren="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingVertical="5dp"
>
<TextView
android:id="@+id/value1Txt"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="5dp"
android:autoSizeMaxTextSize="25dp"
android:autoSizeStepGranularity="1dp"
android:textSize="20dp"
android:textColor="?colorOnSecondaryContainer"
android:layout_weight="1"
android:maxLines="1"
android:gravity="center"
android:textStyle="bold"
android:layout_marginHorizontal="20dp"
android:text="Value"
/>
<TextView
android:id="@+id/value2Txt"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="5dp"
android:autoSizeMaxTextSize="25dp"
android:autoSizeStepGranularity="1dp"
android:textSize="15dp"
android:textColor="?colorOnSecondaryContainer"
android:layout_weight="1"
android:maxLines="1"
android:gravity="center"
android:layout_marginHorizontal="20dp"
android:text="Value"
android:visibility="gone"
/>
</LinearLayout>
</LinearLayout>
@@ -1,110 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/dialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingVertical="10dp"
>
<LinearLayout
android:id="@+id/dialogBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:background="@drawable/dialog_background"
android:gravity="bottom"
android:orientation="vertical">
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:text="Title"
android:textAlignment="center"
android:textColor="?colorOnSecondaryContainer"
android:textSize="25dp" />
<TextView
android:id="@+id/messageTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="10dp"
android:text="Message"
android:textAlignment="viewStart"
android:textColor="?colorOnSecondaryContainer"
android:textSize="20dp"
android:visibility="gone" />
<TextView
android:id="@+id/emptyListTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List is empty"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:textColor="?colorOnSecondaryContainer"
android:visibility="gone"
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
/>
<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn1"
style="@style/SJDialog.ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_weight="1"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:text="Cancel"
android:visibility="visible" />
<Button
android:id="@+id/btn2"
style="@style/SJDialog.ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:text="Ok"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
@@ -1,72 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
>
<LinearLayout
android:id="@+id/dialogBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:background="@drawable/dialog_background"
android:gravity="bottom"
android:orientation="vertical">
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:textColor="?colorOnSecondaryContainer"
android:text="Title"
android:textAlignment="center"
android:textSize="25dp" />
<TextView
android:id="@+id/messageTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="10dp"
android:textColor="?colorOnSecondaryContainer"
android:text="Message"
android:textAlignment="viewStart"
android:textSize="20dp"
android:visibility="gone" />
<LinearLayout
android:id="@+id/buttonRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn"
style="@style/SJDialog.ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_weight="1"
android:autoSizeMaxTextSize="14dp"
android:autoSizeMinTextSize="5dp"
android:autoSizeStepGranularity="1dp"
android:autoSizeTextType="uniform"
android:maxLines="1"
android:text="Ok" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
@@ -1,48 +0,0 @@
<resources>
<color name="md_theme_primary">#B2C5FF</color>
<color name="md_theme_onPrimary">#002A79</color>
<color name="md_theme_primaryContainer">#003EA9</color>
<color name="md_theme_onPrimaryContainer">#DAE2FF</color>
<color name="md_theme_secondary">#C1C6DD</color>
<color name="md_theme_onSecondary">#2A3042</color>
<color name="md_theme_secondaryContainer">#414659</color>
<color name="md_theme_onSecondaryContainer">#DCE1F9</color>
<color name="md_theme_tertiary">#C0C1FF</color>
<color name="md_theme_onTertiary">#1200AA</color>
<color name="md_theme_tertiaryContainer">#2510E1</color>
<color name="md_theme_onTertiaryContainer">#E1E0FF</color>
<color name="md_theme_error">#FFB4A9</color>
<color name="md_theme_errorContainer">#930006</color>
<color name="md_theme_onError">#680003</color>
<color name="md_theme_onErrorContainer">#FFDAD4</color>
<color name="md_theme_background">#1B1B1F</color>
<color name="md_theme_onBackground">#E3E1E6</color>
<color name="md_theme_surface">#1B1B1F</color>
<color name="md_theme_onSurface">#E3E1E6</color>
<color name="md_theme_surfaceVariant">#44464E</color>
<color name="md_theme_onSurfaceVariant">#C6C6D0</color>
<color name="md_theme_outline">#8F909A</color>
<color name="md_theme_inverseOnSurface">#1B1B1F</color>
<color name="md_theme_inverseSurface">#E3E1E6</color>
<color name="md_theme_inversePrimary">#0053DC</color>
<color name="md_theme_shadow">#000000</color>
<color name="md_theme_primaryInverse">#0053DC</color>
<color name="seed">#0060F4</color>
<color name="error">#BA1B1B</color>
<color name="Custom0">#625FCD</color>
<color name="overlay_light_primary">#9C4146</color>
<color name="overlay_light_onPrimary">#FFFFFF</color>
<color name= "overlay_light_primaryContainer">#FFDADB</color>
<color name="overlay_light_onPrimaryContainer">#400008</color>
<color name="SJDialog_oldBackground">#333333</color>
<color name="SJDialog_oldBackground2">#4a4a4a</color>
<color name="SJDialog_oldButton">#0060f4</color>
<color name="SJDialog_red">#BA1B1B</color>
<color name="SJDialog_OldThemeTextColor">#E5E5E5</color>
<color name="SJDialog_ErrorTextColor">#FFDAD4</color>
</resources>
@@ -1,36 +0,0 @@
<resources>
<style name="Theme.SJDialog" parent="Theme.Material3.DynamicColors.DayNight">
<item name="colorPrimary">@color/md_theme_primary</item>
<item name="colorOnPrimary">@color/md_theme_onPrimary</item>
<item name="colorPrimaryContainer">@color/md_theme_primaryContainer</item>
<item name="colorOnPrimaryContainer">@color/md_theme_onPrimaryContainer</item>
<item name="colorSecondary">@color/md_theme_secondary</item>
<item name="colorOnSecondary">@color/md_theme_onSecondary</item>
<item name="colorSecondaryContainer">@color/md_theme_secondaryContainer</item>
<item name="colorOnSecondaryContainer">@color/md_theme_onSecondaryContainer</item>
<item name="colorTertiary">@color/md_theme_tertiary</item>
<item name="colorOnTertiary">@color/md_theme_onTertiary</item>
<item name="colorTertiaryContainer">@color/md_theme_tertiaryContainer</item>
<item name="colorOnTertiaryContainer">@color/md_theme_onTertiaryContainer</item>
<item name="colorError">@color/md_theme_error</item>
<item name="colorErrorContainer">@color/md_theme_errorContainer</item>
<item name="colorOnError">@color/md_theme_onError</item>
<item name="colorOnErrorContainer">@color/md_theme_onErrorContainer</item>
<item name="android:colorBackground">@color/md_theme_background</item>
<item name="colorOnBackground">@color/md_theme_onBackground</item>
<item name="colorSurface">@color/md_theme_surface</item>
<item name="colorOnSurface">@color/md_theme_onSurface</item>
<item name="colorSurfaceVariant">@color/md_theme_surfaceVariant</item>
<item name="colorOnSurfaceVariant">@color/md_theme_onSurfaceVariant</item>
<item name="colorOutline">@color/md_theme_outline</item>
<item name="colorOnSurfaceInverse">@color/md_theme_inverseOnSurface</item>
<item name="colorSurfaceInverse">@color/md_theme_inverseSurface</item>
<item name="colorPrimaryInverse">@color/md_theme_primaryInverse</item>
<item name="materialButtonStyle">@style/SJDialog.ButtonStyle</item>
</style>
</resources>
-49
View File
@@ -1,49 +0,0 @@
<resources>
<color name="md_theme_primary">#0053DC</color>
<color name="md_theme_onPrimary">#FFFFFF</color>
<color name="md_theme_primaryContainer">#DAE2FF</color>
<color name="md_theme_onPrimaryContainer">#00174D</color>
<color name="md_theme_secondary">#585E71</color>
<color name="md_theme_onSecondary">#FFFFFF</color>
<color name="md_theme_secondaryContainer">#DCE1F9</color>
<color name="md_theme_onSecondaryContainer">#151B2C</color>
<color name="md_theme_tertiary">#433EF7</color>
<color name="md_theme_onTertiary">#FFFFFF</color>
<color name="md_theme_tertiaryContainer">#E1E0FF</color>
<color name="md_theme_onTertiaryContainer">#07006D</color>
<color name="md_theme_error">#BA1B1B</color>
<color name="md_theme_errorContainer">#FFDAD4</color>
<color name="md_theme_onError">#FFFFFF</color>
<color name="md_theme_onErrorContainer">#410001</color>
<color name="md_theme_background">#FEFBFF</color>
<color name="md_theme_onBackground">#1B1B1F</color>
<color name="md_theme_surface">#FEFBFF</color>
<color name="md_theme_onSurface">#1B1B1F</color>
<color name="md_theme_surfaceVariant">#E2E2EC</color>
<color name="md_theme_onSurfaceVariant">#44464E</color>
<color name="md_theme_outline">#75767F</color>
<color name="md_theme_inverseOnSurface">#F2F0F5</color>
<color name="md_theme_inverseSurface">#303033</color>
<color name="md_theme_inversePrimary">#B2C5FF</color>
<color name="md_theme_shadow">#000000</color>
<color name="md_theme_primaryInverse">#B2C5FF</color>
<color name="seed">#0060F4</color>
<color name="error">#BA1B1B</color>
<color name="Custom0">#625FCD</color>
<color name="overlay_light_primary">#9C4146</color>
<color name="overlay_light_onPrimary">#FFFFFF</color>
<color name= "overlay_light_primaryContainer">#FFDADB</color>
<color name="overlay_light_onPrimaryContainer">#400008</color>
<color name="SJDialog_oldBackground">#E5E5E5</color>
<color name="SJDialog_oldBackground2">#D5D5D5</color>
<color name="SJDialog_oldButton">#0060f4</color>
<color name="SJDialog_red">#BA1B1B</color>
<color name="SJDialog_OldThemeErrorDialog">#930006</color>
<color name="SJDialog_OldThemeTextColor">#333333</color>
<color name="SJDialog_ErrorTextColor">#410001</color>
</resources>
-28
View File
@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- "@android:style/Widget.Button"/-->
<style name="SJDialog.ButtonStyle" parent="@android:style/Widget.Button">
<item name="android:background">@drawable/ripple_button</item>
<item name="android:textSize">12dp</item>
<item name="android:paddingStart">15dp</item>
<item name="android:paddingEnd">15dp</item>
<!-- <item name="android:padding">14dp</item>-->
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
<item name="textAllCaps">false</item>
<item name="android:textAppearance">?android:attr/textAppearanceSmallInverse</item>
<item name="android:textColor">?colorOnPrimary</item>
<item name="android:gravity">center_vertical|center_horizontal</item>
</style>
<style name="SJDialog.ButtonStyle.Red" parent="@style/SJDialog.ButtonStyle">
<item name="backgroundTint">@color/md_theme_error</item>
<item name="android:textColor">@color/md_theme_onError</item>
</style>
<style name="SJDialogAnimation">
<item name="android:windowEnterAnimation">@anim/slide_in</item>
<item name="android:windowExitAnimation">@anim/slide_out</item>
</style>
</resources>
-34
View File
@@ -1,34 +0,0 @@
<resources>
<style name="Theme.SJDialog" parent="Theme.Material3.DynamicColors.DayNight">
<item name="colorPrimary">@color/md_theme_primary</item>
<item name="colorOnPrimary">@color/md_theme_onPrimary</item>
<item name="colorPrimaryContainer">@color/md_theme_primaryContainer</item>
<item name="colorOnPrimaryContainer">@color/md_theme_onPrimaryContainer</item>
<item name="colorSecondary">@color/md_theme_secondary</item>
<item name="colorOnSecondary">@color/md_theme_onSecondary</item>
<item name="colorSecondaryContainer">@color/md_theme_secondaryContainer</item>
<item name="colorOnSecondaryContainer">@color/md_theme_onSecondaryContainer</item>
<item name="colorTertiary">@color/md_theme_tertiary</item>
<item name="colorOnTertiary">@color/md_theme_onTertiary</item>
<item name="colorTertiaryContainer">@color/md_theme_tertiaryContainer</item>
<item name="colorOnTertiaryContainer">@color/md_theme_onTertiaryContainer</item>
<item name="colorError">@color/md_theme_error</item>
<item name="colorErrorContainer">@color/md_theme_errorContainer</item>
<item name="colorOnError">@color/md_theme_onError</item>
<item name="colorOnErrorContainer">@color/md_theme_onErrorContainer</item>
<item name="android:colorBackground">@color/md_theme_background</item>
<item name="colorOnBackground">@color/md_theme_onBackground</item>
<item name="colorSurface">@color/md_theme_surface</item>
<item name="colorOnSurface">@color/md_theme_onSurface</item>
<item name="colorSurfaceVariant">@color/md_theme_surfaceVariant</item>
<item name="colorOnSurfaceVariant">@color/md_theme_onSurfaceVariant</item>
<item name="colorOutline">@color/md_theme_outline</item>
<item name="colorOnSurfaceInverse">@color/md_theme_inverseOnSurface</item>
<item name="colorSurfaceInverse">@color/md_theme_inverseSurface</item>
<item name="colorPrimaryInverse">@color/md_theme_primaryInverse</item>
<item name="materialButtonStyle">@style/SJDialog.ButtonStyle</item>
</style>
</resources>
@@ -1,17 +0,0 @@
package com.sjapps.library;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
-1
View File
@@ -1 +0,0 @@
/build
-46
View File
@@ -1,46 +0,0 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.3.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.core:core-ktx:1.3.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
View File
-21
View File
@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -1,24 +0,0 @@
package com.thecode.aestheticdialogs
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.thecode.aestheticdialogs", appContext.packageName)
}
}
@@ -1,2 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thecode.aestheticdialogs" />
@@ -1,620 +0,0 @@
package com.thecode.aestheticdialogs
import android.app.Activity
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Handler
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import androidx.annotation.Keep
import androidx.annotation.NonNull
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.AppCompatButton
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.content.ContextCompat
import kotlinx.android.synthetic.main.dialog_connectify_error.view.*
import kotlinx.android.synthetic.main.dialog_connectify_success.view.*
import kotlinx.android.synthetic.main.dialog_emoji.view.*
import kotlinx.android.synthetic.main.dialog_emotion.view.*
import kotlinx.android.synthetic.main.dialog_flash.view.*
import kotlinx.android.synthetic.main.dialog_flat.view.*
import kotlinx.android.synthetic.main.dialog_rainbow.view.*
import kotlinx.android.synthetic.main.dialog_toaster.view.*
import java.text.SimpleDateFormat
import java.util.*
/**
* Aesthetic Dialog class
* Use Builder to create a new instance.
*
* @author Gabriel The Code
*/
@Keep
class AestheticDialog {
class Builder(
//Necessary parameters
@NonNull private val activity: Activity,
@NonNull private val dialogStyle: DialogStyle,
@NonNull private val dialogType: DialogType) {
lateinit var alertDialog: AlertDialog
private val dialogBuilder: AlertDialog.Builder = AlertDialog.Builder(activity)
private var title: String = "Title"
private var message: String = "Message"
// Optional features
private var isDarkMode: Boolean = false
private var isCancelable: Boolean = true
private var duration: Int = 0
private var gravity: Int = Gravity.NO_GRAVITY
private var animation: DialogAnimation = DialogAnimation.DEFAULT
private lateinit var layoutView: View
private var onClickListener: OnDialogClickListener = object : OnDialogClickListener {
override fun onClick(dialog: Builder) {
dialog.dismiss()
}
}
/**
* Set dialog title text
*
* @param title
* @return this, for chaining.
*/
@NonNull
fun setTitle(@NonNull title: String): Builder {
this.title = title
return this
}
/**
* Set dialog message text
*
* @param message
* @return this, for chaining.
*/
@NonNull
fun setMessage(@NonNull message: String): Builder {
this.message = message
return this
}
/**
* Set dialog mode. Defined by default to false
*
* @param isDarkMode
* @return this, for chaining.
*/
@NonNull
fun setDarkMode(@NonNull isDarkMode: Boolean): Builder {
this.isDarkMode = isDarkMode
return this
}
/**
* Set an OnClickListener to the dialog
*
* @param onDialogClickListener interface for callback event on click of button.
* @return this, for chaining.
*/
@NonNull
fun setOnClickListener(onDialogClickListener: OnDialogClickListener): Builder {
this.onClickListener = onDialogClickListener
return this
}
/**
* Define if the dialog is cancelable
*
* @param isCancelable
* @return this, for chaining.
*/
@NonNull
fun setCancelable(isCancelable: Boolean): Builder {
this.isCancelable = isCancelable
return this
}
/**
* Define the display duration of the dialog
*
* @param duration in milliseconds
* @return this, for chaining.
*/
@NonNull
fun setDuration(duration: Int): Builder {
if (duration != 0) {
this.duration = duration
Handler().postDelayed({
this.dismiss()
}, duration.toLong())
}
return this
}
/**
* Set the gravity of the dialog
*
* @param gravity in milliseconds
* @return this, for chaining.
*/
@NonNull
fun setGravity(gravity: Int): Builder {
this.gravity = gravity
return this
}
/**
* Set the animation of the dialog
*
* @param animation in milliseconds
* @return this, for chaining.
*/
@NonNull
fun setAnimation(animation: DialogAnimation): Builder {
this.animation = animation
return this
}
/**
* Dismiss the dialog
*
* @return Aesthetic Dialog instance.
*/
@NonNull
fun dismiss(): AestheticDialog {
if (alertDialog.isShowing) {
alertDialog.dismiss()
}
return AestheticDialog()
}
/**
* Choose the dialog animation according to the parameter
*
*/
@NonNull
private fun chooseAnimation() {
when (animation) {
DialogAnimation.ZOOM -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationZoom
}
DialogAnimation.FADE -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationFade
}
DialogAnimation.CARD -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationCard
}
DialogAnimation.SHRINK -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationShrink
}
DialogAnimation.SWIPE_LEFT -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationSwipeLeft
}
DialogAnimation.SWIPE_RIGHT -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationSwipeRight
}
DialogAnimation.IN_OUT -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationInOut
}
DialogAnimation.SPIN -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationSpin
}
DialogAnimation.SPLIT -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationSplit
}
DialogAnimation.DIAGONAL -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationDiagonal
}
DialogAnimation.WINDMILL -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationWindMill
}
DialogAnimation.SLIDE_UP -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationSlideUp
}
DialogAnimation.SLIDE_DOWN -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationSlideDown
}
DialogAnimation.SLIDE_LEFT -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationSlideLeft
}
DialogAnimation.SLIDE_RIGHT -> {
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimationSlideRight
}
DialogAnimation.DEFAULT ->{
alertDialog.window?.attributes?.windowAnimations = R.style.DialogAnimation
}
}
}
/**
* Displays the dialog according to the parameters of the Builder
*
* @return Aesthetic Dialog instance.
*/
@NonNull
fun show(): AestheticDialog {
when (dialogStyle) {
DialogStyle.EMOJI -> {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_emoji, null)
val layoutDialog = layoutView.dialog_layout_emoji
val imgClose: AppCompatImageView = layoutView.image_close_emoji
val icon: AppCompatImageView = layoutView.dialog_icon_emoji
val textTitle: AppCompatTextView = layoutView.text_title_emoji
val textMessage: AppCompatTextView = layoutView.text_message_emoji
textMessage.text = message
textTitle.text = title
if (dialogType == DialogType.SUCCESS) {
textTitle.setTextColor(ContextCompat.getColor(activity, R.color.dialog_success))
icon.setImageResource(R.drawable.thumbs_up_sign)
} else {
textTitle.setTextColor(ContextCompat.getColor(activity, R.color.dialog_error))
icon.setImageResource(R.drawable.man_shrugging)
}
if (isDarkMode) {
textMessage.setTextColor(ContextCompat.getColor(activity, R.color.md_white_1000))
layoutDialog.setBackgroundColor(ContextCompat.getColor(activity, R.color.dark_background))
}
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.TOP)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height_emoji_dialog)
alertDialog.window?.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, height)
imgClose.setOnClickListener { onClickListener.onClick(this) }
}
DialogStyle.DRAKE -> {
layoutView = if (dialogType == DialogType.SUCCESS) {
activity.layoutInflater.inflate(R.layout.dialog_drake_success, null)
} else {
activity.layoutInflater.inflate(R.layout.dialog_drake_error, null)
}
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.CENTER)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height_drake)
alertDialog.window?.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, height)
}
DialogStyle.TOASTER -> {
if (isDarkMode) {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_toaster, null)
val layoutDialog = layoutView.dialog_layout_toaster
layoutDialog.setBackgroundColor(ContextCompat.getColor(activity, R.color.dark_background))
val imgClose: AppCompatImageView = layoutView.image_close_toaster
val icon: AppCompatImageView = layoutView.dialog_icon_toaster
val textTitle: AppCompatTextView = layoutView.text_title_toaster
val textMessage: AppCompatTextView = layoutView.text_message_toaster
textMessage.setTextColor(ContextCompat.getColor(activity, R.color.md_white_1000))
val verticalView = layoutView.vertical_view_toaster
textMessage.text = message
textTitle.text = title
when (dialogType) {
DialogType.ERROR -> {
textTitle.setTextColor(ContextCompat.getColor(activity, R.color.dialog_error))
verticalView.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_error))
icon.setImageResource(R.drawable.ic_error_red_24dp)
}
DialogType.SUCCESS -> {
textTitle.setTextColor(ContextCompat.getColor(activity, R.color.dialog_success))
verticalView.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_success))
icon.setImageResource(R.drawable.ic_check_circle_green_24dp)
}
DialogType.WARNING -> {
textTitle.setTextColor(ContextCompat.getColor(activity, R.color.dialog_warning))
verticalView.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_warning))
icon.setImageResource(R.drawable.ic_warning_orange_24dp)
}
DialogType.INFO -> {
textTitle.setTextColor(ContextCompat.getColor(activity, R.color.dialog_info))
verticalView.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_info))
icon.setImageResource(R.drawable.ic_info_blue_24dp)
}
}
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.TOP)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height_toaster)
alertDialog.window?.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, height)
imgClose.setOnClickListener { onClickListener.onClick(this) }
} else {
val dialogBuilder: AlertDialog.Builder = AlertDialog.Builder(activity)
layoutView = activity.layoutInflater.inflate(R.layout.dialog_toaster, null)
val imgClose: AppCompatImageView = layoutView.image_close_toaster
val icon: AppCompatImageView = layoutView.dialog_icon_toaster
val textTitle: AppCompatTextView = layoutView.text_title_toaster
val textMessage: AppCompatTextView = layoutView.text_message_toaster
val verticalView = layoutView.vertical_view_toaster
textMessage.text = message
textTitle.text = title
when (dialogType) {
DialogType.ERROR -> {
verticalView.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_error))
icon.setImageResource(R.drawable.ic_error_red_24dp)
}
DialogType.SUCCESS -> {
verticalView.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_success))
icon.setImageResource(R.drawable.ic_check_circle_green_24dp)
}
DialogType.WARNING -> {
verticalView.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_warning))
icon.setImageResource(R.drawable.ic_warning_orange_24dp)
}
DialogType.INFO -> {
verticalView.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_info))
icon.setImageResource(R.drawable.ic_info_blue_24dp)
}
}
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.TOP)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height_toaster)
alertDialog.window?.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, height)
imgClose.setOnClickListener { onClickListener.onClick(this) }
}
}
DialogStyle.RAINBOW -> {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_rainbow, null)
val icon: AppCompatImageView = layoutView.dialog_icon_rainbow
val layoutDialog = layoutView.dialog_layout_rainbow
when (dialogType) {
DialogType.ERROR -> {
layoutDialog.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_error))
icon.setImageResource(R.drawable.ic_error_red_24dp)
}
DialogType.SUCCESS -> {
layoutDialog.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_success))
icon.setImageResource(R.drawable.ic_check_circle_green_24dp)
}
DialogType.WARNING -> {
layoutDialog.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_warning))
icon.setImageResource(R.drawable.ic_warning_orange_24dp)
}
DialogType.INFO -> {
layoutDialog.setBackgroundColor(ContextCompat.getColor(activity, R.color.dialog_info))
icon.setImageResource(R.drawable.ic_info_blue_24dp)
}
}
val imgClose: AppCompatImageView = layoutView.image_close_rainbow
val textTitle: AppCompatTextView = layoutView.text_title_rainbow
val textMessage: AppCompatTextView = layoutView.text_message_rainbow
textMessage.text = message
textTitle.text = title
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.TOP)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height_emoji_dialog)
alertDialog.window?.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, height)
imgClose.setOnClickListener { onClickListener.onClick(this) }
}
DialogStyle.CONNECTIFY -> {
val imgClose: AppCompatImageView
val textTitle: AppCompatTextView
val textMessage: AppCompatTextView
val layoutDialog: LinearLayoutCompat
if (dialogType == DialogType.SUCCESS) {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_connectify_success, null)
layoutDialog = layoutView.dialog_layout_connectify_success
imgClose = layoutView.image_close_connectify_success
textTitle = layoutView.text_title_connectify_success
textMessage = layoutView.text_message_connectify_success
} else {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_connectify_error, null)
layoutDialog = layoutView.dialog_layout_connectify_error
imgClose = layoutView.image_close_connectify_error
textTitle = layoutView.text_title_connectify_error
textMessage = layoutView.text_message_connectify_error
}
textTitle.text = title
textMessage.text = message
if (isDarkMode) {
layoutDialog.setBackgroundColor(ContextCompat.getColor(activity, R.color.dark_background))
textMessage.setTextColor(ContextCompat.getColor(activity, R.color.md_white_1000))
}
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.TOP)
this.chooseAnimation()
alertDialog.show()
alertDialog.window?.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT)
imgClose.setOnClickListener { onClickListener.onClick(this) }
}
DialogStyle.FLASH -> {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_flash, null)
val btnOk: AppCompatButton = layoutView.btn_action_flash
val textTitle: AppCompatTextView = layoutView.dialog_title_flash
val textMessage: AppCompatTextView = layoutView.dialog_message_flash
val dialogFrame = layoutView.dialog_frame_flash
val icon: AppCompatImageView = layoutView.img_icon_flash
if (dialogType == DialogType.SUCCESS) {
dialogFrame.setBackgroundResource(R.drawable.rounded_green_gradient_bg)
icon.setImageResource(R.drawable.circle_validation_success)
} else {
dialogFrame.setBackgroundResource(R.drawable.rounded_red_gradient_bg)
icon.setImageResource(R.drawable.circle_validation_error)
}
textMessage.text = message
textTitle.text = title
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.CENTER)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height)
val width = activity.resources.getDimensionPixelSize(R.dimen.popup_height)
alertDialog.window?.setLayout(width, height)
btnOk.setOnClickListener { onClickListener.onClick(this) }
}
DialogStyle.EMOTION -> {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_emotion, null)
val icon: AppCompatImageView = layoutView.img_icon_emotion
val layoutDialog = layoutView.dialog_layout_emotion
val textTitle: AppCompatTextView = layoutView.dialog_title_emotion
val textMessage: AppCompatTextView = layoutView.dialog_message_emotion
val textHour: AppCompatTextView = layoutView.dialog_hour_emotion
if (dialogType == DialogType.SUCCESS) {
icon.setImageResource(R.drawable.smiley_success)
layoutDialog.setBackgroundResource(R.drawable.background_emotion_success)
} else {
icon.setImageResource(R.drawable.smiley_error)
layoutDialog.setBackgroundResource(R.drawable.background_emotion_error)
}
val sdf = SimpleDateFormat("HH:mm")
val hour = sdf.format(Calendar.getInstance().time)
textMessage.text = message
textTitle.text = title
textHour.text = hour
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.CENTER)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height_emotion)
alertDialog.window?.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, height)
}
DialogStyle.FLAT -> {
if (isDarkMode) {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_flat, null)
val btnOk: AppCompatButton = layoutView.btn_action_flat
val textTitle: AppCompatTextView = layoutView.dialog_title_flat
val textMessage: AppCompatTextView = layoutView.dialog_message_flat
val icon: AppCompatImageView = layoutView.dialog_icon_flat
val layoutDialog: LinearLayoutCompat = layoutView.dialog_layout_flat
val frameLayout = layoutView.dialog_frame_flat
when (dialogType) {
DialogType.ERROR -> {
icon.setImageResource(R.drawable.ic_error_red_24dp)
btnOk.setBackgroundResource(R.drawable.btn_red_selector)
frameLayout.setBackgroundResource(R.drawable.rounded_rect_red)
}
DialogType.SUCCESS -> {
icon.setImageResource(R.drawable.ic_check_circle_green_24dp)
btnOk.setBackgroundResource(R.drawable.btn_green_selector)
frameLayout.setBackgroundResource(R.drawable.rounded_rect_green)
}
DialogType.WARNING -> {
icon.setImageResource(R.drawable.ic_warning_orange_24dp)
btnOk.setBackgroundResource(R.drawable.btn_yellow_selector)
frameLayout.setBackgroundResource(R.drawable.rounded_rect_yellow)
}
DialogType.INFO -> {
icon.setImageResource(R.drawable.ic_info_blue_24dp)
btnOk.setBackgroundResource(R.drawable.btn_blue_selector)
frameLayout.setBackgroundResource(R.drawable.rounded_rect_blue)
}
}
layoutDialog.setBackgroundResource(R.drawable.rounded_dark_bg)
textTitle.setTextColor(ContextCompat.getColor(activity, R.color.md_white_1000))
textMessage.setTextColor(ContextCompat.getColor(activity, R.color.md_white_1000))
textMessage.text = message
textTitle.text = title
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.CENTER)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height)
val width = activity.resources.getDimensionPixelSize(R.dimen.popup_height)
alertDialog.window?.setLayout(width, height)
btnOk.setOnClickListener { onClickListener.onClick(this) }
} else {
layoutView = activity.layoutInflater.inflate(R.layout.dialog_flat, null)
val btnOk: AppCompatButton = layoutView.btn_action_flat
val textTitle: AppCompatTextView = layoutView.dialog_title_flat
val textMessage: AppCompatTextView = layoutView.dialog_message_flat
val icon: AppCompatImageView = layoutView.dialog_icon_flat
val layoutDialog: LinearLayoutCompat = layoutView.dialog_layout_flat
val frameLayout = layoutView.dialog_frame_flat
when (dialogType) {
DialogType.ERROR -> {
icon.setImageResource(R.drawable.ic_error_red_24dp)
btnOk.setBackgroundResource(R.drawable.btn_red_selector)
frameLayout.setBackgroundResource(R.drawable.rounded_rect_red)
}
DialogType.SUCCESS -> {
icon.setImageResource(R.drawable.ic_check_circle_green_24dp)
btnOk.setBackgroundResource(R.drawable.btn_green_selector)
frameLayout.setBackgroundResource(R.drawable.rounded_rect_green)
}
DialogType.WARNING -> {
icon.setImageResource(R.drawable.ic_warning_orange_24dp)
btnOk.setBackgroundResource(R.drawable.btn_yellow_selector)
frameLayout.setBackgroundResource(R.drawable.rounded_rect_yellow)
}
DialogType.INFO -> {
icon.setImageResource(R.drawable.ic_info_blue_24dp)
btnOk.setBackgroundResource(R.drawable.btn_blue_selector)
frameLayout.setBackgroundResource(R.drawable.rounded_rect_blue)
}
}
layoutDialog.setBackgroundResource(R.drawable.rounded_white_bg)
textMessage.text = message
textTitle.text = title
dialogBuilder.setView(layoutView)
alertDialog = dialogBuilder.create()
alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
alertDialog.window?.setGravity(Gravity.CENTER)
this.chooseAnimation()
alertDialog.show()
val height = activity.resources.getDimensionPixelSize(R.dimen.popup_height)
val width = activity.resources.getDimensionPixelSize(R.dimen.popup_height)
alertDialog.window?.setLayout(width, height)
btnOk.setOnClickListener { onClickListener.onClick(this) }
}
}
}
alertDialog.setCancelable(isCancelable)
if (gravity != Gravity.NO_GRAVITY) {
alertDialog.window?.setGravity(gravity)
}
return AestheticDialog()
}
}
}
@@ -1,6 +0,0 @@
package com.thecode.aestheticdialogs
enum class DialogAnimation {
DEFAULT, SLIDE_UP, SLIDE_DOWN, SLIDE_LEFT, SLIDE_RIGHT, SWIPE_LEFT, SWIPE_RIGHT, IN_OUT, CARD, SHRINK, SPLIT , DIAGONAL , SPIN , WINDMILL , FADE , ZOOM
}
@@ -1,6 +0,0 @@
package com.thecode.aestheticdialogs
enum class DialogStyle {
EMOJI, DRAKE, TOASTER, CONNECTIFY, FLAT, RAINBOW, FLASH, EMOTION
}
@@ -1,6 +0,0 @@
package com.thecode.aestheticdialogs
enum class DialogType {
SUCCESS, ERROR, WARNING, INFO
}
@@ -1,6 +0,0 @@
package com.thecode.aestheticdialogs
interface OnDialogClickListener {
fun onClick(dialog: AestheticDialog.Builder)
}
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXDelta="-1000"
android:toXDelta="0" />
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" />
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.5" />
</set>
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:interpolator="@android:anim/decelerate_interpolator">
<translate
android:fromXDelta="-100%p"
android:fromYDelta="-100%p"
android:toXDelta="0%p"
android:toYDelta="0%p" />
<scale
android:fromXScale="0.0"
android:fromYScale="0.0"
android:toXScale="1.0"
android:toYScale="1.0" />
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:interpolator="@android:anim/decelerate_interpolator">
<translate
android:fromXDelta="0%p"
android:fromYDelta="0%p"
android:toXDelta="100%p"
android:toYDelta="100%p" />
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="0.0"
android:toYScale="0.0" />
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="750" />
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:fillAfter="true"
android:duration="750" />
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_mediumAnimTime">
<translate
android:fromXDelta="1000"
android:toXDelta="0" />
<scale
android:fromXScale="0.5"
android:fromYScale="0.5"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />
<alpha
android:fromAlpha="0.5"
android:toAlpha="1.0" />
</set>

Some files were not shown because too many files have changed in this diff Show More