Java Code Examples for android.widget.EditText

The following are top voted examples for showing how to use android.widget.EditText. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: kouchat-android   File: PrivateChatControllerTest.java View source code 7 votes vote down vote up
@Test
public void onCreateShouldRegisterKeyListenerThatSendsMessageAndClearsInputOnEnter() {
    activityController.create();

    final EditText privateChatInput = (EditText) controller.findViewById(R.id.privateChatInput);
    privateChatInput.setText("Hello");

    privateChatInput.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER));

    verify(ui).sendPrivateMessage("Hello", vivi);
    assertEquals("", privateChatInput.getText().toString());
}
 
Example 2
Project: arduino-android   File: DroidDroid.java View source code 6 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    Log.d(TAG, "Main onStart");
    
    // get references to views defined in our main.xml layout file
    idField = (EditText) findViewById(R.id.deviceIDField);
    button = (Button) findViewById(R.id.okButton);
    // register listeners
    button.setOnClickListener(this);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    DEVICE_ADDRESS = prefs.getString("device", "00:11:04:08:04:64");
    idField.setText(DEVICE_ADDRESS);
}
 
Example 3
Project: ExcusePro   File: PlacePickerFragment.java View source code 6 votes vote down vote up
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ViewGroup view = (ViewGroup) getView();
    if (showSearchBox) {
        ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_placepickerfragment_search_box_stub);
        if (stub != null) {
            searchBox = (EditText) stub.inflate();

            // Put the list under the search box
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.FILL_PARENT,
                    RelativeLayout.LayoutParams.FILL_PARENT);
            layoutParams.addRule(RelativeLayout.BELOW, R.id.search_box);

            ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);
            listView.setLayoutParams(layoutParams);

            // If we need to, put the search box under the title bar.
            if (view.findViewById(R.id.com_facebook_picker_title_bar) != null) {
                layoutParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.FILL_PARENT,
                        RelativeLayout.LayoutParams.WRAP_CONTENT);
                layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar);

                searchBox.setLayoutParams(layoutParams);
            }

            searchBox.addTextChangedListener(new SearchTextWatcher());
            if (!TextUtils.isEmpty(searchText)) {
                searchBox.setText(searchText);
            }
        }
    }
}
 
Example 4
Project: WiFi-Automatic   File: Preferences.java View source code 6 votes vote down vote up
private static void showPre11NumberPicker(final Context c, final SharedPreferences prefs, final Preference p, final int summary, final int min, final int max, final String title, final String setting, final int def, final boolean changeTitle) {
    final EditText np = new EditText(c);
    np.setInputType(InputType.TYPE_CLASS_NUMBER);
    np.setText(String.valueOf(prefs.getInt(setting, def)));
    new AlertDialog.Builder(c).setTitle(title).setView(np)
            .setPositiveButton(android.R.string.ok, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    int number = -1;
                    try {
                        number = Integer.parseInt(np.getText().toString());
                    } catch (Exception e) {
                    }
                    if (number >= min && number <= max) {
                        prefs.edit().putInt(setting, number).commit();
                        if (changeTitle) p.setTitle(c.getString(summary, number));
                        else p.setSummary(c.getString(summary, number));
                    } else {
                        Toast.makeText(c,
                                c.getString(R.string.invalid_input_number_has_to_be_, min, max),
                                Toast.LENGTH_SHORT).show();
                    }
                }
            }).create().show();
}
 
Example 5
Project: RedditInPictures   File: SaveImageDialogFragment.java View source code 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    String initialFilename = BundleUtil.getString(getArguments(), FILENAME, null);

    LayoutInflater lf = LayoutInflater.from(getActivity());
    View dialogView = lf.inflate(R.layout.save_image_dialog, null);

    filename = (EditText) dialogView.findViewById(R.id.save_image_name);
    filename.setText(initialFilename);
    filename.selectAll();
    filename.setOnEditorActionListener(this);
    filename.requestFocus();
    final AlertDialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView)
                                                                     .setTitle(R.string.save_image)
                                                                     .setPositiveButton(R.string.save_image, null)
                                                                     .setNegativeButton(R.string.cancel, null)
                                                                     .create();
    // We have to override setOnShowListener here (min API level 8) in order to validate
    // the inputs before closing the dialog. Just overriding setPositiveButton closes the
    // automatically when the button is pressed
    dialog.setOnShowListener(getDialogOnShowListener());
    dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    filename.addTextChangedListener(this);
    return dialog;
}
 
Example 6
Project: QEditor   File: OFeedBackAct.java View source code 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setTitle(R.string.feedback);

       setActionBarContentView(R.layout.o_feedback);
       
       final TextView aboutText = (TextView) findViewById(R.id.about);
       aboutText.setMovementMethod(LinkMovementMethod.getInstance());
       
       //initWidgetTabItem(4);
       addActionBarItem(getGDActionBar()
       		.newActionBarItem(NormalActionBarItem.class)
       		.setDrawable(new ActionBarDrawable(this, R.drawable.ic_about)), 0);

       
       final EditText searchInput = (EditText)findViewById(R.id.feedback_content);
   	searchInput.setOnKeyListener(new OnKeyListener() {
   		@Override
   		public boolean onKey(View v, int keyCode, KeyEvent event) {
   		    String barcode = searchInput.getText().toString();
   		    if (keyCode == KeyEvent.KEYCODE_ENTER && barcode.length() > 0) {
   		    	onNext(null);
   		        return true;
   		    }
   		    return false;
   		}
   	});
   	
       MNApp mnApp = (MNApp) this.getApplication();
       mnApp.trackPageView("/"+NAction.getCode(getApplicationContext())+"/ofeedback");
       MyApp.getInstance().addActivity(this); 


   }
 
Example 7
Project: Pure-File-Manager   File: CreateDirectoryDialog.java View source code 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = this.getActivity();
    if (activity == null || activity.isFinishing()) {
        return null;
    }
    //noinspection InflateParams
    mFileNameInput = (EditText) activity.getLayoutInflater().inflate(
            R.layout.text_field_filename, null);
    mFileNameInput.setHint(R.string.menu_new_folder);
    mFileNameInput.setFilters(new InputFilter[] {
            new PFMFileUtils.FileNameFilter(),
            new InputFilter.LengthFilter(PFMFileUtils.FileNameFilter.MAX_FILENAME_LENGTH)});
    final File current = (File) this.getArguments().getSerializable(Extras.EXTRA_CURRENT_DIR);
    final AlertDialog.Builder b = new AlertDialog.Builder(activity);
    b.setTitle(R.string.dialog_new_folder_title);
    b.setView(this.mFileNameInput);
    b.setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String newName = mFileNameInput.getText().toString().trim();
            if (newName.isEmpty()) {
                newName = mFileNameInput.getHint().toString();
            }
            OperationsService.createDirectory(activity, current, newName);
        }
    });
    b.setNegativeButton(R.string.cancel, null);
    return b.create();
}
 
Example 8
Project: sawan-bar   File: GetPin2Screen.java View source code 6 votes vote down vote up
/**
 * Reflect the changes in the layout that force the user to open
 * the keyboard. 
 */
