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();
}
});
}
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);
}
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);
}
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;
}
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();
}
});
}
Aggregations