Java Code Examples for android.app.Dialog#requestWindowFeature()

The following examples show how to use android.app.Dialog#requestWindowFeature() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DialogManager.java    From Gizwits-SmartSocket_Android with MIT License 6 votes vote down vote up
/**
 * 确定关机对话框
 * 
 * @param ctx
 * @param contentStr
 *            对话框内容
 * @param r
 *            右按钮监听器
 * @return
 */
public static Dialog getPowerOffDialog(final Activity ctx, OnClickListener r) {
	final Dialog dialog = new Dialog(ctx, R.style.noBackgroundDialog) {
	};
	LayoutInflater layoutInflater = LayoutInflater.from(ctx);
	View v = layoutInflater.inflate(R.layout.dialog_power_off, null);
	Button leftBtn = (Button) v.findViewById(R.id.left_btn);
	Button rightBtn = (Button) v.findViewById(R.id.right_btn);
	leftBtn.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View arg0) {
			dismissDialog(ctx, dialog);
		}
	});
	rightBtn.setOnClickListener(r);

	dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	dialog.setCanceledOnTouchOutside(false);
	dialog.setCancelable(false);
	dialog.setContentView(v);
	return dialog;
}
 
Example 2
Source File: DialogMaker.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
@NonNull
public static DialogMaker makeDialog(Context context) {
    DialogMaker dialogMaker = new DialogMaker();
    dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.gif_dialog);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

    dialog.setOnKeyListener(new Dialog.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                dialog.dismiss();
            }
            return true;
        }
    });

    return dialogMaker;
}
 
Example 3
Source File: FragmentCharacteristicDetail.java    From EFRConnect-android with Apache License 2.0 6 votes vote down vote up
private void initCharacteristicWriteDialog() {
    editableFieldsDialog = new Dialog(getActivity());
    editableFieldsDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    editableFieldsDialog.setContentView(R.layout.dialog_characteristic_write);
    editableFieldsDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    writableFieldsContainer = editableFieldsDialog.findViewById(R.id.characteristic_writable_fields_container);

    int width = (int) (getResources().getDisplayMetrics().widthPixels * 0.9);
    editableFieldsDialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);

    initWriteModeView(editableFieldsDialog);

    saveValueBtn = editableFieldsDialog.findViewById(R.id.save_btn);
    clearBtn = editableFieldsDialog.findViewById(R.id.clear_btn);
    closeIV = editableFieldsDialog.findViewById(R.id.image_view_close);
}
 
Example 4
Source File: SettingsActivity.java    From thunderboard-android with Apache License 2.0 6 votes vote down vote up
public void initHelpDialog() {
    helpDialog = new Dialog(this);
    helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    helpDialog.setContentView(R.layout.dialog_help_demo_item);
    ((TextView) helpDialog.findViewById(R.id.dialog_help_version_text)).setText(getString(R.string.version_text,
            BuildConfig.VERSION_NAME));
    View okButton = helpDialog.findViewById(R.id.help_ok_button);
    TextView textView = helpDialog.findViewById(R.id.help_text_playstore);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            helpDialog.dismiss();
        }
    });
}
 
Example 5
Source File: UserFeedbackView.java    From applivery-android-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Overrided in order to get fullScreen dialog
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {

    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
    dialog.getWindow()
            .setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return dialog;
}
 
Example 6
Source File: DialogBuilder.java    From meiShi with Apache License 2.0 5 votes vote down vote up
public Dialog create(){
    Dialog dialog=new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (dialogView!=null)
        dialog.setContentView(dialogView);
    else if(dialogViewId!=-1)
        dialog.setContentView(dialogViewId);
    return  dialog;
}
 
Example 7
Source File: FullScreenDialogFragment.java    From FullScreenDialog with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    initBuilderArguments();

    Dialog dialog = new Dialog(getActivity(), getTheme()) {
        @Override
        public void onBackPressed() {
            onDiscardButtonClick();
        }
    };
    if (!fullScreen)
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    return dialog;
}
 
Example 8
Source File: TextEditorDialogFragment.java    From MotionViews-Android with MIT License 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.requestWindowFeature(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return dialog;
}
 
Example 9
Source File: DialogFragment.java    From letv with Apache License 2.0 5 votes vote down vote up
public void setupDialog(Dialog dialog, int style) {
    switch (style) {
        case 1:
        case 2:
            break;
        case 3:
            dialog.getWindow().addFlags(24);
            break;
        default:
            return;
    }
    dialog.requestWindowFeature(1);
}
 
Example 10
Source File: DeviceServicesActivity.java    From EFRConnect-android with Apache License 2.0 5 votes vote down vote up
/**
 * INITIALIZES ABOUT DIALOG
 *******************************************************/
private void initAboutDialog() {
    dialogLicense = new Dialog(this);
    dialogLicense.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialogLicense.setContentView(R.layout.dialog_about_silicon_labs_blue_gecko);
    WebView webView = dialogLicense.findViewById(R.id.menu_item_license);
    Button closeButton = dialogLicense.findViewById(R.id.close_about_btn);
    webView.loadUrl(ABOUT_DIALOG_HTML_ASSET_FILE_PATH);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialogLicense.dismiss();
        }
    });
}
 
