InputDialog.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. package com.kongzue.dialogx.dialogs;
  2. import com.kongzue.dialogx.interfaces.OnBackPressedListener;
  3. import com.kongzue.dialogx.interfaces.OnInputDialogButtonClickListener;
  4. import com.kongzue.dialogx.interfaces.OnInputDialogButtonClickListener;
  5. import com.kongzue.dialogx.util.InputInfo;
  6. import com.kongzue.dialogx.util.TextInfo;
  7. /**
  8. * @author: Kongzue
  9. * @github: https://github.com/kongzue/
  10. * @homepage: http://kongzue.com/
  11. * @mail: myzcxhh@live.cn
  12. * @createTime: 2020/9/24 13:53
  13. */
  14. public class InputDialog extends MessageDialog {
  15. public InputDialog() {
  16. me = this;
  17. }
  18. public static InputDialog build() {
  19. return new InputDialog();
  20. }
  21. public InputDialog(CharSequence title, CharSequence message, CharSequence okText) {
  22. this.title = title;
  23. this.message = message;
  24. this.okText = okText;
  25. }
  26. public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText) {
  27. InputDialog inputDialog = new InputDialog(title, message, okText);
  28. inputDialog.show();
  29. return inputDialog;
  30. }
  31. public InputDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText) {
  32. this.title = title;
  33. this.message = message;
  34. this.okText = okText;
  35. this.cancelText = cancelText;
  36. }
  37. public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText) {
  38. InputDialog inputDialog = new InputDialog(title, message, okText, cancelText);
  39. inputDialog.show();
  40. return inputDialog;
  41. }
  42. public InputDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, String inputText) {
  43. this.title = title;
  44. this.message = message;
  45. this.okText = okText;
  46. this.cancelText = cancelText;
  47. this.inputText = inputText;
  48. }
  49. public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, String inputText) {
  50. InputDialog inputDialog = new InputDialog(title, message, okText, cancelText, inputText);
  51. inputDialog.show();
  52. return inputDialog;
  53. }
  54. public InputDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText) {
  55. this.title = title;
  56. this.message = message;
  57. this.okText = okText;
  58. this.cancelText = cancelText;
  59. this.otherText = otherText;
  60. }
  61. public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText) {
  62. InputDialog inputDialog = new InputDialog(title, message, okText, cancelText, otherText);
  63. inputDialog.show();
  64. return inputDialog;
  65. }
  66. public InputDialog(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText, String inputText) {
  67. this.title = title;
  68. this.message = message;
  69. this.okText = okText;
  70. this.cancelText = cancelText;
  71. this.otherText = otherText;
  72. this.inputText = inputText;
  73. }
  74. public static InputDialog show(CharSequence title, CharSequence message, CharSequence okText, CharSequence cancelText, CharSequence otherText, String inputText) {
  75. InputDialog inputDialog = new InputDialog(title, message, okText, cancelText, otherText, inputText);
  76. inputDialog.show();
  77. return inputDialog;
  78. }
  79. public CharSequence getOkButton() {
  80. return okText;
  81. }
  82. public InputDialog setOkButton(CharSequence okText) {
  83. this.okText = okText;
  84. refreshUI();
  85. return this;
  86. }
  87. public InputDialog setOkButton(OnInputDialogButtonClickListener okButtonClickListener) {
  88. this.okButtonClickListener = okButtonClickListener;
  89. refreshUI();
  90. return this;
  91. }
  92. public InputDialog setOkButton(CharSequence okText, OnInputDialogButtonClickListener okButtonClickListener) {
  93. this.okText = okText;
  94. this.okButtonClickListener = okButtonClickListener;
  95. refreshUI();
  96. return this;
  97. }
  98. public CharSequence getCancelButton() {
  99. return cancelText;
  100. }
  101. public InputDialog setCancelButton(CharSequence cancelText) {
  102. this.cancelText = cancelText;
  103. refreshUI();
  104. return this;
  105. }
  106. public InputDialog setCancelButton(OnInputDialogButtonClickListener cancelButtonClickListener) {
  107. this.cancelButtonClickListener = cancelButtonClickListener;
  108. refreshUI();
  109. return this;
  110. }
  111. public InputDialog setCancelButton(CharSequence cancelText, OnInputDialogButtonClickListener cancelButtonClickListener) {
  112. this.cancelText = cancelText;
  113. this.cancelButtonClickListener = cancelButtonClickListener;
  114. refreshUI();
  115. return this;
  116. }
  117. public CharSequence getOtherButton() {
  118. return otherText;
  119. }
  120. public InputDialog setOtherButton(CharSequence otherText) {
  121. this.otherText = otherText;
  122. refreshUI();
  123. return this;
  124. }
  125. public InputDialog setOtherButton(OnInputDialogButtonClickListener otherButtonClickListener) {
  126. this.otherButtonClickListener = otherButtonClickListener;
  127. refreshUI();
  128. return this;
  129. }
  130. public InputDialog setOtherButton(CharSequence otherText, OnInputDialogButtonClickListener otherButtonClickListener) {
  131. this.otherText = otherText;
  132. this.otherButtonClickListener = otherButtonClickListener;
  133. refreshUI();
  134. return this;
  135. }
  136. public OnInputDialogButtonClickListener getOkButtonClickListener() {
  137. return (OnInputDialogButtonClickListener) okButtonClickListener;
  138. }
  139. public InputDialog setOkButtonClickListener(OnInputDialogButtonClickListener okButtonClickListener) {
  140. this.okButtonClickListener = okButtonClickListener;
  141. refreshUI();
  142. return this;
  143. }
  144. public OnInputDialogButtonClickListener getCancelButtonClickListener() {
  145. return (OnInputDialogButtonClickListener) cancelButtonClickListener;
  146. }
  147. public InputDialog setCancelButtonClickListener(OnInputDialogButtonClickListener cancelButtonClickListener) {
  148. this.cancelButtonClickListener = cancelButtonClickListener;
  149. refreshUI();
  150. return this;
  151. }
  152. public OnInputDialogButtonClickListener getOtherButtonClickListener() {
  153. return (OnInputDialogButtonClickListener) otherButtonClickListener;
  154. }
  155. public InputDialog setOtherButtonClickListener(OnInputDialogButtonClickListener otherButtonClickListener) {
  156. this.otherButtonClickListener = otherButtonClickListener;
  157. refreshUI();
  158. return this;
  159. }
  160. public CharSequence getTitle() {
  161. return title;
  162. }
  163. public InputDialog setTitle(CharSequence title) {
  164. this.title = title;
  165. refreshUI();
  166. return this;
  167. }
  168. public CharSequence getMessage() {
  169. return message;
  170. }
  171. public InputDialog setMessage(CharSequence message) {
  172. this.message = message;
  173. refreshUI();
  174. return this;
  175. }
  176. public String getInputText() {
  177. return inputText;
  178. }
  179. public InputDialog setInputText(String inputText) {
  180. this.inputText = inputText;
  181. refreshUI();
  182. return this;
  183. }
  184. public String getInputHintText() {
  185. return inputHintText;
  186. }
  187. public InputDialog setInputHintText(String inputHintText) {
  188. this.inputHintText = inputHintText;
  189. refreshUI();
  190. return this;
  191. }
  192. public TextInfo getTitleTextInfo() {
  193. return titleTextInfo;
  194. }
  195. public InputDialog setTitleTextInfo(TextInfo titleTextInfo) {
  196. this.titleTextInfo = titleTextInfo;
  197. refreshUI();
  198. return this;
  199. }
  200. public TextInfo getMessageTextInfo() {
  201. return messageTextInfo;
  202. }
  203. public InputDialog setMessageTextInfo(TextInfo messageTextInfo) {
  204. this.messageTextInfo = messageTextInfo;
  205. refreshUI();
  206. return this;
  207. }
  208. public TextInfo getOkTextInfo() {
  209. return okTextInfo;
  210. }
  211. public InputDialog setOkTextInfo(TextInfo okTextInfo) {
  212. this.okTextInfo = okTextInfo;
  213. refreshUI();
  214. return this;
  215. }
  216. public TextInfo getCancelTextInfo() {
  217. return cancelTextInfo;
  218. }
  219. public InputDialog setCancelTextInfo(TextInfo cancelTextInfo) {
  220. this.cancelTextInfo = cancelTextInfo;
  221. refreshUI();
  222. return this;
  223. }
  224. public TextInfo getOtherTextInfo() {
  225. return otherTextInfo;
  226. }
  227. public InputDialog setOtherTextInfo(TextInfo otherTextInfo) {
  228. this.otherTextInfo = otherTextInfo;
  229. refreshUI();
  230. return this;
  231. }
  232. public InputInfo getInputInfo() {
  233. return inputInfo;
  234. }
  235. public InputDialog setInputInfo(InputInfo inputInfo) {
  236. this.inputInfo = inputInfo;
  237. refreshUI();
  238. return this;
  239. }
  240. public int getButtonOrientation() {
  241. return buttonOrientation;
  242. }
  243. public InputDialog setButtonOrientation(int buttonOrientation) {
  244. this.buttonOrientation = buttonOrientation;
  245. refreshUI();
  246. return this;
  247. }
  248. public boolean isCancelable() {
  249. return cancelable;
  250. }
  251. public InputDialog setCancelable(boolean cancelable) {
  252. this.cancelable = cancelable;
  253. return this;
  254. }
  255. public OnBackPressedListener getOnBackPressedListener() {
  256. return onBackPressedListener;
  257. }
  258. public InputDialog setOnBackPressedListener(OnBackPressedListener onBackPressedListener) {
  259. this.onBackPressedListener = onBackPressedListener;
  260. return this;
  261. }
  262. public boolean isAutoShowInputKeyboard() {
  263. return autoShowInputKeyboard;
  264. }
  265. public InputDialog setAutoShowInputKeyboard(boolean autoShowInputKeyboard) {
  266. this.autoShowInputKeyboard = autoShowInputKeyboard;
  267. return this;
  268. }
  269. }