Example usage for android.app AlertDialog requestWindowFeature

List of usage examples for android.app AlertDialog requestWindowFeature

Introduction

In this page you can find the example usage for android.app AlertDialog requestWindowFeature.

Prototype

public final boolean requestWindowFeature(int featureId) 

Source Link

Document

Enable extended window features.

Usage

From source file:org.dkf.jmule.util.UIUtils.java

/**
 *
 * @param context -  containing Context.
 * @param showInstallationCompleteSection - true if you want to display "Your installation is now complete. Thank You" section
 * @param dismissListener - what happens when the dialog is dismissed.
 * @param referrerContextSuffix - string appended at the end of social pages click urls's ?ref=_android_ parameter.
 *///from w w w .jav a 2  s .  c om
public static void showSocialLinksDialog(final Context context, boolean showInstallationCompleteSection,
        DialogInterface.OnDismissListener dismissListener, String referrerContextSuffix) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    View customView = View.inflate(context, R.layout.view_social_buttons, null);
    builder.setView(customView);
    builder.setPositiveButton(context.getString(android.R.string.ok), new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    final AlertDialog socialLinksDialog = builder.create();
    socialLinksDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    socialLinksDialog.setOnDismissListener(dismissListener);

    ImageButton githubButton = (ImageButton) customView.findViewById(R.id.view_buttons_github);
    //ImageButton twitterButton = (ImageButton) customView.findViewById(R.id.view_social_buttons_twitter_button);
    //ImageButton redditButton = (ImageButton) customView.findViewById(R.id.view_social_buttons_reddit_button);

    //final String referrerParam  = "?ref=android_" + ((referrerContextSuffix!=null) ? referrerContextSuffix.trim() : "");

    githubButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            UIUtils.openURL(v.getContext(), Constants.GITHUB_PAGE);
        }
    });
    /*
            twitterButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_TWITTER_PAGE + referrerParam);
    }
            });
            
            redditButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_REDDIT_PAGE + referrerParam);
    }
            });
            
    */
    if (showInstallationCompleteSection) {
        LinearLayout installationCompleteLayout = (LinearLayout) customView
                .findViewById(R.id.view_social_buttons_installation_complete_layout);
        installationCompleteLayout.setVisibility(View.VISIBLE);
        ImageButton dismissCheckButton = (ImageButton) customView
                .findViewById(R.id.view_social_buttons_dismiss_check);
        dismissCheckButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                socialLinksDialog.dismiss();
            }
        });
    }

    socialLinksDialog.show();
}

From source file:com.frostwire.android.gui.util.UIUtils.java

/**
 * @param context                         -  containing Context.
 * @param showInstallationCompleteSection - true if you want to display "Your installation is now complete. Thank You" section
 * @param dismissListener                 - what happens when the dialog is dismissed.
 * @param referrerContextSuffix           - string appended at the end of social pages click urls's ?ref=_android_ parameter.
 *//* w w  w.  ja  v  a  2 s . c  om*/
public static void showSocialLinksDialog(final Context context, boolean showInstallationCompleteSection,
        DialogInterface.OnDismissListener dismissListener, String referrerContextSuffix) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    View customView = View.inflate(context, R.layout.view_social_buttons, null);
    builder.setView(customView);
    builder.setPositiveButton(context.getString(android.R.string.ok), (dialog, which) -> dialog.dismiss());
    final AlertDialog socialLinksDialog = builder.create();
    socialLinksDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    socialLinksDialog.setOnDismissListener(dismissListener);
    ImageButton fbButton = customView.findViewById(R.id.view_social_buttons_facebook_button);
    ImageButton twitterButton = customView.findViewById(R.id.view_social_buttons_twitter_button);
    ImageButton redditButton = customView.findViewById(R.id.view_social_buttons_reddit_button);
    final String referrerParam = "?ref=android_"
            + ((referrerContextSuffix != null) ? referrerContextSuffix.trim() : "");
    fbButton.setOnClickListener(
            v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_FACEBOOK_PAGE + referrerParam));
    twitterButton.setOnClickListener(
            v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_TWITTER_PAGE + referrerParam));
    redditButton.setOnClickListener(
            v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_REDDIT_PAGE + referrerParam));
    if (showInstallationCompleteSection) {
        LinearLayout installationCompleteLayout = customView
                .findViewById(R.id.view_social_buttons_installation_complete_layout);
        installationCompleteLayout.setVisibility(View.VISIBLE);
        ImageButton dismissCheckButton = customView.findViewById(R.id.view_social_buttons_dismiss_check);
        dismissCheckButton.setOnClickListener(v -> socialLinksDialog.dismiss());
    }
    socialLinksDialog.show();
}

