List of usage examples for android.text InputType TYPE_NULL
int TYPE_NULL
To view the source code for android.text InputType TYPE_NULL.
Click Source Link
From source file:com.duy.pascal.ui.view.console.ConsoleView.java
@Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { outAttrs.inputType = InputType.TYPE_NULL; // outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE; return new InputConnection() { /**/*from w ww . jav a 2s . c om*/ * Used to handle composing text requests */ private int mCursor; private int mComposingTextStart; private int mComposingTextEnd; private int mSelectedTextStart = 0; private int mSelectedTextEnd = 0; private boolean mInBatchEdit; private void sendText(CharSequence text) { DLog.d(TAG, "sendText: " + text); int n = text.length(); for (int i = 0; i < n; i++) { mKeyBuffer.push(text.charAt(i)); putString(Character.toString(text.charAt(i))); } } @Override public boolean performEditorAction(int actionCode) { DLog.d(TAG, "performEditorAction: " + actionCode); if (actionCode == EditorInfo.IME_ACTION_DONE || actionCode == EditorInfo.IME_ACTION_GO || actionCode == EditorInfo.IME_ACTION_NEXT || actionCode == EditorInfo.IME_ACTION_SEND || actionCode == EditorInfo.IME_ACTION_UNSPECIFIED) { sendText("\n"); return true; } return false; } public boolean beginBatchEdit() { { DLog.w(TAG, "beginBatchEdit"); } setImeBuffer(""); mCursor = 0; mComposingTextStart = 0; mComposingTextEnd = 0; mInBatchEdit = true; return true; } public boolean clearMetaKeyStates(int arg0) { { DLog.w(TAG, "clearMetaKeyStates " + arg0); } return false; } public boolean commitCompletion(CompletionInfo arg0) { { DLog.w(TAG, "commitCompletion " + arg0); } return false; } @Override public boolean commitCorrection(CorrectionInfo correctionInfo) { return false; } public boolean endBatchEdit() { { DLog.w(TAG, "endBatchEdit"); } mInBatchEdit = false; return true; } public boolean finishComposingText() { { DLog.w(TAG, "finishComposingText"); } sendText(mImeBuffer); setImeBuffer(""); mComposingTextStart = 0; mComposingTextEnd = 0; mCursor = 0; return true; } public int getCursorCapsMode(int arg0) { { DLog.w(TAG, "getCursorCapsMode(" + arg0 + ")"); } return 0; } public ExtractedText getExtractedText(ExtractedTextRequest arg0, int arg1) { { DLog.w(TAG, "getExtractedText" + arg0 + "," + arg1); } return null; } public CharSequence getTextAfterCursor(int n, int flags) { { DLog.w(TAG, "getTextAfterCursor(" + n + "," + flags + ")"); } int len = Math.min(n, mImeBuffer.length() - mCursor); if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) { return ""; } return mImeBuffer.substring(mCursor, mCursor + len); } public CharSequence getTextBeforeCursor(int n, int flags) { { DLog.w(TAG, "getTextBeforeCursor(" + n + "," + flags + ")"); } int len = Math.min(n, mCursor); if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) { return ""; } return mImeBuffer.substring(mCursor - len, mCursor); } public boolean performContextMenuAction(int arg0) { { DLog.w(TAG, "performContextMenuAction" + arg0); } return true; } public boolean performPrivateCommand(String arg0, Bundle arg1) { { DLog.w(TAG, "performPrivateCommand" + arg0 + "," + arg1); } return true; } @Override public boolean requestCursorUpdates(int cursorUpdateMode) { return false; } @Override public Handler getHandler() { return null; } @Override public void closeConnection() { } @Override public boolean commitContent(@NonNull InputContentInfo inputContentInfo, int flags, Bundle opts) { return false; } public boolean reportFullscreenMode(boolean arg0) { { DLog.w(TAG, "reportFullscreenMode" + arg0); } return true; } public boolean commitText(CharSequence text, int newCursorPosition) { { DLog.w(TAG, "commitText(\"" + text + "\", " + newCursorPosition + ")"); } char[] characters = text.toString().toCharArray(); for (char character : characters) { mKeyBuffer.push(character); } clearComposingText(); sendText(text); setImeBuffer(""); mCursor = 0; return true; } private void clearComposingText() { setImeBuffer( mImeBuffer.substring(0, mComposingTextStart) + mImeBuffer.substring(mComposingTextEnd)); if (mCursor < mComposingTextStart) { // do nothing } else if (mCursor < mComposingTextEnd) { mCursor = mComposingTextStart; } else { mCursor -= mComposingTextEnd - mComposingTextStart; } mComposingTextEnd = mComposingTextStart = 0; } public boolean deleteSurroundingText(int leftLength, int rightLength) { { DLog.w(TAG, "deleteSurroundingText(" + leftLength + "," + rightLength + ")"); } if (leftLength > 0) { for (int i = 0; i < leftLength; i++) { sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); } } else if ((leftLength == 0) && (rightLength == 0)) { // Delete key held down / repeating sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); } // TODO: handle forward deletes. return true; } @Override public boolean deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) { return false; } public boolean sendKeyEvent(KeyEvent event) { { DLog.w(TAG, "sendKeyEvent(" + event + ")"); } // Some keys are sent here rather than to commitText. // In particular, del and the digit keys are sent here. // (And I have reports that the HTC Magic also sends Return here.) // As a bit of defensive programming, handle every key. dispatchKeyEvent(event); return true; } public boolean setComposingText(CharSequence text, int newCursorPosition) { { DLog.w(TAG, "setComposingText(\"" + text + "\", " + newCursorPosition + ")"); } setImeBuffer(mImeBuffer.substring(0, mComposingTextStart) + text + mImeBuffer.substring(mComposingTextEnd)); mComposingTextEnd = mComposingTextStart + text.length(); mCursor = newCursorPosition > 0 ? mComposingTextEnd + newCursorPosition - 1 : mComposingTextStart - newCursorPosition; return true; } public boolean setSelection(int start, int end) { { DLog.w(TAG, "setSelection" + start + "," + end); } int length = mImeBuffer.length(); if (start == end && start > 0 && start < length) { mSelectedTextStart = mSelectedTextEnd = 0; mCursor = start; } else if (start < end && start > 0 && end < length) { mSelectedTextStart = start; mSelectedTextEnd = end; mCursor = start; } return true; } public boolean setComposingRegion(int start, int end) { { DLog.w(TAG, "setComposingRegion " + start + "," + end); } if (start < end && start > 0 && end < mImeBuffer.length()) { clearComposingText(); mComposingTextStart = start; mComposingTextEnd = end; } return true; } public CharSequence getSelectedText(int flags) { try { { DLog.w(TAG, "getSelectedText " + flags); } if (mImeBuffer.length() < 1) { return ""; } return mImeBuffer.substring(mSelectedTextStart, mSelectedTextEnd + 1); } catch (Exception ignored) { } return ""; } }; }
From source file:org.catrobat.catroid.uitest.util.UiTestUtils.java
public static void enterText(Solo solo, int editTextIndex, String text) { solo.sleep(50);//w w w. ja v a 2 s . c o m final EditText editText = solo.getEditText(editTextIndex); solo.getCurrentActivity().runOnUiThread(new Runnable() { public void run() { editText.setInputType(InputType.TYPE_NULL); } }); solo.clearEditText(editTextIndex); solo.enterText(editTextIndex, text); solo.sleep(50); }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
private void exitEditTagsMode() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)) .setImageResource(R.drawable.ic_done_anim); Drawable editIcon = ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)).getDrawable(); ((Animatable) editIcon).start(); } else/* w w w. ja va 2 s . c o m*/ ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)).setImageResource(R.drawable.ic_edit); if (getActivity().getCurrentFocus() != null) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isAcceptingText()) imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0); } EditText songTV = (EditText) getActivity().findViewById(R.id.song); EditText artistTV = ((EditText) getActivity().findViewById(R.id.artist)); EditText newLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics); songTV.setInputType(InputType.TYPE_NULL); artistTV.setInputType(InputType.TYPE_NULL); songTV.setBackgroundColor(Color.TRANSPARENT); artistTV.setBackgroundColor(Color.TRANSPARENT); String txt = mLrcThread == null ? null : mLyrics.getText(); if (txt == null) txt = ""; File musicFile = Id3Reader.getFile(getActivity(), mLyrics.getOriginalArtist(), mLyrics.getOriginalTrack()); if (!mLyrics.getArtist().equals(artistTV.getText().toString()) || !mLyrics.getTitle().equals(songTV.getText().toString()) || !Html.fromHtml(txt).toString().equals(newLyrics.getText().toString())) { mLyrics.setArtist(artistTV.getText().toString()); mLyrics.setTitle(songTV.getText().toString()); mLyrics.setText(newLyrics.getText().toString().replaceAll("\n", "<br/>")); if (PermissionsChecker.requestPermission(getActivity(), "android.permission.WRITE_EXTERNAL_STORAGE", 0, Id3Writer.REQUEST_CODE)) new Id3Writer(this).execute(mLyrics, musicFile); } else new Id3Writer(this).onPreExecute(); }
From source file:org.akop.crosswords.view.CrosswordView.java
@Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { outAttrs.actionLabel = null;//from w w w .ja v a2 s . c o m outAttrs.inputType = InputType.TYPE_NULL; //InputType.TYPE_CLASS_TEXT; outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_FULLSCREEN; outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI; outAttrs.imeOptions &= ~EditorInfo.IME_MASK_ACTION; outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT; outAttrs.packageName = getContext().getPackageName(); CrosswordInputConnection inputConnection = new CrosswordInputConnection(this); inputConnection.setOnInputEventListener(mInputEventListener); return inputConnection; }
From source file:org.apache.cordova.core.InAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject/*from w w w . ja va 2 s .c o m*/ */ public String showWebPage(final String url, HashMap<String, Boolean> features) { // Determine if we should hide the location bar. showLocationBar = true; openWindowHidden = false; if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { showLocationBar = show.booleanValue(); } Boolean hidden = features.get(HIDDEN); if (hidden != null) { openWindowHidden = hidden.booleanValue(); } } final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button Button back = new Button(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); back.setText("<"); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button Button forward = new Button(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); forward.setText(">"); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button Button close = new Button(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); close.setText(buttonLabel); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); WebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); WebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (openWindowHidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:com.example.carsharing.ShortWayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { photouri = Uri// ww w. jav a 2 s. c om .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_short_way); activity_drawer = new Drawer(this, R.id.short_way_layout); mDrawerToggle = activity_drawer.newdrawer(); mDrawerLayout = activity_drawer.setDrawerLayout(); bdriver = true; // SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE); UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0"); // standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE); primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE); standard_time = new SimpleDateFormat("HH:mm:ss", Locale.SIMPLIFIED_CHINESE); primary_time = new SimpleDateFormat("HHmmss", Locale.SIMPLIFIED_CHINESE); queue = Volley.newRequestQueue(this); exchange = (ImageView) findViewById(R.id.shortway_exchange); exchange.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub String temp = startplace.getText().toString(); if (!temp.equals("") && !endplace.getText().toString().equals("")) { startplace.setText(endplace.getText().toString()); endplace.setText(temp); float a, b; a = startplace_longitude; b = startplace_latitude; startplace_longitude = destination_longitude; startplace_latitude = destination_latitude; destination_longitude = a; destination_latitude = b; } } }); datebutton = (Button) findViewById(R.id.shortway_dates); earlystarttime = (Button) findViewById(R.id.shortway_earliest_start_time); latestarttime = (Button) findViewById(R.id.shortway_latest_start_time); increase = (Button) findViewById(R.id.shortway_increase); decrease = (Button) findViewById(R.id.shortway_decrease); s2 = (TextView) findViewById(R.id.shortway_count); startplace = (Button) findViewById(R.id.shortway_startplace); endplace = (Button) findViewById(R.id.shortway_endplace); sure = (Button) findViewById(R.id.shortway_sure); commute = findViewById(R.id.drawer_commute); shortway = findViewById(R.id.drawer_shortway); longway = findViewById(R.id.drawer_longway); setting = findViewById(R.id.drawer_setting); personalcenter = findViewById(R.id.drawer_personalcenter); about = findViewById(R.id.drawer_respond); taxi = findViewById(R.id.drawer_taxi); drawericon = (ImageView) findViewById(R.id.drawer_icon); drawername = (TextView) findViewById(R.id.drawer_name); drawernum = (TextView) findViewById(R.id.drawer_phone); carbrand = (EditText) findViewById(R.id.shortway_CarBrand); model = (EditText) findViewById(R.id.shortway_CarModel); color = (EditText) findViewById(R.id.shortway_color); licensenum = (EditText) findViewById(R.id.shortway_Num); licensenum.addTextChangedListener(numTextWatcher); carbrand.addTextChangedListener(detTextWatcher); color.addTextChangedListener(coTextWatcher); model.addTextChangedListener(moTextWatcher); next = (Button) findViewById(R.id.shortway_sure); next.setEnabled(false); db = new DatabaseHelper(ShortWayActivity.this, "test", null, 1); db1 = db.getWritableDatabase(); final TextView content = (TextView) findViewById(R.id.shortway_content); mRadio1 = (RadioButton) findViewById(R.id.shortway_radioButton1); mRadio2 = (RadioButton) findViewById(R.id.shortway_radioButton2); shortway_group = (RadioGroup) findViewById(R.id.shortway_radiobutton01); star1 = (ImageView) findViewById(R.id.shortway_star); star2 = (ImageView) findViewById(R.id.shortway_star01); // judge the value of "pre_page" Bundle bundle = this.getIntent().getExtras(); String PRE_PAGE = bundle.getString("pre_page"); if (PRE_PAGE.compareTo("ReOrder") == 0) { // startplace.setText(bundle.getString("stpusername") + "," + bundle.getString("stpmapname")); bstart = true; endplace.setText(bundle.getString("epusername") + "," + bundle.getString("epmapname")); bend = true; startplace_longitude = bundle.getFloat("stpx"); Log.e("startplace_longitude", String.valueOf(startplace_longitude)); startplace_latitude = bundle.getFloat("stpy"); Log.e("startplace_latitude", String.valueOf(startplace_latitude)); destination_longitude = bundle.getFloat("epx"); Log.e("destination_longitude", String.valueOf(destination_longitude)); destination_latitude = bundle.getFloat("epy"); Log.e("destination_latitude", String.valueOf(destination_latitude)); datebutton.setText(bundle.getString("re_short_startdate")); bdate = true; earlystarttime.setText(bundle.getString("re_short_starttime")); best = true; latestarttime.setText(bundle.getString("re_short_endtime")); blst = true; } // judge the value of "pre_page" about.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent about = new Intent(ShortWayActivity.this, AboutActivity.class); startActivity(about); } }); setting.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent setting = new Intent(ShortWayActivity.this, SettingActivity.class); startActivity(setting); } }); // database db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1); db1 = db.getWritableDatabase(); // database end star1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (bstart) { if (Pointisliked(StartPointMapName)) { // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { StartPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs); star1.setImageResource(R.drawable.ic_action_not_important); } else { ContentValues content = new ContentValues(); content.put(getString(R.string.dbstring_PlaceUserName), StartPointUserName); content.put(getString(R.string.dbstring_PlaceMapName), StartPointMapName); content.put(getString(R.string.dbstring_longitude), startplace_longitude); content.put(getString(R.string.dbstring_latitude), startplace_latitude); db1.insert(getString(R.string.dbtable_placeliked), null, content); // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { StartPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs); star1.setImageResource(R.drawable.ic_action_important); } } } }); star2.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (bend) { if (Pointisliked(EndPointMapName)) { // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { EndPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs); star2.setImageResource(R.drawable.ic_action_not_important); } else { ContentValues content = new ContentValues(); content.put(getString(R.string.dbstring_PlaceUserName), EndPointUserName); content.put(getString(R.string.dbstring_PlaceMapName), EndPointMapName); content.put(getString(R.string.dbstring_longitude), destination_longitude); content.put(getString(R.string.dbstring_latitude), destination_latitude); db1.insert(getString(R.string.dbtable_placeliked), null, content); // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { EndPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs); star2.setImageResource(R.drawable.ic_action_important); } } } }); taxi.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); personalcenter.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent personalcenter = new Intent(ShortWayActivity.this, PersonalCenterActivity.class); startActivity(personalcenter); } }); shortway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); longway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent longway = new Intent(ShortWayActivity.this, MainActivity.class); startActivity(longway); } }); commute.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent commute = new Intent(ShortWayActivity.this, CommuteActivity.class); commute.putExtra("pre_page", "Drawer"); startActivity(commute); } }); // RadioGroup shortway_group.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup arg0, int checkedId) { // TODO Auto-generated method stub18 // ID // """"textView if (checkedId == mRadio2.getId()) { bpassenager = true; bdriver = false; licensenum.setEnabled(false); carbrand.setEnabled(false); color.setEnabled(false); model.setEnabled(false); licensenum.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); carbrand.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); color.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); model.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); content.setText(getString(R.string.warningInfo_seatNeed)); licensenum.setHintTextColor(Color.parseColor("#cccccc")); carbrand.setHintTextColor(Color.parseColor("#cccccc")); color.setHintTextColor(Color.parseColor("#cccccc")); model.setHintTextColor(Color.parseColor("#cccccc")); licensenum.setInputType(InputType.TYPE_NULL); carbrand.setInputType(InputType.TYPE_NULL); color.setInputType(InputType.TYPE_NULL); model.setInputType(InputType.TYPE_NULL); } else { bpassenager = false; bdriver = true; licensenum.setEnabled(true); carbrand.setEnabled(true); color.setEnabled(true); model.setEnabled(true); licensenum.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); carbrand.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); color.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); model.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); content.setText(getString(R.string.warningInfo_seatOffer)); licensenum.setHintTextColor(Color.parseColor("#9F35FF")); carbrand.setHintTextColor(Color.parseColor("#9F35FF")); color.setHintTextColor(Color.parseColor("#9F35FF")); model.setHintTextColor(Color.parseColor("#9F35FF")); // licensenum.setText(""); // carbrand.setText(""); // color.setText(""); // model.setText(""); licensenum.setInputType(InputType.TYPE_CLASS_TEXT); carbrand.setInputType(InputType.TYPE_CLASS_TEXT); color.setInputType(InputType.TYPE_CLASS_TEXT); model.setInputType(InputType.TYPE_CLASS_TEXT); // start! selectcarinfo(UserPhoneNumber); // end! } confirm(); } }); sure.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub if (shortway_group.getCheckedRadioButtonId() == mRadio1.getId()) userrole = "d"; else userrole = "p"; // start! shortway_request(UserPhoneNumber, datebutton.getText().toString(), earlystarttime.getText().toString(), latestarttime.getText().toString()); // end! } private void shortway_request(final String shortway_phonenum, final String shortway_date, final String shortway_starttime, final String shortway_endtime) { // TODO Auto-generated method stub // start try { test_date = primary_date.parse(shortway_date); standard_shortway_startdate = standard_date.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_starttime); standard_shortway_starttime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_endtime); standard_shortway_endtime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // end! String shortway_baseurl = getString(R.string.uri_base) + getString(R.string.uri_ShortwayRequest) + getString(R.string.uri_addrequest_action); // "http://192.168.1.111:8080/CarsharingServer/ShortwayRequest!addrequest.action?"; Log.w("URL", shortway_baseurl); StringRequest stringRequest = new StringRequest(Request.Method.POST, shortway_baseurl, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d("shortway_result", response); JSONObject json1 = null; try { json1 = new JSONObject(response); requestok = json1.getBoolean("result"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (requestok == true) { if (carinfochoosing_type == 1) { // add // start! carinfo(shortway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 1); // end! } else { // update // start! carinfo(shortway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 2); // end! } Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "true"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } else { // Toast errorinfo = // Toast.makeText(getApplicationContext(), // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("shortway_result", error.getMessage(), error); // Toast errorinfo = Toast.makeText(null, // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } }) { protected Map<String, String> getParams() { // POSTgetParams // start try { test_date = primary_date.parse(shortway_date); standard_shortway_startdate = standard_date.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_starttime); standard_shortway_starttime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_endtime); standard_shortway_endtime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // end! Map<String, String> params = new HashMap<String, String>(); params.put("phonenum", shortway_phonenum); params.put("userrole", userrole); params.put("startplacex", String.valueOf(startplace_longitude)); params.put("startplacey", String.valueOf(startplace_latitude)); params.put(getString(R.string.uri_startplace), startplace.getText().toString()); params.put("destinationx", String.valueOf(destination_longitude)); params.put("destinationy", String.valueOf(destination_latitude)); params.put(getString(R.string.uri_destination), endplace.getText().toString()); params.put("startdate", standard_shortway_startdate); params.put("starttime", standard_shortway_starttime); params.put("endtime", standard_shortway_endtime); return params; } }; queue.add(stringRequest); } }); startplace.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub startActivityForResult(new Intent(ShortWayActivity.this, ChooseAddressActivity.class), 1); } }); endplace.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub startActivityForResult(new Intent(ShortWayActivity.this, ChooseArrivalActivity.class), 2); } }); increase.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum++; s2.setText("" + sum); confirm(); } }); decrease.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum--; if (sum < 0) { sum = 0; } s2.setText("" + sum); confirm(); } }); datebutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(DATE_DIALOG); } }); earlystarttime.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(TIME_DIALOG); } }); latestarttime.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(TIME_DIALOG1); } }); }
From source file:org.apache.cordova.plugins.InAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject/*from ww w . j a v a 2s. c o m*/ */ public String showWebPage(final String url, HashMap<String, Boolean> features) { // Determine if we should hide the location bar. showLocationBar = true; openWindowHidden = false; if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { showLocationBar = show.booleanValue(); } Boolean hidden = features.get(HIDDEN); if (hidden != null) { openWindowHidden = hidden.booleanValue(); } } final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button Button back = new Button(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); back.setText("<"); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button Button forward = new Button(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); forward.setText(">"); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button Button close = new Button(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); close.setText(buttonLabel); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); WebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); WebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout /*cemerson*/ if (arrowButtonsAllowed) { actionButtonContainer.addView(back); actionButtonContainer.addView(forward); } // ================================================ // CHANGING per: // http://stackoverflow.com/a/16596554/826308 // *** ORIG CODE *** // // Add the views to our toolbar // toolbar.addView(actionButtonContainer); // toolbar.addView(edittext); // toolbar.addView(close); // // Don't add the toolbar if its been disabled // if (getShowLocationBar()) { // // Add our toolbar to our main view/layout // main.addView(toolbar); // } // *** CHANGED CODE *** // Add the views to our toolbar toolbar.addView(actionButtonContainer); if (getShowLocationBar()) { toolbar.addView(edittext); } toolbar.addView(close); // Add our toolbar to our main view/layout main.addView(toolbar); // ================================================ // Add our webview to our main view/layout main.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (openWindowHidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:org.apache.cordova.InAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject/*from w ww . jav a 2s . co m*/ */ public String showWebPage(final String url, HashMap<String, Boolean> features) { // Determine if we should hide the location bar. showLocationBar = true; openWindowHidden = false; if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { showLocationBar = show.booleanValue(); } Boolean hidden = features.get(HIDDEN); if (hidden != null) { openWindowHidden = hidden.booleanValue(); } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); } else { cache = features.get(CLEAR_SESSION_CACHE); if (cache != null) { clearSessionCache = cache.booleanValue(); } } } final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { closeDialog(); } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); //Please, no more black! toolbar.setBackgroundColor(android.graphics.Color.LTGRAY); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button Button back = new Button(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); back.setText("<"); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button Button forward = new Button(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); forward.setText(">"); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button Button close = new Button(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); close.setText(buttonLabel); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); WebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); WebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); if (clearAllCache) { CookieManager.getInstance().removeAllCookie(); } else if (clearSessionCache) { CookieManager.getInstance().removeSessionCookie(); } inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (openWindowHidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:com.example.cuisoap.agrimac.homePage.machineDetail.machineInfoFragment.java
private void lock() { machine_name.setInputType(InputType.TYPE_NULL); passenger_num.setInputType(InputType.TYPE_NULL); power.setInputType(InputType.TYPE_NULL); wheel_distance.setInputType(InputType.TYPE_NULL); check_time.setInputType(InputType.TYPE_NULL); machine_name.setFocusableInTouchMode(false); passenger_num.setFocusableInTouchMode(false); power.setFocusableInTouchMode(false); wheel_distance.setFocusableInTouchMode(false); check_time.setFocusableInTouchMode(false); license_pic1.setOnClickListener(null); license_pic1.setOnClickListener(null); if (pay_type.getCheckedRadioButtonId() == R.id.machine_paytype1) pay_type2.setEnabled(false);/*from w ww . ja v a2 s. co m*/ else pay_type1.setEnabled(false); if (power_type.getCheckedRadioButtonId() == R.id.machine_powertype1) { power_type2.setEnabled(false); power_type3.setEnabled(false); power_type4.setEnabled(false); } else if (power_type.getCheckedRadioButtonId() == R.id.machine_powertype2) { power_type1.setEnabled(false); power_type3.setEnabled(false); power_type4.setEnabled(false); } else if (power_type.getCheckedRadioButtonId() == R.id.machine_powertype3) { power_type1.setEnabled(false); power_type2.setEnabled(false); power_type4.setEnabled(false); } else if (power_type.getCheckedRadioButtonId() == R.id.machine_powertype4) { power_type1.setEnabled(false); power_type2.setEnabled(false); power_type3.setEnabled(false); } license1.setEnabled(false); license_pic1.setEnabled(false); license2.setEnabled(false); license_pic2.setEnabled(false); machine_type.setEnabled(false); }
From source file:com.oonhee.oojs.inappbrowser.InAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject//w w w .j av a 2 s. c o m */ public String showWebPage(final String url, HashMap<String, Boolean> features) { // Determine if we should hide the location bar. showLocationBar = true; openWindowHidden = false; if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { showLocationBar = show.booleanValue(); } Boolean hidden = features.get(HIDDEN); if (hidden != null) { openWindowHidden = hidden.booleanValue(); } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); } else { cache = features.get(CLEAR_SESSION_CACHE); if (cache != null) { clearSessionCache = cache.booleanValue(); } } } final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { closeDialog(); } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); //Please, no more black! toolbar.setBackgroundColor(android.graphics.Color.LTGRAY); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button Button back = new Button(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); back.setText("<"); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button Button forward = new Button(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); forward.setText(">"); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button Button close = new Button(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); close.setText(buttonLabel); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView inAppWebView = new AmazonWebView(cordova.getActivity()); CordovaActivity app = (CordovaActivity) cordova.getActivity(); cordova.getFactory().initializeWebView(inAppWebView, 0x00FF00, false, null); inAppWebView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); AmazonWebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); AmazonWebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginState(com.amazon.android.webkit.AmazonWebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); if (clearAllCache) { AmazonCookieManager.getInstance().removeAllCookie(); } else if (clearSessionCache) { AmazonCookieManager.getInstance().removeSessionCookie(); } inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (openWindowHidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }