GithubHelp home page GithubHelp logo

yarolegovich / lovelydialog Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 191.0 2.07 MB

This library is a set of simple wrapper classes that are aimed to help you easily create fancy material dialogs.

License: Apache License 2.0

Java 100.00%
android android-library android-ui dialog dialogs fancy-material-dialogs material-design view

lovelydialog's People

Contributors

aliab avatar antonkozyriatskyi avatar pierfrancescosoffritti avatar seroperson avatar shaishavgandhi avatar yarolegovich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lovelydialog's Issues

Dialog color

How can I change the dialog's colour? Not the top section, but the one containing the list or the message

How to change font size ?

i tried adding textSize in style.xml but it only affect the button (positive, negative & neutral button). The title and description text stay same.


<style name="quitAlert" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="android:gravity">center</item>
        <item name="android:textSize">50sp</item>
 </style>

Buttons gravity

Hi there,
Is there any way to set the gravity of the buttons?
I saw that it is possible with the message and title, but not the buttons

Thank you

setTitle does not work!!

When I try to add the setTitle method it returns null and does not show anything on the title section. How can I fix it? Thanks.

Lovely Library! More color options?

Great library, I will use it for my app. Could you maybe add more color options?

Since my app offers a dark mode, I need to be able to change the color of the background of the dialog and the text colors. Otherwise it's perfect! Thank you very much.

How to dismiss the LovelyCustomDialog?

I'm using custom view for displaying two EditTexts.
But i'm unable to dismiss the dialog.
And i'm checking whether they are empty or not. If empty, then an error is displayed on edittext.
And if not empty then performing some task.
But the problem here is after performing the tasks the dialog is not dismissed.

Using Fragments vs .setTopColor and .setButtonsColor

Hello, I have run into 2 issues.

I'm using Fragments to inflate my main_layout because of the way I use a Navigation Drawer on my app.

So while using:

