List of usage examples for android.content Context CLIPBOARD_SERVICE
String CLIPBOARD_SERVICE
To view the source code for android.content Context CLIPBOARD_SERVICE.
Click Source Link
From source file:com.kaixin.android.activity.ChatActivity.java
private void setUpView() { Intent intent = new Intent(this, MessagePushService.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stopService(intent);/* ww w. ja va 2 s . c om*/ // ??????,??? mEmail = getIntent().getStringExtra("email"); mName = getIntent().getStringExtra("name"); mAvatar = getIntent().getStringExtra("avatar"); activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ??? toChatUsername = mEmail; ((TextView) findViewById(R.id.chat_title)).setText(mName); conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(mKXApplication, this, toChatUsername, chatType, mAvatar); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); expressionContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } // ??options EMChatOptions options = EMChatManager.getInstance().getChatOptions(); options.setNotificationEnable(true); // ?? options.setNotifyText(new OnMessageNotifyListener() { @Override public String onNewMessageNotify(EMMessage message) { // ??message????? try { return "?" + message.getStringAttribute("mName") + "????"; } catch (EaseMobException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } @Override public String onLatestMessageNotify(EMMessage message, int fromUsersNum, int messageNum) { return fromUsersNum + "???" + messageNum + "??"; } }); /*options.setOnNotificationClickListener(new OnNotificationClickListener() { @Override public Intent onNotificationClick(EMMessage message) { Intent intent = new Intent(C.this, ChatActivity1.class); intent.putExtra("email", message.getFrom()); intent.putExtra("isNews", "yes"); intent.putExtra("isNews", message.getMsgId()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (msgReceiver != null) { try { unregisterReceiver(msgReceiver); } catch (Exception e) { e.printStackTrace(); } } return intent; } });*/ // timer = new Timer(); // timer.schedule(new RemindTask(), 1* 1000, 4 * 1000); mFaceGridView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // ??? int currentPosition = mEditTextContent.getSelectionStart(); // mEditTextContent.setText(new TextUtil(mKXApplication).replace(mEditTextContent.getText() .insert(currentPosition, mKXApplication.mFacesText.get(position)))); // ? dismissFace(); } }); //app? EMChat.getInstance().setAppInited(); }
From source file:com.hx.hxchat.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*from w w w.j av a2 s . com*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); toChatUserNick = getIntent().getStringExtra("userName"); /* userId10000??????????? */ if (getIntent().getStringExtra("userId").equals("10000")) { rl_bottom.setVisibility(View.GONE); } // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.rl_setting).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); if (group != null) ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); else ((TextView) findViewById(R.id.name)).setText(toChatUsername); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(9); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.feytuo.chat.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//from w ww . j a v a 2 s . com chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); String nickName = getIntent().getStringExtra("userNickName"); TextView nickNameTV = (TextView) findViewById(R.id.name); if (!TextUtils.isEmpty(nickName)) {//? nickNameTV.setText(nickName); } else { nickName = new UserDao(this).getUserNickName(toChatUsername); if (!TextUtils.isEmpty(nickName)) {//? nickNameTV.setText(nickName); } else {//?? setTitleName(toChatUsername, nickNameTV); } } // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); // findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); expressionContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } //?? if (App.getInstance().getContactList().containsKey(toChatUsername)) { findViewById(R.id.chat_add_friend_btn).setVisibility(View.INVISIBLE); } else { findViewById(R.id.chat_add_friend_btn).setVisibility(View.VISIBLE); } }
From source file:com.indoorsy.frash.easemob.activity.ChatActivity.java
@SuppressLint("ClickableViewAccessibility") @Override//from ww w . j a va 2 s .c o m public void initData() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); SharedPreferences sharedPreFerences = getSharedPreferences("customernumber", Context.MODE_PRIVATE); toChatUsername = sharedPreFerences.getString("customerkey", Constants.CUSTOMERKEY); customTitleView.setTitle(toChatUsername); conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); adapter.refresh(); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); if (stImage == null) { } else { String stfirst = stImage.substring(0, 1); if (stfirst.equals("2")) { //? String pathOne = "/sdcard/appname/" + "one" + ".png"; saveImage(R.drawable.one, pathOne); //??image+ sendPicture(pathOne); } else if (stfirst.equals("")) { String pathTwo = "/sdcard/appname/" + "two" + ".png"; saveImage(R.drawable.two, pathTwo); sendPicture(pathTwo); } else if (stfirst.equals("?")) { String pathThree = "/sdcard/appname/" + "three" + ".png"; saveImage(R.drawable.three, pathThree); sendPicture(pathThree); } else if (stfirst.equals("?")) { String pathFour = "/sdcard/appname/" + "four" + ".png"; saveImage(R.drawable.four, pathFour); sendPicture(pathFour); } } }
From source file:de.baumann.browser.popups.Popup_bookmarks.java
private void setBookmarksList() { //display data final int layoutstyle = R.layout.list_item; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "bookmarks_title", "bookmarks_content", "bookmarks_creation" }; final Cursor row = db.fetchAllData(this); adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0) { @Override/*from ww w .j a v a 2 s . co m*/ public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title")); final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content")); final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon")); final String bookmarks_attachment = row2 .getString(row2.getColumnIndexOrThrow("bookmarks_attachment")); final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation")); View v = super.getView(position, convertView, parent); final ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (bookmarks_attachment) { case "": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.star_outline); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.star_grey); break; } iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if (bookmarks_attachment.equals("")) { if (db.isExistFav("true")) { Snackbar.make(listView, R.string.bookmark_setFav_not, Snackbar.LENGTH_LONG).show(); } else { iv_attachment.setImageResource(R.drawable.star_grey); db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "true", bookmarks_creation); setBookmarksList(); sharedPref.edit().putString("startURL", bookmarks_content).apply(); Snackbar.make(listView, R.string.bookmark_setFav, Snackbar.LENGTH_LONG).show(); } } else { iv_attachment.setImageResource(R.drawable.star_outline); db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "", bookmarks_creation); setBookmarksList(); } } }); return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_bookmarksBY", "bookmarks_title"); sharedPref.edit().putString("filter_bookmarksBY", "bookmarks_title").apply(); editText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return db.fetchDataByFilter(constraint.toString(), note_search); } }); listView.setAdapter(adapter); //onClick function listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row = (Cursor) listView.getItemAtPosition(position); final String bookmarks_content = row.getString(row.getColumnIndexOrThrow("bookmarks_content")); sharedPref.edit().putString("openURL", bookmarks_content).apply(); finish(); } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title")); final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content")); final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon")); final String bookmarks_attachment = row2 .getString(row2.getColumnIndexOrThrow("bookmarks_attachment")); final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation")); final CharSequence[] options = { getString(R.string.menu_share), getString(R.string.menu_save), getString(R.string.bookmark_edit_title), getString(R.string.bookmark_remove_bookmark) }; new AlertDialog.Builder(Popup_bookmarks.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))) { sharedPref.edit().putString("edit_id", _id).apply(); sharedPref.edit().putString("edit_content", bookmarks_content).apply(); sharedPref.edit().putString("edit_icon", bookmarks_icon).apply(); sharedPref.edit().putString("edit_attachment", bookmarks_attachment).apply(); sharedPref.edit().putString("edit_creation", bookmarks_creation).apply(); editText.setVisibility(View.VISIBLE); helper_editText.showKeyboard(Popup_bookmarks.this, editText, 2, bookmarks_title, getString(R.string.bookmark_edit_title)); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(listView, R.string.bookmark_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setBookmarksList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.menu_share))) { final CharSequence[] options = { getString(R.string.menu_share_link), getString(R.string.menu_share_link_copy) }; new AlertDialog.Builder(Popup_bookmarks.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.menu_share_link))) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, bookmarks_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, bookmarks_content); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.app_share_link)))); } if (options[item] .equals(getString(R.string.menu_share_link_copy))) { ClipboardManager clipboard = (ClipboardManager) Popup_bookmarks.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip( ClipData.newPlainText("text", bookmarks_content)); Snackbar.make(listView, R.string.context_linkCopy_toast, Snackbar.LENGTH_SHORT).show(); } } }).show(); } if (options[item].equals(getString(R.string.menu_save))) { final CharSequence[] options = { getString(R.string.menu_save_readLater), getString(R.string.menu_save_pass), getString(R.string.menu_createShortcut) }; new AlertDialog.Builder(Popup_bookmarks.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.menu_save_pass))) { helper_editText.editText_savePass(Popup_bookmarks.this, listView, bookmarks_title, bookmarks_content); } if (options[item] .equals(getString(R.string.menu_save_readLater))) { DbAdapter_ReadLater db = new DbAdapter_ReadLater( Popup_bookmarks.this); db.open(); if (db.isExist(bookmarks_content)) { Snackbar.make(editText, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG).show(); } else { db.insert(bookmarks_title, bookmarks_content, "", "", helper_main.createDate()); Snackbar.make(listView, R.string.bookmark_added, Snackbar.LENGTH_LONG).show(); } } if (options[item] .equals(getString(R.string.menu_createShortcut))) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.setClassName(Popup_bookmarks.this, "de.baumann.browser.Browser_left"); i.setData(Uri.parse(bookmarks_content)); Intent shortcut = new Intent(); shortcut.putExtra("android.intent.extra.shortcut.INTENT", i); shortcut.putExtra("android.intent.extra.shortcut.NAME", "THE NAME OF SHORTCUT TO BE SHOWN"); shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, bookmarks_title); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext( Popup_bookmarks.this .getApplicationContext(), R.mipmap.ic_launcher)); shortcut.setAction( "com.android.launcher.action.INSTALL_SHORTCUT"); Popup_bookmarks.this.sendBroadcast(shortcut); Snackbar.make(listView, R.string.menu_createShortcut_success, Snackbar.LENGTH_SHORT).show(); } } }).show(); } } }).show(); return true; } }); }
From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java
public static void copyImageURL(Fragment fragment, JSONParcelable imageData) { final Activity activity = fragment.getActivity(); final JSONParcelable data = imageData; final Fragment frag = fragment; String[] copyTypes = fragment.getResources().getStringArray(R.array.copyTypes); try {/* w w w.ja v a2s.c om*/ copyTypes[0] = copyTypes[0] + "\nhttp://imgur.com/" + imageData.getJSONObject().getString("id"); copyTypes[1] = copyTypes[1] + "\n" + imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK); copyTypes[2] = copyTypes[2] + "\n<a href=\"http://imgur.com/" + imageData.getJSONObject().getString("id") + "\"><img src=\"" + imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK) + "\" title=\"Hosted by imgur.com\"/></a>"; copyTypes[3] = copyTypes[3] + "\n[IMG]" + imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK) + "[/IMG]"; copyTypes[4] = copyTypes[4] + "\n[URL=http://imgur.com/" + imageData.getJSONObject().getString("id") + "][IMG]" + imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK) + "[/IMG][/URL]"; copyTypes[5] = copyTypes[5] + "\n[Imgur](http://i.imgur.com/" + imageData.getJSONObject().getString("id") + ")"; } catch (JSONException e) { Log.e("Error!", e.toString()); } new AlertDialog.Builder(activity).setTitle("Set Link Type to Copy") .setItems(copyTypes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ClipboardManager clipboard = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); try { String link = ""; switch (whichButton) { case 0: link = "http://imgur.com/" + data.getJSONObject().getString("id"); break; case 1: link = data.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK); break; case 2: link = "<a href=\"http://imgur.com/" + data.getJSONObject().getString("id") + "\"><img src=\"" + data.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK) + "\" title=\"Hosted by imgur.com\"/></a>"; break; case 3: link = "[IMG]" + data.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK) + "[/IMG]"; break; case 4: link = "[URL=http://imgur.com/" + data.getJSONObject().getString("id") + "][IMG]" + data.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK) + "[/IMG][/URL]"; break; case 5: link = "[Imgur](http://i.imgur.com/" + data.getJSONObject().getString("id") + ")"; break; default: break; } int duration = Toast.LENGTH_SHORT; Toast toast; toast = Toast.makeText(frag.getActivity(), "URL Copied!", duration); toast.show(); ClipData clip = ClipData.newPlainText("imgur Link", link); clipboard.setPrimaryClip(clip); } catch (JSONException e) { Log.e("Error!", "No link in image data!"); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); }
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); roomId = getIntent().getStringExtra("roomId"); // ???/*from w ww. j a v a 2 s. c o m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? findViewById(R.id.container_dadu).setVisibility(View.GONE); findViewById(R.id.container_jingcai).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("userId"); String nickname = getIntent().getStringExtra("nickname"); ((TextView) findViewById(R.id.name)).setText(nickname); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); findViewById(R.id.container_file).setVisibility(View.GONE); // findViewById(R.id.container_photo).setVisibility(View.GONE); findViewById(R.id.container_location).setVisibility(View.GONE); findViewById(R.id.container_video).setVisibility(View.GONE); findViewById(R.id.score_lay).setVisibility(View.VISIBLE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); doPullDate("2061", new MCHttpCallBack() { @Override public void onSuccess(MCHttpResp resp) { super.onSuccess(resp); try { String resultCode = resp.getJson().getString("result_code"); if (resultCode.equals("0")) { match = resp.getJson().getJSONObject("match"); loader.LoadImage( resp.getJson().getJSONObject("match").getJSONObject("team1").getString("icon"), team_icon1); loader.LoadImage( resp.getJson().getJSONObject("match").getJSONObject("team2").getString("icon"), team_icon2); score_textView.setText( resp.getJson().getJSONObject("match").getJSONObject("team1").getString("score") + ":" + resp.getJson().getJSONObject("match").getJSONObject("team2") .getString("score")); String stateStr = ""; String stateJson = resp.getJson().getJSONObject("match").getString("state"); if (stateJson.equals("0")) { stateStr = ""; } else if (stateJson.equals("1")) { stateStr = ""; } else if (stateJson.equals("2")) { stateStr = "?"; } tv_state.setText(stateStr); // private CircleImageView team_icon1, team_icon2; // private TextView tv_state, score_textView; } else { Toast.makeText(getApplicationContext(), resp.getJson().getString("message"), Toast.LENGTH_SHORT).show(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onError(MCHttpResp resp) { super.onError(resp); } }); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.wemolian.app.wml.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???// www .ja v a 2 s . c o m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); // type=getIntent().getIntExtra("type", 0); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra(LocalDBKey.CONTACTS_COLUMN_NAME_HXID); String toChatUserCName = getIntent().getStringExtra(LocalDBKey.CONTACTS_COLUMN_NAME_USERCNAME); ((TextView) findViewById(R.id.name)).setText(toChatUserCName); toUserCName = getIntent().getStringExtra(LocalDBKey.CONTACTS_COLUMN_NAME_USERCNAME); toUserImgName = getIntent().getStringExtra(LocalDBKey.CONTACTS_COLUMN_NAME_IMGNAME); } else { findViewById(R.id.container_voice_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupHxId"); groupId = getIntent().getStringExtra("groupId"); groupName = getIntent().getStringExtra("groupName"); ((TextView) findViewById(R.id.name)).setText(groupName); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } iv_setting = (ImageView) this.findViewById(R.id.iv_setting); iv_setting_group = (ImageView) this.findViewById(R.id.iv_setting_group); if (chatType == CHATTYPE_SINGLE) { iv_setting.setVisibility(View.VISIBLE); iv_setting_group.setVisibility(View.GONE); iv_setting.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity( new Intent(ChatActivity.this, ChatSingleSettingActivity.class).putExtra("userId", toChatUsername)); } }); } else { iv_setting.setVisibility(View.GONE); iv_setting_group.setVisibility(View.VISIBLE); iv_setting_group.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivityForResult((new Intent(ChatActivity.this, ChatRoomSettingActivity.class) .putExtra("groupHxId", toChatUsername).putExtra("groupId", groupId) .putExtra("groupName", groupName)), REQUEST_CODE_GROUP_DETAIL); } }); } }
From source file:com.ccxt.whl.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//from ww w . j ava2 s. c o m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); UserDao userdao = new UserDao(this); User user = userdao.getUser(toChatUsername); //nickname = getIntent().getStringExtra("nickname"); //headurl = getIntent().getStringExtra("headurl"); ((TextView) findViewById(R.id.name)).setText(user.getNick()); } else if (chatType == 0) { // ? toChatUsername = getIntent().getStringExtra("userId"); ((TextView) findViewById(R.id.name)).setText("?"); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); expressionContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:net.gsantner.opoc.util.ShareUtil.java
/*** * Replace (primary) clipboard contents with given {@code text} * @param text Text to be set//from ww w.j a v a 2s. co m */ public boolean setClipboard(CharSequence text) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager cm = ((android.text.ClipboardManager) _context .getSystemService(Context.CLIPBOARD_SERVICE)); if (cm != null) { cm.setText(text); return true; } } else { android.content.ClipboardManager cm = ((android.content.ClipboardManager) _context .getSystemService(Context.CLIPBOARD_SERVICE)); if (cm != null) { ClipData clip = ClipData.newPlainText(_context.getPackageName(), text); cm.setPrimaryClip(clip); return true; } } return false; }