From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java

private void showConnectToAmritaAlert() {
    AlertDialog.Builder builder = new AlertDialog.Builder(baseContext);
    builder.setMessage("Connect to the Amrita WiFi if possible, for a reliable connection to the GPMS Server.")
            .setCancelable(true).setIcon(R.drawable.ic_action_info_small)
            .setPositiveButton("Ok. I'll connect.", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
                    finish();/*from ww  w.  ja  v a 2 s .c  o m*/
                }
            }).setNegativeButton("No. I won't.", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                    initialiseGpms();
                    hideSoftKeyboard();
                }
            });

    AlertDialog alert = builder.create();
    alert.requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (!Identifier.isConnectedToAmrita(baseContext)) {
        alert.show();
    } else {
        initialiseGpms();
    }
}

From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java

@Override
public void init(Bundle savedInstanceState) {
    setupLayout(R.layout.activity_gpms_login, Color.parseColor("#009688"));
    rollNoEditText = (EditText) findViewById(R.id.roll_no);
    passwordEditText = (EditText) findViewById(R.id.pwd);

    AlertDialog.Builder builder = new AlertDialog.Builder(baseContext);
    builder.setMessage("Amrita University does not provide an API for accessing GPMS data. "
            + "So, if any changes are made to the GPMS Website, please be patient while I try to catch up.")
            .setCancelable(true).setIcon(R.drawable.ic_action_info_small)
            .setPositiveButton("Got it !", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();//w  w w  .  ja  va2s. c  o m
                    hideSoftKeyboard();
                    showConnectToAmritaAlert();
                }
            });
    AlertDialog alert = builder.create();
    alert.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alert.show();

    dialog = new ProgressDialog(baseContext);
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);
    dialog.setInverseBackgroundForced(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setMessage("Authenticating your credentials ... ");
    preferences = getSharedPreferences("gpms_prefs", Context.MODE_PRIVATE);
    String rollNo = preferences.getString("roll_no", "");
    String encodedPassword = preferences.getString("password", "");
    if (!rollNo.equals("")) {
        rollNoEditText.setText(rollNo);
        studentRollNo = rollNo;
        hideSoftKeyboard();
    } else {
        SharedPreferences aumsPrefs = getSharedPreferences("aums_prefs", Context.MODE_PRIVATE);
        String aumsRollNo = aumsPrefs.getString("RollNo", "");
        if (!aumsRollNo.equals("")) {
            rollNoEditText.setText(aumsRollNo);
            studentRollNo = aumsRollNo;
            hideSoftKeyboard();
        }
    }

    if (!encodedPassword.equals("")) {
        passwordEditText.setText(Security.decrypt(encodedPassword, MainApplication.key));
        hideSoftKeyboard();
    }
}

From source file:com.njlabs.amrita.aid.aums.AumsActivity.java