private void setupView() {
    mPin2Field = (EditText) findViewById(R.id.pin);
    if (mPin2Field != null) {
        mPin2Field.setKeyListener(DigitsKeyListener.getInstance());
        mPin2Field.setMovementMethod(null);
        mPin2Field.setOnClickListener(mClicked);
    }
}
 
Example 9
Project: sawan-bar   File: EditFdnContactScreen.java View source code 6 votes vote down vote up
/**
 * We have multiple layouts, one to indicate that the user needs to
 * open the keyboard to enter information (if the keybord is hidden).
 * So, we need to make sure that the layout here matches that in the
 * layout file.
 */
private void setupView() {
    mNameField = (EditText) findViewById(R.id.fdn_name);
    if (mNameField != null) {
        mNameField.setOnFocusChangeListener(mOnFocusChangeHandler);
        mNameField.setOnClickListener(mClicked);
    }

    mNumberField = (EditText) findViewById(R.id.fdn_number);
    if (mNumberField != null) {
        mNumberField.setKeyListener(DialerKeyListener.getInstance());
        mNumberField.setOnFocusChangeListener(mOnFocusChangeHandler);
        mNumberField.setOnClickListener(mClicked);
    }

    if (!mAddContact) {
        if (mNameField != null) {
            mNameField.setText(mName);
        }
        if (mNumberField != null) {
            mNumberField.setText(mNumber);
        }
    }

    mButton = (Button) findViewById(R.id.button);
    if (mButton != null) {
        mButton.setOnClickListener(mClicked);
    }

    mPinFieldContainer = (LinearLayout) findViewById(R.id.pinc);

}
 
Example 10
Project: BioWiki   File: BlogPreferencesActivity.java View source code 6 votes vote down vote up
/**
 * Hides / shows the scaled image settings
 *
 * @param show
 */
private void showScaledSetting(boolean show) {
    TextView tw = (TextView) findViewById(R.id.l_scaledImage);
    EditText et = (EditText) findViewById(R.id.scaledImageWidth);
    tw.setVisibility(show ? View.VISIBLE : View.GONE);
    et.setVisibility(show ? View.VISIBLE : View.GONE);
}
 
Example 11
Project: packages_apps_Launcher2   File: Launcher.java View source code 6 votes vote down vote up
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {
        case DIALOG_CREATE_SHORTCUT:
            break;
        case DIALOG_RENAME_FOLDER:
            if (mFolderInfo != null) {
                EditText input = (EditText) dialog.findViewById(R.id.folder_name);
                final CharSequence text = mFolderInfo.title;
                input.setText(text);
                input.setSelection(0, text.length());
            }
            break;
    }
}
 
Example 12
Project: Morse-Messenger   File: VibrateLocally.java View source code 6 votes vote down vote up
protected void onPreExecute(){
	WebView singALong = (WebView) mActicity.findViewById(R.id.singALong);
	singALong.setVisibility(WebView.VISIBLE);
	singALong.loadData("<br/><br/>", "text/html", "UTF-8");

	SeekBar speedBar = 	(SeekBar) mActicity.findViewById(R.id.seekBarSpeed);

	speed = (150 - (30 + speedBar.getProgress())) * 3;	//make it 3 times longer
	
	Button VibrateButton = (Button)mActicity.findViewById(R.id.vibrateMorse);
	VibrateButton.setText("Stop");
	Button playButton = (Button)mActicity.findViewById(R.id.playMorse);
	playButton.setEnabled(false);
	Button translateButton = (Button)mActicity.findViewById(R.id.translateMorse);
	translateButton.setEnabled(false);
	EditText messageView = (EditText) mActicity.findViewById(R.id.messageInput);
	mMessage = messageView.getText().toString();
	messageView.setEnabled(false);
	LinearLayout seekbars = (LinearLayout)mActicity.findViewById(R.id.SeekbarView);
	seekbars.setVisibility(View.GONE);
}
 
Example 13
Project: BioWiki   File: EditPostContentFragment.java View source code 6 votes vote down vote up
private int getEditTextIntegerClamped(EditText editText, int min, int max) {
    int width = 10;
    try {
        if (editText.getText() != null)
            width = Integer.parseInt(editText.getText().toString().replace("px", ""));
    } catch (NumberFormatException e) {
        AppLog.e(AppLog.T.POSTS, e);
    }
    width = Math.min(max, Math.max(width, min));
    return width;
}
 
Example 14
Project: BioWiki   File: EditCommentActivity.java View source code 6 votes vote down vote up
private void saveComment() {
    // make sure comment content was entered
    final EditText editContent = (EditText) findViewById(R.id.comment_content);
    if (EditTextUtils.isEmpty(editContent)) {
        editContent.setError(getString(R.string.content_required));
        return;
    }

    // return immediately if comment hasn't changed
    if (!isCommentEdited()) {
        ToastUtils.showToast(this, R.string.toast_comment_unedited);
        return;
    }

    // make sure we have an active connection
    if (!NetworkUtils.checkConnection(this))
        return;

    if (mIsUpdateTaskRunning)
        AppLog.w(AppLog.T.COMMENTS, "update task already running");
    new UpdateCommentTask().execute();
}
 
Example 15
Project: SudoQ   File: PlayerPreferencesActivity.java View source code 6 votes vote down vote up
/**
 * Wird aufgerufen, falls die Activity zum ersten Mal gestartet wird. Läd
 * die Preferences anhand der zur Zeit aktiven Profil-ID.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);		
	this.setContentView(R.layout.preferences_player);

	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	setSupportActionBar(toolbar);

	final ActionBar ab = getSupportActionBar();
	ab.setHomeAsUpIndicator(R.drawable.launcher);
	ab.setDisplayHomeAsUpEnabled(true);
	ab.setDisplayShowTitleEnabled(true);
	
	gesture =            (CheckBox) findViewById(R.id.checkbox_gesture);
	autoAdjustNotes =    (CheckBox) findViewById(R.id.checkbox_autoAdjustNotes);
	markRowColumn =      (CheckBox) findViewById(R.id.checkbox_markRowColumn);
	markWrongSymbol =    (CheckBox) findViewById(R.id.checkbox_markWrongSymbol);
	restrictCandidates = (CheckBox) findViewById(R.id.checkbox_restrictCandidates);
	
	name = (EditText) findViewById(R.id.edittext_profilename);
	name.clearFocus();
	name.setSingleLine(true);// no multiline names

	firstStartup = false;		
	createProfile = true;

	Profile.getInstance().registerListener(this);
}
 
Example 16
Project: javainstaller   File: CheckPoint.java View source code 6 votes vote down vote up
public void showalert() {
	AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.context);
	alert.setTitle(text);

	// Set an EditText view to get user input 
	final EditText input = new EditText(MainActivity.context);
	input.setId(1);
	if(src==false){
		alert.setMessage("path to install");
		input.setText(getPath());
	}
	else{
		alert.setMessage("source file");
		input.setText(getSource());
	}
	alert.setView(input);

	alert.setPositiveButton("save", this);

	alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
	  public void onClick(DialogInterface dialog, int whichButton) {
	    // Canceled.
	  }
	});

	alert.show();
}
 
Example 17
Project: Gui2Go   File: EditorActivity.java View source code 6 votes vote down vote up
private View createNewEditText() {
    EditText newWidget = new EditText(this);
    newWidget.setText("EditText");
    newWidget.setTextColor(Color.GRAY);
    newWidget.setFocusableInTouchMode(false);
    return newWidget;
}
 
Example 18
Project: gcmobile   File: StringWidget.java View source code 6 votes vote down vote up
public StringWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mAnswer = new EditText(context);

    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

    TableLayout.LayoutParams params = new TableLayout.LayoutParams();
    params.setMargins(7, 5, 7, 5);
    mAnswer.setLayoutParams(params);
    
    // capitalize the first letter of the sentence
    mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));

    // needed to make long read only text scroll
    mAnswer.setHorizontallyScrolling(false);
    mAnswer.setSingleLine(false);

    if (prompt != null) {
        mReadOnly = prompt.isReadOnly();
        String s = prompt.getAnswerText();
        if (s != null) {
            mAnswer.setText(s);
        }

        if (mReadOnly) {
            mAnswer.setBackgroundDrawable(null);
            mAnswer.setFocusable(false);
            mAnswer.setClickable(false);
        }
    }

    addView(mAnswer);
}
 
Example 19
Project: sawan-bar   File: EditPinPreference.java View source code 6 votes vote down vote up
/**
 * Overridden to setup the correct dialog layout, as well as setting up 
 * other properties for the pin / puk entry field.
 */
