Skip to content

Latest commit

 

History

History
152 lines (113 loc) · 5.07 KB

README.md

File metadata and controls

152 lines (113 loc) · 5.07 KB

PostOffice

Android Arsenal
Version 1.0.6

This is a library for easily constructing Holo and Material Design Dialogs in either Light or Dark modes, and are completely styleable and customizable.

Usage

Call PostOffice.newMail() to start building a new dialog. This method will return a Delivery object which is an interface into the actual system Dialog that is created from the builder.

OR

Call one of the simpler quick call items;

PostOffice.newAlertMail(Context, Title, Message)
PostOffice.newAlertMail(Context, Title, Message, AlertHandler)
PostOffice.newEditTextMail(Context, Title, Hint, InputType, OnTextAcceptedListener)
PostOffice.newProgressMail(Context, Title, Suffix, Indeterminate);
PostOffice.newSimpleListMail(Context, Title, Design, Contents[], OnItemAcceptedListener<T>)

Mail Interface

Delivery interface = PostOffice.newMail(Context)
		.setTitle(<CharSequence|Integer>)
		.setMessage(<CharSequence|Integer>)
		.setIcon(Integer)
		
		.setButton(Integer, <CharSequence, Integer>, DialogInterface.OnClickListener)
		.setThemeColor(int color)
		.setThemeColorFromResource(int colorResId)
		
		.showKeyboardOnDisplay(Boolean)
		.setCancelable(Boolean)
		.setCanceledOnTouchOutside(Boolean)
		.setDesign(Designs.<HOLO|MATERIAL>_<LIGHT|DARK>)
		
		.setStyle(
			new EditTextStyle.Builder(Context)
				.setText(CharSequence)
				.setHint(CharSequence)
				.setTextColor(Integer)
				.setHintColor(Integer)
				.addTextWatcher(TextWatcher)
				.setInputType(Integer)
				.setOnTextAcceptedListener(OnTextAcceptedListener)
				.build
			new ProgressStyle.Builder(Context)
				.setSuffix(String)	
				.setCloseOnFinish(Boolean)
				.setPercentageMode(Boolean)
				.setInterdeterminate(Boolean)
				.build()
			new ListStyle.Builder(Context)
				.setDividerHeight(Float)
				.setDivider(Drawable)
				.setListSelector(<Integer|Drawable>)
				.setDrawSelectorOnTop(Boolean)
				.setFooterDividersEnabled(Boolean)
				.setHeaderDividersEnabled(Boolean)
				.addHeader(View)
				.addHeader(View, Object, Boolean)
				.addFooter(View)
				.addFooter(View, Object, Boolean)
				.setOnItemClickListener(OnItemClickListener)
				.setOnItemLongClickListener(OnItemLongClickListener)
				.setOnItemAcceptedListener(OnItemAcceptedListener<T>)
				.build(BaseAdapter)
		)
		.build();
		.show(FragmentManager, String);
		.show(FragmentTransaction, String);
		.show(android.support.v4.FragmentManager, String);
		.show(android.support.v4.FragmentTransaction, String);

Delivery Interface

Here is the list of delivery interface methods

.setOnCancelListener(DialogInterface.OnCancelListener)
.setOnDismissListener(DialogInterface.OnDismissListener)
.setOnShowListener(DialogInterface.OnShowListener)
.getStyle()	

.show(FragmentManager manager, String tag)
.show(FragmentManager manager)
.show(FragmentTransaction transaction, String tag)
.show(FragmentTransaction transaction)

.show(android.support.v4.app.FragmentManager, String tag)
.show(android.support.v4.app.FragmentManager)
.show(android.support.v4.app.FragmentTransaction, String tag)
.show(android.support.v4.app.FragmentTransaction)

.getMail()
.getSupportMail()

.dismiss()
.dismissAllowStateLoss()

Example Usage

PostOffice.newAlertMail(ctx, R.string.title, R.string.message)
	      .show(getFragmentManager(), null);

or

PostOffice.newMail(ctx)
		  .setTitle("Some awesome title")
		  .setMessage("Something cool just happened, check it out.")
		  .setIcon(R.drawable.ic_launcher)
		  .setThemeColor(R.color.app_color)
		  .setDesign(Design.MATERIAL_LIGHT)
		  .show(getFragmentManager());

Screenshots

Home Home Dark Alert Holo Alert Material
EditText Material Progress Holo
List Holo List Mtrl

Going Forward

Here is a list of features I will add or look into adding in the near future. If you have any features you would like to add feel free to submit a Pull request or email me.

  • [DONE] Support for Support FragmentManager
  • [DONE] Update the text tracking and kerning for Material Design dialogs to become full spec
  • [DONE] Add a delay to dismissing Material design dialogs so the user can see the ripple effect

Example

Implementing

Add this line to your gradle dependencies

compile 'com.r0adkll:postoffice:1.0.6'

Author

Attribution

License