Search in sources :

Example 96 with Button

use of android.widget.Button in project AndroidImageCrop by lorensiuswlt.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final String[] items = new String[] { "Take from camera", "Select from gallery" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_item, items);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Select Image");
    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int item) {
            //pick from camera
            if (item == 0) {
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                mImageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "tmp_avatar_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
                intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
                try {
                    intent.putExtra("return-data", true);
                    startActivityForResult(intent, PICK_FROM_CAMERA);
                } catch (ActivityNotFoundException e) {
                    e.printStackTrace();
                }
            } else {
                //pick from file
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_FILE);
            }
        }
    });
    final AlertDialog dialog = builder.create();
    Button button = (Button) findViewById(R.id.btn_crop);
    mImageView = (ImageView) findViewById(R.id.iv_photo);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.show();
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) ActivityNotFoundException(android.content.ActivityNotFoundException) Button(android.widget.Button) File(java.io.File) ArrayAdapter(android.widget.ArrayAdapter)

Example 97 with Button

use of android.widget.Button in project NotificationPeekPort by lzanita09.

the class MainActivity method initViews.

private void initViews() {
    // Device Admin access button.
    View deviceAccessBtn = findViewById(R.id.device_access);
    deviceAccessBtn.setOnClickListener(this);
    // Notification access button.
    View notificationAccessBtn = findViewById(R.id.notification_access);
    notificationAccessBtn.setOnClickListener(this);
    // Status text and icons
    TextView instructionText = (TextView) findViewById(R.id.instruction_text);
    ImageView notificationAccessIcon = (ImageView) findViewById(R.id.notification_access_checkbox);
    ImageView deviceAdminAcessIcon = (ImageView) findViewById(R.id.device_access_checkbox);
    boolean isAccessEnabled = true;
    if (AccessChecker.isNotificationAccessEnabled(this)) {
        notificationAccessIcon.setImageResource(R.drawable.ic_checkmark);
    } else {
        notificationAccessIcon.setImageResource(R.drawable.ic_cancel);
        isAccessEnabled = false;
    }
    if (AccessChecker.isDeviceAdminEnabled(this)) {
        deviceAdminAcessIcon.setImageResource(R.drawable.ic_checkmark);
    } else {
        deviceAdminAcessIcon.setImageResource(R.drawable.ic_cancel);
        isAccessEnabled = false;
    }
    if (!isAccessEnabled || NotificationHelper.isPeekDisabled(this)) {
        SpannableString spannableString = new SpannableString(getString(R.string.instruction_start));
        spannableString.setSpan(new ForegroundColorSpan(getResources().getColor(android.R.color.holo_red_dark)), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        instructionText.setText(spannableString);
    } else {
        SpannableString spannableString = new SpannableString(getString(R.string.instruction_ok));
        spannableString.setSpan(new ForegroundColorSpan(getResources().getColor(android.R.color.holo_green_dark)), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        instructionText.setText(spannableString);
    }
    // Sensor status.
    ImageView proxLightSensorImg = (ImageView) findViewById(R.id.prox_light_check);
    ImageView gyroSensorImg = (ImageView) findViewById(R.id.gyro_check);
    if (SensorHelper.checkSensorStatus(this, SensorHelper.SENSOR_PROXIMITY_LIGHT, true)) {
        proxLightSensorImg.setImageResource(R.drawable.ic_checkmark);
    } else {
        proxLightSensorImg.setImageResource(R.drawable.ic_cancel);
    }
    if (SensorHelper.checkSensorStatus(this, SensorHelper.SENSOR_GYRO, true)) {
        gyroSensorImg.setImageResource(R.drawable.ic_checkmark);
    } else {
        gyroSensorImg.setImageResource(R.drawable.ic_cancel);
    }
    View proxLightSensorRoot = findViewById(R.id.prox_light_sensor);
    proxLightSensorRoot.setOnClickListener(this);
    View gyroSensorRoot = findViewById(R.id.gyro_sensor);
    gyroSensorRoot.setOnClickListener(this);
    // Send test notification button.
    Button sendNotificationButton = (Button) findViewById(R.id.send_notification_btn);
    sendNotificationButton.setOnClickListener(this);
}
Also used : SpannableString(android.text.SpannableString) ForegroundColorSpan(android.text.style.ForegroundColorSpan) Button(android.widget.Button) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 98 with Button

use of android.widget.Button in project NotificationPeekPort by lzanita09.

the class EverythingCard method init.

private void init(Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    boolean isPeekDisabled = preferences.getBoolean(PreferenceKeys.PREF_DISABLE_PEEK, false);
    String quietHourStr = preferences.getString(PreferenceKeys.PREF_QUIET_HOUR, PreferenceKeys.PREF_QUIET_HOUR_DEF);
    boolean isQuietHourSet = !quietHourStr.equals(PreferenceKeys.PREF_QUIET_HOUR_DEF);
    mOptionsShowing = !(isPeekDisabled || isQuietHourSet);
    mQuietHour = QuietHour.createQuietHour(quietHourStr);
    LayoutInflater.from(context).inflate(R.layout.everything_card, this, true);
    mPanelSwitcher = (ViewSwitcher) findViewById(R.id.view_switcher);
    if (!mOptionsShowing) {
        mPanelSwitcher.setVisibility(GONE);
    }
    mFromBtn = (Button) findViewById(R.id.quiet_hour_from_btn);
    mFromBtn.setOnClickListener(this);
    mToBtn = (Button) findViewById(R.id.quiet_hour_to_btn);
    mToBtn.setOnClickListener(this);
    Button mQuietHourBtn = (Button) findViewById(R.id.quiet_hour_btn);
    mQuietHourBtn.setOnClickListener(this);
    Button mDisableBtn = (Button) findViewById(R.id.as_is_btn);
    mDisableBtn.setOnClickListener(this);
    mFromToText = (TextView) findViewById(R.id.from_to_text);
    if (isQuietHourSet) {
        displayTime();
    }
    mFromToText.setOnClickListener(this);
}
Also used : SharedPreferences(android.content.SharedPreferences) Button(android.widget.Button)

Example 99 with Button

use of android.widget.Button in project AdvancedMaterialDrawer by madcyph3r.

the class FragmentActionBarButtons method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.example_action_bar_buttons, container, false);
    setHasOptionsMenu(true);
    LinearLayout ll = (LinearLayout) v.findViewById(R.id.linearLayout);
    Button button = new Button(this.getActivity());
    button.setText("show menu icon and unlock the drawer");
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    button.setLayoutParams(params);
    button.setGravity(Gravity.CENTER);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            MaterialNavigationDrawer drawer = (MaterialNavigationDrawer) getActivity();
            // show the menu button and unlock the drawer
            drawer.showActionBarMenuIcon(MaterialNavigationDrawer.ActionBarMenuItem.MENU);
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        }
    });
    Button button2 = new Button(this.getActivity());
    button2.setText("hide menu icon and lock the drawer");
    LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    button2.setLayoutParams(params2);
    button2.setGravity(Gravity.CENTER);
    button2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // hide the drawer button and lock the drawer to close
            MaterialNavigationDrawer drawer = (MaterialNavigationDrawer) getActivity();
            drawer.showActionBarMenuIcon(MaterialNavigationDrawer.ActionBarMenuItem.NONE);
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        }
    });
    Button button3 = new Button(this.getActivity());
    button3.setText("convert menu icon to back icon and lock the drawer");
    LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    button3.setLayoutParams(params3);
    button3.setGravity(Gravity.CENTER);
    button3.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // hide the drawer button and show the back button and lock the drawer to close
            MaterialNavigationDrawer drawer = (MaterialNavigationDrawer) getActivity();
            drawer.showActionBarMenuIcon(MaterialNavigationDrawer.ActionBarMenuItem.BACK);
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        }
    });
    ll.addView(button);
    ll.addView(button2);
    ll.addView(button3);
    return v;
}
Also used : MaterialNavigationDrawer(de.madcyph3r.materialnavigationdrawer.MaterialNavigationDrawer) Button(android.widget.Button) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 100 with Button

use of android.widget.Button in project AdvancedMaterialDrawer by madcyph3r.

the class CustomHeaderActivity method afterInit.

@Override
public void afterInit(Bundle savedInstanceState) {
    Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(drawer, "I'm a button", Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : Button(android.widget.Button) View(android.view.View)

Aggregations

Button (android.widget.Button)1477 View (android.view.View)909 TextView (android.widget.TextView)609 OnClickListener (android.view.View.OnClickListener)275 Intent (android.content.Intent)200 LinearLayout (android.widget.LinearLayout)189 ImageView (android.widget.ImageView)146 EditText (android.widget.EditText)126 ListView (android.widget.ListView)112 AdapterView (android.widget.AdapterView)76 ViewGroup (android.view.ViewGroup)65 LayoutInflater (android.view.LayoutInflater)56 CompoundButton (android.widget.CompoundButton)53 ScrollView (android.widget.ScrollView)53 Test (org.junit.Test)51 Bundle (android.os.Bundle)49 CheckBox (android.widget.CheckBox)48 FrameLayout (android.widget.FrameLayout)47 AlertDialog (android.app.AlertDialog)45 ImageButton (android.widget.ImageButton)45