package com.marcoscg.easylicensesdialogsample;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TextView;

import com.marcoscg.easylicensesdialog.EasyLicensesDialog;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }

    public void showLicensesDialog(View view) {
        EasyLicensesDialog easyLicensesDialog = new EasyLicensesDialog(this);
        easyLicensesDialog.setTitle("Licenses"); //by default EasyLicensesDialog comes without any title.
        easyLicensesDialog.setCancelable(true); //true or false
        //easyLicensesDialog.setIcon(R.mipmap.ic_launcher);
        easyLicensesDialog.show();
    }

    public void showAboutDialog() {
        String msg = getResources().getString(R.string.about_text);
        LinearLayout rl = new LinearLayout(this);
        rl.setPadding(dpToPx(24),dpToPx(16),dpToPx(24),dpToPx(0));
        rl.setOrientation(LinearLayout.VERTICAL);
        rl.setGravity(Gravity.CENTER_HORIZONTAL);
        TextView tv  = new TextView(this);
        tv.setMovementMethod(LinkMovementMethod.getInstance());
        tv.setText(Html.fromHtml(msg));
        tv.setTextSize(16);
        tv.setTextColor(Color.parseColor("#757575"));
        tv.setLayoutParams(new TableLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
        rl.addView(tv);
        AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogStyle);
        builder.setTitle("About " + getResources().getString(R.string.library_name));
        builder.setView(rl);
        builder.setPositiveButton("Close", null);
        builder.setNeutralButton("View On GitHub",
                new DialogInterface.OnClickListener()
                {
                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {
                        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/marcoscgdev/EasyLicensesDialog")));
                    }
                });
        builder.show();
    }

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

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            showAboutDialog();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public int dpToPx(int dp) {
        DisplayMetrics displayMetrics = getApplicationContext().getResources().getDisplayMetrics();
        int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
        return px;
    }

}
@@ -416,45 +416,8 @@
 d;%0D%0A
-import android.util.DisplayMetrics;%0D%0A
 impo
@@ -531,81 +531,8 @@
 w;%0D%0A
-import android.widget.LinearLayout;%0D%0Aimport android.widget.TableLayout;%0D%0A
 impo
@@ -1485,453 +1485,306 @@
     
-LinearLayout rl = new LinearLayout(this);%0D%0A        rl.setPadding(dpToPx(24),dpToPx(16),dpToPx(24),dpToPx(0));%0D%0A        rl.setOrientation(LinearLayout.VERTICAL);%0D%0A        rl.setGravity(Gravity.CENTER_HORIZONTAL);%0D%0A        TextView tv  = new TextView(this);%0D%0A        tv.setMovementMethod(LinkMovementMethod.getInstance());%0D%0A        tv.setText(Html.fromHtml(msg));%0D%0A        tv.setTextSize(16);%0D%0A        tv.setTextColor(Color.parseColor(%22#757575%22));
+AlertDialog alertDialog = new AlertDialog.Builder(this, R.style.DialogStyle).create();%0D%0A        alertDialog.setTitle(%22About %22 + getResources().getString(R.string.app_name));%0D%0A        alertDialog.setMessage(Html.fromHtml(msg));%0D%0A        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,%22Close%22,
 %0D%0A  
@@ -1793,141 +1793,55 @@
     
+ 
-tv.setLayoutParams(new TableLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
+       new DialogInterface.OnClickListener() %7B
 %0D%0A  
@@ -1850,324 +1850,190 @@
     
+ 
-rl.addView(tv);%0D%0A        AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogStyle);%0D%0A        builder.setTitle(%22About %22 + getResources().getString(R.string.library_name));%0D%0A        builder.setView(rl);%0D%0A        builder.setPositiveButton(%22Close%22, null);%0D%0A        builder.setNeutralButton(
+           public void onClick(DialogInterface dialog, int which) %7B%0D%0A                    %7D%0D%0A                %7D);%0D%0A        alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
 %22View 
-O
+o
 n Gi
@@ -2097,60 +2097,12 @@
 er()
-%0D%0A               
  %7B%0D%0A
-                    @Override%0D%0A
     
@@ -2171,37 +2171,16 @@
 t which)
-%0D%0A                   
  %7B%0D%0A    
@@ -2367,21 +2367,349 @@
     
-builder.show(
+alertDialog.show();%0D%0A        TextView messageView = (TextView)alertDialog.findViewById(android.R.id.message);%0D%0A        messageView.setGravity(Gravity.CENTER);%0D%0A        messageView.setTextColor(Color.parseColor(%22#757575%22));%0D%0A        ((TextView)alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()
 );%0D%0A
@@ -3162,259 +3162,7 @@
 %0D%0A%0D%0A
-    public int dpToPx(int dp) %7B%0D%0A        DisplayMetrics displayMetrics = getApplicationContext().getResources().getDisplayMetrics();%0D%0A        int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));%0D%0A        return px;%0D%0A    %7D%0D%0A%0D%0A%7D
+%7D%0D%0A

Update MainActivity.java