List of usage examples for android.app AlertDialog setTitle
@Override public void setTitle(CharSequence title)
From source file:org.epstudios.epcoding.ScreenSlideActivity.java
protected void displayResult(String title, String message, Context context) { AlertDialog dialog = new AlertDialog.Builder(context).create(); dialog.setMessage(message);/*from w w w. j av a2s .com*/ dialog.setButton(DialogInterface.BUTTON_POSITIVE, "Exit Wizard", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // just close dialog } }); dialog.setTitle(title); dialog.show(); }
From source file:fm.smart.r1.ItemActivity.java
public void addToList(final String item_id) { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Adding item to study goal ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add = new Thread() { public void run() { ItemActivity.add_item_result = new AddItemResult( Main.lookup.addItemToGoal(Main.transport, Main.default_study_goal_id, item_id, null)); myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(ItemActivity.add_item_result.getTitle()); dialog.setMessage(ItemActivity.add_item_result.getMessage()); ItemActivity.add_item_result = null; dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }//from w w w. j av a 2 s .c o m }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add.start(); }
From source file:no.barentswatch.fiskinfo.MapActivity.java
/** * //from ww w.j av a 2 s .co m * @param activityContext * The context of the current activity */ @SuppressLint("InflateParams") public void setProximityAlertDialog(Context activityContext) { LayoutInflater layoutInflater = getLayoutInflater(); View view = layoutInflater.inflate(R.layout.dialog_scheduled_task_executor, null); final AlertDialog builder = new AlertDialog.Builder(activityContext).create(); builder.setTitle(R.string.map_set_proximity_alert_title); builder.setView(view); final EditText distanceEditText = (EditText) view.findViewById(R.id.scheduledProximityRangeEditText); final SeekBar seekbar = (SeekBar) view.findViewById(R.id.scheduledSetProximityRangeSeekBar); distanceEditText.setText(String.valueOf(minLenghtMeters)); final Spinner measuringUnitSpinner = (Spinner) view.findViewById(R.id.scheduledMeasuringUnitsSpinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.measurement_units, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); measuringUnitSpinner.setAdapter(adapter); seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser == true) { if (currentlySelected == meterIndex) { distanceEditText .setText(String.valueOf((int) (minLenghtMeters + (stepSizeMeters * progress)))); } else if (currentlySelected == nauticalMileIndex) { distanceEditText.setText( String.valueOf(minLenghtNauticalMiles + (stepSizeNauticalMiles * progress))); } } } }); measuringUnitSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { double distance = (distanceEditText.length() != 0 ? Double.parseDouble(distanceEditText.getText().toString()) : 0); System.out.println("posistion: " + position); System.out.println("currentlySelected: " + position); if (position == meterIndex) { if (position != currentlySelected) { distance = convertDistance(distance, position); distanceEditText.setText(String.valueOf(distance)); currentlySelected = position; } } else if (position == nauticalMileIndex) { if (position != currentlySelected) { distance = convertDistance(distance, position); distanceEditText.setText(String.valueOf(distance)); currentlySelected = position; } } else { return; } System.out.println("distance: " + distance); int newProgress = findProgress(distance, position); seekbar.setProgress(newProgress); System.out.println("progress: " + newProgress); distanceEditText.setText(String.valueOf(distance)); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); Button setProximityAlertButton = (Button) view.findViewById(R.id.scheduledSetProximityCheckerDialogButton); Button cancelButton = (Button) view.findViewById(R.id.cancel_button); builder.setView(view); builder.setCanceledOnTouchOutside(false); setProximityAlertButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!alarmSet) { mGpsLocationTracker = new GpsLocationTracker(getContext()); double latitude, longitude = 0; if (mGpsLocationTracker.canGetLocation()) { latitude = mGpsLocationTracker.getLatitude(); cachedLat = latitude; longitude = mGpsLocationTracker.getLongitude(); cachedLon = longitude; } else { mGpsLocationTracker.showSettingsAlert(); return; } String distance = distanceEditText.getText().toString(); cachedDistance = distance; cacheWriter = new DownloadMapLayerFromBarentswatchApiInBackground().execute("fishingfacility", "OLEX", "cachedResults", String.valueOf(longitude), String.valueOf(latitude), distance, "true"); alarmSet = true; runScheduledAlarm(); } builder.dismiss(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { builder.cancel(); } }); builder.show(); }
From source file:com.example.yuen.e_carei.ShowAppointmentList.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle("E-care"); setSupportActionBar(toolbar);/* ww w .jav a 2 s. co m*/ db = new SQLiteHandler(getApplicationContext()); session = new SessionManager(getApplicationContext()); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); view.getMenu().getItem(1).setChecked(true); view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { Toast.makeText(ShowAppointmentList.this, menuItem.getItemId() + " pressed", Toast.LENGTH_LONG) .show(); Intent intent = new Intent(); Log.d(R.id.nav_1 + "", menuItem.getItemId() + " "); switch (menuItem.getItemId()) { case R.id.nav_1: intent.setClass(ShowAppointmentList.this, Case_history_review.class); startActivity(intent); break; case R.id.nav_2: intent.setClass(ShowAppointmentList.this, ShowAppointmentList.class); //intent .putExtra("name", "Hello B Activity"); startActivity(intent); break; case R.id.nav_3: intent.setClass(ShowAppointmentList.this, Appointmentcreate.class); //intent .putExtra("name", "Hello B Activity"); startActivity(intent); break; case R.id.nav_4: intent.setClass(ShowAppointmentList.this, AlarmActivity.class); //intent .putExtra("name", "Hello B Activity"); startActivity(intent); break; case R.id.nav_5: intent.setClass(ShowAppointmentList.this, PatientReport.class); //intent .putExtra("name", "Hello B Activity"); startActivity(intent); break; case R.id.nav_6: //logout AlertDialog.Builder builder = new AlertDialog.Builder(ShowAppointmentList.this); //Uncomment the below code to Set the message and title from the strings.xml file //builder.setMessage(R.string.dialog_message) .setTitle(R.string.dialog_title); //Setting message manually and performing action on button click builder.setMessage("Do you want to close this application ?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { session.setLogin(false); db.deleteUsers(); final Intent intent_logout = new Intent(ShowAppointmentList.this, LoginActivity.class); startActivity(intent_logout); finish(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Action for 'NO' Button dialog.cancel(); } }); //Creating dialog box AlertDialog alert = builder.create(); //Setting the title manually alert.setTitle("AlertDialogExample"); alert.show(); break; } menuItem.setChecked(true); drawerLayout.closeDrawers(); return true; } }); ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; db = new SQLiteHandler(getApplicationContext()); dbuser = db.getUserDetails(); View header = view.getHeaderView(0); TextView headerName = (TextView) header.findViewById(R.id.drawer_name); username = dbuser.get("name"); uid = dbuser.get("uid"); headerName.setText(username); ImageLoader imageLoader = AppController.getInstance().getImageLoader(); com.example.yuen.e_carei_doctor.customlistviewvolley.CirculaireNetworkImageView headerphoto = (com.example.yuen.e_carei_doctor.customlistviewvolley.CirculaireNetworkImageView) header .findViewById(R.id.drawer_thumbnail); headerphoto.setImageUrl("http://10.89.133.147/test/" + dbuser.get("image"), imageLoader); drawerLayout.setDrawerListener(actionBarDrawerToggle); actionBarDrawerToggle.syncState(); mListView = (SwipeMenuListView) findViewById(R.id.listView); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); swipeRefreshLayout.setOnRefreshListener(this); /** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */ swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); fetchPatients(); } }); PD = new ProgressDialog(this); //Showing progress dialog before making http request PD.setMessage("Loading..."); PD.show(); mAdapter = new AppointmentListAdapter(this, appointmentList); mListView.setAdapter(mAdapter); //fetchPatients(); // step 1. create a MenuCreator SwipeMenuCreator creator = new SwipeMenuCreator() { @Override public void create(SwipeMenu menu) { // create "delete" item SwipeMenuItem deleteItem = new SwipeMenuItem(getApplicationContext()); // set item background deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25))); // set item width deleteItem.setWidth(dp2px(90)); // set a icon deleteItem.setIcon(R.drawable.ic_delete); // add to menu menu.addMenuItem(deleteItem); } }; // set creator mListView.setMenuCreator(creator); // step 2. listener item click event mListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(int position, SwipeMenu menu, int index) { AppointmentList item = appointmentList.get(position); switch (index) { case 0: // delete //delete(item); final String row_aid = aidlist.get(position).toString(); AlertDialog.Builder builder = new AlertDialog.Builder(ShowAppointmentList.this); //Setting message manually and performing action on button click builder.setMessage("Do you want to delete this row ?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { delete(uid, row_aid); fetchPatients(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Action for 'NO' Button dialog.cancel(); } }); //Creating dialog box AlertDialog alert = builder.create(); //Setting the title manually alert.setTitle("AlertDialogExample"); alert.show(); break; } return false; } }); // set SwipeListener mListView.setOnSwipeListener(new SwipeMenuListView.OnSwipeListener() { @Override public void onSwipeStart(int position) { // swipe start } @Override public void onSwipeEnd(int position) { // swipe end } }); // set MenuStateChangeListener mListView.setOnMenuStateChangeListener(new SwipeMenuListView.OnMenuStateChangeListener() { @Override public void onMenuOpen(int position) { } @Override public void onMenuClose(int position) { } }); // other setting // listView.setCloseInterpolator(new BounceInterpolator()); // test item long click mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getApplicationContext(), position + " long click", Toast.LENGTH_SHORT).show(); return false; } }); }
From source file:foam.littlej.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog//from ww w.j av a2 s . c o m */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deleteExistingPhoto(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deleteExistingPhoto(); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete any existing photo in the pending folder new DiscardTask(AddCheckinActivity.this).execute((String) null); finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete checkin deleteCheckins(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:group.pals.android.lib.ui.filechooser.utils.ui.bookmark.BookmarkFragment.java
/** * Shows a dialog to let user enter new name or change current name of a * bookmark.//ww w. j a va 2 s .c o m * * @param context * {@link Context} * @param providerId * the provider ID. * @param id * the bookmark ID. * @param uri * the URI to the bookmark. * @param name * the name. To enter new name, this is the suggested name you * provide. To rename, this is the old name. */ public static void doEnterNewNameOrRenameBookmark(final Context context, final String providerId, final int id, final Uri uri, final String name) { final AlertDialog dialog = Dlg.newDlg(context); View view = LayoutInflater.from(context).inflate(R.layout.afc_simple_text_input_view, null); final EditText textName = (EditText) view.findViewById(R.id.afc_text1); textName.setText(name); textName.selectAll(); textName.setHint(R.string.afc_hint_new_name); textName.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { Ui.showSoftKeyboard(textName, false); Button btn = dialog.getButton(DialogInterface.BUTTON_POSITIVE); if (btn.isEnabled()) btn.performClick(); return true; } return false; }// onEditorAction() }); dialog.setView(view); dialog.setIcon(R.drawable.afc_bookmarks_dark); dialog.setTitle(id < 0 ? R.string.afc_title_new_bookmark : R.string.afc_title_rename); dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String newName = textName.getText().toString().trim(); if (android.text.TextUtils.isEmpty(newName)) { Dlg.toast(context, R.string.afc_msg_bookmark_name_is_invalid, Dlg._LengthShort); return; } Ui.showSoftKeyboard(textName, false); ContentValues values = new ContentValues(); values.put(BookmarkContract.Bookmark._ColumnName, newName); if (id >= 0) { values.put(BookmarkContract.Bookmark._ColumnModificationTime, DbUtils.formatNumber(new Date().getTime())); context.getContentResolver() .update(Uri.withAppendedPath(BookmarkContract.Bookmark._ContentIdUriBase, Uri.encode(Integer.toString(id))), values, null, null); } else { /* * Check if the URI exists or doesn't. If it exists, * update it instead of inserting the new one. */ Cursor cursor = context.getContentResolver().query( BookmarkContract.Bookmark._ContentUri, null, String.format("%s = %s AND %s LIKE %s", BookmarkContract.Bookmark._ColumnProviderId, DatabaseUtils.sqlEscapeString(providerId), BookmarkContract.Bookmark._ColumnUri, DatabaseUtils.sqlEscapeString(uri.toString())), null, null); try { if (cursor != null && cursor.moveToFirst()) { values.put(BookmarkContract.Bookmark._ColumnModificationTime, DbUtils.formatNumber(new Date().getTime())); context.getContentResolver().update( Uri.withAppendedPath(BookmarkContract.Bookmark._ContentIdUriBase, Uri.encode(cursor.getString( cursor.getColumnIndex(BookmarkContract.Bookmark._ID)))), values, null, null); } else { values.put(BookmarkContract.Bookmark._ColumnProviderId, providerId); values.put(BookmarkContract.Bookmark._ColumnUri, uri.toString()); context.getContentResolver().insert(BookmarkContract.Bookmark._ContentUri, values); } } finally { if (cursor != null) cursor.close(); } } Dlg.toast(context, context.getString(R.string.afc_msg_done), Dlg._LengthShort); }// onClick() }); dialog.show(); Ui.showSoftKeyboard(textName, true); final Button buttonOk = dialog.getButton(DialogInterface.BUTTON_POSITIVE); buttonOk.setEnabled(id < 0); textName.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { String newName = s.toString().trim(); boolean enabled = !android.text.TextUtils.isEmpty(newName); buttonOk.setEnabled(enabled); /* * If renaming, only enable button OK if new name is not equal * to the old one. */ if (enabled && id >= 0) buttonOk.setEnabled(!newName.equals(name)); } }); }
From source file:net.fabiszewski.ulogger.MainActivity.java
/** * Display warning before deleting not synchronized track *//*from www . j a va 2 s. c o m*/ private void showNotSyncedWarning() { AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(getString(R.string.warning)); alertDialog.setMessage(getString(R.string.notsync_warning)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); showTrackDialog(); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
From source file:net.fabiszewski.ulogger.MainActivity.java
/** * Display About dialog/*from w ww . j a v a 2 s . c o m*/ */ private void showAbout() { @SuppressLint("InflateParams") View view = getLayoutInflater().inflate(R.layout.about, null, false); AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(getString(R.string.app_name)); alertDialog.setView(view); alertDialog.setIcon(R.drawable.ic_ulogger_logo_24dp); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); final TextView versionLabel = (TextView) alertDialog.findViewById(R.id.about_version); versionLabel.setText(getString(R.string.about_version, BuildConfig.VERSION_NAME)); final TextView descriptionLabel = (TextView) alertDialog.findViewById(R.id.about_description); final TextView description2Label = (TextView) alertDialog.findViewById(R.id.about_description2); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { descriptionLabel.setText(fromHtmlDepreciated(getString(R.string.about_description))); description2Label.setText(fromHtmlDepreciated(getString(R.string.about_description2))); } else { descriptionLabel.setText( Html.fromHtml(getString(R.string.about_description), android.text.Html.FROM_HTML_MODE_LEGACY)); description2Label.setText( Html.fromHtml(getString(R.string.about_description2), android.text.Html.FROM_HTML_MODE_LEGACY)); } }
From source file:com.fvd.nimbus.MainActivity.java
@SuppressLint("NewApi") @Override//from w w w.ja v a2 s .c o m protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == TAKE_PHOTO) { if (resultCode == -1) { try { if (data != null) { if (data.hasExtra("data")) { Bitmap bm = data.getParcelableExtra("data"); photoFileName = appSettings.saveTempBitmap(bm); bm.recycle(); } } else { if (outputFileUri != null) photoFileName = outputFileUri.getPath(); else photoFileName = getImagePath(); } if (appSettings.isFileExists(photoFileName)) { Intent iPaint = new Intent(); iPaint.putExtra("temp", true); iPaint.putExtra("path", photoFileName); iPaint.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity"); startActivity(iPaint); } showProgress(false); } catch (Exception e) { appSettings.appendLog("main:onActivityResult: exception - " + e.getMessage()); showProgress(false); } } else showProgress(false); } else if (requestCode == TAKE_PICTURE) { if (resultCode == -1 && data != null) { boolean temp = false; try { Uri resultUri = data.getData(); String drawString = resultUri.getPath(); String galleryString = getGalleryPath(resultUri); if (galleryString != null && galleryString.length() > 0) { drawString = galleryString; } else { try { InputStream input = getApplicationContext().getContentResolver() .openInputStream(resultUri); Bitmap bm = BitmapFactory.decodeStream(input); drawString = appSettings.saveTempBitmap(bm); bm.recycle(); temp = true; } catch (Exception e) { drawString = ""; showProgress(false); } } if (drawString.length() > 0 && drawString.indexOf("/exposed_content/") == -1) { try { Intent iPaint = new Intent(); iPaint.putExtra("temp", temp); iPaint.putExtra("path", drawString); iPaint.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity"); startActivity(iPaint); } catch (Exception e) { } } showProgress(false); } catch (Exception e) { appSettings.appendLog("main:onActivityResult " + e.getMessage()); showProgress(false); } } else showProgress(false); } else if (requestCode == 5) { if (resultCode == RESULT_OK) { userMail = data.getStringExtra("userMail"); userPass = data.getStringExtra("userPass"); serverHelper.getInstance().sendOldRequest("user_register", String.format( "{\"action\": \"user_register\",\"email\":\"%s\",\"password\":\"%s\",\"_client_software\": \"ff_addon\"}", userMail, userPass), ""); } } else if (requestCode == 6) { showLogin(); } else if (requestCode == SHOW_SETTINGS) { switch (resultCode) { case RESULT_FIRST_USER + 1: Intent i = new Intent(getApplicationContext(), PrefsActivity.class); startActivity(i); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 2: if (appSettings.sessionId.length() == 0) showLogin(); else { if (true || appSettings.service == "") { appSettings.sessionId = ""; Editor e = prefs.edit(); e.putString("userMail", userMail); e.putString("userPass", ""); e.putString("sessionId", appSettings.sessionId); e.commit(); showLogin(); } else { i = new Intent(getApplicationContext(), loginWithActivity.class); i.putExtra("logout", "true"); i.putExtra("service", appSettings.service); startActivity(i); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); } } break; case RESULT_FIRST_USER + 3: try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getApplicationInfo().packageName))); } catch (Exception e) { } case RESULT_FIRST_USER + 4: Uri uri = Uri.parse( "http://help.everhelper.me/customer/portal/articles/1376820-nimbus-clipper-for-android---quick-guide"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 5: final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); alertDialogBuilder.setMessage(getScriptContent("license.txt")).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // no alert dialog shown //alertDialogShown = null; // canceled setResult(RESULT_CANCELED); // and finish //finish(); } }); // create alert dialog final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setTitle(getString(R.string.license_title)); // and show //alertDialogShown = alertDialog; try { alertDialog.show(); } catch (final java.lang.Exception e) { // nothing to do } catch (final java.lang.Error e) { // nothing to do } break; default: break; } } }
From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java
public void handleQRcodeScanRequest() { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); intent.putExtra("SAVE_HISTORY", false); try {/* w w w .j a v a 2 s. c o m*/ startActivityForResult(intent, 0); // request code is 0 } catch (ActivityNotFoundException e) { // No application to view, ask to download one AlertDialog alertDialog = new AlertDialog.Builder(POIMapActivity.this).create();// context).create(); alertDialog.setTitle(getResources().getString(R.string.qr_scanner_not_found)); alertDialog.setMessage(getResources().getString(R.string.install_it_now_question)); alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getResources().getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.setButton(Dialog.BUTTON_POSITIVE, getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { try { // TODO test this startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=qr+scanner&c=apps"))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/search?q=qr+scanner&c=apps"))); } } }); alertDialog.show(); } }