Search in sources :

Example 91 with CheckBox

use of android.widget.CheckBox in project android_frameworks_base by crdroidandroid.

the class MediaProjectionPermissionActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mPackageName = getCallingPackage();
    IBinder b = ServiceManager.getService(MEDIA_PROJECTION_SERVICE);
    mService = IMediaProjectionManager.Stub.asInterface(b);
    if (mPackageName == null) {
        finish();
        return;
    }
    PackageManager packageManager = getPackageManager();
    ApplicationInfo aInfo;
    try {
        aInfo = packageManager.getApplicationInfo(mPackageName, 0);
        mUid = aInfo.uid;
    } catch (PackageManager.NameNotFoundException e) {
        Log.e(TAG, "unable to look up package name", e);
        finish();
        return;
    }
    try {
        if (mService.hasProjectionPermission(mUid, mPackageName)) {
            setResult(RESULT_OK, getMediaProjectionIntent(mUid, mPackageName, false));
            finish();
            return;
        }
    } catch (RemoteException e) {
        Log.e(TAG, "Error checking projection permissions", e);
        finish();
        return;
    }
    TextPaint paint = new TextPaint();
    paint.setTextSize(42);
    String label = aInfo.loadLabel(packageManager).toString();
    // If the label contains new line characters it may push the security
    // message below the fold of the dialog. Labels shouldn't have new line
    // characters anyways, so just truncate the message the first time one
    // is seen.
    final int labelLength = label.length();
    int offset = 0;
    while (offset < labelLength) {
        final int codePoint = label.codePointAt(offset);
        final int type = Character.getType(codePoint);
        if (type == Character.LINE_SEPARATOR || type == Character.CONTROL || type == Character.PARAGRAPH_SEPARATOR) {
            label = label.substring(0, offset) + ELLIPSIS;
            break;
        }
        offset += Character.charCount(codePoint);
    }
    if (label.isEmpty()) {
        label = mPackageName;
    }
    String unsanitizedAppName = TextUtils.ellipsize(label, paint, MAX_APP_NAME_SIZE_PX, TextUtils.TruncateAt.END).toString();
    String appName = BidiFormatter.getInstance().unicodeWrap(unsanitizedAppName);
    String actionText = getString(R.string.media_projection_dialog_text, appName);
    SpannableString message = new SpannableString(actionText);
    int appNameIndex = actionText.indexOf(appName);
    if (appNameIndex >= 0) {
        message.setSpan(new StyleSpan(Typeface.BOLD), appNameIndex, appNameIndex + appName.length(), 0);
    }
    mDialog = new AlertDialog.Builder(this).setIcon(aInfo.loadIcon(packageManager)).setMessage(message).setPositiveButton(R.string.media_projection_action_text, this).setNegativeButton(android.R.string.cancel, this).setView(R.layout.remember_permission_checkbox).setOnCancelListener(this).create();
    mDialog.create();
    mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setFilterTouchesWhenObscured(true);
    ((CheckBox) mDialog.findViewById(R.id.remember)).setOnCheckedChangeListener(this);
    mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    mDialog.show();
}
Also used : SpannableString(android.text.SpannableString) IBinder(android.os.IBinder) PackageManager(android.content.pm.PackageManager) CheckBox(android.widget.CheckBox) StyleSpan(android.text.style.StyleSpan) ApplicationInfo(android.content.pm.ApplicationInfo) SpannableString(android.text.SpannableString) RemoteException(android.os.RemoteException) TextPaint(android.text.TextPaint) TextPaint(android.text.TextPaint)

Example 92 with CheckBox

use of android.widget.CheckBox in project LiveLessons by douglascraigschmidt.

the class CalculatorGUIVerbose method unCheckAll.

/** Resets the GUI. */
public void unCheckAll() {
    checkRadioGroup(rg1, false);
    checkRadioGroup(rg2, false);
    checkRadioGroup(rg3, false);
    CheckBox cb = (CheckBox) findViewById(R.id.cb);
    cb.setChecked(false);
}
Also used : CheckBox(android.widget.CheckBox)

Example 93 with CheckBox

use of android.widget.CheckBox in project LiveLessons by douglascraigschmidt.

the class CalculatorGUIVerbose method enableCheckbox.

/** Enables/Disables the Check Box */
private void enableCheckbox(boolean enable) {
    CheckBox cb = (CheckBox) findViewById(R.id.cb);
    cb.setEnabled(enable);
}
Also used : CheckBox(android.widget.CheckBox)

Example 94 with CheckBox

use of android.widget.CheckBox in project LiveLessons by douglascraigschmidt.

the class AndroidPlatform method buttonToggled.

/**
     * Retrieves textual input of the toggled button determined by the
     * user.
     */