@Override
protected View onCreateDialogView() {
    // set the dialog layout
    setDialogLayoutResource(R.layout.pref_dialog_editpin);
    
    View dialog = super.onCreateDialogView();
    
    // set the transformation method and the key listener to ensure
    // correct input and presentation of the pin / puk.
    final EditText textfield = getEditText();
    textfield.setTransformationMethod(PasswordTransformationMethod.getInstance());
    textfield.setKeyListener(DigitsKeyListener.getInstance());
    
    return dialog;
}
 
Example 20
Project: TweetLanes   File: ComposeBaseFragment.java View source code 6 votes vote down vote up
void autoComplete(String text, EditText editText) {
    if (mAutocompleteListView == null) {
        return;
    }

    if (text == null || text.length() == 0) {
        mAutocompleteListView.setVisibility(View.GONE);
        return;
    }

    int currentStart = editText.getSelectionStart();
    int currentEnd = editText.getSelectionEnd();
    int currentPosition = text.length() - 1;
    if (currentStart == currentEnd) {
        currentPosition = currentStart;
    }
    if (currentPosition < 0) currentPosition = 0;

    String lastWholeWord = "";

    for (int i = currentPosition; i > 0; i--) {
        String nextChar = text.substring(i-1,i).toLowerCase();
        if (nextChar.equals(" ") || nextChar.equals(".")) {
            break;
        }
        lastWholeWord = nextChar + lastWholeWord;
    }

    if (lastWholeWord.startsWith("@")) {
        List<TwitterUser> autoCompleteMentions = getAutoCompleteMentions(lastWholeWord);

        mAutocompleteListView.setVisibility(View.VISIBLE);
        mAutocompleteListView.setAdapter(new AutoCompleteMentionAdapter(this.getActivity(), autoCompleteMentions));
        mAutocompleteTarget = editText;
        mAutocompleteListView.setOnItemClickListener(mOnAutoCompleteItemClickListener);
    } else if (lastWholeWord.startsWith("#")) {
        List<String> autoCompleteHashtags = getAutoCompleteHashtags(lastWholeWord);

        mAutocompleteListView.setVisibility(View.VISIBLE);
        mAutocompleteListView.setAdapter(new AutoCompleteHashtagAdapter(this.getActivity(), autoCompleteHashtags));
        mAutocompleteTarget = editText;
        mAutocompleteListView.setOnItemClickListener(mOnAutoCompleteItemClickListener);
    } else {
        mAutocompleteListView.setVisibility(View.GONE);
    }
}
 
Example 21
Project: sawan-bar   File: InCallScreen.java View source code 6 votes vote down vote up
private View createWildPromptView() {
    LinearLayout result = new LinearLayout(this);
    result.setOrientation(LinearLayout.VERTICAL);
    result.setPadding(5, 5, 5, 5);

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);

    TextView promptMsg = new TextView(this);
    promptMsg.setTextSize(14);
    promptMsg.setTypeface(Typeface.DEFAULT_BOLD);
    promptMsg.setText(getResources().getText(R.string.wild_prompt_str));

    result.addView(promptMsg, lp);

    mWildPromptText = new EditText(this);
    mWildPromptText.setKeyListener(DialerKeyListener.getInstance());
    mWildPromptText.setMovementMethod(null);
    mWildPromptText.setTextSize(14);
    mWildPromptText.setMaxLines(1);
    mWildPromptText.setHorizontallyScrolling(true);
    mWildPromptText.setBackgroundResource(android.R.drawable.editbox_background);

    LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.setMargins(0, 3, 0, 0);

    result.addView(mWildPromptText, lp2);

    return result;
}
 
Example 22
Project: notes   File: OEditTextField.java View source code 6 votes vote down vote up
public void initControl() {
    // Creating control
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    removeAllViews();
    setOrientation(VERTICAL);
    if (mEditable) {
        edtText = new EditText(mContext);
        edtText.setTypeface(OControlHelper.lightFont());
        edtText.setLayoutParams(params);
        edtText.setBackgroundColor(Color.TRANSPARENT);
        edtText.setPadding(0, 10, 10, 10);
        edtText.setHint(getLabel());
        edtText.setOnFocusChangeListener(this);
        if (textSize > -1) {
            edtText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            edtText.setTextAppearance(mContext, appearance);
        }
        edtText.setTextColor(textColor);
        addView(edtText);
    } else {
        txvText = new TextView(mContext);
        txvText.setTypeface(OControlHelper.lightFont());
        txvText.setLayoutParams(params);
        txvText.setBackgroundColor(Color.TRANSPARENT);
        txvText.setPadding(0, 10, 10, 10);
        if (textSize > -1) {
            txvText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            txvText.setTextAppearance(mContext, appearance);
        }
        txvText.setTextColor(textColor);
        addView(txvText);
    }
}
 
Example 23
Project: Coding-Android   File: TopicListDetailActivity.java View source code 6 votes vote down vote up
private void prepareComment() {
    EditText message = mEnterComment.getEnterLayout().content;
    message.setHint("????");
    message.setTag(topicObject);

    mEnterComment.getEnterLayout().restoreLoad(topicObject);
}
 
Example 24
Project: QEditor   File: MTubebook.java View source code 6 votes vote down vote up
public void doSearch(View v) {
 	EditText termT = (EditText)findViewById(R.id.url_input);    	
 	String url;
 	if (termT == null || termT.getText().toString().equals("")) {
 		Toast.makeText(getApplicationContext(), R.string.err_need_url, Toast.LENGTH_SHORT).show();
 	} else {
 		url = termT.getText().toString();
 		if (!url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("file://") && !url.startsWith("content://") && !url.startsWith("md://")) {
 			url = "http://"+url;
 			termT.setText(url);
 		}
 		InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
 		//t.setText(null);
 		imm.hideSoftInputFromWindow(termT.getWindowToken(), 0);
 		termT.clearFocus();
 		
loadurl(wv, url);
 	}
 }
 