new LovelyStandardDialog(this)
.setTopColor(color(R.color.indigo))
.setButtonsColor(color(R.color.darkDeepOrange))
.setIcon(R.drawable.ic_star_border_white_36dp)
.setTitle(R.string.rate_title)
.setMessage(R.string.rate_message)
.setPositiveButton(android.R.string.ok, new View.OnClickListener() {
@OverRide
public void onClick(View v) {
Toast.makeText(context, "positive clicked", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton(android.R.string.no, null)
.show();

I ran into an issue where I had to replace the "new LovelyStandardDialog(this)" for "new LovelyStandardDialog(getActivity())" so I could get rid of the errors, but while trying to use both .setTopColor(...) and .setButtonsColor(...) I always get an error message saying "method called expected".

I'm fairly new to using libraries so I'm probably doing something wrong, any suggestions?

Here's my code:

lovelydialogfragmentissue

Set text cusrsor position in LovelyTextInputDialog

Hello sir,
I have set initial input to edit text in LovelyTextInputDialog. but when dialog appears, cursor is set to starting of edit text instead of to the end of text content in edit text. Please help me to set text cursor position to the end when using setInitialInput().

add button negative

hello sir can you add button negative for dismiss the dialog on LovelyChoiceDialog single choice?
like if user not choice now
and then its can setTopColorRes not show like hide the layout
thank you

Adding Fragment to a view

Is it possible to add a fragment to the view ?

I have tried this :

              Dialog showw = new LovelyCustomDialog(this)
                        .setTopColorRes(R.color.yellow)
                        .setIcon(R.drawable.ic_menu_camera)
                        .setView(R.layout.fragment_maps)
                        .configureView(new LovelyCustomDialog.ViewConfigurator() {
                            public ImageView mImageView;

                            @Override
                            public void configureView(final View v) {


   FrameLayout mapContainer= (FrameLayout) v.findViewById(R.id.mapView);

                                    SupportMapFragment fragment = new SupportMapFragment();
                                    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                                    transaction.add(mapContainer.getId(), fragment).commit();

                            }
                        })
                        .show();

Help

Hello!
i need create some static method for start loading and cancel loading... and call this method just passing the parameters.

Suggestion setPositiveButton compatibility

On thing I've noticed is that the setPositiveButton and related calls use View OnClick instead of the Dialog OnClick, this makes converting existing dialogs more work than they need to be.

Password EditText in LovelyTextInputDialog

Hi,

I tried to do this:
.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD)

But that doesn't work...

Does anyone have an idea of how to use a password mask in this textinput?

Default selected item in single choice

Hi,

I have a simple dialog with 2 options, I am saving the selected value so users can change whenever they want.

I want to show the previous selected value

how can i do this ?

LovelyChoiceDialog

Is there a way to trap/prevent confirmation if the number of selected items does not satisfy/meet your required count?

iconView always is null

I install LovelyDialog with gradle,and copy your code to my project, but

iconView = findView(R.id.ld_icon);
titleView = findView(R.id.ld_title);
messageView = findView(R.id.ld_message);
topTitleView = findView(R.id.ld_top_title);

iconView,titleView,messageView and topTitleView always is null

And I install LovelyDialog with gradle in a new project,it's normal.

ViewPager not working when .setView is used

I tried to merge the Dialog I was using to a LovelyCustomDialog, but the viewpagers doesnt seem to get the items, as it worked fine on a simple dialog, I dont know whether this is a Lovely Dialogs error or mine. Any clue?

LayoutInflater inflater = this.getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.reviewleer, null);
adaptervp = new MyPagerAdapter(this, arrayReview);
ViewPager viewPager = (ViewPager) dialogView.findViewById(R.id.viewpager);
viewPager.setAdapter(adaptervp);

**new LovelyCustomDialog(this)
                .setView(dialogView )
                .setTopColorRes(R.color.vimeo)
                .setTitle("asd")
                .setMessage("asd")
                .setIcon(R.drawable.ic_settings_ethernet_white_24dp)
                .show();**



Help with custom dialog

i am trying to use your custom dialog, but i am having a problem. I cannot access the EditText strings, every time i push it to the database it shows up as an empty string like this "". Will you please help? There is no problem with passing hardcoded strings to the database, the only problem is with converting edittext to string and passing it to the database, it just comes up like this "". I think it is something wrong with how i configured my view, i had to guess because i could not find any examples of the custom dialog. here is my code

public class MainActivity extends AppCompatActivity {

    private static final int ID_TEXT_INPUT_DIALOG = R.id.fab;
    private String mUsername;
    private String mPhotoUrl;
    private SharedPreferences mSharedPreferences;
    private GoogleSignInClient mSignInClient;
    private static final String MESSAGE_URL = "http://pantryapp.firebase.google.com/message/";
    public static final String ANONYMOUS = "anonymous";
    public static final String FOODS_CHILD = "Pantry2";
    private DrawerLayout mDrawerLayout;
    private EditText mName, mQuantity, mLifecycle;

    // Firebase instance variables
    private FirebaseAuth mFirebaseAuth;
    private FirebaseUser mFirebaseUser;
    private DatabaseReference mFirebaseDatabaseReference;
    private View PrivateChatsView;


    FirebaseDatabase database = FirebaseDatabase.getInstance();
    private DatabaseReference mRef = database.getReference("foods");


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);




        //remove below if it breaks
        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

//         Set default username as anonymous.
        mUsername = ANONYMOUS;

        // Initialize Firebase Auth
        mFirebaseAuth = FirebaseAuth.getInstance();
        mFirebaseUser = mFirebaseAuth.getCurrentUser();
        if (mFirebaseUser == null) {
            // Not signed in, launch the Sign In activity
            startActivity(new Intent(this, SignInActivity.class));
            finish();
            return;
        } else {
            mUsername = mFirebaseUser.getDisplayName();
            if (mFirebaseUser.getPhotoUrl() != null) {
                mPhotoUrl = mFirebaseUser.getPhotoUrl().toString();
            }
        }


        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        final ActionBar ab = getSupportActionBar();
        ab.setHomeAsUpIndicator(R.drawable.ic_menu);
        ab.setDisplayHomeAsUpEnabled(true);

        //new child entries
        mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference();

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        if (navigationView != null) {
            setupDrawerContent(navigationView);
        }

        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
        if (viewPager != null) {
            setupViewPager(viewPager);
        }

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {


                //this is the one with all three fields that works.
                showEditDialog();

            }
        });

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(viewPager);
    }

    private void showTextInputDialog(Bundle savedInstanceState) {
        new LovelyTextInputDialog(this, R.style.EditTextTintTheme)
                .setTopColorRes(R.color.PINK)
                .setTitle(R.string.text_input_title)
                .setMessage(R.string.text_input_message)
                .setIcon(R.drawable.ic_forum)
                .setInstanceStateHandler(ID_TEXT_INPUT_DIALOG, new LovelySaveStateHandler())
                .setConfirmButton(android.R.string.ok, new LovelyTextInputDialog.OnTextInputConfirmListener() {
                    @Override
                    public void onTextInputConfirmed(String text) {
                        Toast.makeText(MainActivity.this,"Added "+ text, Toast.LENGTH_SHORT).show();

                    }
                })

                .setSavedInstanceState(savedInstanceState)
                .show();
    }

    private void showEditDialog(){

        final Context context = this;
        final LovelyCustomDialog mDialog = new LovelyCustomDialog(context);

        mDialog.setView(R.layout.item_donate_option);
        LayoutInflater inflater = this.getLayoutInflater();

        mDialog.setTopColorRes(R.color.PINK);
        mDialog.setTitle(R.string.text_input_title);

        mDialog.setInstanceStateHandler(ID_TEXT_INPUT_DIALOG, new LovelySaveStateHandler());
        mDialog.show();
        mDialog.setListener(R.id.ld_btn_confirm, new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                final View v = getLayoutInflater().inflate(R.layout.item_donate_option, null);
                final EditText name = (EditText) v.findViewById(R.id.item_name);
                final EditText quantity = (EditText) v.findViewById(R.id.item_quantity);
                final EditText lifecycle = (EditText) v.findViewById(R.id.item_lifecycle);

                String mName = name.getText().toString().trim();
                String mQuantity = quantity.getText().toString().trim();
                String mLifecycle = lifecycle.getText().toString().trim();
                String id = "1";

                Foods food = new Foods(mName, mQuantity, mLifecycle);

                String lemon = "lemon";
                String quant = "3";
                String life = "5";

                DatabaseReference foodRef = mRef.child("Pantry");
                DatabaseReference newFoodRef = foodRef.push();
                newFoodRef.setValue(food);
                mRef.child("Pantry").setValue(new Foods(lemon, quant, life));



                Snackbar.make(view, "Added a " + food.getmName(), Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();

 public void writeNewFood(String name, String quantity, String lifecycle) {
        Foods foods = new Foods(name, quantity, lifecycle);
        mRef.child(name).setValue(foods);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.sample_actions, menu);
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        switch (AppCompatDelegate.getDefaultNightMode()) {
            case AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM:
                menu.findItem(R.id.menu_night_mode_system).setChecked(true);
                break;
            case AppCompatDelegate.MODE_NIGHT_AUTO:
                menu.findItem(R.id.menu_night_mode_auto).setChecked(true);
                break;
            case AppCompatDelegate.MODE_NIGHT_YES:
                menu.findItem(R.id.menu_night_mode_night).setChecked(true);
                break;
            case AppCompatDelegate.MODE_NIGHT_NO:
                menu.findItem(R.id.menu_night_mode_day).setChecked(true);
                break;
        }
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.sign_out_menu:
                mFirebaseAuth.signOut();
                mSignInClient.signOut();
                mUsername = ANONYMOUS;
                startActivity(new Intent(this, SignInActivity.class));
                finish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
            case android.R.id.home:
                mDrawerLayout.openDrawer(GravityCompat.START);
                return true;
            case R.id.menu_night_mode_system:
                setNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
                break;
            case R.id.menu_night_mode_day:
                setNightMode(AppCompatDelegate.MODE_NIGHT_NO);
                break;
            case R.id.menu_night_mode_night:
                setNightMode(AppCompatDelegate.MODE_NIGHT_YES);
                break;
            case R.id.menu_night_mode_auto:
                setNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
                break;


        }
        return super.onOptionsItemSelected(item);
    }

And here is my layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <include layout="@layout/view_color_area" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/texts">

            <Space
                android:layout_width="wrap_content"
                android:layout_height="12dp" />

            <include layout="@layout/view_title_and_message" />



                <EditText
                    android:id="@+id/item_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:ems="20"
                    android:hint="@string/food_name"
                    android:padding="22dp" />


                <EditText
                    android:id="@+id/item_quantity"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:ems="20"
                    android:hint="@string/item_quantity"
                    android:padding="22dp" />


                <EditText
                    android:id="@+id/item_lifecycle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:ems="20"
                    android:hint="@string/item_lifecycle_in_days"
                    android:padding="22dp" />




            <Space
                android:layout_width="wrap_content"
                android:layout_height="8dp" />

        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:orientation="horizontal">


        <Button
            android:id="@+id/ld_btn_confirm"
            style="@style/DialogButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:text="@android:string/ok"/>

    </LinearLayout>

</LinearLayout>

Please can you help me i have been working on this for days. Its my first android project and i really need to figure this out. Thank you for your time, You are my last hope.

custom view

how do i make this dialog to display my custom activity or have a custom look to the display e.g. display an order or checkout form, or a login form? And how is the CustomDalog option used? Any example?

Can't set TopColor to my choice

In the tutorial you have set the topColor like this
.setTopColor(color(R.color.indigo))
you are sending the color id into some kind of color90 function what is it. And if I try this
setTopColor(R.color.my_custom_color)
it is always showing same dark grey type of color ,

Theme.AppCompat Error!

When running the App I am getting this error!
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:354) at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:83) at android.support.v7.app.AlertController.installContent(AlertController.java:226) at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:260) at android.app.Dialog.dispatchOnCreate(Dialog.java:402) at android.app.Dialog.show(Dialog.java:301) at com.yarolegovich.lovelydialog.AbsLovelyDialog.show(AbsLovelyDialog.java:163) at ytstudios.wall.bucket.MainActivity$checkForAppUpdates.onPostExecute(MainActivity.java:333) at ytstudios.wall.bucket.MainActivity$checkForAppUpdates.onPostExecute(MainActivity.java:286) at android.os.AsyncTask.finish(AsyncTask.java:673) at android.os.AsyncTask.-wrap1(AsyncTask.java) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:690) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6236) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)

How should I fix this ?

Multiple edittext

Is it possible to have multiple Text field. I want to use it for adding home address?

Like address 1, address 2, Zip Code

Thanks!

Get the editText of TextInputDialog

I think the TextInputDialog should have a method that returns the EditText of the dialog itself so we can edit it programmatically Like settings the text change inputType ...etc

Empty space around image in dialog

There's always unnecessary empty space in the dialog when an image is present. Why does this happen? Check out these examples (in this case the unnecessary space is green):

Screenshot_20190905-120055_NewsMap

I'd highly appreciate it if this is solved with a quick update. Should be an easy fix. Thanks!

Screenshot_20190905-120130_NewsMap

Put buttons vertically

Hello! your library is awesome, but i have a little question.

Can i put the buttons of standar dialog vertically?

Like this:

image

Thanks for your time!

Have good day!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.