Example 11
Source File: ItemChooserDialog.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void showDialogForView(View view) {
    mDialog = new Dialog(mActivity) {
        @Override
        public void onWindowFocusChanged(boolean hasFocus) {
            super.onWindowFocusChanged(hasFocus);
            if (!hasFocus) super.dismiss();
        }
    };
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setCanceledOnTouchOutside(true);
    mDialog.addContentView(view,
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                          LinearLayout.LayoutParams.MATCH_PARENT));
    mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mItemSelectedCallback.onItemSelected("");
        }
    });

    Window window = mDialog.getWindow();
    if (!DeviceFormFactor.isTablet(mActivity)) {
        // On smaller screens, make the dialog fill the width of the screen,
        // and appear at the top.
        window.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        window.setGravity(Gravity.TOP);
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                         ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    mDialog.show();
}
 
Example 12
Source File: DialogManager.java    From Gizwits-SmartSocket_Android with MIT License 5 votes vote down vote up
/**
 * Gets the no network dialog.
 * 
 * @param ctx
 *            the ctx
 * @return the no network dialog
 */
public static Dialog getNoNetworkDialog(Context ctx) {
	Dialog dialog = new Dialog(ctx, R.style.noBackgroundDialog);
	LayoutInflater layoutInflater = LayoutInflater.from(ctx);
	View contentView = layoutInflater.inflate(R.layout.dialog_no_network,
			null);
	dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	dialog.setContentView(contentView);
	return dialog;
}
 
Example 13
Source File: Dialogs.java    From MapsMeasure with Apache License 2.0 5 votes vote down vote up
/**
 * @param m        the Map
 * @param distance the current distance
 * @param area     the current area
 * @return the units dialog
 */
public static Dialog getUnits(final Map m, float distance, double area) {
    final Dialog d = new Dialog(m);
    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.setContentView(R.layout.dialog_unit);
    CheckBox metricCb = (CheckBox) d.findViewById(R.id.metric);
    metricCb.setChecked(Map.metric);
    metricCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Map.metric = !Map.metric;
            m.getSharedPreferences("settings", Context.MODE_PRIVATE).edit()
                    .putBoolean("metric", isChecked).commit();
            m.updateValueText();
        }
    });
    ((TextView) d.findViewById(R.id.distance)).setText(
            Map.formatter_two_dec.format(Math.max(0, distance)) + " m\n" +
                    Map.formatter_two_dec.format(distance / 1000) + " km\n\n" +
                    Map.formatter_two_dec.format(Math.max(0, distance / 0.3048f)) + " ft\n" +
                    Map.formatter_two_dec.format(Math.max(0, distance / 0.9144)) + " yd\n" +
                    Map.formatter_two_dec.format(distance / 1609.344f) + " mi\n" +
                    Map.formatter_two_dec.format(distance / 1852f) + " nautical miles");

    ((TextView) d.findViewById(R.id.area)).setText(
            Map.formatter_two_dec.format(Math.max(0, area)) + " m²\n" +
                    Map.formatter_two_dec.format(area / 10000) + " ha\n" +
                    Map.formatter_two_dec.format(area / 1000000) + " km²\n\n" +
                    Map.formatter_two_dec.format(Math.max(0, area / 0.09290304d)) + " ft²\n" +
                    Map.formatter_two_dec.format(area / 4046.8726099d) + " ac (U.S. Survey)\n" +
                    Map.formatter_two_dec.format(area / 2589988.110336d) + " mi²");
    d.findViewById(R.id.close).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            d.dismiss();
        }
    });
    return d;
}
 
Example 14
Source File: Dialog_Statistics.java    From Pedometer with Apache License 2.0 5 votes vote down vote up
public static Dialog getDialog(final Context c, int since_boot) {
	final Dialog d = new Dialog(c);
	d.requestWindowFeature(Window.FEATURE_NO_TITLE);
	d.setContentView(R.layout.statistics);
	d.findViewById(R.id.close).setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			d.dismiss();
		}
	});
	Database db = Database.getInstance(c);

	Pair<Date, Integer> record = db.getRecordData();

	Calendar date = Calendar.getInstance();
	date.setTimeInMillis(Util.getToday());
	int daysThisMonth = date.get(Calendar.DAY_OF_MONTH);

	date.add(Calendar.DATE, -6);

	int thisWeek = db.getSteps(date.getTimeInMillis(), System.currentTimeMillis()) + since_boot;

	date.setTimeInMillis(Util.getToday());
	date.set(Calendar.DAY_OF_MONTH, 1);
	int thisMonth = db.getSteps(date.getTimeInMillis(), System.currentTimeMillis()) + since_boot;

	((TextView) d.findViewById(R.id.record)).setText(
               Fragment_Overview.formatter.format(record.second) + " @ "
			+ java.text.DateFormat.getDateInstance().format(record.first));

	((TextView) d.findViewById(R.id.totalthisweek)).setText(Fragment_Overview.formatter.format(thisWeek));
	((TextView) d.findViewById(R.id.totalthismonth)).setText(Fragment_Overview.formatter.format(thisMonth));

	((TextView) d.findViewById(R.id.averagethisweek)).setText(Fragment_Overview.formatter.format(thisWeek / 7));
	((TextView) d.findViewById(R.id.averagethismonth)).setText(Fragment_Overview.formatter.format(thisMonth / daysThisMonth));
	
	db.close();
	
	return d;
}
 