@Override
public void init(Bundle savedInstanceState) {
    setupLayout(R.layout.activity_aums, Color.parseColor("#e91e63"));

    rollNoEditText = (EditText) findViewById(R.id.roll_no);
    passwordEditText = (EditText) findViewById(R.id.pwd);

    List<String> campusDataSet = new LinkedList<>(Arrays.asList("Ettimadai", "Amritapuri", "Bangalore",
            "Mysore", "AIMS", "Business schools", "ASAS Kochi"));

    spinner = (MaterialSpinner) findViewById(R.id.spinner);
    spinner.setItems(campusDataSet);//from   ww  w .j ava 2 s  .c  o m

    AlertDialog.Builder builder = new AlertDialog.Builder(baseContext);
    builder.setMessage("Amrita University does not provide an API for accessing AUMS data. "
            + "So, if any changes are made to the AUMS Website, please be patient while I try to catch up.")
            .setCancelable(true).setIcon(R.drawable.ic_action_info_small)
            .setPositiveButton("Got it !", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                    hideSoftKeyboard();
                }
            });

    AlertDialog alert = builder.create();
    alert.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alert.show();

    dialog = new ProgressDialog(baseContext);
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);
    dialog.setInverseBackgroundForced(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setMessage("Authenticating your credentials ... ");

    aumsPreferences = getSharedPreferences("aums_prefs", Context.MODE_PRIVATE);
    String rollNo = aumsPreferences.getString("RollNo", "");
    String encodedPassword = aumsPreferences.getString("Password", "");
    spinner.setSelectedIndex(aumsPreferences.getInt("server_ordinal", 0));

    aums = new Aums(baseContext);

    if (!rollNo.equals("")) {
        ((EditText) findViewById(R.id.roll_no)).setText(rollNo);
        aums.studentRollNo = rollNo;
        hideSoftKeyboard();
    }

    if (!encodedPassword.equals("")) {
        ((EditText) findViewById(R.id.pwd)).setText(Security.decrypt(encodedPassword, MainApplication.key));
        hideSoftKeyboard();
    }

}

From source file:fr.forexperts.ui.PortfolioFragment.java

public void showAddDialog() {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View alertView = inflater.inflate(R.layout.alertdialog_add_value, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(alertView);// ww w .j a  v a  2  s.c o m
    final AlertDialog dialog = builder.create();
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
    wmlp.gravity = Gravity.TOP | Gravity.CENTER;
    wmlp.x = 10;
    wmlp.y = 10;

    final EditText mStockName = (EditText) alertView.findViewById(R.id.stockName);
    mListViewStock = (ListView) alertView.findViewById(R.id.listViewStock);
    mListViewStock.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String text = (String) parent.getItemAtPosition(position);
            String[] result = text.split(" ");

            AddTickerTask task = new AddTickerTask();
            task.execute(result[0]);

            dialog.dismiss();
        }
    });

    mStockName.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            SuggestStockTask task = new SuggestStockTask();
            task.execute(mStockName.getText().toString());
        }
    });

    // TODO: Change hard coded width
    mStockName.setWidth(10000);

    dialog.show();
}

From source file:fr.forexperts.ui.MarketOverviewFragment.java

public void showAddDialog() {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View alertView = inflater.inflate(R.layout.alertdialog_add_value, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(alertView);/*  w  ww.  j a v  a 2 s. c  o  m*/
    final AlertDialog dialog = builder.create();
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
    wmlp.gravity = Gravity.TOP | Gravity.CENTER;
    wmlp.x = 10;
    wmlp.y = 10;

    final EditText mStockName = (EditText) alertView.findViewById(R.id.stockName);
    mListViewStock = (ListView) alertView.findViewById(R.id.listViewStock);
    mListViewStock.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String text = (String) parent.getItemAtPosition(position);
            String[] result = text.split(" ");
            mCallback.onItemSelect(result[0]);
            dialog.dismiss();
        }
    });

    mStockName.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            SuggestStockTask task = new SuggestStockTask();
            task.execute(mStockName.getText().toString());
        }
    });

    // TODO: Change hard coded width
    mStockName.setWidth(10000);

    dialog.show();
}

From source file:fr.forexperts.ui.ArticleListFragment.java

public void showAddDialog() {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View alertView = inflater.inflate(R.layout.alertdialog_add_value, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(alertView);/*from   w w  w  .  j  av  a 2 s  .  c  o m*/
    final AlertDialog dialog = builder.create();
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
    wmlp.gravity = Gravity.TOP | Gravity.CENTER;
    wmlp.x = 10;
    wmlp.y = 10;

    final EditText mStockName = (EditText) alertView.findViewById(R.id.stockName);
    mListViewStock = (ListView) alertView.findViewById(R.id.listViewStock);
    mListViewStock.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String text = (String) parent.getItemAtPosition(position);
            String[] result = text.split(" ");
            Intent detailIntent = new Intent(getActivity(), GraphActivity.class);
            detailIntent.putExtra("code", result[0]);
            startActivity(detailIntent);
            dialog.dismiss();
        }
    });

    mStockName.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            SuggestStockTask task = new SuggestStockTask();
            task.execute(mStockName.getText().toString());
        }
    });

    // TODO: Change hard coded width
    mStockName.setWidth(10000);

    dialog.show();
}