List of usage examples for android.content Intent ACTION_INSERT
String ACTION_INSERT
To view the source code for android.content Intent ACTION_INSERT.
Click Source Link
From source file:net.news.inrss.activity.HomeActivity.java
private void selectDrawerItem(int position) { mCurrentDrawerPos = position;// w ww .ja v a 2s .c o m if (mDrawerAdapter == null) return; mDrawerAdapter.setSelectedItem(position); mIcon = null; Uri newUri; boolean showFeedInfo = true; switch (position) { case SEARCH_DRAWER_POSITION: newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch()); break; case 0: newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI; break; case 1: newUri = EntryColumns.FAVORITES_CONTENT_URI; break; default: long feedOrGroupId = mDrawerAdapter.getItemId(position); if (mDrawerAdapter.isItemAGroup(position)) { newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId); } else { byte[] iconBytes = mDrawerAdapter.getItemIcon(position); Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24); if (bitmap != null) { mIcon = new BitmapDrawable(getResources(), bitmap); } newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId); showFeedInfo = false; } mTitle = mDrawerAdapter.getItemName(position); break; } if (!newUri.equals(mEntriesFragment.getUri())) { mEntriesFragment.setData(newUri, showFeedInfo); } mDrawerList.setItemChecked(position, true); // First open => we open the drawer for you if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) { PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false); if (mDrawerLayout != null) { mDrawerLayout.postDelayed(new Runnable() { @Override public void run() { mDrawerLayout.openDrawer(mLeftDrawer); } }, 500); } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle( Html.fromHtml("<font color='#FF7F27'>Welcome to inRSS. Would you like to add one feed?</font>")) .setItems(new CharSequence[] { getString(R.string.google_news_title), getString(R.string.add_custom_feed) }, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 1) { startActivity( new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI)); } else { startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class)); } } }); builder.show(); } refreshTitle(0); }
From source file:spit.matrix2017.Activities.EventDetails.java
private void goToCalendar(Calendar beginTime, Calendar endTime) { mEventID = getLastEventId(getContentResolver()) + 1; Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis()) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()) .putExtra(CalendarContract.Events._ID, mEventID).putExtra(CalendarContract.Events.TITLE, event_name) .putExtra(CalendarContract.Events.DESCRIPTION, "Event at Matrix 17") .putExtra(CalendarContract.Events.EVENT_LOCATION, getIntent().getStringExtra("venue") + ", S.P.I.T.") .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY); visitedCalendar = true;//from w w w .j av a 2s .c o m startActivity(intent); }
From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionListFragment.java
/** * start RepeatingTransaction for insert or edit transaction * * @param billDepositsId Id of the recurring transaction. * @param purposeCode Code that indicates why we are opening the editor. * example: REQUEST_ADD_REPEATING_TRANSACTION *//* www . ja v a2 s . c o m*/ private void startRecurringTransactionEditActivity(Integer billDepositsId, int purposeCode) { // create intent, set Bill Deposits ID Intent intent = new Intent(getActivity(), RecurringTransactionEditActivity.class); // check transId not null if (billDepositsId != null) { intent.putExtra(RecurringTransactionEditActivity.KEY_BILL_DEPOSITS_ID, billDepositsId); intent.setAction(Intent.ACTION_EDIT); } else { intent.setAction(Intent.ACTION_INSERT); } // launch activity startActivityForResult(intent, purposeCode); }
From source file:com.silentcircle.contacts.editor.ContactEditorFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); validateAction(mAction);/*from ww w .j a va 2 s .com*/ // Handle initial actions only when existing state missing final boolean hasIncomingState = savedInstanceState != null; if (mState == null) { // The delta list may not have finished loading before orientation change happens. // In this case, there will be a saved state but deltas will be missing. Reload from // database. if (Intent.ACTION_EDIT.equals(mAction)) { // Either... // 1) orientation change but load never finished. // or // 2) not an orientation change. data needs to be loaded for first time. getLoaderManager().initLoader(LOADER_DATA, null, mDataLoaderListener); } } else { // Orientation change, we already have mState, it was loaded by onCreate bindEditors(); } if (!hasIncomingState) { if (Intent.ACTION_INSERT.equals(mAction)) { selectAccountAndCreateContact(); } } }
From source file:org.openintents.notepad.NoteEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (DEBUG) {/*from w ww .j a va2 s.c om*/ Log.d(TAG, "onCreate()"); } if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) { createShortcut(); return; } if (savedInstanceState == null) { // sDecryptedText has no use for brand new activities sDecryptedText = null; } // Usually, sDecryptedText == null. mDecryptedText = sDecryptedText; if (sDecryptedText != null) { // we use the text right now, // so don't encrypt the text anymore. EncryptActivity.cancelEncrypt(); if (EncryptActivity.getPendingEncryptActivities() == 0) { if (DEBUG) { Log.d(TAG, "sDecryptedText = null"); } // no more encrypt activies will be called sDecryptedText = null; } } mSelectionStart = 0; mSelectionStop = 0; // If an instance of this activity had previously stopped, we can // get the original text it started with. if (savedInstanceState != null) { mOriginalContent = savedInstanceState.getString(BUNDLE_ORIGINAL_CONTENT); mUndoRevert = savedInstanceState.getString(BUNDLE_UNDO_REVERT); mState = savedInstanceState.getInt(BUNDLE_STATE); String uriString = savedInstanceState.getString(BUNDLE_URI); if (uriString != null) { mUri = Uri.parse(uriString); } mSelectionStart = savedInstanceState.getInt(BUNDLE_SELECTION_START); mSelectionStop = savedInstanceState.getInt(BUNDLE_SELECTION_STOP); mFileContent = savedInstanceState.getString(BUNDLE_FILE_CONTENT); if (mApplyText == null && mApplyTextBefore == null && mApplyTextAfter == null) { // Only read values if they had not been set by // onActivityResult() yet: mApplyText = savedInstanceState.getString(BUNDLE_APPLY_TEXT); mApplyTextBefore = savedInstanceState.getString(BUNDLE_APPLY_TEXT_BEFORE); mApplyTextAfter = savedInstanceState.getString(BUNDLE_APPLY_TEXT_AFTER); } } else { // Do some setup based on the action being performed. final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_EDIT.equals(action) || Intent.ACTION_VIEW.equals(action)) { // Requested to edit: set that state, and the data being edited. mState = STATE_EDIT; mUri = intent.getData(); if (mUri != null && mUri.getScheme().equals("file")) { mState = STATE_EDIT_NOTE_FROM_SDCARD; // Load the file into a new note. if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { mFileContent = readFile(FileUriUtils.getFile(mUri)); } else { if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_CODE_PERMISSION_READ_EXTERNAL_STORAGE); mFileContent = getString(R.string.request_permissions); } } } else if (mUri != null && !mUri.getAuthority().equals(NotePad.AUTHORITY)) { // Note a notepad note. Treat slightly differently. // (E.g. a note from OI Shopping List) mState = STATE_EDIT_EXTERNAL_NOTE; } } else if (Intent.ACTION_INSERT.equals(action) || Intent.ACTION_SEND.equals(action)) { // Use theme of most recently modified note: ContentValues values = new ContentValues(1); String theme = getMostRecentlyUsedTheme(); values.put(Notes.THEME, theme); String tags = intent.getStringExtra(NotepadInternalIntents.EXTRA_TAGS); values.put(Notes.TAGS, tags); if (mText != null) { values.put(Notes.SELECTION_START, mText.getSelectionStart()); values.put(Notes.SELECTION_END, mText.getSelectionEnd()); } // Requested to insert: set that state, and create a new entry // in the container. mState = STATE_INSERT; /* * intent.setAction(Intent.ACTION_EDIT); intent.setData(mUri); * setIntent(intent); */ if (Intent.ACTION_SEND.equals(action)) { values.put(Notes.NOTE, getIntent().getStringExtra(Intent.EXTRA_TEXT)); mUri = getContentResolver().insert(Notes.CONTENT_URI, values); } else { mUri = getContentResolver().insert(intent.getData(), values); } // If we were unable to create a new note, then just finish // this activity. A RESULT_CANCELED will be sent back to the // original activity if they requested a result. if (mUri == null) { Log.e(TAG, "Failed to insert new note into " + getIntent().getData()); finish(); return; } // The new entry was created, so assume all will end well and // set the result to be returned. // setResult(RESULT_OK, (new // Intent()).setAction(mUri.toString())); setResult(RESULT_OK, intent); } else { // Whoops, unknown action! Bail. Log.e(TAG, "Unknown action, exiting"); finish(); return; } } // setup actionbar if (mActionBarAvailable) { requestWindowFeature(Window.FEATURE_ACTION_BAR); WrapActionBar bar = new WrapActionBar(this); bar.setDisplayHomeAsUpEnabled(true); // force to show the actionbar on version 14+ if (Integer.valueOf(android.os.Build.VERSION.SDK) >= 14) { bar.setHomeButtonEnabled(true); } } else { requestWindowFeature(Window.FEATURE_RIGHT_ICON); } // Set the layout for this activity. You can find it in // res/layout/note_editor.xml setContentView(R.layout.note_editor); // The text view for our note, identified by its ID in the XML file. mText = (EditText) findViewById(R.id.note); if (mState == STATE_EDIT_NOTE_FROM_SDCARD) { // We add a text watcher, so that the title can be updated // to indicate a small "*" if modified. mText.addTextChangedListener(mTextWatcherSdCard); } if (mState != STATE_EDIT_NOTE_FROM_SDCARD) { // Check if we load a note from notepad or from some external module if (mState == STATE_EDIT_EXTERNAL_NOTE) { // Get all the columns as we don't know which columns are // supported. mCursor = managedQuery(mUri, null, null, null, null); // Now check which columns are available List<String> columnNames = Arrays.asList(mCursor.getColumnNames()); if (!columnNames.contains(Notes.NOTE)) { hasNoteColumn = false; } if (!columnNames.contains(Notes.TAGS)) { hasTagsColumn = false; } if (!columnNames.contains(Notes.ENCRYPTED)) { hasEncryptionColumn = false; } if (!columnNames.contains(Notes.THEME)) { hasThemeColumn = false; } if (!columnNames.contains(Notes.SELECTION_START)) { hasSelection_startColumn = false; } if (!columnNames.contains(Notes.SELECTION_END)) { hasSelection_endColumn = false; } } else { // Get the note! mCursor = managedQuery(mUri, PROJECTION, null, null, null); // It's not an external note, so all the columns are available // in the database } } else { mCursor = null; } mText.addTextChangedListener(mTextWatcherCharCount); initSearchPanel(); }
From source file:com.silentcircle.contacts.editor.ContactEditorFragment.java
/** * Checks if the requested action is valid. * * @param action The action to test.//from w w w . j a v a 2s . c o m * @throws IllegalArgumentException when the action is invalid. */ private void validateAction(String action) { if (Intent.ACTION_EDIT.equals(action) || Intent.ACTION_INSERT.equals(action) || ScContactEditorActivity.ACTION_SAVE_COMPLETED.equals(action)) { return; } throw new IllegalArgumentException( "Unknown Action String " + mAction + ". Only support " + Intent.ACTION_EDIT + " or " + Intent.ACTION_INSERT + " or " + ScContactEditorActivity.ACTION_SAVE_COMPLETED); }
From source file:de.baumann.hhsmoodle.popup.Popup_note.java
private void setNotesList() { //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "note_title", "note_content", "note_creation" }; final String search = sharedPref.getString("filter_note_subject", ""); final Cursor row = db.fetchDataByFilter(search, "note_title"); SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_note.this, layoutstyle, row, column, xml_id, 0) {//from ww w . j a v a 2 s .co m @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (note_icon) { case "3": iv_icon.setImageResource(R.drawable.circle_green); break; case "2": iv_icon.setImageResource(R.drawable.circle_yellow); break; case "1": iv_icon.setImageResource(R.drawable.circle_red); break; } switch (note_attachment) { case "": iv_attachment.setVisibility(View.GONE); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.ic_attachment); break; } File file = new File(note_attachment); if (!file.exists()) { iv_attachment.setVisibility(View.GONE); } iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final Item[] items = { new Item(getString(R.string.note_priority_0), R.drawable.circle_green), new Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new Item(getString(R.string.note_priority_2), R.drawable.circle_red), }; ListAdapter adapter = new ArrayAdapter<Item>(Popup_note.this, android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(Popup_note.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { db.update(Integer.parseInt(_id), note_title, note_content, "3", note_attachment, note_creation); setNotesList(); } else if (item == 1) { db.update(Integer.parseInt(_id), note_title, note_content, "2", note_attachment, note_creation); setNotesList(); } else if (item == 2) { db.update(Integer.parseInt(_id), note_title, note_content, "1", note_attachment, note_creation); setNotesList(); } } }).show(); } }); iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(Popup_note.this, lv, note_attachment); } }); return v; } }; lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); final Button attachment2; final TextView textInput; LayoutInflater inflater = Popup_note.this.getLayoutInflater(); final ViewGroup nullParent = null; final View dialogView = inflater.inflate(R.layout.dialog_note_show, nullParent); final String attName = note_attachment.substring(note_attachment.lastIndexOf("/") + 1); final String att = getString(R.string.app_att) + ": " + attName; attachment2 = (Button) dialogView.findViewById(R.id.button_att); if (attName.equals("")) { attachment2.setVisibility(View.GONE); } else { attachment2.setText(att); } File file2 = new File(note_attachment); if (!file2.exists()) { attachment2.setVisibility(View.GONE); } textInput = (TextView) dialogView.findViewById(R.id.note_text_input); textInput.setText(note_content); Linkify.addLinks(textInput, Linkify.WEB_URLS); attachment2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(Popup_note.this, lv, note_attachment); } }); final ImageView be = (ImageView) dialogView.findViewById(R.id.imageButtonPri); switch (note_icon) { case "3": be.setImageResource(R.drawable.circle_green); break; case "2": be.setImageResource(R.drawable.circle_yellow); break; case "1": be.setImageResource(R.drawable.circle_red); break; } android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(Popup_note.this) .setTitle(note_title).setView(dialogView) .setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setNegativeButton(R.string.note_edit, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { sharedPref.edit().putString("handleTextTitle", note_title) .putString("handleTextText", note_content) .putString("handleTextIcon", note_icon).putString("handleTextSeqno", _id) .putString("handleTextAttachment", note_attachment) .putString("handleTextCreate", note_creation).apply(); helper_main.switchToActivity(Popup_note.this, Activity_EditNote.class, false); } }); dialog.show(); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); final CharSequence[] options = { getString(R.string.note_edit), getString(R.string.note_share), getString(R.string.todo_menu), getString(R.string.bookmark_createEvent), getString(R.string.note_remove_note) }; new AlertDialog.Builder(Popup_note.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.note_edit))) { sharedPref.edit().putString("handleTextTitle", note_title) .putString("handleTextText", note_content) .putString("handleTextIcon", note_icon) .putString("handleTextSeqno", _id) .putString("handleTextAttachment", note_attachment) .putString("handleTextCreate", note_creation).apply(); helper_main.switchToActivity(Popup_note.this, Activity_EditNote.class, false); } if (options[item].equals(getString(R.string.note_share))) { File attachment = new File(note_attachment); Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, note_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, note_content); if (attachment.exists()) { Uri bmpUri = Uri.fromFile(attachment); sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); } startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.todo_menu))) { Todo_DbAdapter db = new Todo_DbAdapter(Popup_note.this); db.open(); if (db.isExist(note_title)) { Snackbar.make(lv, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG) .show(); } else { db.insert(note_title, note_content, "3", "true", helper_main.createDate()); ViewPager viewPager = (ViewPager) Popup_note.this .findViewById(R.id.viewpager); viewPager.setCurrentItem(2); Popup_note.this.setTitle(R.string.todo_title); dialog.dismiss(); } } if (options[item].equals(getString(R.string.bookmark_createEvent))) { Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); calIntent.putExtra(CalendarContract.Events.TITLE, note_title); calIntent.putExtra(CalendarContract.Events.DESCRIPTION, note_content); startActivity(calIntent); } if (options[item].equals(getString(R.string.note_remove_note))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setNotesList(); } }); snackbar.show(); } } }).show(); return true; } }); if (lv.getAdapter().getCount() == 0) { new android.app.AlertDialog.Builder(this) .setMessage(helper_main.textSpannable(getString(R.string.toast_noEntry))) .setPositiveButton(this.getString(R.string.toast_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }).show(); new Handler().postDelayed(new Runnable() { public void run() { finish(); } }, 2000); } }
From source file:de.baumann.hhsmoodle.popup.Popup_todo.java
private void setTodoList() { PreferenceManager.setDefaultValues(Popup_todo.this, R.xml.user_settings, false); final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(Popup_todo.this); NotificationManager nMgr = (NotificationManager) Popup_todo.this .getSystemService(Context.NOTIFICATION_SERVICE); nMgr.cancelAll();//from w w w . j ava2s .c om //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "todo_title", "todo_content", "todo_creation" }; final String search = sharedPref.getString("filter_todo_subject", ""); final Cursor row = db.fetchDataByFilter(search, "todo_title"); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_todo.this, layoutstyle, row, column, xml_id, 0) { @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (todo_icon) { case "3": iv_icon.setImageResource(R.drawable.circle_green); break; case "2": iv_icon.setImageResource(R.drawable.circle_yellow); break; case "1": iv_icon.setImageResource(R.drawable.circle_red); break; } switch (todo_attachment) { case "true": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle_red); int n = Integer.valueOf(_id); android.content.Intent iMain = new android.content.Intent(); iMain.setAction("shortcutToDo"); iMain.setClassName(Popup_todo.this, "de.baumann.hhsmoodle.activities.Activity_splash"); PendingIntent piMain = PendingIntent.getActivity(Popup_todo.this, n, iMain, 0); NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(Popup_todo.this) .setSmallIcon(R.drawable.school) .setColor(ContextCompat.getColor(Popup_todo.this, R.color.colorPrimary)) .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain); Notification notification = new NotificationCompat.Builder(Popup_todo.this) .setColor(ContextCompat.getColor(Popup_todo.this, R.color.colorPrimary)) .setSmallIcon(R.drawable.school).setContentTitle(todo_title) .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true) .setGroup("HHS_Moodle") .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content)) .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build(); NotificationManager notificationManager = (NotificationManager) Popup_todo.this .getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(n, notification); notificationManager.notify(0, builderSummary.build()); break; } iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final Item[] items = { new Item(getString(R.string.note_priority_0), R.drawable.circle_green), new Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new Item(getString(R.string.note_priority_2), R.drawable.circle_red), }; ListAdapter adapter = new ArrayAdapter<Item>(Popup_todo.this, android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(Popup_todo.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { db.update(Integer.parseInt(_id), todo_title, todo_content, "3", todo_attachment, todo_creation); setTodoList(); } else if (item == 1) { db.update(Integer.parseInt(_id), todo_title, todo_content, "2", todo_attachment, todo_creation); setTodoList(); } else if (item == 2) { db.update(Integer.parseInt(_id), todo_title, todo_content, "1", todo_attachment, todo_creation); setTodoList(); } } }).show(); } }); iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { switch (todo_attachment) { case "true": db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "", todo_creation); setTodoList(); break; default: db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "true", todo_creation); setTodoList(); break; } } }); return v; } }; lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); sharedPref.edit().putString("toDo_title", todo_title).apply(); sharedPref.edit().putString("toDo_text", todo_content).apply(); sharedPref.edit().putString("toDo_seqno", _id).apply(); sharedPref.edit().putString("toDo_icon", todo_icon).apply(); sharedPref.edit().putString("toDo_create", todo_creation).apply(); sharedPref.edit().putString("toDo_attachment", todo_attachment).apply(); helper_main.switchToActivity(Popup_todo.this, Activity_todo.class, false); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); final CharSequence[] options = { getString(R.string.bookmark_edit_title), getString(R.string.todo_share), getString(R.string.bookmark_createNote), getString(R.string.bookmark_createEvent), getString(R.string.bookmark_remove_bookmark) }; new AlertDialog.Builder(Popup_todo.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.bookmark_edit_title))) { AlertDialog.Builder builder = new AlertDialog.Builder(Popup_todo.this); View dialogView = View.inflate(Popup_todo.this, R.layout.dialog_edit_title, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setHint(R.string.bookmark_edit_title); edit_title.setText(todo_title); builder.setView(dialogView); builder.setTitle(R.string.bookmark_edit_title); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); db.update(Integer.parseInt(_id), inputTag, todo_content, todo_icon, todo_attachment, todo_creation); setTodoList(); Snackbar.make(lv, R.string.bookmark_added, Snackbar.LENGTH_SHORT).show(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(Popup_todo.this, edit_title); } if (options[item].equals(getString(R.string.todo_share))) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, todo_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, todo_content); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.bookmark_createEvent))) { Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); calIntent.putExtra(CalendarContract.Events.TITLE, todo_title); calIntent.putExtra(CalendarContract.Events.DESCRIPTION, todo_content); startActivity(calIntent); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setTodoList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.bookmark_createNote))) { sharedPref.edit().putString("handleTextTitle", todo_title) .putString("handleTextText", todo_content).apply(); helper_main.switchToActivity(Popup_todo.this, Activity_EditNote.class, false); } } }).show(); return true; } }); if (lv.getAdapter().getCount() == 0) { new android.app.AlertDialog.Builder(this) .setMessage(helper_main.textSpannable(getString(R.string.toast_noEntry))) .setPositiveButton(this.getString(R.string.toast_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }).show(); new Handler().postDelayed(new Runnable() { public void run() { finish(); } }, 2000); } }
From source file:com.pgmacdesign.rsrtoolbox.InputSchedule.java
public void CreateEvent(String title, String address, String description, DatePicker dp) { //First run method that calculates all end times GetEndTimes();//ww w . jav a2 s. c o m //Create an intent that will enter data into the calendar Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); //Put information in calIntent.putExtra(Events.TITLE, title); calIntent.putExtra(Events.EVENT_LOCATION, address); calIntent.putExtra(Events.DESCRIPTION, description); //Start and End Timing Calendar startTime = Calendar.getInstance(); Calendar endTime = Calendar.getInstance(); //Format: startTime.set(year, month, day, hourOfDay, minute) startTime.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(), daily_hour_start, daily_min_start); endTime.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(), daily_hour_end, daily_min_end); //Put the calculated start and end time into the calIntent Intent calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime.getTimeInMillis()); calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()); //Puts event into calendar startActivity(calIntent); }
From source file:edu.usf.cutr.opentripplanner.android.fragments.DirectionListFragment.java
private void setCalendarItinerary() { // Obtaining of the selected itinerary, along with its relevant parameters int selecItinID = (int) tripList.getSelectedItemId(); Itinerary itinerary = otpBundle.getItineraryList().get(selecItinID); long startTime = Long.parseLong(itinerary.startTime); long endTime = Long.parseLong(itinerary.endTime); String departure = (fromHeader.getText().toString().split(","))[0]; String arrival = (toHeader.getText().toString().split(","))[0]; String tripDescription = departure + " " + arrival; Intent intent = new Intent(Intent.ACTION_INSERT); intent.setData(CalendarContract.Events.CONTENT_URI); intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime); intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime); intent.putExtra(CalendarContract.Events.TITLE, tripDescription); intent.putExtra(CalendarContract.Events.EVENT_LOCATION, departure); startActivity(intent);// w w w.j a va2s. com }