Example 15
Source File: CustomDialog.java    From nubo-test with Apache License 2.0 5 votes vote down vote up
public CustomDialog(Context context, int type, String title, String message) {

        this.mContext = context;
        this.type = type;
        this.title = title;
        this.message = message;

        dialog = new Dialog(mContext);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        int i = 0;

        dialog.setContentView(R.layout.dialog_custom);
        dialog.setCancelable(false);

        dialog_title = (TextView)dialog.findViewById(R.id.textView_dialog_title);
        dialog_message = (TextView)dialog.findViewById(R.id.textView_dialog_message);
        numberPicker = (NumberPicker)dialog.findViewById(R.id.numberPicker);
        button_dialog_ok=(Button)dialog.findViewById(R.id.button_dialog_ok);
        button_dialog_cancel=(Button)dialog.findViewById(R.id.button_dialog_cancel);
        dialogProgressBar = (ProgressBar)dialog.findViewById(R.id.progressBar);

        editText1 = (EditText)dialog.findViewById(R.id.editText1);
        editText2 = (EditText)dialog.findViewById(R.id.editText2);
        editText3 = (EditText)dialog.findViewById(R.id.editText3);


        if(message.length()==0 || message==null)
            dialog_message.setVisibility(View.GONE);

    }
 
Example 16
Source File: PhotosViewSlider.java    From PhotoViewSlider with Apache License 2.0 5 votes vote down vote up
private void generatePhotoDetail() {
    viewDialog = inflate(getContext(), R.layout.photo_detail, null);
    imgPhoto = (ImageView) viewDialog.findViewById(R.id.img_photo_gallery_detail);
    txtDescriptionGallery = (TextView) viewDialog.findViewById(R.id.txt_photo_gallery_description);
    txtCurrentPosition = (TextView) viewDialog.findViewById(R.id.txt_photo_current_position);
    txtPhotosTotal = (TextView) viewDialog.findViewById(R.id.txt_photo_total);
    btnShare = (ImageButton) viewDialog.findViewById(R.id.btn_share);

    builder = new Dialog(getContext());
    builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
    builder.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
 
Example 17
Source File: ThemedDialog.java    From echo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().getDecorView().setBackgroundDrawable(null);
    return dialog;
}
 
Example 18
Source File: QuickAppTile.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
public boolean handleLongClick() {
    LayoutInflater inflater = LayoutInflater.from(mGbContext);
    View appv = inflater.inflate(R.layout.quick_settings_app_dialog, null);
    int count = 0;
    AppInfo lastAppInfo = null;
    for (AppInfo ai : mAppSlots) {
        TextView tv = (TextView) appv.findViewById(ai.getResId());
        if (ai.getValue() == null) {
            tv.setVisibility(View.GONE);
            continue;
        }

        tv.setText(ai.getAppName());
        tv.setTextSize(1, 10);
        tv.setMaxLines(2);
        tv.setEllipsize(TruncateAt.END);
        tv.setCompoundDrawablesWithIntrinsicBounds(null, ai.getAppIcon(), null, null);
        tv.setClickable(true);
        tv.setOnClickListener(mOnSlotClick);
        count++;
        lastAppInfo = ai;
    }

    if (count == 1) {
        try {
            startActivity(lastAppInfo.getIntent());
        } catch (Throwable t) {
            log(getKey() + ": Unable to start activity: " + t.getMessage());
        }
    } else if (count > 1) {
        mDialog = new Dialog(mContext, android.R.style.Theme_Material_Dialog_NoActionBar);
        mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        mDialog.setContentView(appv);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL);
        int pf = XposedHelpers.getIntField(mDialog.getWindow().getAttributes(), "privateFlags");
        pf |= 0x00000010;
        XposedHelpers.setIntField(mDialog.getWindow().getAttributes(), "privateFlags", pf);
        mDialog.getWindow().clearFlags(LayoutParams.FLAG_DIM_BEHIND);
        mDialog.show();
        mHandler.removeCallbacks(mDismissDialogRunnable);
        mHandler.postDelayed(mDismissDialogRunnable, 4000);
    }
    return true;
}
 
Example 19
Source File: TimePickerDialog.java    From date_picker_converter with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}
 
Example 20
Source File: RemoteInstallDialog.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
  Dialog dialog = super.onCreateDialog(savedInstanceState);
  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  return dialog;
}