Example 25
Project: barbot   File: HealthActivity.java View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_health);
    enterHealthLimit = (EditText)findViewById(R.id.healthLimit);
    enterHealthLimit.setHintTextColor(Color.WHITE);
    enterHealthLimit.setTextColor(Color.WHITE);
    View view = this.getWindow().getDecorView();
    view.setBackgroundColor(Color.parseColor("#551a8b"));
    nxt = (Button)findViewById(R.id.nBtn);
    nxt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ParseUser.getCurrentUser().put("healthLimit",Integer.parseInt(enterHealthLimit.getText().toString()));
            ParseUser.getCurrentUser().saveInBackground(new SaveCallback() {
                @Override
                public void done(ParseException e) {
                    Intent i = new Intent(getApplicationContext(),MainActivity.class);
                    i.putExtra("from","here");
                    startActivity(i);
                }
            });
        }
    });



}
 
Example 26
Project: LightSDKAndroid   File: EditActivity.java View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {


    // ??Theme????setContentView????
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        int resourceId = extras.getInt(THEME, 0);
        if (resourceId != 0) {
            setTheme(resourceId);
        }
    }
    super.onCreate(savedInstanceState);
    Helper.setShowSoftKeyboard(this);
    Helper.setNoIconBackActionBar(this, "Edit");
    setContentView(R.layout.activity_edit);

    if (extras != null) {
        String title = extras.getString(TITLE);
        setTitle(title);

        String defaults = extras.getString(DEFAULT);
        EditText edit = (EditText) findViewById(R.id.edit_text);
        edit.setText(defaults == null ? "" : defaults);

        int inputType = extras.getInt(INPUT_TYPE);
        // ???????????0????????
        if (inputType == 0) {
            edit.setInputType(InputType.TYPE_CLASS_TEXT);
        } else {
            edit.setInputType(inputType);
        }

        String lineType = extras.getString(LINE_TYPE);
        if (SINGLE_LINE.equalsIgnoreCase(lineType)) {
            edit.setLines(1);
            edit.setSingleLine(true);
        } else {
            edit.setLines(4);
            edit.setSingleLine(false);
        }

        boolean isReadOnly = extras.getBoolean(READONLY);
        edit.setEnabled(!isReadOnly);
    }

}
 
Example 27
Project: packages_apps_Mms   File: ComposeMessageActivity.java View source code 6 votes vote down vote up
private void showSubjectEditor(boolean show) {
    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("" + show);
    }

    if (mSubjectTextEditor == null) {
        // Don't bother to initialize the subject editor if
        // we're just going to hide it.
        if (show == false) {
            return;
        }
        mSubjectTextEditor = (EditText)findViewById(R.id.subject);
        mSubjectTextEditor.setFilters(new InputFilter[] {
                new LengthFilter(MmsConfig.getMaxSubjectLength())});
    }

    mSubjectTextEditor.setOnKeyListener(show ? mSubjectKeyListener : null);

    if (show) {
        mSubjectTextEditor.addTextChangedListener(mSubjectEditorWatcher);
    } else {
        mSubjectTextEditor.removeTextChangedListener(mSubjectEditorWatcher);
    }

    mSubjectTextEditor.setText(mWorkingMessage.getSubject());
    mSubjectTextEditor.setVisibility(show ? View.VISIBLE : View.GONE);
    hideOrShowTopPanel();
}
 
Example 28
Project: PalmCalc   File: Logic.java View source code 6 votes vote down vote up
boolean eatHorizontalMove(boolean isToLeft) {
	EditText etxtEditText = mDisplay.getEditText();
	ScientificActivity.imm.hideSoftInputFromWindow(
			etxtEditText.getWindowToken(), 0);
	int cursorPos = etxtEditText.getSelectionStart();
	return isToLeft ? cursorPos == 0 : cursorPos >= etxtEditText.length();
}
 
Example 29
Project: android-app-study   File: BluetoothActivity.java View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    etView = (EditText)findViewById(R.id.editText1);
    mArrayAdapter = new ArrayAdapter<String>(this, 0);
    
    etView.append("Start\n");
    mBTAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBTAdapter == null) {
    	etView.append("Warning: device doest not support Bluetooth\n");
    }
    
    // enable the BT
    if (mBTAdapter != null && !mBTAdapter.isEnabled()) {
    	etView.append("try to enable BT...\n");
    	Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    	startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
    }
    
    // query about paired devices
    etView.append("Paired Device\n---------------\n");
    Set<BluetoothDevice> pairedDevice = mBTAdapter.getBondedDevices();
    if (pairedDevice.size() != 0) {
    	for (BluetoothDevice device : pairedDevice) {
    		etView.append(device.getName()+ "\n" + device.getAddress() + "\n");
    	}
    }
    
    
    // register
    IntentFilter filter = new IntentFilter();
    filter.addAction(BluetoothDevice.ACTION_FOUND);
    filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    registerReceiver(mReceiver, filter);
    
    mBTAdapter.startDiscovery();
}
 
Example 30
Project: openxface-android   File: XInAppBrowser.java View source code 6 votes vote down vote up
/**
 * ???????
 * @param id ??????????
 * @param layoutParams ????
 * @param isSingleLine ???????
 * @param text ??????
 * @param inputType ????
 * @param imeOption ime??
 * @param listener ?????
 * @return
 */
protected EditText createEditText(int id,
        RelativeLayout.LayoutParams layoutParams, boolean isSingleLine,
        String text, int inputType, int imeOption,
        View.OnKeyListener listener) {
    EditText editText = new EditText(mContext);
    editText.setLayoutParams(layoutParams);
    editText.setId(id);
    editText.setSingleLine(true);
    editText.setText(text);
    editText.setInputType(inputType);
    editText.setImeOptions(imeOption);
    editText.setOnKeyListener(listener);
    return editText;
}
 
Example 31
Project: property-db   File: EditTextPreference.java View source code 6 votes vote down vote up
@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);

    EditText editText = mEditText;
    editText.setText(getText());
    
    ViewParent oldParent = editText.getParent();
    if (oldParent != view) {
        if (oldParent != null) {
            ((ViewGroup) oldParent).removeView(editText);
        }
        onAddEditTextToDialogView(view, editText);
    }
}
 
Example 32
Project: XHangouts   File: UiEnterKey.java View source code 6 votes vote down vote up
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
    config.reload((Context) param.args[0]);

    if(!config.modEnabled) {
        return;
    }

    debug(config.enterKey.name());

    if(config.enterKey == Setting.UiEnterKey.EMOJI_SELECTOR) {
        return;
    }

    EditText et = (EditText)param.thisObject;
    // Remove Emoji selector (works for new line)
    int inputType = et.getInputType() ^ InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
    if(config.enterKey == Setting.UiEnterKey.SEND) {
        // Disable multi-line input which shows the send button
        inputType ^= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
    }
    et.setInputType(inputType);
}
 