private String buttonToggled() {
    Log.e("AndroidPlatform", "buttonToggled");
    /** Checks the format radio group for checked buttons. */
    RadioGroup rg = (RadioGroup) activity.findViewById(R.id.rad1);
    for (int i = 0; i < rg.getChildCount(); i++) if (((RadioButton) rg.getChildAt(i)).isChecked() && ((RadioButton) rg.getChildAt(i)).isEnabled())
        return ("format" + " " + (String) ((TextView) rg.getChildAt(i)).getText()).toLowerCase();
    /** Checks the print radio group for checked buttons. */
    rg = (RadioGroup) activity.findViewById(R.id.rad2);
    for (int i = 0; i < rg.getChildCount(); i++) if (((RadioButton) rg.getChildAt(i)).isChecked() && ((RadioButton) rg.getChildAt(i)).isEnabled()) {
        ((TextView) activity.findViewById(R.id.tv)).setText("");
        return ("print" + " " + (String) ((TextView) rg.getChildAt(i)).getText()).toLowerCase();
    }
    /** Checks the eval radio group for checked buttons. */
    rg = (RadioGroup) activity.findViewById(R.id.rad3);
    for (int i = 0; i < rg.getChildCount(); i++) if (((RadioButton) rg.getChildAt(i)).isChecked() && ((RadioButton) rg.getChildAt(i)).isEnabled())
        return ("eval" + " " + (String) ((TextView) rg.getChildAt(i)).getText()).toLowerCase();
    /** Checks the set checkbox. */
    CheckBox cb = (CheckBox) activity.findViewById(R.id.cb);
    if (cb.isChecked() && cb.isEnabled())
        return ("set" + (String) ((TextView) cb).getText()).toLowerCase();
    return "expr";
}
Also used : RadioGroup(android.widget.RadioGroup) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) RadioButton(android.widget.RadioButton)

Example 95 with CheckBox

use of android.widget.CheckBox in project double-espresso by JakeWharton.

the class ViewMatchersTest method testCheckBoxMatchers.

public void testCheckBoxMatchers() {
    assertFalse(isChecked().matches(new Spinner(getInstrumentation().getTargetContext())));
    assertFalse(isNotChecked().matches(new Spinner(getInstrumentation().getTargetContext())));
    CheckBox checkBox = new CheckBox(getInstrumentation().getTargetContext());
    checkBox.setChecked(true);
    assertTrue(isChecked().matches(checkBox));
    assertFalse(isNotChecked().matches(checkBox));
    checkBox.setChecked(false);
    assertFalse(isChecked().matches(checkBox));
    assertTrue(isNotChecked().matches(checkBox));
    RadioButton radioButton = new RadioButton(getInstrumentation().getTargetContext());
    radioButton.setChecked(false);
    assertFalse(isChecked().matches(radioButton));
    assertTrue(isNotChecked().matches(radioButton));
    radioButton.setChecked(true);
    assertTrue(isChecked().matches(radioButton));
    assertFalse(isNotChecked().matches(radioButton));
    CheckedTextView checkedText = new CheckedTextView(getInstrumentation().getTargetContext());
    checkedText.setChecked(false);
    assertFalse(isChecked().matches(checkedText));
    assertTrue(isNotChecked().matches(checkedText));
    checkedText.setChecked(true);
    assertTrue(isChecked().matches(checkedText));
    assertFalse(isNotChecked().matches(checkedText));
    Checkable checkable = new Checkable() {

        @Override
        public boolean isChecked() {
            return true;
        }

        @Override
        public void setChecked(boolean ignored) {
        }

        @Override
        public void toggle() {
        }
    };
    assertFalse(isChecked().matches(checkable));
    assertFalse(isNotChecked().matches(checkable));
}
Also used : Spinner(android.widget.Spinner) CheckBox(android.widget.CheckBox) CheckedTextView(android.widget.CheckedTextView) RadioButton(android.widget.RadioButton) Checkable(android.widget.Checkable)

Aggregations

CheckBox (android.widget.CheckBox)197 View (android.view.View)102 TextView (android.widget.TextView)78 CompoundButton (android.widget.CompoundButton)51 Button (android.widget.Button)48 ImageView (android.widget.ImageView)32 Intent (android.content.Intent)30 EditText (android.widget.EditText)30 LayoutInflater (android.view.LayoutInflater)25 AdapterView (android.widget.AdapterView)25 DialogInterface (android.content.DialogInterface)21 ListView (android.widget.ListView)20 SuppressLint (android.annotation.SuppressLint)19 RadioButton (android.widget.RadioButton)19 AlertDialog (android.app.AlertDialog)17 Paint (android.graphics.Paint)14 Bundle (android.os.Bundle)12 ViewGroup (android.view.ViewGroup)12 GridLayout (android.widget.GridLayout)12 LinearLayout (android.widget.LinearLayout)12