List of usage examples for android.view.inputmethod InputMethodManager SHOW_IMPLICIT
int SHOW_IMPLICIT
To view the source code for android.view.inputmethod InputMethodManager SHOW_IMPLICIT.
Click Source Link
From source file:im.neon.activity.VectorRoomActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_vector_room); if (CommonActivityUtils.shouldRestartApp(this)) { Log.e(LOG_TAG, "onCreate : Restart the application."); CommonActivityUtils.restartApp(this); return;//from w ww .j ava2s.c om } final Intent intent = getIntent(); if (!intent.hasExtra(EXTRA_ROOM_ID)) { Log.e(LOG_TAG, "No room ID extra."); finish(); return; } mSession = MXCActionBarActivity.getSession(this, intent); if (mSession == null) { Log.e(LOG_TAG, "No MXSession."); finish(); return; } String roomId = intent.getStringExtra(EXTRA_ROOM_ID); // ensure that the preview mode is really expected if (!intent.hasExtra(EXTRA_ROOM_PREVIEW_ID)) { sRoomPreviewData = null; Matrix.getInstance(this).clearTmpStoresList(); } if (CommonActivityUtils.isGoingToSplash(this, mSession.getMyUserId(), roomId)) { Log.d(LOG_TAG, "onCreate : Going to splash screen"); return; } //setDragEdge(SwipeBackLayout.DragEdge.LEFT); // bind the widgets of the room header view. The room header view is displayed by // clicking on the title of the action bar mRoomHeaderView = (RelativeLayout) findViewById(R.id.action_bar_header); mActionBarHeaderRoomTopic = (TextView) findViewById(R.id.action_bar_header_room_topic); mActionBarHeaderRoomName = (TextView) findViewById(R.id.action_bar_header_room_title); mActionBarHeaderActiveMembers = (TextView) findViewById(R.id.action_bar_header_room_members); mActionBarHeaderRoomAvatar = (ImageView) mRoomHeaderView.findViewById(R.id.avatar_img); mActionBarHeaderInviteMemberView = mRoomHeaderView.findViewById(R.id.action_bar_header_invite_members); mRoomPreviewLayout = findViewById(R.id.room_preview_info_layout); mVectorPendingCallView = (VectorPendingCallView) findViewById(R.id.room_pending_call_view); mVectorOngoingConferenceCallView = (VectorOngoingConferenceCallView) findViewById( R.id.room_ongoing_conference_call_view); mE2eImageView = (ImageView) findViewById(R.id.room_encrypted_image_view); // hide the header room as soon as the bottom layout (text edit zone) is touched findViewById(R.id.room_bottom_layout).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { enableActionBarHeader(HIDE_ACTION_BAR_HEADER); return false; } }); // use a toolbar instead of the actionbar // to be able to display an expandable header mToolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.room_toolbar); this.setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // set the default custom action bar layout, // that will be displayed from the custom action bar layout setActionBarDefaultCustomLayout(); mCallId = intent.getStringExtra(EXTRA_START_CALL_ID); mEventId = intent.getStringExtra(EXTRA_EVENT_ID); mDefaultRoomName = intent.getStringExtra(EXTRA_DEFAULT_NAME); mDefaultTopic = intent.getStringExtra(EXTRA_DEFAULT_TOPIC); // the user has tapped on the "View" notification button if ((null != intent.getAction()) && (intent.getAction().startsWith(NotificationUtils.TAP_TO_VIEW_ACTION))) { // remove any pending notifications NotificationManager notificationsManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); notificationsManager.cancelAll(); } Log.d(LOG_TAG, "Displaying " + roomId); mEditText = (EditText) findViewById(R.id.editText_messageBox); // hide the header room as soon as the message input text area is touched mEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { enableActionBarHeader(HIDE_ACTION_BAR_HEADER); } }); // IME's DONE button is treated as a send action mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { int imeActionId = actionId & EditorInfo.IME_MASK_ACTION; if (EditorInfo.IME_ACTION_DONE == imeActionId) { sendTextMessage(); } return false; } }); mSendingMessagesLayout = findViewById(R.id.room_sending_message_layout); mSendImageView = (ImageView) findViewById(R.id.room_send_image_view); mSendButtonLayout = findViewById(R.id.room_send_layout); mSendButtonLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!TextUtils.isEmpty(mEditText.getText())) { sendTextMessage(); } else { // hide the header room enableActionBarHeader(HIDE_ACTION_BAR_HEADER); FragmentManager fm = getSupportFragmentManager(); IconAndTextDialogFragment fragment = (IconAndTextDialogFragment) fm .findFragmentByTag(TAG_FRAGMENT_ATTACHMENTS_DIALOG); if (fragment != null) { fragment.dismissAllowingStateLoss(); } final Integer[] messages = new Integer[] { R.string.option_send_files, R.string.option_take_photo_video, }; final Integer[] icons = new Integer[] { R.drawable.ic_material_file, // R.string.option_send_files R.drawable.ic_material_camera, // R.string.option_take_photo }; fragment = IconAndTextDialogFragment.newInstance(icons, messages, null, ContextCompat.getColor(VectorRoomActivity.this, R.color.vector_text_black_color)); fragment.setOnClickListener(new IconAndTextDialogFragment.OnItemClickListener() { @Override public void onItemClick(IconAndTextDialogFragment dialogFragment, int position) { Integer selectedVal = messages[position]; if (selectedVal == R.string.option_send_files) { VectorRoomActivity.this.launchFileSelectionIntent(); } else if (selectedVal == R.string.option_take_photo_video) { if (CommonActivityUtils.checkPermissions( CommonActivityUtils.REQUEST_CODE_PERMISSION_TAKE_PHOTO, VectorRoomActivity.this)) { launchCamera(); } } } }); fragment.show(fm, TAG_FRAGMENT_ATTACHMENTS_DIALOG); } } }); mEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(android.text.Editable s) { if (null != mRoom) { MXLatestChatMessageCache latestChatMessageCache = VectorRoomActivity.this.mLatestChatMessageCache; String textInPlace = latestChatMessageCache.getLatestText(VectorRoomActivity.this, mRoom.getRoomId()); // check if there is really an update // avoid useless updates (initializations..) if (!mIgnoreTextUpdate && !textInPlace.equals(mEditText.getText().toString())) { latestChatMessageCache.updateLatestMessage(VectorRoomActivity.this, mRoom.getRoomId(), mEditText.getText().toString()); handleTypingNotification(mEditText.getText().length() != 0); } manageSendMoreButtons(); refreshCallButtons(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); mVectorPendingCallView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { IMXCall call = VectorCallViewActivity.getActiveCall(); if (null != call) { final Intent intent = new Intent(VectorRoomActivity.this, VectorCallViewActivity.class); intent.putExtra(VectorCallViewActivity.EXTRA_MATRIX_ID, call.getSession().getCredentials().userId); intent.putExtra(VectorCallViewActivity.EXTRA_CALL_ID, call.getCallId()); VectorRoomActivity.this.runOnUiThread(new Runnable() { @Override public void run() { VectorRoomActivity.this.startActivity(intent); } }); } else { // if the call is no more active, just remove the view mVectorPendingCallView.onCallTerminated(); } } }); mActionBarHeaderInviteMemberView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { launchRoomDetails(VectorRoomDetailsActivity.PEOPLE_TAB_INDEX); } }); // notifications area mNotificationsArea = findViewById(R.id.room_notifications_area); mNotificationIconImageView = (ImageView) mNotificationsArea.findViewById(R.id.room_notification_icon); mNotificationTextView = (TextView) mNotificationsArea.findViewById(R.id.room_notification_message); mCanNotPostTextView = findViewById(R.id.room_cannot_post_textview); // increase the clickable area to open the keyboard. // when there is no text, it is quite small and some user thought the edition was disabled. findViewById(R.id.room_sending_message_layout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mEditText.requestFocus()) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT); } } }); mStartCallLayout = findViewById(R.id.room_start_call_layout); mStartCallLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ((null != mRoom) && mRoom.isEncrypted() && (mRoom.getActiveMembers().size() > 2)) { // display the dialog with the info text AlertDialog.Builder permissionsInfoDialog = new AlertDialog.Builder(VectorRoomActivity.this); Resources resource = getResources(); permissionsInfoDialog .setMessage(resource.getString(R.string.room_no_conference_call_in_encrypted_rooms)); permissionsInfoDialog.setIcon(android.R.drawable.ic_dialog_alert); permissionsInfoDialog.setPositiveButton(resource.getString(R.string.ok), null); permissionsInfoDialog.show(); } else if (isUserAllowedToStartConfCall()) { displayVideoCallIpDialog(); } else { displayConfCallNotAllowed(); } } }); mStopCallLayout = findViewById(R.id.room_end_call_layout); mStopCallLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { IMXCall call = mSession.mCallsManager.getCallWithRoomId(mRoom.getRoomId()); if (null != call) { call.hangup(null); } } }); findViewById(R.id.room_button_margin_right).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // extend the right side of right button // to avoid clicking in the void if (mStopCallLayout.getVisibility() == View.VISIBLE) { mStopCallLayout.performClick(); } else if (mStartCallLayout.getVisibility() == View.VISIBLE) { mStartCallLayout.performClick(); } else if (mSendButtonLayout.getVisibility() == View.VISIBLE) { mSendButtonLayout.performClick(); } } }); mMyUserId = mSession.getCredentials().userId; CommonActivityUtils.resumeEventStream(this); mRoom = mSession.getDataHandler().getRoom(roomId, false); FragmentManager fm = getSupportFragmentManager(); mVectorMessageListFragment = (VectorMessageListFragment) fm .findFragmentByTag(TAG_FRAGMENT_MATRIX_MESSAGE_LIST); if (mVectorMessageListFragment == null) { Log.d(LOG_TAG, "Create VectorMessageListFragment"); // this fragment displays messages and handles all message logic mVectorMessageListFragment = VectorMessageListFragment.newInstance(mMyUserId, roomId, mEventId, (null == sRoomPreviewData) ? null : VectorMessageListFragment.PREVIEW_MODE_READ_ONLY, org.matrix.androidsdk.R.layout.fragment_matrix_message_list_fragment); fm.beginTransaction().add(R.id.anchor_fragment_messages, mVectorMessageListFragment, TAG_FRAGMENT_MATRIX_MESSAGE_LIST).commit(); } else { Log.d(LOG_TAG, "Reuse VectorMessageListFragment"); } mVectorRoomMediasSender = new VectorRoomMediasSender(this, mVectorMessageListFragment, Matrix.getInstance(this).getMediasCache()); mVectorRoomMediasSender.onRestoreInstanceState(savedInstanceState); manageRoomPreview(); addRoomHeaderClickListeners(); // in timeline mode (i.e search in the forward and backward room history) // or in room preview mode // the edition items are not displayed if (!TextUtils.isEmpty(mEventId) || (null != sRoomPreviewData)) { mNotificationsArea.setVisibility(View.GONE); findViewById(R.id.bottom_separator).setVisibility(View.GONE); findViewById(R.id.room_notification_separator).setVisibility(View.GONE); findViewById(R.id.room_notifications_area).setVisibility(View.GONE); View v = findViewById(R.id.room_bottom_layout); ViewGroup.LayoutParams params = v.getLayoutParams(); params.height = 0; v.setLayoutParams(params); } mLatestChatMessageCache = Matrix.getInstance(this).getDefaultLatestChatMessageCache(); // some medias must be sent while opening the chat if (intent.hasExtra(EXTRA_ROOM_INTENT)) { final Intent mediaIntent = intent.getParcelableExtra(EXTRA_ROOM_INTENT); // sanity check if (null != mediaIntent) { mEditText.postDelayed(new Runnable() { @Override public void run() { intent.removeExtra(EXTRA_ROOM_INTENT); sendMediasIntent(mediaIntent); } }, 1000); } } mVectorOngoingConferenceCallView.initRoomInfo(mSession, mRoom); mVectorOngoingConferenceCallView .setCallClickListener(new VectorOngoingConferenceCallView.ICallClickListener() { private void startCall(boolean isVideo) { if (CommonActivityUtils.checkPermissions( isVideo ? CommonActivityUtils.REQUEST_CODE_PERMISSION_VIDEO_IP_CALL : CommonActivityUtils.REQUEST_CODE_PERMISSION_AUDIO_IP_CALL, VectorRoomActivity.this)) { startIpCall(isVideo); } } @Override public void onVoiceCallClick() { startCall(false); } @Override public void onVideoCallClick() { startCall(true); } }); View avatarLayout = findViewById(R.id.room_self_avatar); if (null != avatarLayout) { mAvatarImageView = (ImageView) avatarLayout.findViewById(R.id.avatar_img); } refreshSelfAvatar(); // in case a "Send as" dialog was in progress when the activity was destroyed (life cycle) mVectorRoomMediasSender.resumeResizeMediaAndSend(); // header visibility has launched enableActionBarHeader(intent.getBooleanExtra(EXTRA_EXPAND_ROOM_HEADER, false) ? SHOW_ACTION_BAR_HEADER : HIDE_ACTION_BAR_HEADER); // the both flags are only used once intent.removeExtra(EXTRA_EXPAND_ROOM_HEADER); Log.d(LOG_TAG, "End of create"); }
From source file:ir.occc.android.irc.activity.ConversationActivity.java
/** * Open the soft keyboard (helper function) *//*from w ww . ja v a 2 s . c o m*/ private void openSoftKeyboard(View view) { ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); }
From source file:com.mobilis.android.nfc.activities.MagTekFragment.java
void ShowSoftKeyboard(EditText lpEditText) { InputMethodManager objInputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); // only will trigger it if no physical keyboard is open objInputManager.showSoftInput(lpEditText, InputMethodManager.SHOW_IMPLICIT); }
From source file:org.akop.crosswords.view.CrosswordView.java
protected void showKeyboard() { InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(CrosswordView.this, InputMethodManager.SHOW_IMPLICIT); }
From source file:com.raspi.chatapp.ui.chatting.ChatFragment.java
/** * initialize the emojiconKeyboard/*from ww w . j a v a 2 s. c o m*/ */ private void initEmoji() { // save the views I will use final EmojiconEditText emojiconEditText = (EmojiconEditText) getActivity().findViewById(R.id.chat_in); final ImageButton emojiBtn = (ImageButton) getActivity().findViewById(R.id.emoti_switch); final EmojiconPopup popup = new EmojiconPopup(getActivity().findViewById(R.id.root_view), getContext(), new EmojiconGridView.OnEmojiconClickedListener() { @Override public void OnEmojiconClicked(Emojicon emojicon) { if (emojiconEditText == null || emojicon == null) return; int start = emojiconEditText.getSelectionStart(); int end = emojiconEditText.getSelectionEnd(); if (start < 0) emojiconEditText.append(emojicon.getEmoji()); else emojiconEditText.getText().replace(Math.min(start, end), Math.max(start, end), emojicon.getEmoji(), 0, emojicon.getEmoji().length()); } }); popup.setSoftKeyboardSize(); popup.setOnSoftKeyboardOpenCloseListener(new EmojiconPopup.OnSoftKeyboardOpenCloseListener() { @Override public void onKeyboardOpen(int keyboardHeight) { } @Override public void onKeyboardClose() { if (popup.isShowing()) popup.dismiss(); } }); // open/close the emojicon keyboard when pressing the button emojiBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!popup.isShowing()) { if (popup.isKeyboardOpen()) popup.showAtBottom(); else { emojiconEditText.setFocusableInTouchMode(true); emojiconEditText.requestFocus(); popup.showAtBottomPending(); InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(emojiconEditText, InputMethodManager.SHOW_IMPLICIT); } } else popup.dismiss(); } }); popup.setOnEmojiconBackspaceClickedListener(new EmojiconPopup.OnEmojiconBackspaceClickedListener() { @Override public void onEmojiconBackspaceClicked(View view) { emojiconEditText.dispatchKeyEvent( new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL)); } }); }
From source file:org.akop.ararat.view.CrosswordView.java
protected void showKeyboard() { if (mInputMode != INPUT_MODE_NONE) { InputMethodManager imm = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(CrosswordView.this, InputMethodManager.SHOW_IMPLICIT); }//from w w w.j av a 2 s .c o m }
From source file:foam.mongoose.StarwispBuilder.java
public void Update(final StarwispActivity ctx, final String ctxname, JSONArray arr) { try {//from w w w . j av a 2s. co m String type = arr.getString(0); final Integer id = arr.getInt(1); String token = arr.getString(2); //Log.i("starwisp", "Update: "+type+" "+id+" "+token); // non widget commands if (token.equals("toast")) { Toast msg = Toast.makeText(ctx.getBaseContext(), arr.getString(3), Toast.LENGTH_SHORT); msg.show(); return; } if (token.equals("play-sound")) { String name = arr.getString(3); if (name.equals("ping")) { MediaPlayer mp = MediaPlayer.create(ctx, R.raw.ping); mp.start(); } if (name.equals("active")) { MediaPlayer mp = MediaPlayer.create(ctx, R.raw.active); mp.start(); } } if (token.equals("vibrate")) { Vibrator v = (Vibrator) ctx.getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(arr.getInt(3)); } if (type.equals("replace-fragment")) { int ID = arr.getInt(1); String name = arr.getString(2); Fragment fragment = ActivityManager.GetFragment(name); FragmentTransaction ft = ctx.getSupportFragmentManager().beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); //ft.setCustomAnimations( // R.animator.card_flip_right_in, R.animator.card_flip_right_out, // R.animator.card_flip_left_in, R.animator.card_flip_left_out); ft.replace(ID, fragment); //ft.addToBackStack(null); ft.commit(); return; } if (token.equals("dialog-fragment")) { FragmentManager fm = ctx.getSupportFragmentManager(); final int ID = arr.getInt(3); final JSONArray lp = arr.getJSONArray(4); final String name = arr.getString(5); final Dialog dialog = new Dialog(ctx); dialog.setTitle("Title..."); LinearLayout inner = new LinearLayout(ctx); inner.setId(ID); inner.setLayoutParams(BuildLayoutParams(lp)); dialog.setContentView(inner); // Fragment fragment = ActivityManager.GetFragment(name); // FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); // fragmentTransaction.add(ID,fragment); // fragmentTransaction.commit(); dialog.show(); /* DialogFragment df = new DialogFragment() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout inner = new LinearLayout(ctx); inner.setId(ID); inner.setLayoutParams(BuildLayoutParams(lp)); return inner; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog ret = super.onCreateDialog(savedInstanceState); Log.i("starwisp","MAKINGDAMNFRAGMENT"); Fragment fragment = ActivityManager.GetFragment(name); FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(1,fragment); fragmentTransaction.commit(); return ret; } }; df.show(ctx.getFragmentManager(), "foo"); */ } if (token.equals("time-picker-dialog")) { final Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); // Create a new instance of TimePickerDialog and return it TimePickerDialog d = new TimePickerDialog(ctx, null, hour, minute, true); d.show(); return; } ; if (token.equals("make-directory")) { File file = new File(((StarwispActivity) ctx).m_AppDir + arr.getString(3)); file.mkdirs(); return; } if (token.equals("list-files")) { final String name = arr.getString(3); File file = new File(((StarwispActivity) ctx).m_AppDir + arr.getString(5)); // todo, should probably call callback with empty list if (file != null) { File list[] = file.listFiles(); if (list != null) { String code = "("; for (int i = 0; i < list.length; i++) { code += " \"" + list[i].getName() + "\""; } code += ")"; DialogCallback(ctx, ctxname, name, code); } } return; } if (token.equals("gps-start")) { final String name = arr.getString(3); if (m_LocationManager == null) { m_LocationManager = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); m_GPS = new DorisLocationListener(m_LocationManager); } m_GPS.Start((StarwispActivity) ctx, name, this); return; } if (token.equals("delayed")) { final String name = arr.getString(3); final int d = arr.getInt(5); Runnable timerThread = new Runnable() { public void run() { DialogCallback(ctx, ctxname, name, ""); } }; m_Handler.removeCallbacksAndMessages(null); m_Handler.postDelayed(timerThread, d); return; } if (token.equals("network-connect")) { final String name = arr.getString(3); final String ssid = arr.getString(5); m_NetworkManager.Start(ssid, (StarwispActivity) ctx, name, this); return; } if (token.equals("http-request")) { if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http request"); final String name = arr.getString(3); final String url = arr.getString(5); m_NetworkManager.StartRequestThread(url, "normal", name); } return; } if (token.equals("http-download")) { if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http dl request"); final String filename = arr.getString(4); final String url = arr.getString(5); m_NetworkManager.StartRequestThread(url, "download", filename); } return; } if (token.equals("send-mail")) { final String to[] = new String[1]; to[0] = arr.getString(3); final String subject = arr.getString(4); final String body = arr.getString(5); JSONArray attach = arr.getJSONArray(6); ArrayList<String> paths = new ArrayList<String>(); for (int a = 0; a < attach.length(); a++) { Log.i("starwisp", attach.getString(a)); paths.add(attach.getString(a)); } email(ctx, to[0], "", subject, body, paths); } if (token.equals("date-picker-dialog")) { final Calendar c = Calendar.getInstance(); int day = c.get(Calendar.DAY_OF_MONTH); int month = c.get(Calendar.MONTH); int year = c.get(Calendar.YEAR); final String name = arr.getString(3); // Create a new instance of TimePickerDialog and return it DatePickerDialog d = new DatePickerDialog(ctx, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int month, int day) { DialogCallback(ctx, ctxname, name, day + " " + month + " " + year); } }, year, month, day); d.show(); return; } ; if (token.equals("alert-dialog")) { final String name = arr.getString(3); final String msg = arr.getString(5); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int result = 0; if (which == DialogInterface.BUTTON_POSITIVE) result = 1; DialogCallback(ctx, ctxname, name, "" + result); } }; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(msg).setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); return; } if (token.equals("start-activity")) { ActivityManager.StartActivity(ctx, arr.getString(3), arr.getInt(4), arr.getString(5)); return; } if (token.equals("start-activity-goto")) { ActivityManager.StartActivityGoto(ctx, arr.getString(3), arr.getString(4)); return; } if (token.equals("finish-activity")) { ctx.setResult(arr.getInt(3)); ctx.finish(); return; } /////////////////////////////////////////////////////////// // problem associating the id number if (id == 0) return; // now try and find the widget View vv = ctx.findViewById(id); if (vv == null) { Log.i("starwisp", "Can't find widget : " + id); return; } // tokens that work on everything if (token.equals("hide")) { vv.setVisibility(View.GONE); return; } if (token.equals("show")) { vv.setVisibility(View.VISIBLE); return; } // tokens that work on everything if (token.equals("set-enabled")) { vv.setEnabled(arr.getInt(3) == 1); return; } // special cases if (type.equals("linear-layout")) { LinearLayout v = (LinearLayout) vv; if (token.equals("contents")) { v.removeAllViews(); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } } } if (type.equals("button-grid")) { LinearLayout horiz = (LinearLayout) vv; if (token.equals("grid-buttons")) { horiz.removeAllViews(); JSONArray params = arr.getJSONArray(3); String buttontype = params.getString(0); int height = params.getInt(1); int textsize = params.getInt(2); LinearLayout.LayoutParams lp = BuildLayoutParams(params.getJSONArray(3)); final JSONArray buttons = params.getJSONArray(4); final int count = buttons.length(); int vertcount = 0; LinearLayout vert = null; for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); if (vertcount == 0) { vert = new LinearLayout(ctx); vert.setId(0); vert.setOrientation(LinearLayout.VERTICAL); horiz.addView(vert); } vertcount = (vertcount + 1) % height; if (buttontype.equals("button")) { Button b = new Button(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } else if (buttontype.equals("toggle")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg); } }); vert.addView(b); } else if (buttontype.equals("single")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); int bid = button.getInt(0); if (bid != v.getId()) { ToggleButton tb = (ToggleButton) ctx.findViewById(bid); tb.setChecked(false); } } } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } } } } /* if (type.equals("grid-layout")) { GridLayout v = (GridLayout)vv; if (token.equals("contents")) { v.removeAllViews(); JSONArray children = arr.getJSONArray(3); for (int i=0; i<children.length(); i++) { Build(ctx,ctxname,new JSONArray(children.getString(i)), v); } } } */ if (type.equals("view-pager")) { ViewPager v = (ViewPager) vv; if (token.equals("switch")) { v.setCurrentItem(arr.getInt(3)); } if (token.equals("pages")) { final JSONArray items = arr.getJSONArray(3); v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) { @Override public int getCount() { return items.length(); } @Override public Fragment getItem(int position) { try { String fragname = items.getString(position); return ActivityManager.GetFragment(fragname); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } return null; } }); } } if (type.equals("image-view")) { ImageView v = (ImageView) vv; if (token.equals("image")) { int iid = ctx.getResources().getIdentifier(arr.getString(3), "drawable", ctx.getPackageName()); v.setImageResource(iid); } if (token.equals("external-image")) { Bitmap bitmap = BitmapFactory.decodeFile(arr.getString(3)); v.setImageBitmap(bitmap); } return; } if (type.equals("text-view") || type.equals("debug-text-view")) { TextView v = (TextView) vv; if (token.equals("text")) { if (type.equals("debug-text-view")) { //v.setMovementMethod(new ScrollingMovementMethod()); } v.setText(arr.getString(3)); } return; } if (type.equals("edit-text")) { EditText v = (EditText) vv; if (token.equals("text")) { v.setText(arr.getString(3)); } if (token.equals("request-focus")) { v.requestFocus(); InputMethodManager imm = (InputMethodManager) ctx .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT); } return; } if (type.equals("button")) { Button v = (Button) vv; if (token.equals("text")) { v.setText(arr.getString(3)); } if (token.equals("listener")) { final String fn = arr.getString(3); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { m_Scheme.eval("(" + fn + ")"); } }); } return; } if (type.equals("toggle-button")) { ToggleButton v = (ToggleButton) vv; if (token.equals("text")) { v.setText(arr.getString(3)); return; } if (token.equals("checked")) { if (arr.getInt(3) == 0) v.setChecked(false); else v.setChecked(true); return; } if (token.equals("listener")) { final String fn = arr.getString(3); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { m_Scheme.eval("(" + fn + ")"); } }); } return; } if (type.equals("canvas")) { StarwispCanvas v = (StarwispCanvas) vv; if (token.equals("drawlist")) { v.SetDrawList(arr.getJSONArray(3)); } return; } if (type.equals("camera-preview")) { final CameraPreview v = (CameraPreview) vv; if (token.equals("take-picture")) { final String path = ((StarwispActivity) ctx).m_AppDir + arr.getString(3); v.TakePicture(new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { String datetime = getDateTime(); String filename = path + datetime + ".jpg"; SaveData(filename, data); v.Shutdown(); ctx.finish(); } }); } if (token.equals("shutdown")) { v.Shutdown(); } return; } if (type.equals("seek-bar")) { SeekBar v = new SeekBar(ctx); if (token.equals("max")) { // android seekbar bug workaround int p = v.getProgress(); v.setMax(0); v.setProgress(0); v.setMax(arr.getInt(3)); v.setProgress(1000); // not working.... :( } } if (type.equals("spinner")) { Spinner v = (Spinner) vv; if (token.equals("selection")) { v.setSelection(arr.getInt(3)); } if (token.equals("array")) { final JSONArray items = arr.getJSONArray(3); ArrayList<String> spinnerArray = new ArrayList<String>(); for (int i = 0; i < items.length(); i++) { spinnerArray.add(items.getString(i)); } ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx, android.R.layout.simple_spinner_item, spinnerArray) { public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface); return v; } }; v.setAdapter(spinnerArrayAdapter); final int wid = id; // need to update for new values v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> a, View v, int pos, long id) { try { CallbackArgs(ctx, ctxname, wid, "\"" + items.getString(pos) + "\""); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } } public void onNothingSelected(AdapterView<?> v) { } }); } return; } } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } }
From source file:com.igniva.filemanager.activities.MainActivity.java
/** * show search view with a circular reveal animation *///w ww . jav a 2 s.co m void revealSearchView() { final int START_RADIUS = 16; int endRadius = Math.max(toolbar.getWidth(), toolbar.getHeight()); Animator animator; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32, searchCoords[1] - 16, START_RADIUS, endRadius); } else { // TODO:ViewAnimationUtils.createCircularReveal animator = new ObjectAnimator().ofFloat(searchViewLayout, "alpha", 0f, 1f); } utils.revealShow(mFabBackground, true); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setDuration(600); searchViewLayout.setVisibility(View.VISIBLE); animator.start(); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { searchViewEditText.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(searchViewEditText, InputMethodManager.SHOW_IMPLICIT); isSearchViewEnabled = true; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
/** * Shows/hides the soft keyboard.//from w ww . j av a 2 s . c om * @param view the current focused view. * @param show whether to show soft keyboard. */ public static void showSoftKeyboard(final View view, final boolean show) { if (view == null) return; InputMethodManager imm = (InputMethodManager) view.getContext() .getSystemService(Activity.INPUT_METHOD_SERVICE); if (imm != null) { boolean useForce = (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT || Build.VERSION.SDK_INT >= 8) ? true : false; String model = TiPlatformHelper.getInstance().getModel(); if (model != null && model.toLowerCase().startsWith("droid")) { useForce = true; } if (show) { imm.showSoftInput(view, useForce ? InputMethodManager.SHOW_FORCED : InputMethodManager.SHOW_IMPLICIT); } else { imm.hideSoftInputFromWindow(view.getWindowToken(), useForce ? 0 : InputMethodManager.HIDE_IMPLICIT_ONLY); } } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
/** * show search view with a circular reveal animation *//*w w w . j a v a 2 s . c om*/ void revealSearchView() { final int START_RADIUS = 16; int endRadius = Math.max(toolbar.getWidth(), toolbar.getHeight()); Animator animator; if (SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32, searchCoords[1] - 16, START_RADIUS, endRadius); } else { // TODO:ViewAnimationUtils.createCircularReveal animator = ObjectAnimator.ofFloat(searchViewLayout, "alpha", 0f, 1f); } utils.revealShow(fabBgView, true); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setDuration(600); searchViewLayout.setVisibility(View.VISIBLE); animator.start(); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { searchViewEditText.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(searchViewEditText, InputMethodManager.SHOW_IMPLICIT); isSearchViewEnabled = true; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); }