Example 33
Project: XRead   File: MainActivity.java View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	stopButton = (ImageButton) findViewById(id.stopButtonMain);
	playButton = (ImageButton) findViewById(id.playButtonMain);
	historyButton = (ImageButton) findViewById(id.historyButtonMain);
	twitterButton = (ImageButton) findViewById(id.twitterButton);
	globeButton = (ImageButton) findViewById(id.geoButton);
	stackoverflowButton = (ImageButton) findViewById(id.stackoverflowButton);
	dbpediaButton = (ImageButton) findViewById(id.mediaButton);
	progressWheel = (ProgressBar) findViewById(id.progressWheelMain);
	
	editText = (EditText) findViewById(id.editTextMain);
	editText.setSelectAllOnFocus(true);
	editText.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			editText.setText("");
		}
	});
}
 
Example 34
Project: QuickLyric   File: LyricsViewFragment.java View source code 6 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mLyrics != null)
        try {
            outState.putByteArray("lyrics", mLyrics.toBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    View searchView = getActivity().findViewById(R.id.search_view);
    if (searchView instanceof SearchView) {
        outState.putString("searchQuery", ((SearchView) searchView).getQuery().toString());
        outState.putBoolean("searchFocused", searchView.hasFocus());
    }

    outState.putBoolean("refreshFabEnabled", getActivity().findViewById(R.id.refresh_fab).isEnabled());

    EditText editedLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics);
    if (editedLyrics.getVisibility() == View.VISIBLE) {
        EditText editedTitle = (EditText) getActivity().findViewById(R.id.song);
        EditText editedArtist = (EditText) getActivity().findViewById(R.id.artist);
        outState.putCharSequence("editedLyrics", editedLyrics.getText());
        outState.putCharSequence("editedTitle", editedTitle.getText());
        outState.putCharSequence("editedArtist", editedArtist.getText());
    }
}
 
Example 35
Project: BioWiki   File: EditTextUtils.java View source code 6 votes vote down vote up
public static void hideSoftInput(EditText edit) {
    if (edit == null)
        return;
    Context context = edit.getContext();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null)
        imm.hideSoftInputFromWindow(edit.getWindowToken(), 0);
}
 
Example 36
Project: Soundroid-2.x   File: LogoActivity.java View source code 6 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.logo_activity);

    EditText splash = (EditText)findViewById(R.id.splash);
    splash.setEnabled(false);
    splash.setCursorVisible(false);
    splash.setSelected(false);

    EditText version = (EditText)findViewById(R.id.version);
    version.setEnabled(false);
    version.setCursorVisible(false);
    version.setSelected(false);
    version.setText("Version: " + Soundroid.getVersionString(this).split(":")[1]);

    // If no data was given in the intent (because we were started
    // as a MAIN activity), then use our default content provider.
    Intent intent = getIntent();

    if (intent.getData() == null) {
        intent.setData(Oauth.CONTENT_URI);
    }

    if(!SoundcloudOauth.CALLBACK_URL_SCHEMA.equals(intent.getScheme())){

        new FetchToken().execute();

    }else{
        //Si es un callback es porque el usuario acaba de permitir a la aplicacin acceder a su cuenta de soundcloud
        //Por tanto tenemos que guardar el access token y el token secret para poderlo usar las siguientes veces

        new RetieveAndSaveToken().execute();
    }
}
 
Example 37
Project: afwall   File: ColorPickerDialog.java View source code 5 votes vote down vote up
private void setUp(int color) {

        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View layout = inflater.inflate(R.layout.dialog_color_picker, null);

        setContentView(layout);

        setTitle(R.string.dialog_color_picker);

        mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
        mOldColor = (ColorPickerPanelView) layout.findViewById(R.id.old_color_panel);
        mNewColor = (ColorPickerPanelView) layout.findViewById(R.id.new_color_panel);

        mHexVal = (EditText) layout.findViewById(R.id.hex_val);
        mHexVal.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        mHexDefaultTextColor = mHexVal.getTextColors();

        mHexVal.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                    String s = mHexVal.getText().toString();
                    if (s.length() > 5 || s.length() < 10) {
                        try {
                            int c = ColorPickerPreference.convertToColorInt(s.toString());
                            mColorPicker.setColor(c, true);
                            mHexVal.setTextColor(mHexDefaultTextColor);
                        } catch (IllegalArgumentException e) {
                            mHexVal.setTextColor(Color.RED);
                        }
                    } else {
                        mHexVal.setTextColor(Color.RED);
                    }
                    return true;
                }
                return false;
            }
        });

        ((LinearLayout) mOldColor.getParent()).setPadding(
                Math.round(mColorPicker.getDrawingOffset()),
                0,
                Math.round(mColorPicker.getDrawingOffset()),
                0
        );

        mOldColor.setOnClickListener(this);
        mNewColor.setOnClickListener(this);
        mColorPicker.setOnColorChangedListener(this);
        mOldColor.setColor(color);
        mColorPicker.setColor(color, true);

    }
 
