List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.httrack.android.HTTrackActivity.java
/** * We just entered in a new pane./* w ww. j a va 2 s . c om*/ */ protected void onEnterNewPane() { switch (layouts[pane_id]) { case R.layout.activity_startup: final TextView text = TextView.class.cast(this.findViewById(R.id.fieldDisplay)); final TextView textDebug = TextView.class.cast(this.findViewById(R.id.fieldDebug)); // Welcome message. final String html = getString(R.string.welcome_message).replace("\n-", "\n").replace("\n", "<br />") .replace("HTTrack Website Copier", "<b>HTTrack Website Copier</b>"); text.setText(Html.fromHtml(html)); // Debugging and information. final StringBuilder str = new StringBuilder(); str.append("<i>"); if (version != null) { str.append("<br />Version: "); // Library version str.append(version); str.append(versionFeatures); // Android version str.append(" (Android version "); str.append(versionCode); str.append(")"); } // str.append(" Path: "); // str.append(getProjectRootFile().getAbsolutePath()); str.append(" IPv6: "); final InetAddress addrV6 = getIPv6Address(); str.append(addrV6 != null ? ("YES (" + addrV6.getHostAddress() + ")") : "NO"); str.append("</i>"); textDebug.setText(Html.fromHtml(str.toString())); // Enable or disable browse & cleanup button depending on existing // project(s) View.class.cast(this.findViewById(R.id.buttonClear)).setEnabled(hasProjectNames()); View.class.cast(this.findViewById(R.id.buttonBrowseAll)).setEnabled(hasProjectRootIndexFile()); break; case R.layout.activity_proj_name: // Refresh suggest refreshprojectNameSuggests(); /* Base path */ TextView.class.cast(findViewById(R.id.fieldBasePath)).setText(getProjectRootFile().getAbsolutePath()); // "Next" button is disabled if no project name is defined switchEmptyProjectName = !OptionsMapper.isStringNonEmpty(mapper.getProjectName()); View.class.cast(findViewById(R.id.buttonNext)).setEnabled(!switchEmptyProjectName); /* * Prior to Honeycomb (TODO FIXME: check that), the android browser is * unable to browse local file:// pages embedding spaces (%20 or +) * Therefore, warn the user. */ warnPreHoneycombSpaceIssue = android.os.Build.VERSION.SDK_INT < VERSION_CODES.HONEYCOMB; /* Add text watcher for the "Next" button. */ final AutoCompleteTextView name = AutoCompleteTextView.class .cast(this.findViewById(R.id.fieldProjectName)); name.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { // Warn when seeing space if (warnPreHoneycombSpaceIssue) { for (int i = start; i < start + count; i++) { if (s.charAt(i) == ' ') { showNotification(getString(R.string.warning_space_in_filename), true); warnPreHoneycombSpaceIssue = false; break; } } } } @Override public void afterTextChanged(final Editable s) { // Enable/disable next button boolean empty = true; for (int i = 0; i < s.length(); i++) { if (Character.isLetterOrDigit(s.charAt(i))) { empty = false; break; } } if (empty != switchEmptyProjectName) { switchEmptyProjectName = empty; View.class.cast(findViewById(R.id.buttonNext)).setEnabled(!empty); } // (re) Set category final String category = getProjectCategory(s.toString()); TextView.class.cast(findViewById(R.id.fieldProjectCategory)) .setText(category != null ? category : ""); } // NOOP @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } }); break; case R.layout.activity_proj_setup: // Existing cache ? final boolean hasProfile = hasCacheFile(); View.class.cast(this.findViewById(R.id.radioAction)).setEnabled(hasProfile); View.class.cast(this.findViewById(R.id.radioAction)) .setVisibility(hasProfile ? View.VISIBLE : View.GONE); if (hasProfile) { // Update is the default unless something was broken RadioGroup.class.cast(this.findViewById(R.id.radioAction)) .check(isInterruptedProfile() ? R.id.radioItemContinue : R.id.radioItemUpdate); } else { // Reset RadioGroup.class.cast(this.findViewById(R.id.radioAction)).check(-1); } break; case R.layout.activity_mirror_progress: setProgressLinesInternal(new String[] { getString(R.string.starting_worker_thread) }); startRunner(); if (runner != null) { ProgressBar.class.cast(findViewById(R.id.progressMirror)).setVisibility(View.VISIBLE); } break; case R.layout.activity_mirror_finished: // Ensure the engine has stopped running if (runner != null) { runner.stopMirror(true); } // Enable browse button if index.html exists final boolean hasIndex = hasTargetIndexFile(); View.class.cast(this.findViewById(R.id.buttonBrowse)).setEnabled(hasIndex); if (!hasIndex) { final File index = getTargetIndexFile(); Log.d(getClass().getSimpleName(), "no index found (" + (index != null ? index.getAbsolutePath() : "unknown location") + ")"); final String template = getString(R.string.no_index_html_in_xx); if (template == null) { throw new RuntimeException("R.string.no_index_html_in_xx is null"); } final File target = getTargetFile(); if (target != null) { final String warning = template.replace("%s", target.getPath()); showNotification(warning); } } // Enable logs if present final boolean hasLog = hasTargetLogFile(); View.class.cast(this.findViewById(R.id.buttonLogs)).setEnabled(hasLog); if (!hasLog) { final File log = getTargetLogFile(); Log.d(getClass().getSimpleName(), "no log found (" + (log != null ? log.getAbsolutePath() : "unknown location") + ")"); } // Final stats if (runner != null) { final HTTrackStats lastStats = runner.getLastStats(); if (lastStats != null && lastStats.errorsCount != 0) { // TODO } } break; } }
From source file:org.csp.everyaware.offline.Map.java
private void insertAnnDialog(final ExtendedLatLng annLatLng) { final Dialog insertDialog = new Dialog(Map.this); insertDialog.setContentView(R.layout.insert_dialog); insertDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); insertDialog.setTitle(R.string.annotation_insertion); insertDialog.setCancelable(false);/*from w w w. ja va2s .co m*/ //get reference to send button final Button sendButton = (Button) insertDialog.findViewById(R.id.send_button); sendButton.setEnabled(false); //active only if there's text //get reference to cancel/close window button final Button cancelButton = (Button) insertDialog.findViewById(R.id.cancel_button); cancelButton.setEnabled(true); //active all time cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { insertDialog.dismiss(); } }); //get reference to edittext in which user writes annotation final EditText editText = (EditText) insertDialog.findViewById(R.id.annotation_editText); editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //if modified text length is more than 0, activate send button if (s.length() > 0) sendButton.setEnabled(true); else sendButton.setEnabled(false); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); //get checkbox references CheckBox facebookChBox = (CheckBox) insertDialog.findViewById(R.id.facebook_checkBox); CheckBox twitterChBox = (CheckBox) insertDialog.findViewById(R.id.twitter_checkBox); //activate check boxes depends from log in facebook/twitter boolean[] logs = new boolean[2]; logs[0] = Utils.getValidFbSession(getApplicationContext()); logs[1] = Utils.getValidTwSession(getApplicationContext()); facebookChBox.setEnabled(logs[0]); twitterChBox.setEnabled(logs[1]); //checked on check boxes final boolean[] checkeds = Utils.getShareCheckedOn(getApplicationContext()); if (checkeds[0] == true) facebookChBox.setChecked(true); else facebookChBox.setChecked(false); if (checkeds[1] == true) twitterChBox.setChecked(true); else twitterChBox.setChecked(false); facebookChBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean checked) { Utils.setShareCheckedOn(checked, checkeds[1], getApplicationContext()); checkeds[0] = checked; } }); twitterChBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean checked) { Utils.setShareCheckedOn(checkeds[0], checked, getApplicationContext()); checkeds[1] = checked; } }); //send annotation to server and on facebook/twitter if user is logged on sendButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //1 - read inserted annotation String annotation = editText.getText().toString(); //2 - update record on db with annotation and save recordId double recordId = annLatLng.mRecordId; int result = mDbManager.updateRecordAnnotation(recordId, annotation); if (result == 1) Toast.makeText(getApplicationContext(), "Updated record", Toast.LENGTH_LONG).show(); else Toast.makeText(getApplicationContext(), "Error!", Toast.LENGTH_LONG).show(); boolean[] checks = Utils.getShareCheckedOn(getApplicationContext()); //3 - share on facebook is user wants and internet is active now if (checks[0] == true) { Record annotatedRecord = mDbManager.loadRecordById(recordId); try { FacebookManager fb = FacebookManager.getInstance(null, null); if (fb != null) fb.postMessageOnWall(annotatedRecord); } catch (Exception e) { e.printStackTrace(); } } //4 - share on twitter is user wants and internet is active now if (checks[1] == true) { Record annotatedRecord = mDbManager.loadRecordById(recordId); try { TwitterManager twManager = TwitterManager.getInstance(null); twManager.postMessage(annotatedRecord); } catch (Exception e) { e.printStackTrace(); } } //5 - show marker for annotated record Record annotatedRecord = mDbManager.loadRecordById(recordId); String userAnn = annotatedRecord.mUserData1; if (!userAnn.equals("") && (annotatedRecord.mValues[0] != 0)) { BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.annotation_marker); Marker marker = mGoogleMap.addMarker(new MarkerOptions() .position(new LatLng(annotatedRecord.mValues[0], annotatedRecord.mValues[1])) .title("BC: " + String.valueOf(annotatedRecord.mBcMobile) + " " + getResources().getString(R.string.micrograms)) .snippet("Annotation: " + userAnn).icon(icon).anchor(0f, 1f)); } insertDialog.dismiss(); } }); insertDialog.show(); }
From source file:dentex.youtube.downloader.DashboardActivity.java
public void spawnSearchBar() { Utils.logger("d", "showing searchbar...", DEBUG_TAG); EditText inputSearch = new EditText(DashboardActivity.this); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); inputSearch.setLayoutParams(layoutParams); if (TextUtils.isEmpty(searchText)) { inputSearch.setHint(R.string.menu_search); } else {//from w w w . j a v a 2 s . co m inputSearch.setText(searchText); } inputSearch.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); inputSearch.setSingleLine(); inputSearch.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); inputSearch.setId(999); LinearLayout layout = (LinearLayout) findViewById(R.id.dashboard); layout.addView(inputSearch, 0); isSearchBarVisible = true; inputSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { Utils.logger("d", "Text [" + s + "] - Start [" + start + "] - Before [" + before + "] - Count [" + count + "]", DEBUG_TAG); if (count < before) da.resetData(); da.getFilter().filter(s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); }
From source file:com.mantz_it.rfanalyzer.MainActivity.java
public void showRecordingDialog() { if (!running || scheduler == null || demodulator == null || source == null) { Toast.makeText(MainActivity.this, "Analyzer must be running to start recording", Toast.LENGTH_LONG) .show();//from w ww . j a v a2s . c o m return; } // Check for the WRITE_EXTERNAL_STORAGE permission: if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { "android.permission.WRITE_EXTERNAL_STORAGE" }, PERMISSION_REQUEST_RECORDING_WRITE_FILES); return; // wait for the permission response (handled in onRequestPermissionResult()) } final String externalDir = Environment.getExternalStorageDirectory().getAbsolutePath(); final int[] supportedSampleRates = source.getSupportedSampleRates(); final double maxFreqMHz = source.getMaxFrequency() / 1000000f; // max frequency of the source in MHz final int sourceType = Integer.valueOf(preferences.getString(getString(R.string.pref_sourceType), "1")); final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US); // Get references to the GUI components: final ScrollView view = (ScrollView) this.getLayoutInflater().inflate(R.layout.start_recording, null); final EditText et_filename = (EditText) view.findViewById(R.id.et_recording_filename); final EditText et_frequency = (EditText) view.findViewById(R.id.et_recording_frequency); final Spinner sp_sampleRate = (Spinner) view.findViewById(R.id.sp_recording_sampleRate); final TextView tv_fixedSampleRateHint = (TextView) view.findViewById(R.id.tv_recording_fixedSampleRateHint); final CheckBox cb_stopAfter = (CheckBox) view.findViewById(R.id.cb_recording_stopAfter); final EditText et_stopAfter = (EditText) view.findViewById(R.id.et_recording_stopAfter); final Spinner sp_stopAfter = (Spinner) view.findViewById(R.id.sp_recording_stopAfter); // Setup the sample rate spinner: final ArrayAdapter<Integer> sampleRateAdapter = new ArrayAdapter<Integer>(this, android.R.layout.simple_list_item_1); for (int sampR : supportedSampleRates) sampleRateAdapter.add(sampR); sampleRateAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sp_sampleRate.setAdapter(sampleRateAdapter); // Add listener to the frequency textfield, the sample rate spinner and the checkbox: et_frequency.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (et_frequency.getText().length() == 0) return; double freq = Double.valueOf(et_frequency.getText().toString()); if (freq < maxFreqMHz) freq = freq * 1000000; et_filename.setText(simpleDateFormat.format(new Date()) + "_" + SOURCE_NAMES[sourceType] + "_" + (long) freq + "Hz_" + sp_sampleRate.getSelectedItem() + "Sps.iq"); } }); sp_sampleRate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (et_frequency.getText().length() == 0) return; double freq = Double.valueOf(et_frequency.getText().toString()); if (freq < maxFreqMHz) freq = freq * 1000000; et_filename.setText(simpleDateFormat.format(new Date()) + "_" + SOURCE_NAMES[sourceType] + "_" + (long) freq + "Hz_" + sp_sampleRate.getSelectedItem() + "Sps.iq"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); cb_stopAfter.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { et_stopAfter.setEnabled(isChecked); sp_stopAfter.setEnabled(isChecked); } }); // Set default frequency, sample rate and stop after values: et_frequency.setText("" + analyzerSurface.getVirtualFrequency()); int sampleRateIndex = 0; int lastSampleRate = preferences.getInt(getString(R.string.pref_recordingSampleRate), 1000000); for (; sampleRateIndex < supportedSampleRates.length; sampleRateIndex++) { if (supportedSampleRates[sampleRateIndex] >= lastSampleRate) break; } if (sampleRateIndex >= supportedSampleRates.length) sampleRateIndex = supportedSampleRates.length - 1; sp_sampleRate.setSelection(sampleRateIndex); cb_stopAfter.toggle(); // just to trigger the listener at least once! cb_stopAfter.setChecked(preferences.getBoolean(getString(R.string.pref_recordingStopAfterEnabled), false)); et_stopAfter.setText("" + preferences.getInt(getString(R.string.pref_recordingStopAfterValue), 10)); sp_stopAfter.setSelection(preferences.getInt(getString(R.string.pref_recordingStopAfterUnit), 0)); // disable sample rate selection if demodulation is running: if (demodulationMode != Demodulator.DEMODULATION_OFF) { sampleRateAdapter.add(source.getSampleRate()); // add the current sample rate in case it's not already in the list sp_sampleRate.setSelection(sampleRateAdapter.getPosition(source.getSampleRate())); // select it sp_sampleRate.setEnabled(false); // disable the spinner tv_fixedSampleRateHint.setVisibility(View.VISIBLE); } // Show dialog: new AlertDialog.Builder(this).setTitle("Start recording").setView(view) .setPositiveButton("Record", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String filename = et_filename.getText().toString(); final int stopAfterUnit = sp_stopAfter.getSelectedItemPosition(); final int stopAfterValue = Integer.valueOf(et_stopAfter.getText().toString()); //todo check filename // Set the frequency in the source: if (et_frequency.getText().length() == 0) return; double freq = Double.valueOf(et_frequency.getText().toString()); if (freq < maxFreqMHz) freq = freq * 1000000; if (freq <= source.getMaxFrequency() && freq >= source.getMinFrequency()) source.setFrequency((long) freq); else { Toast.makeText(MainActivity.this, "Frequency is invalid!", Toast.LENGTH_LONG).show(); return; } // Set the sample rate (only if demodulator is off): if (demodulationMode == Demodulator.DEMODULATION_OFF) source.setSampleRate((Integer) sp_sampleRate.getSelectedItem()); // Open file and start recording: recordingFile = new File(externalDir + "/" + RECORDING_DIR + "/" + filename); recordingFile.getParentFile().mkdir(); // Create directory if it does not yet exist try { scheduler.startRecording(new BufferedOutputStream(new FileOutputStream(recordingFile))); } catch (FileNotFoundException e) { Log.e(LOGTAG, "showRecordingDialog: File not found: " + recordingFile.getAbsolutePath()); } // safe preferences: SharedPreferences.Editor edit = preferences.edit(); edit.putInt(getString(R.string.pref_recordingSampleRate), (Integer) sp_sampleRate.getSelectedItem()); edit.putBoolean(getString(R.string.pref_recordingStopAfterEnabled), cb_stopAfter.isChecked()); edit.putInt(getString(R.string.pref_recordingStopAfterValue), stopAfterValue); edit.putInt(getString(R.string.pref_recordingStopAfterUnit), stopAfterUnit); edit.apply(); analyzerSurface.setRecordingEnabled(true); updateActionBar(); // if stopAfter was selected, start thread to supervise the recording: if (cb_stopAfter.isChecked()) { Thread supervisorThread = new Thread() { @Override public void run() { Log.i(LOGTAG, "recording_superviser: Supervisor Thread started. (Thread: " + this.getName() + ")"); try { long startTime = System.currentTimeMillis(); boolean stop = false; // We check once per half a second if the stop criteria is met: Thread.sleep(500); while (recordingFile != null && !stop) { switch (stopAfterUnit) { // see arrays.xml - recording_stopAfterUnit case 0: /* MB */ if (recordingFile.length() / 1000000 >= stopAfterValue) stop = true; break; case 1: /* GB */ if (recordingFile.length() / 1000000000 >= stopAfterValue) stop = true; break; case 2: /* sec */ if (System.currentTimeMillis() - startTime >= stopAfterValue * 1000) stop = true; break; case 3: /* min */ if (System.currentTimeMillis() - startTime >= stopAfterValue * 1000 * 60) stop = true; break; } } // stop recording: stopRecording(); } catch (InterruptedException e) { Log.e(LOGTAG, "recording_superviser: Interrupted!"); } catch (NullPointerException e) { Log.e(LOGTAG, "recording_superviser: Recording file is null!"); } Log.i(LOGTAG, "recording_superviser: Supervisor Thread stopped. (Thread: " + this.getName() + ")"); } }; supervisorThread.start(); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }).show().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); }
From source file:self.philbrown.droidQuery.$.java
/** * Registers change listeners for TextViews, EditTexts, and CompoundButtons. For all other * view types, this will trigger a function when the view's layout has been changed. * @param function the Function to call when the change event occurs. This will receive a * droidQuery instance for the changed view * @return this/*from w ww . j ava 2 s . co m*/ */ public $ change(final Function function) { for (int i = 0; i < this.views.size(); i++) { View view = this.views.get(i); final int index = i; if (view instanceof TextView) { ((TextView) view).addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { function.invoke($.with($.this.views.get(index))); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); } else if (view instanceof EditText) {//this is overkill, but what the hey ((EditText) view).addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { function.invoke($.with($.this.views.get(index))); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); } else if (view instanceof CompoundButton) { ((CompoundButton) view).setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { function.invoke($.with($.this.views.get(index))); } }); } else if (android.os.Build.VERSION.SDK_INT >= 11) { //default to size for API 11+ try { Class<?> eventInterface = Class.forName("android.view.View.OnLayoutChangeListener"); Method addOnLayoutChangeListener = view.getClass().getMethod("addOnLayoutChangeListener", new Class<?>[] { eventInterface }); InvocationHandler proxy = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { function.invoke($.with($.this.views.get(index))); return null; } }; Object eventHandler = Proxy.newProxyInstance(eventInterface.getClassLoader(), new Class<?>[] { eventInterface }, proxy); addOnLayoutChangeListener.invoke(view, eventInterface.cast(eventHandler)); } catch (Throwable t) { //unknown error } } } return this; }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void setupWidgets() { this.mStatus = (ImageView) findViewById(R.id.statusVal); this.mStatus.setImageResource(R.drawable.btn_radio_off); this.mStatusText = (TextView) findViewById(R.id.statusStr); this.mDNS = (EditText) findViewById(R.id.dnsval); this.mDNS.setFocusableInTouchMode(true); this.mDNS.setFocusable(true); this.mDNS.setText(LimboSettingsManager.getDNSServer(activity)); this.mAppend = (EditText) findViewById(R.id.appendval); this.mAppend.setFocusableInTouchMode(true); this.mAppend.setFocusable(true); this.mAppend.setEnabled(false); this.mAppend.setText(LimboSettingsManager.getAppend(activity)); this.mMachine = (Spinner) findViewById(R.id.machineval); this.mCPU = (Spinner) findViewById(R.id.cpuval); this.mMachineType = (Spinner) findViewById(R.id.machinetypeval); this.mMachineType.setEnabled(false); this.mCPUNum = (Spinner) findViewById(R.id.cpunumval); this.mUI = (Spinner) findViewById(R.id.uival); if (!Const.enable_SDL) this.mUI.setEnabled(false); this.mRamSize = (Spinner) findViewById(R.id.rammemval); this.mKernel = (Spinner) findViewById(R.id.kernelval); this.mKernel.setEnabled(false); this.mInitrd = (Spinner) findViewById(R.id.initrdval); this.mInitrd.setEnabled(false); this.mHDA = (Spinner) findViewById(R.id.hdimgval); this.mHDB = (Spinner) findViewById(R.id.hdbimgval); this.mCD = (Spinner) findViewById(R.id.cdromimgval); this.mFDA = (Spinner) findViewById(R.id.floppyimgval); this.mFDB = (Spinner) findViewById(R.id.floppybimgval); this.mBootDevices = (Spinner) findViewById(R.id.bootfromval); this.mNetConfig = (Spinner) findViewById(R.id.netcfgval); this.mNetDevices = (Spinner) findViewById(R.id.netDevicesVal); this.mVGAConfig = (Spinner) findViewById(R.id.vgacfgval); this.mSoundCardConfig = (Spinner) findViewById(R.id.soundcfgval); this.mHDCacheConfig = (Spinner) findViewById(R.id.hdcachecfgval); this.mHDCacheConfig.setEnabled(false); // Disabled for now this.mACPI = (CheckBox) findViewById(R.id.acpival); this.mHPET = (CheckBox) findViewById(R.id.hpetval); this.mVNCAllowExternal = (CheckBox) findViewById(R.id.vncexternalval); // No // external/* w w w . j a v a2 s . c om*/ // connections // mVNCAllowExternal.setChecked(LimboSettingsManager.getVNCAllowExternal(activity)); mVNCAllowExternal.setChecked(false); this.mPrio = (CheckBox) findViewById(R.id.prioval); // mPrio.setChecked(LimboSettingsManager.getPrio(activity)); this.mReverseLandscape = (CheckBox) findViewById(R.id.reverselval); // mReverseLandscape.setChecked(LimboSettingsManager.getOrientationReverse(activity)); this.mMultiAIO = (CheckBox) findViewById(R.id.enableMultiThreadval); // No // external // connections mMultiAIO.setChecked(LimboSettingsManager.getMultiAIO(activity)); this.mSnapshot = (Spinner) findViewById(R.id.snapshotval); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mStart = (Button) findViewById(R.id.startvm); mStart.setFocusableInTouchMode(true); mStart.setOnClickListener(new OnClickListener() { public void onClick(View view) { onStartButton(); } }); mStop = (Button) findViewById(R.id.stopvm); mStop.setOnClickListener(new OnClickListener() { public void onClick(View view) { Log.v(TAG, "Stopping VM..."); onStopButton(false); } }); mRestart = (Button) findViewById(R.id.restartvm); mRestart.setOnClickListener(new OnClickListener() { public void onClick(View view) { Log.v(TAG, "Restarting VM..."); onRestartButton(); } }); // mSave = (Button) findViewById(R.id.savevm); // mSave.setOnClickListener(new OnClickListener() { // public void onClick(View view) { // Log.v(TAG, "Restarting VM..."); // onSaveButton(); // // } // }); // mResume = (Button) findViewById(R.id.resumevm); // mResume.setOnClickListener(new OnClickListener() { // // public void onClick(View view) { // Log.v(TAG, "Resuming VM..."); // onResumeButton(); // // } // }); mMachine.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { // your code here // Log.v(TAG, "Position " + position); if (position == 0) { } else if (position == 1) { promptMachineName(activity); // Log.v(TAG, "Promtp for Machine createion"); } else { String machine = (String) ((ArrayAdapter) mMachine.getAdapter()).getItem(position); // Log.v(TAG, "Machine selected: " + machine); loadMachine(machine, ""); populateSnapshot(); } } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mCPU.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { // your code here String cpu = (String) ((ArrayAdapter) mCPU.getAdapter()).getItem(position); Log.v(TAG, "Position " + position + " CPU = " + cpu + " userPressed = " + userPressedCPU); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedCPU) { currMachine.cpu = cpu; int ret = machineDB.update(currMachine, MachineOpenHelper.CPU, cpu); if (currMachine.cpu.endsWith("(arm)")) { mKernel.setEnabled(true); mInitrd.setEnabled(true); mAppend.setEnabled(true); mMachineType.setEnabled(true); } else { mKernel.setEnabled(false); mInitrd.setEnabled(false); mAppend.setEnabled(false); mMachineType.setEnabled(false); } } userPressedCPU = true; Log.v("setOnItemSelectedListener", "set userPressed = " + userPressedCPU); // Log.v("CPU List", "reset userPressed = " + userPressedCPU); } public void onNothingSelected(AdapterView<?> parentView) { // your code here userPressedCPU = true; Log.v("setOnItemSelectedListener2", "set userPressed = " + userPressedCPU); // Log.v("CPU none", "reset userPressed = " + userPressedCPU); } }); mMachineType.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { // your code here String machineType = (String) ((ArrayAdapter) mMachineType.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " CPU = " + cpu // + " userPressed = " + userPressedCPU); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedMachineType) { currMachine.machine_type = machineType; int ret = machineDB.update(currMachine, MachineOpenHelper.MACHINE_TYPE, machineType); } userPressedMachineType = true; // Log.v("CPU List", "reset userPressed = " + userPressedCPU); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); userPressedMachineType = true; // Log.v("CPU none", "reset userPressed = " + userPressedCPU); } }); mUI.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { // your code here String ui = (String) ((ArrayAdapter) mUI.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " CPU = " + cpu // + " userPressed = " + userPressedCPU); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedUI) { // save UI fav LimboSettingsManager.setUI(activity, ui); } if (position == 0) { mVNCAllowExternal.setEnabled(true); if (mSnapshot.getSelectedItemPosition() == 0) mSoundCardConfig.setEnabled(false); } else { mVNCAllowExternal.setEnabled(false); if (mSnapshot.getSelectedItemPosition() == 0) mSoundCardConfig.setEnabled(true); } userPressedUI = true; // Log.v("CPU List", "reset userPressed = " + userPressedCPU); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); userPressedUI = true; // Log.v("CPU none", "reset userPressed = " + userPressedCPU); } }); mCPUNum.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String cpuNum = (String) ((ArrayAdapter) mCPUNum.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " RAM = " + ram // + " userPressed = " + userPressedRAM); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedCPUNum) { currMachine.cpuNum = Integer.parseInt(cpuNum); int ret = machineDB.update(currMachine, MachineOpenHelper.CPUNUM, cpuNum); } userPressedCPUNum = true; // Log.v("Ram list", "reset userPressed = " + userPressedRAM); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); userPressedCPUNum = true; // Log.v("Ram none", "reset userPressed = " + userPressedRAM); } }); mRamSize.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String ram = (String) ((ArrayAdapter) mRamSize.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " RAM = " + ram // + " userPressed = " + userPressedRAM); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedRAM) { currMachine.memory = Integer.parseInt(ram); int ret = machineDB.update(currMachine, MachineOpenHelper.MEMORY, ram); } userPressedRAM = true; // Log.v("Ram list", "reset userPressed = " + userPressedRAM); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); userPressedRAM = true; // Log.v("Ram none", "reset userPressed = " + userPressedRAM); } }); mKernel.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String kernel = (String) ((ArrayAdapter) mKernel.getAdapter()).getItem(position); if (userPressedKernel && position == 0) { int ret = machineDB.update(currMachine, MachineOpenHelper.KERNEL, null); currMachine.kernel = null; } else if (userPressedKernel && position == 1) { browse("kernel"); } else if (userPressedKernel && position > 1) { int ret = machineDB.update(currMachine, MachineOpenHelper.KERNEL, kernel); currMachine.kernel = kernel; // TODO: If Machine is running eject and set floppy img } userPressedKernel = true; } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mInitrd.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String initrd = (String) ((ArrayAdapter) mInitrd.getAdapter()).getItem(position); if (userPressedInitrd && position == 0) { int ret = machineDB.update(currMachine, MachineOpenHelper.INITRD, null); currMachine.initrd = null; } else if (userPressedInitrd && position == 1) { browse("initrd"); } else if (userPressedInitrd && position > 1) { int ret = machineDB.update(currMachine, MachineOpenHelper.INITRD, initrd); currMachine.initrd = initrd; // TODO: If Machine is running eject and set floppy img } userPressedInitrd = true; } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mHDA.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String hda = (String) ((ArrayAdapter) mHDA.getAdapter()).getItem(position); if (userPressedHDA && position == 0) { int ret = machineDB.update(currMachine, MachineOpenHelper.HDA, null); currMachine.hda_img_path = hda; } else if (userPressedHDA && position == 1) { promptImageName(activity, "hda"); Log.v(TAG, "Promtp for Image createion"); } else if (userPressedHDA && position == 2) { browse("hda"); } else if (userPressedHDA && position > 2) { int ret = machineDB.update(currMachine, MachineOpenHelper.HDA, hda); currMachine.hda_img_path = hda; } // if (userPressedHDA && currStatus.equals("RUNNING")) { // vmexecutor.change_dev("ide0-hd0", currMachine.hda_img_path); // } userPressedHDA = true; // Log.v("HDA List", "reset userPressed = " + userPressedHDA); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mHDB.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String hdb = (String) ((ArrayAdapter) mHDB.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " HDB = " + hdb // + " userPressed = " + userPressedHDB); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedHDB && position == 0) { int ret = machineDB.update(currMachine, MachineOpenHelper.HDB, null); currMachine.hdb_img_path = hdb; } else if (userPressedHDB && position == 1) { promptImageName(activity, "hdb"); // Log.v(TAG, "Promtp for Image createion"); } else if (userPressedHDB && position == 2) { browse("hdb"); } else if (userPressedHDB && position > 2) { int ret = machineDB.update(currMachine, MachineOpenHelper.HDB, hdb); currMachine.hdb_img_path = hdb; } // if (userPressedHDB && currStatus.equals("RUNNING")) { // vmexecutor.change_dev("ide0-hd1", currMachine.hdb_img_path); // } userPressedHDB = true; // Log.v("HDB List", "reset userPressed = " + userPressedHDB); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mSnapshot.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String snapshot_name = (String) ((ArrayAdapter) mSnapshot.getAdapter()).getItem(position); if (userPressedSnapshot && position == 0) { currMachine.snapshot_name = ""; userPressedSnapshot = false; loadMachine(currMachine.machinename, currMachine.snapshot_name); mStart.setText("Start"); enableNonRemovableDeviceOptions(true); mSnapshot.setEnabled(true); } else if (userPressedSnapshot && position > 0) { currMachine.snapshot_name = snapshot_name; userPressedSnapshot = false; loadMachine(currMachine.machinename, currMachine.snapshot_name); mStart.setText("Resume"); enableOptions(false); mSnapshot.setEnabled(true); } else { userPressedSnapshot = true; } // Log.v("Snapshot List", "reset userPressed = " + // userPressedSnapshot); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mCD.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String cd = (String) ((ArrayAdapter) mCD.getAdapter()).getItem(position); if (userPressedCDROM && position == 0) { int ret = machineDB.update(currMachine, MachineOpenHelper.CDROM, null); currMachine.cd_iso_path = null; } else if (userPressedCDROM && position == 1) { browse("cd"); } else if (userPressedCDROM && position > 1) { int ret = machineDB.update(currMachine, MachineOpenHelper.CDROM, cd); currMachine.cd_iso_path = cd; // TODO: If Machine is running eject and set floppy img } if (userPressedCDROM && currStatus.equals("RUNNING") && position > 1) { vmexecutor.change_dev("ide1-cd0", currMachine.cd_iso_path); } else if (userPressedCDROM && currStatus.equals("RUNNING") && position == 0) { vmexecutor.change_dev("ide1-cd0", null); // Eject } userPressedCDROM = true; } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mFDA.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String fda = (String) ((ArrayAdapter) mFDA.getAdapter()).getItem(position); if (userPressedFDA && position == 0) { int ret = machineDB.update(currMachine, MachineOpenHelper.FDA, null); currMachine.fda_img_path = null; } else if (userPressedFDA && position == 1) { browse("fda"); } else if (userPressedFDA && position > 1) { int ret = machineDB.update(currMachine, MachineOpenHelper.FDA, fda); currMachine.fda_img_path = fda; // TODO: If Machine is running eject and set floppy img } if (userPressedFDA && currStatus.equals("RUNNING") && position > 1) { vmexecutor.change_dev("floppy0", currMachine.fda_img_path); } else if (userPressedFDA && currStatus.equals("RUNNING") && position == 0) { vmexecutor.change_dev("floppy0", null); // Eject } userPressedFDA = true; } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mFDB.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String fdb = (String) ((ArrayAdapter) mFDB.getAdapter()).getItem(position); if (userPressedFDB && position == 0) { int ret = machineDB.update(currMachine, MachineOpenHelper.FDB, null); currMachine.fdb_img_path = null; } else if (userPressedFDB && position == 1) { browse("fdb"); } else if (userPressedFDB && position > 1) { int ret = machineDB.update(currMachine, MachineOpenHelper.FDB, fdb); currMachine.fdb_img_path = fdb; // TODO: If Machine is running eject and set floppy img } if (userPressedFDB && currStatus.equals("RUNNING") && position > 1) { vmexecutor.change_dev("floppy1", currMachine.fdb_img_path); } else if (userPressedFDB && currStatus.equals("RUNNING") && position == 0) { vmexecutor.change_dev("floppy1", null); // Eject } userPressedFDB = true; } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mBootDevices.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String bootDev = (String) ((ArrayAdapter) mBootDevices.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " bootDev = " + bootDev // + " userPressed = " + userPressedBootDev); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedBootDev) { int ret = machineDB.update(currMachine, MachineOpenHelper.BOOT_CONFIG, bootDev); currMachine.bootdevice = bootDev; } userPressedBootDev = true; // Log.v("BootDev List", "reset userPressed = " // + userPressedBootDev); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); this.mNetConfig.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String netfcg = (String) ((ArrayAdapter) mNetConfig.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " netfcg = " + netfcg // + " userPressed = " + userPressedNetCfg); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedNetCfg) { int ret = machineDB.update(currMachine, MachineOpenHelper.NET_CONFIG, netfcg); currMachine.net_cfg = netfcg; } if (position > 0) { mNetDevices.setEnabled(true); } else { mNetDevices.setEnabled(false); } userPressedNetCfg = true; ApplicationInfo pInfo = null; if (netfcg.equals("TAP")) { onTap(); } // Log.v("Net CFG List", "reset userPressed = " // + userPressedNetCfg); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); this.mNetDevices.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String niccfg = (String) ((ArrayAdapter) mNetDevices.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " nicfcg = " // + niccfg + " userPressed = " // + userPressedNicCfg); // LimboSettingsManager.setLastCPU(activity,cpu); if (position < 0) { Toast.makeText(getApplicationContext(), "Not a valid card, using ne2k_pci instead", Toast.LENGTH_LONG).show(); userPressedNicCfg = true; mNetDevices.setSelection(4); return; } if (userPressedNicCfg) { int ret = machineDB.update(currMachine, MachineOpenHelper.NIC_CONFIG, niccfg); currMachine.nic_driver = niccfg; } userPressedNicCfg = true; // Log.v("BootDev List", "reset userPressed = " // + userPressedNicCfg); } public void onNothingSelected(final AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mVGAConfig.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { // your code here String vgacfg = (String) ((ArrayAdapter) mVGAConfig.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " vgafcg = " + vgacfg // + " userPressed = " + userPressedVGACfg); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedVGACfg) { int ret = machineDB.update(currMachine, MachineOpenHelper.VGA, vgacfg); currMachine.vga_type = vgacfg; } userPressedVGACfg = true; // Log.v("BootDev List", "reset userPressed = " // + userPressedVGACfg); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); this.mSoundCardConfig.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String sndcfg = (String) ((ArrayAdapter) mSoundCardConfig.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " sndfcg = " // + sndcfg + " userPressed = " // + userPressedSndCfg); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedSndCfg) { int ret = machineDB.update(currMachine, MachineOpenHelper.SOUNDCARD_CONFIG, sndcfg); currMachine.soundcard = sndcfg; } userPressedSndCfg = true; // Log.v("Snd List", "reset userPressed = " // + userPressedSndCfg); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mHDCacheConfig.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String hdcfg = (String) ((ArrayAdapter) mHDCacheConfig.getAdapter()).getItem(position); // Log.v(TAG, "Position " + position + " sndfcg = " + hdcfg // + " userPressed = " + userPressedHDCfg); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedHDCfg) { int ret = machineDB.update(currMachine, MachineOpenHelper.HDCACHE_CONFIG, hdcfg); currMachine.hd_cache = hdcfg; } userPressedHDCfg = true; // Log.v("HDCache List", "reset userPressed = " + // userPressedHDCfg); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mACPI.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton viewButton, boolean isChecked) { // Log.v(TAG, "ACPI checked: " + isChecked + " userPressed = " + // userPressedACPI); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedACPI) { int ret = machineDB.update(currMachine, MachineOpenHelper.DISABLE_ACPI, ((isChecked ? 1 : 0) + "")); } userPressedACPI = true; // Log.v("ACPI ", "reset userPressed = " + userPressedACPI); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mHPET.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton viewButton, boolean isChecked) { // Log.v(TAG, "ACPI checked: " + isChecked + " userPressed = " + // userPressedHPET); // LimboSettingsManager.setLastCPU(activity,cpu); if (userPressedHPET) { int ret = machineDB.update(currMachine, MachineOpenHelper.DISABLE_HPET, ((isChecked ? 1 : 0) + "")); } userPressedHPET = true; // Log.v("ACPI ", "reset userPressed = " + userPressedHPET); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mDNS.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { LimboSettingsManager.setDNSServer(activity, mDNS.getText().toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Log.d("seachScreen", "beforeTextChanged"); } public void onTextChanged(CharSequence s, int start, int before, int count) { // Log.d("seachScreen", "onTextChanged"); } }); mAppend.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { LimboSettingsManager.setAppend(activity, mAppend.getText().toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Log.d("seachScreen", "beforeTextChanged"); } public void onTextChanged(CharSequence s, int start, int before, int count) { // Log.d("seachScreen", "onTextChanged"); } }); // mVNCAllowExternal.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton viewButton, boolean isChecked) { if (isChecked) { promptVNCAllowExternal(activity); } else { vnc_passwd = null; vnc_allow_external = 0; // LimboSettingsManager.setVNCAllowExternal(activity, // false); } } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mPrio.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton viewButton, boolean isChecked) { if (isChecked) { promptPrio(activity); } else { LimboSettingsManager.setPrio(activity, false); } } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mReverseLandscape.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton viewButton, boolean isChecked) { LimboSettingsManager.setOrientationReverse(activity, isChecked); } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); mMultiAIO.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton viewButton, boolean isChecked) { if (isChecked) { promptMultiAIO(activity); } else { LimboSettingsManager.setMultiAIO(activity, false); } } public void onNothingSelected(AdapterView<?> parentView) { // your code here // Log.v(TAG, "Nothing selected"); } }); }
From source file:cl.gisred.android.InspActivity.java
public void setActionsForm(final int idRes, String sNombre) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(idRes, null); final int topeWidth = 650; ArrayAdapter<CharSequence> adapter; DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int widthSize = displayMetrics.widthPixels; int widthScale = (widthSize * 3) / 4; if (topeWidth < widthScale) widthScale = topeWidth;//from w w w.j a v a2s. com v.setMinimumWidth(widthScale); formCrear.setTitle(sNombre); formCrear.setContentView(v); idResLayoutSelect = idRes; boolean bSpinnerMedidor = idRes == R.layout.form_inspec_telemedida; Spinner spTipoFase = (Spinner) v.findViewById(R.id.spinnerFase); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoFaseInsp); spTipoFase.setAdapter(adapter); Spinner spTipoMarca = (Spinner) v.findViewById(R.id.spinnerTipo); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, (bSpinnerMedidor) ? arrayTipoMarcaTM : arrayTipoMarca); spTipoMarca.setAdapter(adapter); Spinner spMarca = (Spinner) v.findViewById(R.id.spinnerMarca); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, (bSpinnerMedidor) ? arrayMarcaTM : arrayMarca); spMarca.setAdapter(adapter); final GisEditText txtPoste = (GisEditText) v.findViewById(R.id.txtPoste); final EditText txtRotulo = (EditText) v.findViewById(R.id.txtRotulo); txtPoste.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (i2 > 1) { if (bInspRotulo) { txtRotulo.setText(charSequence); if (!txtRotulo.hasFocus()) txtRotulo.requestFocus(); bInspRotulo = false; txtPoste.setText(String.format("%s", txtPoste.getIdObjeto())); } else bInspRotulo = true; } } @Override public void afterTextChanged(Editable editable) { } }); ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste); btnIdentPoste.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { formCrear.hide(); bMapTap = true; bCallOut = true; oLySelectAsoc = LyAddPoste; oLyExistAsoc = LyPOSTES; oLyExistAsoc.setVisible(true); myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9); setValueToAsoc(getLayoutContenedor(view)); } }); final EditText txtFecha = (EditText) v.findViewById(R.id.txtFechaEjec); txtFecha.setText(dateFormatter.format(Calendar.getInstance().getTime())); txtFecha.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { datePickerDialog.show(); } }); Calendar newCalendar = Calendar.getInstance(); datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Calendar newDate = Calendar.getInstance(); newDate.set(year, monthOfYear, dayOfMonth); txtFecha.setText(dateFormatter.format(newDate.getTime())); } }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH)); final EditText txtHoraIni = (EditText) v.findViewById(R.id.txtHoraIni); txtHoraIni.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { timePickerDialog.show(); txtHora = txtHoraIni; } }); final EditText txtHoraFin = (EditText) v.findViewById(R.id.txtHoraFin); txtHoraFin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { timePickerDialog.show(); txtHora = txtHoraFin; } }); timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { txtHora.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute)); } }, newCalendar.get(Calendar.HOUR), newCalendar.get(Calendar.MINUTE), false); final EditText txtEjecutor = (EditText) v.findViewById(R.id.txtEjecutor); txtEjecutor.setText(Util.getUserWithoutDomain(usuar)); Spinner spFirmante = (Spinner) v.findViewById(R.id.spinnerFirmante); if (spFirmante != null) { adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayFirmante); spFirmante.setAdapter(adapter); spFirmante.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { setRequerido(view, R.id.txtRutInst, i > 0); setRequerido(view, R.id.txtNomInst, i > 0); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } Spinner spTipoMarcaRet = (Spinner) v.findViewById(R.id.spinnerTipoRet); if (spTipoMarcaRet != null) { adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoMarca); spTipoMarcaRet.setAdapter(adapter); } Spinner spMarcaRet = (Spinner) v.findViewById(R.id.spinnerMarcaRet); if (spMarcaRet != null) { adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayMarca); spMarcaRet.setAdapter(adapter); } final CheckBox chkInspFallo = (CheckBox) v.findViewById(R.id.chkInspFallo); if (chkInspFallo != null) { chkInspFallo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bFallo = chkInspFallo.isChecked(); modoFallo(v, bFallo); } }); } ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar); btnClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cerrarFormCrear(false, v, 0); } }); ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar); btnOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cerrarFormCrear(true, v, idRes); } }); imgFirmaTec = (ImageView) v.findViewById(R.id.imgFirmaTec); imgFirmaInsp = (ImageView) v.findViewById(R.id.imgFirmaIns); imgPhoto1 = (ImageView) v.findViewById(R.id.imgPhoto1); imgPhoto2 = (ImageView) v.findViewById(R.id.imgPhoto2); imgPhoto3 = (ImageView) v.findViewById(R.id.imgPhoto3); final ImageButton btnFirmaTec = (ImageButton) v.findViewById(R.id.btnFirmaTec); if (btnFirmaTec != null && imgFirmaTec != null) { btnFirmaTec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgFirmaTec; DialogoFirma oDialog = new DialogoFirma(); oDialog.show(getFragmentManager(), "tagFirma"); } }); imgFirmaTec.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); } final ImageButton btnFirmaInsp = (ImageButton) v.findViewById(R.id.btnFirmaIns); if (btnFirmaInsp != null && imgFirmaInsp != null) { btnFirmaInsp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgFirmaInsp; DialogoFirma oDialog = new DialogoFirma(); oDialog.show(getFragmentManager(), "tagFirma"); } }); imgFirmaInsp.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); } imgPhoto1.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); imgPhoto2.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); imgPhoto3.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); ImageButton btnPhoto1 = (ImageButton) v.findViewById(R.id.btnPhoto1); btnPhoto1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto1; if (Build.VERSION.SDK_INT >= 22) verifCamara("foto1"); else tomarFoto("foto1"); } }); ImageButton btnPhoto2 = (ImageButton) v.findViewById(R.id.btnPhoto2); btnPhoto2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto2; if (Build.VERSION.SDK_INT >= 22) verifCamara("foto2"); else tomarFoto("foto2"); } }); ImageButton btnPhoto3 = (ImageButton) v.findViewById(R.id.btnPhoto3); btnPhoto3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto3; if (Build.VERSION.SDK_INT >= 22) verifCamara("foto3"); else tomarFoto("foto3"); } }); ImageButton btnFile1 = (ImageButton) v.findViewById(R.id.btnFile1); btnFile1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto1; if (Build.VERSION.SDK_INT >= 22) verifAccesoExterno("foto1"); else imageGallery("foto1"); } }); ImageButton btnFile2 = (ImageButton) v.findViewById(R.id.btnFile2); btnFile2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto2; if (Build.VERSION.SDK_INT >= 22) verifAccesoExterno("foto2"); else imageGallery("foto2"); } }); ImageButton btnFile3 = (ImageButton) v.findViewById(R.id.btnFile3); btnFile3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto3; if (Build.VERSION.SDK_INT >= 22) verifAccesoExterno("foto3"); else imageGallery("foto3"); } }); arrayTouchs = new ArrayList<>(); //setEnabledDialog(false); formCrear.show(); dialogCur = formCrear; }
From source file:com.aliyun.homeshell.Folder.java
protected void myonFinishInflate(Folder v) { setContent((CellLayout) findViewById(R.id.folder_content)); mContent.setGridSize(0, 0);/* ww w . j a v a2s . co m*/ mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false); mContent.setInvertIfRtl(true); mContentList.add(mContent); mFolderName = (FolderEditText) findViewById(R.id.folder_name); mFolderName.setFolder(v); mFolderName.setOnFocusChangeListener(v); /*YUNOS BEGIN*/ //##date:2014/9/25 ##author:yangshan.ys BugId:5255762 mContentAdapter = new FolderContentAdapter(); mFolderViewPager = (FolderSelectPager) findViewById(R.id.folder_view_pager); mFolderViewPager.setOffscreenPageLimit(40); mFolderViewPager.setAdapter(mContentAdapter); mFolderViewPager.setOnPageChangeListener(pageChangeListener); mFolderViewPager.setOnClickListener(v); mPageIndicator = (PageIndicatorView) findViewById(R.id.folder_page_indicator); mPageIndicator.setNeedLine(false); /*YUNOS END*/ // We find out how tall the text view wants to be (it is set to wrap_content), so that // we can allocate the appropriate amount of space for it. int measureSpec = MeasureSpec.UNSPECIFIED; mFolderName.measure(measureSpec, measureSpec); /*YUNOS BEGIN*/ //##module(component name) //##date:2014/06/06 ##author:jun.dongj@alibaba-inc.com##BugID:124683 //folder name show wrong, when the system font is super big mFolderNameHeight = mFolderName.getMeasuredHeight(); /*YUNOS END*/ mFolderNameContentGap = getResources().getDimensionPixelSize(R.dimen.folder_name_content_gap); // We disable action mode for now since it messes up the view on phones mFolderName.setOnEditorActionListener(v); mFolderName.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { mFolderName.requestLayout(); } }); mFolderName.setSelectAllOnFocus(true); //topwise zyf add for fixedfolder ??? mFolderName.setEnabled(false); //topwise zyf add end mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS); showFolderNameOutline(false); updateFolderLayout(mIconManager.supprtCardIcon()); mLastOrientation = getResources().getConfiguration().orientation; }