Search in sources :

Example 96 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 97 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 98 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 99 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 100 with CheckBox

use of android.widget.CheckBox in project quickstart-android by firebase.

the class MainActivityTest method caughtExceptionTest.

@Test
public void caughtExceptionTest() {
    // Make sure the checkbox is on screen
    ViewInteraction al = onView(allOf(withId(R.id.catchCrashCheckBox), withText(R.string.catch_crash_checkbox_label), isDisplayed()));
    // Click the checkbox if it's not already checked
    CheckBox checkBox = (CheckBox) mActivityTestRule.getActivity().findViewById(R.id.catchCrashCheckBox);
    if (!checkBox.isChecked()) {
        al.perform(click());
    }
    // Cause a crash
    ViewInteraction ak = onView(allOf(withId(R.id.crashButton), withText(R.string.crash_button_label), isDisplayed()));
    ak.perform(click());
}
Also used : CheckBox(android.widget.CheckBox) ViewInteraction(android.support.test.espresso.ViewInteraction) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Aggregations

CheckBox (android.widget.CheckBox)183 View (android.view.View)92 TextView (android.widget.TextView)69 CompoundButton (android.widget.CompoundButton)46 Button (android.widget.Button)43 ImageView (android.widget.ImageView)29 Intent (android.content.Intent)28 EditText (android.widget.EditText)27 AdapterView (android.widget.AdapterView)25 ListView (android.widget.ListView)20 LayoutInflater (android.view.LayoutInflater)19 DialogInterface (android.content.DialogInterface)16 RadioButton (android.widget.RadioButton)16 SuppressLint (android.annotation.SuppressLint)14 RemoteException (android.os.RemoteException)13 AlertDialog (android.app.AlertDialog)12 Paint (android.graphics.Paint)12 GridLayout (android.widget.GridLayout)12 Bundle (android.os.Bundle)11 ViewGroup (android.view.ViewGroup)11