Example 38
Project: Android_ShareSDK_Example_OAuth   File: EditPage.java View source code 5 votes vote down vote up
private void initPageView() {
	llPage = new LinearLayout(getContext());
	llPage.setBackgroundColor(0xff323232);
	llPage.setOrientation(LinearLayout.VERTICAL);

	// title bar
	llTitle = new TitleLayout(getContext());
	int resId = getBitmapRes(activity, "title_back");
	if (resId > 0) {
		llTitle.setBackgroundResource(resId);
	}
	llTitle.getBtnBack().setOnClickListener(this);
	resId = getStringRes(activity, "multi_share");
	if (resId > 0) {
		llTitle.getTvTitle().setText(resId);
	}
	llTitle.getBtnRight().setVisibility(View.VISIBLE);
	resId = getStringRes(activity, "share");
	if (resId > 0) {
		llTitle.getBtnRight().setText(resId);
	}
	llTitle.getBtnRight().setOnClickListener(this);
	llTitle.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	llPage.addView(llTitle);

	FrameLayout flPage = new FrameLayout(getContext());
	LinearLayout.LayoutParams lpFl = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpFl.weight = 1;
	flPage.setLayoutParams(lpFl);
	llPage.addView(flPage);

	// page body
	LinearLayout llBody = new LinearLayout(getContext());
	llBody.setOrientation(LinearLayout.VERTICAL);
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	lpLl.gravity = Gravity.LEFT | Gravity.TOP;
	llBody.setLayoutParams(lpLl);
	flPage.addView(llBody);

	// the pin
	ivPin = new ImageView(getContext());
	resId = getBitmapRes(activity, "pin");
	if (resId > 0) {
		ivPin.setImageResource(resId);
	}
	int dp_80 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 80);
	int dp_36 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 36);
	FrameLayout.LayoutParams lpPin = new FrameLayout.LayoutParams(dp_80, dp_36);
	lpPin.topMargin = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 6);
	lpPin.gravity = Gravity.RIGHT | Gravity.TOP;
	ivPin.setLayoutParams(lpPin);
	flPage.addView(ivPin);

	ImageView ivShadow = new ImageView(getContext());
	resId = getBitmapRes(activity, "title_shadow");
	if (resId > 0) {
		ivShadow.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpSd = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	ivShadow.setLayoutParams(lpSd);
	flPage.addView(ivShadow);

	LinearLayout llInput = new LinearLayout(getContext());
	llInput.setMinimumHeight(cn.sharesdk.framework.utils.R.dipToPx(getContext(), 150));
	resId = getBitmapRes(activity, "edittext_back");
	if (resId > 0) {
		llInput.setBackgroundResource(resId);
	}
	LinearLayout.LayoutParams lpInput = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	int dp_3 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 3);
	lpInput.setMargins(dp_3, dp_3, dp_3, dp_3);
	lpInput.weight = 1;
	llInput.setLayoutParams(lpInput);
	llBody.addView(llInput);

	// platform logos
	LinearLayout llToolBar = new LinearLayout(getContext());
	resId = getBitmapRes(activity, "share_tb_back");
	if (resId > 0) {
		llToolBar.setBackgroundResource(resId);
	}
	LinearLayout.LayoutParams lpTb = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	int dp_4 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 4);
	lpTb.setMargins(dp_4, 0, dp_4, dp_4);
	llToolBar.setLayoutParams(lpTb);
	llBody.addView(llToolBar);

	LinearLayout llContent = new LinearLayout(getContext());
	llContent.setOrientation(LinearLayout.VERTICAL);
	LinearLayout.LayoutParams lpEt = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	lpEt.weight = 1;
	llContent.setLayoutParams(lpEt);
	llInput.addView(llContent);

	// share content editor
	etContent = new EditText(getContext());
	etContent.setGravity(Gravity.LEFT | Gravity.TOP);
	etContent.setBackgroundDrawable(null);
	etContent.setText(String.valueOf(reqData.get("text")));
	etContent.addTextChangedListener(this);
	etContent.setLayoutParams(lpEt);
	llContent.addView(etContent);

	String platform = String.valueOf(reqData.get("platform"));
	checkAtMth(llContent, platform);

	int dp_74 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 74);
	int dp_16 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 16);
	String imagePath = String.valueOf(reqData.get("imagePath"));
	if(!TextUtils.isEmpty(imagePath) && new File(imagePath).exists()){
		LinearLayout llRight = new LinearLayout(getContext());
		llRight.setOrientation(LinearLayout.VERTICAL);
		llRight.setLayoutParams(new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
		llInput.addView(llRight);

		// shared image container
		ivImage = new ImageView(getContext());
		resId = getBitmapRes(activity, "btn_back_nor");
		if (resId > 0) {
			ivImage.setBackgroundResource(resId);
		}
		ivImage.setScaleType(ScaleType.CENTER_INSIDE);
		ivImage.setVisibility(View.GONE);
		ivImage.setVisibility(View.VISIBLE);
		try {
			shareImage = true;
			image = cn.sharesdk.framework.utils.R.getBitmap(imagePath);
			ivImage.setImageBitmap(image);
		} catch(Throwable t) {
			System.gc();
			try {
				image = cn.sharesdk.framework.utils.R.getBitmap(imagePath, 2);
				ivImage.setImageBitmap(image);
			} catch(Throwable t1) {
				t1.printStackTrace();
				shareImage = false;
			}
		}

		ivImage.setPadding(dp_4, dp_4, dp_4, dp_4);
		LinearLayout.LayoutParams lpImage = new LinearLayout.LayoutParams(dp_74, dp_74);
		int dp_8 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 8);
		lpImage.setMargins(0, dp_16, dp_8, 0);
		ivImage.setLayoutParams(lpImage);
		llRight.addView(ivImage);
		if(!shareImage){
			ivPin.setVisibility(View.GONE);
			ivImage.setVisibility(View.GONE);
		}
		ivImage.setOnClickListener(this);
	}else {
		shareImage = false;
		ivPin.setVisibility(View.GONE);
	}

	// shared image container
	if(shareImage){
		Button btn = new Button(getContext());
		btn.setTag("img_cancel");
		btn.setOnClickListener(this);
		resId = getBitmapRes(activity, "img_cancel");
		if (resId > 0) {
			btn.setBackgroundResource(resId);
		}
		int dp_20 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 20);
		int dp_83 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 83);
		int dp_13 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 13);
		FrameLayout.LayoutParams lpBtn = new FrameLayout.LayoutParams(dp_20, dp_20);
		lpBtn.topMargin = dp_83;
		lpBtn.rightMargin = dp_13;
		lpBtn.gravity = Gravity.RIGHT | Gravity.TOP;
		btn.setPadding(dp_4, dp_4, dp_4, dp_4);
		btn.setLayoutParams(lpBtn);
		flPage.addView(btn);
	}

	// Words counter
	tvCounter = new TextView(getContext());
	tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
	tvCounter.setTextColor(0xffcfcfcf);
	tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
	tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
	FrameLayout.LayoutParams lpCounter = new FrameLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpCounter.bottomMargin = dp_74;
	lpCounter.gravity = Gravity.RIGHT | Gravity.BOTTOM;

	tvCounter.setPadding(0, 0, dp_16, 0);
	tvCounter.setLayoutParams(lpCounter);
	flPage.addView(tvCounter);

	TextView tvShareTo = new TextView(getContext());
	resId = getStringRes(activity, "share_to");
	if (resId > 0) {
		tvShareTo.setText(resId);
	}
	tvShareTo.setTextColor(0xffcfcfcf);
	tvShareTo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
	int dp_9 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 9);
	LinearLayout.LayoutParams lpShareTo = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpShareTo.gravity = Gravity.CENTER_VERTICAL;
	lpShareTo.setMargins(dp_9, 0, 0, 0);
	tvShareTo.setLayoutParams(lpShareTo);
	llToolBar.addView(tvShareTo);

	HorizontalScrollView sv = new HorizontalScrollView(getContext());
	sv.setHorizontalScrollBarEnabled(false);
	sv.setHorizontalFadingEdgeEnabled(false);
	LinearLayout.LayoutParams lpSv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpSv.setMargins(dp_9, dp_9, dp_9, dp_9);
	sv.setLayoutParams(lpSv);
	llToolBar.addView(sv);

	llPlat = new LinearLayout(getContext());
	llPlat.setLayoutParams(new HorizontalScrollView.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
	sv.addView(llPlat);
}
 
Example 39
Project: CrossFitr   File: NumberPicker.java View source code 5 votes vote down vote up
public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    setOrientation(VERTICAL);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.number_picker, this, true);
    mHandler = new Handler();
 
    mIncrementSecButton = (NumberPickerButton) findViewById(R.id.increment_sec);
    mIncrementSecButton.setOnClickListener(this);
    mIncrementSecButton.setOnLongClickListener(this);
    mIncrementSecButton.setNumberPicker(this);
    mDecrementSecButton = (NumberPickerButton) findViewById(R.id.decrement_sec);
    mDecrementSecButton.setOnClickListener(this);
    mDecrementSecButton.setOnLongClickListener(this);
    mDecrementSecButton.setNumberPicker(this);

    mIncrementMinButton = (NumberPickerButton) findViewById(R.id.increment_min);
    mIncrementMinButton.setOnClickListener(this);
    mIncrementMinButton.setOnLongClickListener(this);
    mIncrementMinButton.setNumberPicker(this);
    mDecrementMinButton = (NumberPickerButton) findViewById(R.id.decrement_min);
    mDecrementMinButton.setOnClickListener(this);
    mDecrementMinButton.setOnLongClickListener(this);
    mDecrementMinButton.setNumberPicker(this);
    
    mIncrementHourButton = (NumberPickerButton) findViewById(R.id.increment_hour);
    mIncrementHourButton.setOnClickListener(this);
    mIncrementHourButton.setOnLongClickListener(this);
    mIncrementHourButton.setNumberPicker(this);
    mDecrementHourButton = (NumberPickerButton) findViewById(R.id.decrement_hour);
    mDecrementHourButton.setOnClickListener(this);
    mDecrementHourButton.setOnLongClickListener(this);
    mDecrementHourButton.setNumberPicker(this);

    mTextSec = (EditText) findViewById(R.id.timepicker_input_sec);
    mTextSec.setOnFocusChangeListener(this);
    mTextSec.setOnEditorActionListener(this);
    mTextSec.setRawInputType(InputType.TYPE_CLASS_NUMBER);
    mTextSec.setInputType(0); //See http://code.google.com/p/android/issues/detail?id=7115
    mTextSec.setEnabled(true); 
    
    mTextMin = (EditText) findViewById(R.id.timepicker_input_min);
    mTextMin.setOnFocusChangeListener(this);
    mTextMin.setOnEditorActionListener(this);
    mTextMin.setRawInputType(InputType.TYPE_CLASS_NUMBER);
    mTextMin.setInputType(0); //See http://code.google.com/p/android/issues/detail?id=7115
    mTextMin.setEnabled(true); 
    
    mTextHour = (EditText) findViewById(R.id.timepicker_input_hour);
    mTextHour.setOnFocusChangeListener(this);
    mTextHour.setOnEditorActionListener(this);
    mTextHour.setRawInputType(InputType.TYPE_CLASS_NUMBER);
    mTextHour.setInputType(0); //See http://code.google.com/p/android/issues/detail?id=7115
    mTextHour.setEnabled(true); 

    if (!isEnabled()) {
        setEnabled(false);
    }

    TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.numberpicker );
    mStart = a.getInt( R.styleable.numberpicker_startRange, DEFAULT_MIN );
    mEnd = a.getInt( R.styleable.numberpicker_endRange, DEFAULT_MAX );
    mEndHour = a.getInt( R.styleable.numberpicker_endRange, DEFAULT_MAX_HOUR );
    mWrap = a.getBoolean( R.styleable.numberpicker_wrap, DEFAULT_WRAP );
    
    mCurrentSec = a.getInt( R.styleable.numberpicker_defaultValue, DEFAULT_VALUE );
    mCurrentSec = Math.max( mStart, Math.min( mCurrentSec, mEnd ) );
    mCurrentMin = a.getInt( R.styleable.numberpicker_defaultValue, DEFAULT_VALUE );
    mCurrentMin = Math.max( mStart, Math.min( mCurrentMin, mEnd ) );
    mCurrentHour = a.getInt( R.styleable.numberpicker_defaultValue, DEFAULT_VALUE );
    mCurrentHour = Math.max( mStart, Math.min( mCurrentHour, mEndHour ) );
    
    mTextSec.setText( "" + mCurrentSec);
    mTextMin.setText( "" + mCurrentMin);
    mTextHour.setText( "" + mCurrentHour );
}
 
Example 40
Project: android_packages_apps_phone   File: EmergencyDialer.java View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // set this flag so this activity will stay in front of the keyguard
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

    // Set the content view
    setContentView(R.layout.emergency_dialer);

    // Load up the resources for the text field and delete button
    Resources r = getResources();
    mDigitsBackground = r.getDrawable(R.drawable.btn_dial_textfield_active);
    mDigitsEmptyBackground = r.getDrawable(R.drawable.btn_dial_textfield);

    mDigits = (EditText) findViewById(R.id.digits);
    mDigits.setKeyListener(DialerKeyListener.getInstance());
    mDigits.setOnClickListener(this);
    mDigits.setOnKeyListener(this);
    mDigits.setOnTouchListener(this);
    mDigits.setLongClickable(false);
    maybeAddNumberFormatting();

    // Check for the presence of the keypad
    View view = findViewById(R.id.one);
    if (view != null) {
        setupKeypad();
    }

    mVoicemailDialAndDeleteRow = findViewById(R.id.voicemailAndDialAndDelete);

    // Check whether we should show the onscreen "Dial" button and co.
    if (r.getBoolean(R.bool.config_show_onscreen_dial_button)) {

        // The voicemail button is not active. Even if we marked
        // it as disabled in the layout, we have to manually clear
        // that state as well (b/2134374)
        // TODO: Check with UI designer if we should not show that button at all. (b/2134854)
        mVoicemailDialAndDeleteRow.findViewById(R.id.voicemailButton).setEnabled(false);

        mDialButton = mVoicemailDialAndDeleteRow.findViewById(R.id.dialButton);
        mDialButton.setOnClickListener(this);
        mDialButton.setOnTouchListener(this);

        mDelete = mVoicemailDialAndDeleteRow.findViewById(R.id.deleteButton);
        mDelete.setOnClickListener(this);
        mDelete.setOnLongClickListener(this);
        mDelete.setOnTouchListener(this);
    } else {
        mVoicemailDialAndDeleteRow.setVisibility(View.GONE); // It's VISIBLE by default
        mVoicemailDialAndDeleteRow = null;
    }


    if (icicle != null) {
        super.onRestoreInstanceState(icicle);
    }

    // if the mToneGenerator creation fails, just continue without it.  It is
    // a local audio signal, and is not as important as the dtmf tone itself.
    synchronized (mToneGeneratorLock) {
        if (mToneGenerator == null) {
            try {
                // we want the user to be able to control the volume of the dial tones
                // outside of a call, so we use the stream type that is also mapped to the
                // volume control keys for this activity
                mToneGenerator = new ToneGenerator(DIAL_TONE_STREAM_TYPE, TONE_RELATIVE_VOLUME);
                setVolumeControlStream(DIAL_TONE_STREAM_TYPE);
            } catch (RuntimeException e) {
                Log.w(LOG_TAG, "Exception caught while creating local tone generator: " + e);
                mToneGenerator = null;
            }
        }
    }

    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    registerReceiver(mBroadcastReceiver, intentFilter);

    try {
        mHaptic.init(this, r.getBoolean(R.bool.config_enable_dialer_key_vibration));
    } catch (Resources.NotFoundException nfe) {
         Log.e(LOG_TAG, "Vibrate control bool missing.", nfe);
    }
}
 
Example 41
Project: sawan-bar   File: DTMFTwelveKeyDialer.java View source code 5 votes vote down vote up
/**
 * DTMFTwelveKeyDialer constructor.
 *
 * @param parent the InCallScreen instance that owns us.
 * @param dialerView the DTMFTwelveKeyDialerView we should use to display the dialpad.
 * @param dialerDrawer the SlidingDrawer widget that contains dialerView, or
 *                     null if this device doesn't use a SlidingDrawer
 *                     as a container for the dialpad.
 */
public DTMFTwelveKeyDialer(InCallScreen parent,
                           DTMFTwelveKeyDialerView dialerView,
                           SlidingDrawer dialerDrawer) {
    if (DBG) log("DTMFTwelveKeyDialer constructor... this = " + this);

    mInCallScreen = parent;
    mCM = PhoneApp.getInstance().mCM;

    // The passed-in DTMFTwelveKeyDialerView *should* always be
    // non-null, now that the in-call UI uses only portrait mode.
    if (dialerView == null) {
        Log.e(LOG_TAG, "DTMFTwelveKeyDialer: null dialerView!", new IllegalStateException());
        // ...continue as best we can, although things will
        // be pretty broken without the mDialerView UI elements!
    }
    mDialerView = dialerView;
    if (DBG) log("- Got passed-in mDialerView: " + mDialerView);

    mDialerDrawer = dialerDrawer;
    if (DBG) log("- Got passed-in mDialerDrawer: " + mDialerDrawer);

    if (mDialerView != null) {
        mDialerView.setDialer(this);

        // In the normal in-call DTMF dialpad, mDialpadDigits is an
        // EditText used to display the digits the user has typed so
        // far.  But some other modes (like the OTA call) have no
        // "digits" display at all, in which case mDialpadDigits will
        // be null.
        mDialpadDigits = (EditText) mDialerView.findViewById(R.id.dtmfDialerField);
        if (mDialpadDigits != null) {
            mDialerKeyListener = new DTMFKeyListener();
            mDialpadDigits.setKeyListener(mDialerKeyListener);

            // remove the long-press context menus that support
            // the edit (copy / paste / select) functions.
            mDialpadDigits.setLongClickable(false);

            // TODO: may also want this at some point:
            // mDialpadDigits.setMovementMethod(new DTMFDisplayMovementMethod());
        }

        // Hook up touch / key listeners for the buttons in the onscreen
        // keypad.
        setupKeypad(mDialerView);
    }

    if (mDialerDrawer != null) {
        mDialerDrawer.setOnDrawerOpenListener(this);
        mDialerDrawer.setOnDrawerCloseListener(this);
    }

}
 
Example 42
Project: client   File: StringWidget.java View source code 5 votes vote down vote up
protected StringWidget(Context context, FormEntryPrompt prompt, boolean readOnlyOverride, boolean derived) {
        super(context, prompt);
        mAnswer =
                (EditText) LayoutInflater.from(context).inflate(R.layout.template_edit_text, null);
        mAnswer.setId(QuestionWidget.newUniqueId());
        mReadOnly = prompt.isReadOnly() || readOnlyOverride;

//        mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

//        TableLayout.LayoutParams params = new TableLayout.LayoutParams();
//        params.width = LayoutParams.MATCH_PARENT;
//        params.height = LayoutParams.WRAP_CONTENT;

        /**
         * If a 'rows' attribute is on the input tag, set the minimum number of lines
         * to display in the field to that value.
         *
         * I.e.,
         * <input ref="foo" rows="5">
         *   ...
         * </input>
         *
         * will set the height of the EditText box to 5 rows high.
         */
        String height = prompt.getQuestion().getAdditionalAttribute(null, ROWS);
        if (height == null || height.equals("1")) {
            mAnswer.setSingleLine();
        } else {
            mAnswer.setSingleLine(false);
            mAnswer.setHorizontallyScrolling(false);
        }

        if ( height != null && height.length() != 0 ) {
        	try {
	        	int rows = Integer.valueOf(height);
	        	mAnswer.setMinLines(rows);
	        	mAnswer.setGravity(Gravity.TOP); // to write test starting at the top of the edit area
        	} catch (Exception e) {
        		Log.e(this.getClass().getName(), "Unable to process the rows setting for the answer field: " + e.toString());
        	}
        }

//        params.setMargins(7, 5, 7, 5);
//        mAnswer.setLayoutParams(params);

        // capitalize the first letter of the sentence
        mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));

        // needed to make long read only text scroll
//        mAnswer.setHorizontallyScrolling(false);
//        mAnswer.setSingleLine(false);

        String s = prompt.getAnswerText();
        if (s != null) {
            mAnswer.setText(s);
        }

        if (mReadOnly) {
            mAnswer.setBackgroundDrawable(null);
            mAnswer.setFocusable(false);
            mAnswer.setClickable(false);
        }

        addView(mAnswer);
    }
 
Example 43
Project: android-3d-carousel-view   File: MainActivity.java View source code 5 votes vote down vote up
@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      
      //no keyboard unless requested by user
    	getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
    		
      // compute screen size and scaling
   	Singleton.getInstance().InitGUIFrame(this);
   	
   	int padding = m_Inst.Scale(10);
// create the interface : full screen container
RelativeLayout panel  = new RelativeLayout(this);
   panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
panel.setPadding(padding, padding, padding, padding);
   panel.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, 
   		new int[]{Color.WHITE, Color.GRAY}));
   setContentView(panel); 
   
   // copy images from assets to sdcard
   AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma1.png", "plasma1.png", false);
   AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma2.png", "plasma2.png", false);
   AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma3.png", "plasma3.png", false);
   AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma4.png", "plasma4.png", false);
   
   //Create carousel view documents
   ArrayList<CarouselDataItem> Docus = new ArrayList<CarouselDataItem>();
   for (int i=0;i<1000;i++) {
   	CarouselDataItem docu;
       if (i%4==0) docu = new CarouselDataItem("/mnt/sdcard/plasma1.png", 0, "First Image "+i);
      	else if (i%4==1) docu = new CarouselDataItem("/mnt/sdcard/plasma2.png", 0, "Second Image "+i);
       else if (i%4==2) docu = new CarouselDataItem("/mnt/sdcard/plasma3.png", 0, "Third Image "+i);
       else docu = new CarouselDataItem("/mnt/sdcard/plasma4.png", 0, "4th Image "+i);
       Docus.add(docu);
   } 
   
   // add the serach filter
   EditText etSearch = new EditText(this);
   etSearch.setHint("Search your documents");
   etSearch.setSingleLine();
   etSearch.setTextColor(Color.BLACK);
   etSearch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_search, 0, 0, 0);
   AppUtils.AddView(panel, etSearch, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 
   		new int[][]{new int[]{RelativeLayout.CENTER_HORIZONTAL}, new int[]{RelativeLayout.ALIGN_PARENT_TOP}}, -1,-1);
   etSearch.addTextChangedListener((TextWatcher) this); 

   // add logo
   TextView tv = new TextView(this);
   tv.setTextColor(Color.BLACK);
   tv.setText("www.pocketmagic.net");
   AppUtils.AddView(panel, tv, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 
   		new int[][]{new int[]{RelativeLayout.CENTER_HORIZONTAL}, new int[]{RelativeLayout.ALIGN_PARENT_BOTTOM}}, -1,-1);
   
   // create the carousel
   CarouselView coverFlow = new CarouselView(this);
      
   // create adapter and specify device independent items size (scaling)
   // for more details see: http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/
   m_carouselAdapter =  new CarouselViewAdapter(this,Docus, m_Inst.Scale(400),m_Inst.Scale(300));
      coverFlow.setAdapter(m_carouselAdapter);
      coverFlow.setSpacing(-1*m_Inst.Scale(150));
      coverFlow.setSelection(Integer.MAX_VALUE / 2, true);
      coverFlow.setAnimationDuration(1000);
      coverFlow.setOnItemSelectedListener((OnItemSelectedListener) this);

      AppUtils.AddView(panel, coverFlow, LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT, 
      		new int[][]{new int[]{RelativeLayout.CENTER_IN_PARENT}},
      		-1, -1); 
  }