List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_DONE
int IME_ACTION_DONE
To view the source code for android.view.inputmethod EditorInfo IME_ACTION_DONE.
Click Source Link
From source file:org.sufficientlysecure.keychain.ui.dialog.AddEditSmartPGPAuthorityDialogFragment.java
@NonNull @Override// w w w . j a va2 s.c om public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); mMessenger = getArguments().getParcelable(IN_MESSENGER); mAction = (Action) getArguments().getSerializable(IN_ACTION); mPosition = getArguments().getInt(IN_POSITION); if (getArguments().getString(IN_URI) == null) mURI = null; else mURI = Uri.parse(getArguments().getString(IN_URI)); CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); LayoutInflater inflater = activity.getLayoutInflater(); View view = inflater.inflate(R.layout.add_smartpgp_authority_dialog, null); alert.setView(view); mAuthorityAliasText = (EditText) view.findViewById(R.id.smartpgp_authority_alias_edit_text); mAuthorityAliasTextLayout = (TextInputLayout) view .findViewById(R.id.smartpgp_authority_alias_edit_text_layout); mAuthorityAdd = (Button) view.findViewById(R.id.smartpgp_authority_filename); mAuthorityAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { FileHelper.openDocument(AddEditSmartPGPAuthorityDialogFragment.this, null, "*/*", false, EncryptFilesFragment.REQUEST_CODE_INPUT); } }); mAuthorityAliasText.setText(getArguments().getString(IN_ALIAS)); switch (mAction) { case ADD: alert.setTitle(R.string.add_smartpgp_authority_dialog_title); break; case EDIT: case DELETE: alert.setTitle(R.string.show_smartpgp_authority_dialog_title); break; } // we don't want dialog to be dismissed on click for keyserver addition or edit, // thereby requiring the hack seen below and in onStart alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // we need to have an empty listener to prevent errors on some devices as mentioned // at http://stackoverflow.com/q/13746412/3000919 // actual listener set in onStart for adding keyservers or editing them dismiss(); } }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dismiss(); } }); switch (mAction) { case EDIT: case DELETE: alert.setNeutralButton(R.string.label_smartpgp_authority_dialog_delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { deleteAuthority(); } }); break; } // Hack to open keyboard. // This is the only method that I found to work across all Android versions // http://turbomanage.wordpress.com/2012/05/02/show-soft-keyboard-automatically-when-edittext-receives-focus/ // Notes: * onCreateView can't be used because we want to add buttons to the dialog // * opening in onActivityCreated does not work on Android 4.4 mAuthorityAliasText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { mAuthorityAliasText.post(new Runnable() { @Override public void run() { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mAuthorityAliasText, InputMethodManager.SHOW_IMPLICIT); } }); } }); mAuthorityAliasText.requestFocus(); mAuthorityAliasText.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE); mAuthorityAliasText.setOnEditorActionListener(this); return alert.show(); }
From source file:com.goftagram.telegram.ui.PasscodeActivity.java
@Override public View createView(Context context) { if (type != 3) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); }//from www . j a va 2 s . c o m actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } else if (id == pin_item) { currentPasswordType = 0; updateDropDownTextView(); } else if (id == password_item) { currentPasswordType = 1; updateDropDownTextView(); } } }); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; if (type != 0) { ActionBarMenu menu = actionBar.createMenu(); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); titleTextView = new TextView(context); titleTextView.setTextColor(0xff757575); if (type == 1) { if (UserConfig.passcodeHash.length() != 0) { titleTextView .setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode)); } else { titleTextView.setText( LocaleController.getString("EnterNewFirstPasscode", R.string.EnterNewFirstPasscode)); } } else { titleTextView .setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode)); } titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); frameLayout.addView(titleTextView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); passwordEditText.setTextColor(0xff000000); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); if (type == 1) { passcodeSetStep = 0; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); } else { passcodeSetStep = 1; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); } passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setTypeface(Typeface.DEFAULT); AndroidUtilities.clearCursorDrawable(passwordEditText); frameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(90); layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(40); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (passcodeSetStep == 0) { processNext(); return true; } else if (passcodeSetStep == 1) { processDone(); return true; } return false; } }); passwordEditText.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 (passwordEditText.length() == 4) { if (type == 2 && UserConfig.passcodeType == 0) { processDone(); } else if (type == 1 && currentPasswordType == 0) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } } } }); if (android.os.Build.VERSION.SDK_INT < 11) { passwordEditText.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.clear(); } }); } else { passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); } if (type == 1) { dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector); dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0); dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0); actionBar.addView(dropDownContainer); layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; dropDownContainer.setLayoutParams(layoutParams); dropDownContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dropDownContainer.toggleSubMenu(); } }); dropDown = new TextView(context); dropDown.setGravity(Gravity.LEFT); dropDown.setSingleLine(true); dropDown.setLines(1); dropDown.setMaxLines(1); dropDown.setEllipsize(TextUtils.TruncateAt.END); dropDown.setTextColor(0xffffffff); dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0); dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4)); dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0); dropDownContainer.addView(dropDown); layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.bottomMargin = AndroidUtilities.dp(1); dropDown.setLayoutParams(layoutParams); } else { actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); } updateDropDownTextView(); } else { actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); frameLayout.setBackgroundColor(0xfff0f0f0); listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == changePasscodeRow) { presentFragment(new PasscodeActivity(1)); } else if (i == passcodeRow) { TextCheckCell cell = (TextCheckCell) view; if (UserConfig.passcodeHash.length() != 0) { UserConfig.passcodeHash = ""; UserConfig.appLocked = false; UserConfig.saveConfig(false); int count = listView.getChildCount(); for (int a = 0; a < count; a++) { View child = listView.getChildAt(a); if (child instanceof TextSettingsCell) { TextSettingsCell textCell = (TextSettingsCell) child; textCell.setTextColor(0xffc6c6c6); break; } } cell.setChecked(UserConfig.passcodeHash.length() != 0); NotificationCenter.getInstance() .postNotificationName(NotificationCenter.didSetPasscode); } else { presentFragment(new PasscodeActivity(1)); } } else if (i == autoLockRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock)); final NumberPicker numberPicker = new NumberPicker(getParentActivity()); numberPicker.setMinValue(0); numberPicker.setMaxValue(4); if (UserConfig.autoLockIn == 0) { numberPicker.setValue(0); } else if (UserConfig.autoLockIn == 60) { numberPicker.setValue(1); } else if (UserConfig.autoLockIn == 60 * 5) { numberPicker.setValue(2); } else if (UserConfig.autoLockIn == 60 * 60) { numberPicker.setValue(3); } else if (UserConfig.autoLockIn == 60 * 60 * 5) { numberPicker.setValue(4); } numberPicker.setFormatter(new NumberPicker.Formatter() { @Override public String format(int value) { if (value == 0) { return LocaleController.getString("Disabled", R.string.Disabled); } else if (value == 1) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1)); } else if (value == 2) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5)); } else if (value == 3) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1)); } else if (value == 4) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5)); } return ""; } }); builder.setView(numberPicker); builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { which = numberPicker.getValue(); if (which == 0) { UserConfig.autoLockIn = 0; } else if (which == 1) { UserConfig.autoLockIn = 60; } else if (which == 2) { UserConfig.autoLockIn = 60 * 5; } else if (which == 3) { UserConfig.autoLockIn = 60 * 60; } else if (which == 4) { UserConfig.autoLockIn = 60 * 60 * 5; } listView.invalidateViews(); UserConfig.saveConfig(false); } }); showDialog(builder.create()); } else if (i == fingerprintRow) { UserConfig.useFingerprint = !UserConfig.useFingerprint; UserConfig.saveConfig(false); ((TextCheckCell) view).setChecked(UserConfig.useFingerprint); } } }); } return fragmentView; }
From source file:com.todoroo.astrid.notes.EditNoteActivity.java
private void setUpInterface() { timerView = commentsBar.findViewById(R.id.timer_container); commentButton = commentsBar.findViewById(R.id.commentButton); commentField = (EditText) commentsBar.findViewById(R.id.commentField); final boolean showTimerShortcut = preferences.getBoolean(R.string.p_show_timer_shortcut, false); if (showTimerShortcut) { commentField.setOnFocusChangeListener(new OnFocusChangeListener() { @Override/* w ww.j a v a 2 s. c o m*/ public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { timerView.setVisibility(View.GONE); commentButton.setVisibility(View.VISIBLE); } else { timerView.setVisibility(View.VISIBLE); commentButton.setVisibility(View.GONE); } } }); } commentField.setHorizontallyScrolling(false); commentField.setMaxLines(Integer.MAX_VALUE); commentField.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { AndroidUtilities.hideSoftInputForViews(activity, commentField); return true; } return false; } }); commentField.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { commentField.setCursorVisible(true); } }); commentField.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { commentButton.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.VISIBLE : View.GONE); if (showTimerShortcut) { timerView.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.GONE : View.VISIBLE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // } }); commentField.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (commentField.getText().length() > 0) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_NULL) { // commentField.setCursorVisible(false); addComment(); } } return false; } }); commentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { addComment(); } }); final ClearImageCallback clearImage = new ClearImageCallback() { @Override public void clearImage() { pendingCommentPicture = null; pictureButton.setImageResource(cameraButton); } }; pictureButton = (ImageButton) commentsBar.findViewById(R.id.picture); pictureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (pendingCommentPicture != null) { actFmCameraModule.showPictureLauncher(clearImage); } else { actFmCameraModule.showPictureLauncher(null); } respondToPicture = true; } }); if (!TextUtils.isEmpty(task.getNotes())) { TextView notes = new TextView(getContext()); notes.setLinkTextColor(Color.rgb(100, 160, 255)); notes.setTextSize(18); notes.setText(task.getNotes()); notes.setPadding(5, 10, 5, 10); Linkify.addLinks(notes, Linkify.ALL); } if (activity != null) { String uri = activity.getIntent().getStringExtra(TaskEditFragment.TOKEN_PICTURE_IN_PROGRESS); if (uri != null) { pendingCommentPicture = Uri.parse(uri); setPictureButtonToPendingPicture(); } } }
From source file:com.irccloud.android.activity.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xff0b2e60));/*from ww w . j a v a 2s . c o m*/ cloud.recycle(); } requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); setContentView(R.layout.activity_login); loading = findViewById(R.id.loading); connecting = findViewById(R.id.connecting); connectingMsg = (TextView) findViewById(R.id.connectingMsg); progressBar = (ProgressBar) findViewById(R.id.connectingProgress); loginHint = (LinearLayout) findViewById(R.id.loginHint); signupHint = (LinearLayout) findViewById(R.id.signupHint); hostHint = (TextView) findViewById(R.id.hostHint); login = findViewById(R.id.login); name = (EditText) findViewById(R.id.name); if (savedInstanceState != null && savedInstanceState.containsKey("name")) name.setText(savedInstanceState.getString("name")); email = (AutoCompleteTextView) findViewById(R.id.email); if (BuildConfig.ENTERPRISE) email.setHint(R.string.email_enterprise); ArrayList<String> accounts = new ArrayList<String>(); AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); for (Account a : am.getAccounts()) { if (a.name.contains("@") && !accounts.contains(a.name)) accounts.add(a.name); } if (accounts.size() > 0) email.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, accounts.toArray(new String[accounts.size()]))); if (savedInstanceState != null && savedInstanceState.containsKey("email")) email.setText(savedInstanceState.getString("email")); password = (EditText) findViewById(R.id.password); password.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { new LoginTask().execute((Void) null); return true; } return false; } }); if (savedInstanceState != null && savedInstanceState.containsKey("password")) password.setText(savedInstanceState.getString("password")); host = (EditText) findViewById(R.id.host); if (BuildConfig.ENTERPRISE) host.setText(NetworkConnection.IRCCLOUD_HOST); else host.setVisibility(View.GONE); host.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { new LoginTask().execute((Void) null); return true; } return false; } }); if (savedInstanceState != null && savedInstanceState.containsKey("host")) host.setText(savedInstanceState.getString("host")); else host.setText(getSharedPreferences("prefs", 0).getString("host", BuildConfig.HOST)); if (host.getText().toString().equals("api.irccloud.com") || host.getText().toString().equals("www.irccloud.com")) host.setText(""); loginBtn = (Button) findViewById(R.id.loginBtn); loginBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new LoginTask().execute((Void) null); } }); loginBtn.setFocusable(true); loginBtn.requestFocus(); sendAccessLinkBtn = (Button) findViewById(R.id.sendAccessLink); sendAccessLinkBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { new ResetPasswordTask().execute((Void) null); } }); nextBtn = (Button) findViewById(R.id.nextBtn); nextBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (host.getText().length() > 0) { NetworkConnection.IRCCLOUD_HOST = host.getText().toString(); trimHost(); new EnterpriseConfigTask().execute((Void) null); } } }); TOS = (TextView) findViewById(R.id.TOS); TOS.setMovementMethod(new LinkMovementMethod()); forgotPassword = (TextView) findViewById(R.id.forgotPassword); forgotPassword.setOnClickListener(forgotPasswordClickListener); enterpriseLearnMore = (TextView) findViewById(R.id.enterpriseLearnMore); enterpriseLearnMore.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (isPackageInstalled("com.irccloud.android", LoginActivity.this)) { startActivity(getPackageManager().getLaunchIntentForPackage("com.irccloud.android")); } else { try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.irccloud.android"))); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.irccloud.android"))); } } } private boolean isPackageInstalled(String packagename, Context context) { PackageManager pm = context.getPackageManager(); try { pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES); return true; } catch (NameNotFoundException e) { return false; } } }); enterpriseHint = (LinearLayout) findViewById(R.id.enterpriseHint); EnterYourEmail = (TextView) findViewById(R.id.enterYourEmail); signupHint.setOnClickListener(signupHintClickListener); loginHint.setOnClickListener(loginHintClickListener); signupBtn = (Button) findViewById(R.id.signupBtn); signupBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { new LoginTask().execute((Void) null); } }); TextView version = (TextView) findViewById(R.id.version); try { version.setText("Version " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName); } catch (NameNotFoundException e) { version.setVisibility(View.GONE); } Typeface LatoRegular = Typeface.createFromAsset(getAssets(), "Lato-Regular.ttf"); Typeface LatoLightItalic = Typeface.createFromAsset(getAssets(), "Lato-LightItalic.ttf"); for (int i = 0; i < signupHint.getChildCount(); i++) { View v = signupHint.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(LatoRegular); } } for (int i = 0; i < loginHint.getChildCount(); i++) { View v = loginHint.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(LatoRegular); } } LinearLayout IRCCloud = (LinearLayout) findViewById(R.id.IRCCloud); for (int i = 0; i < IRCCloud.getChildCount(); i++) { View v = IRCCloud.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(LatoRegular); } } notAProblem = (LinearLayout) findViewById(R.id.notAProblem); for (int i = 0; i < notAProblem.getChildCount(); i++) { View v = notAProblem.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface((i == 0) ? LatoRegular : LatoLightItalic); } } loginSignupHint = (LinearLayout) findViewById(R.id.loginSignupHint); for (int i = 0; i < loginSignupHint.getChildCount(); i++) { View v = loginSignupHint.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(LatoRegular); ((TextView) v).setOnClickListener((i == 0) ? loginHintClickListener : signupHintClickListener); } } name.setTypeface(LatoRegular); email.setTypeface(LatoRegular); password.setTypeface(LatoRegular); host.setTypeface(LatoRegular); loginBtn.setTypeface(LatoRegular); signupBtn.setTypeface(LatoRegular); TOS.setTypeface(LatoRegular); EnterYourEmail.setTypeface(LatoRegular); hostHint.setTypeface(LatoLightItalic); if (BuildConfig.ENTERPRISE) { name.setVisibility(View.GONE); email.setVisibility(View.GONE); password.setVisibility(View.GONE); loginBtn.setVisibility(View.GONE); signupBtn.setVisibility(View.GONE); TOS.setVisibility(View.GONE); signupHint.setVisibility(View.GONE); loginHint.setVisibility(View.GONE); forgotPassword.setVisibility(View.GONE); loginSignupHint.setVisibility(View.GONE); EnterYourEmail.setVisibility(View.GONE); sendAccessLinkBtn.setVisibility(View.GONE); notAProblem.setVisibility(View.GONE); enterpriseLearnMore.setVisibility(View.VISIBLE); enterpriseHint.setVisibility(View.VISIBLE); host.setVisibility(View.VISIBLE); nextBtn.setVisibility(View.VISIBLE); hostHint.setVisibility(View.VISIBLE); host.requestFocus(); } if (savedInstanceState != null && savedInstanceState.containsKey("signup") && savedInstanceState.getBoolean("signup")) { signupHintClickListener.onClick(null); } if (savedInstanceState != null && savedInstanceState.containsKey("login") && savedInstanceState.getBoolean("login")) { loginHintClickListener.onClick(null); } if (savedInstanceState != null && savedInstanceState.containsKey("forgotPassword") && savedInstanceState.getBoolean("forgotPassword")) { forgotPasswordClickListener.onClick(null); } mResolvingError = savedInstanceState != null && savedInstanceState.getBoolean("resolving_error", false); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Auth.CREDENTIALS_API) .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build(); }
From source file:ir.besteveryeverapp.ui.PasscodeActivity.java
@Override public View createView(Context context) { if (type != 3) { actionBar.setBackButtonImage(ir.besteveryeverapp.telegram.R.drawable.ic_ab_back); }/*from w w w .j a va 2 s . c o m*/ actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } else if (id == pin_item) { currentPasswordType = 0; updateDropDownTextView(); } else if (id == password_item) { currentPasswordType = 1; updateDropDownTextView(); } } }); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; if (type != 0) { ActionBarMenu menu = actionBar.createMenu(); menu.addItemWithWidth(done_button, ir.besteveryeverapp.telegram.R.drawable.ic_done, AndroidUtilities.dp(56)); titleTextView = new TextView(context); titleTextView.setTextColor(0xff757575); if (type == 1) { if (UserConfig.passcodeHash.length() != 0) { titleTextView.setText(LocaleController.getString("EnterNewPasscode", ir.besteveryeverapp.telegram.R.string.EnterNewPasscode)); } else { titleTextView.setText(LocaleController.getString("EnterNewFirstPasscode", ir.besteveryeverapp.telegram.R.string.EnterNewFirstPasscode)); } } else { titleTextView.setText(LocaleController.getString("EnterCurrentPasscode", ir.besteveryeverapp.telegram.R.string.EnterCurrentPasscode)); } titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); frameLayout.addView(titleTextView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); passwordEditText.setTextColor(0xff000000); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); if (type == 1) { passcodeSetStep = 0; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); } else { passcodeSetStep = 1; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); } passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setTypeface(Typeface.DEFAULT); AndroidUtilities.clearCursorDrawable(passwordEditText); frameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(90); layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(40); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (passcodeSetStep == 0) { processNext(); return true; } else if (passcodeSetStep == 1) { processDone(); return true; } return false; } }); passwordEditText.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 (passwordEditText.length() == 4) { if (type == 2 && UserConfig.passcodeType == 0) { processDone(); } else if (type == 1 && currentPasswordType == 0) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); if (type == 1) { dropDownContainer = new ActionBarMenuItem(context, menu, //R.drawable.bar_selector_f SkinMan.barSelector(context)); dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", ir.besteveryeverapp.telegram.R.string.PasscodePIN), 0); dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", ir.besteveryeverapp.telegram.R.string.PasscodePassword), 0); actionBar.addView(dropDownContainer); layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; dropDownContainer.setLayoutParams(layoutParams); dropDownContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dropDownContainer.toggleSubMenu(); } }); dropDown = new TextView(context); dropDown.setGravity(Gravity.LEFT); dropDown.setSingleLine(true); dropDown.setLines(1); dropDown.setMaxLines(1); dropDown.setEllipsize(TextUtils.TruncateAt.END); dropDown.setTextColor(0xffffffff); dropDown.setTypeface(FontManager.instance().getTypeface()); dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, ir.besteveryeverapp.telegram.R.drawable.ic_arrow_drop_down, 0); dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4)); dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0); dropDownContainer.addView(dropDown); layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.bottomMargin = AndroidUtilities.dp(1); dropDown.setLayoutParams(layoutParams); } else { actionBar.setTitle( LocaleController.getString("Passcode", ir.besteveryeverapp.telegram.R.string.Passcode)); } updateDropDownTextView(); } else { actionBar.setTitle( LocaleController.getString("Passcode", ir.besteveryeverapp.telegram.R.string.Passcode)); frameLayout.setBackgroundColor(0xfff0f0f0); listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == changePasscodeRow) { presentFragment(new PasscodeActivity(1)); } else if (i == passcodeRow) { TextCheckCell cell = (TextCheckCell) view; if (UserConfig.passcodeHash.length() != 0) { UserConfig.passcodeHash = ""; UserConfig.appLocked = false; UserConfig.saveConfig(false); int count = listView.getChildCount(); for (int a = 0; a < count; a++) { View child = listView.getChildAt(a); if (child instanceof TextSettingsCell) { TextSettingsCell textCell = (TextSettingsCell) child; textCell.setTextColor(0xffc6c6c6); break; } } cell.setChecked(UserConfig.passcodeHash.length() != 0); NotificationCenter.getInstance() .postNotificationName(NotificationCenter.didSetPasscode); } else { presentFragment(new PasscodeActivity(1)); } } else if (i == autoLockRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AutoLock", ir.besteveryeverapp.telegram.R.string.AutoLock)); final NumberPicker numberPicker = new NumberPicker(getParentActivity()); numberPicker.setMinValue(0); numberPicker.setMaxValue(4); if (UserConfig.autoLockIn == 0) { numberPicker.setValue(0); } else if (UserConfig.autoLockIn == 60) { numberPicker.setValue(1); } else if (UserConfig.autoLockIn == 60 * 5) { numberPicker.setValue(2); } else if (UserConfig.autoLockIn == 60 * 60) { numberPicker.setValue(3); } else if (UserConfig.autoLockIn == 60 * 60 * 5) { numberPicker.setValue(4); } numberPicker.setFormatter(new NumberPicker.Formatter() { @Override public String format(int value) { if (value == 0) { return LocaleController.getString("AutoLockDisabled", ir.besteveryeverapp.telegram.R.string.AutoLockDisabled); } else if (value == 1) { return LocaleController.formatString("AutoLockInTime", ir.besteveryeverapp.telegram.R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1)); } else if (value == 2) { return LocaleController.formatString("AutoLockInTime", ir.besteveryeverapp.telegram.R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5)); } else if (value == 3) { return LocaleController.formatString("AutoLockInTime", ir.besteveryeverapp.telegram.R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1)); } else if (value == 4) { return LocaleController.formatString("AutoLockInTime", ir.besteveryeverapp.telegram.R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5)); } return ""; } }); builder.setView(numberPicker); builder.setNegativeButton( LocaleController.getString("Done", ir.besteveryeverapp.telegram.R.string.Done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { which = numberPicker.getValue(); if (which == 0) { UserConfig.autoLockIn = 0; } else if (which == 1) { UserConfig.autoLockIn = 60; } else if (which == 2) { UserConfig.autoLockIn = 60 * 5; } else if (which == 3) { UserConfig.autoLockIn = 60 * 60; } else if (which == 4) { UserConfig.autoLockIn = 60 * 60 * 5; } listView.invalidateViews(); UserConfig.saveConfig(false); } }); showDialog(builder.create()); } else if (i == fingerprintRow) { UserConfig.useFingerprint = !UserConfig.useFingerprint; UserConfig.saveConfig(false); ((TextCheckCell) view).setChecked(UserConfig.useFingerprint); } } }); } NightModeUtil.dark(fragmentView); FontManager.instance().setTypefaceImmediate(fragmentView); return fragmentView; }
From source file:com.watasan.infospider.fragment.PrimitiveFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { /** Animation <------------------------------------------------------> */ // ?/*from w w w . ja va2 s.co m*/ this.mShapeWidth = (int) (Factory.getMaxWidthI() / 4); this.mPaddingW = (float) (this.mShapeWidth / 2); this.mPaddingH = (float) (this.mShapeWidth / 2); String padding = getString(R.dimen.padding_m); // xml???padding10???????? String[] paddingArray = padding.split("\\Q.\\E"); this.mImageWidth = this.mShapeWidth - (int) (Integer.parseInt(paddingArray[0]) * Factory.getDensity()) * 2; // this.mImageWidth = this.mShapeWidth - (int)(10 * Factory.getDensity()) * 2; /** Layout <---------------------------------------------------------> */ // Inflate the layout containing a title and body text. mRootView = (ViewGroup) inflater.inflate(R.layout.primitive_fragment, container, false); // ? FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); ((FrameLayout) mRootView.findViewById(R.id.FLBackLayer)).setLayoutParams(layoutParams); // ? FrameLayout.LayoutParams layoutParamsForFrame = new FrameLayout.LayoutParams(this.mShapeWidth, this.mShapeWidth); ((RelativeLayout) mRootView.findViewById(R.id.RLFrameLayer)).setLayoutParams(layoutParamsForFrame); // ? RelativeLayout.LayoutParams layoutParamsForImage = new RelativeLayout.LayoutParams(this.mImageWidth, this.mImageWidth); // layoutParamsForImage.setMargins(100, 300, 0, 0); ((ImageView) mRootView.findViewById(R.id.IBBackImage)).setLayoutParams(layoutParamsForImage); // ? RelativeLayout.LayoutParams layoutParamsForText = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); ((TextView) mRootView.findViewById(R.id.TVText)).setLayoutParams(layoutParamsForText); ((TextView) mRootView.findViewById(R.id.TVText)) .setText(getString(R.string.title_template_step, mPageNumber + 1)); // testAnimation((float)mPageNumber * mShapeWidth, Factory.getMaxHeightF() - mShapeWidth); /** */ this.mGroupTitle = (EditText) mRootView.findViewById(R.id.groupTitle); this.mGroupTitle.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { refreshImage(null); } return false; } }); // 1. ?????? mGroupTitle.setFocusableInTouchMode(false); // 2. ? mGroupTitle.clearFocus(); return mRootView; }
From source file:nu.yona.app.ui.profile.EditDetailsProfileFragment.java
private void inflateView(View view) { firstnameLayout = view.findViewById(R.id.first_name_layout); lastNameLayout = view.findViewById(R.id.last_name_layout); nickNameLayout = view.findViewById(R.id.nick_name_layout); mobileNumberLayout = view.findViewById(R.id.mobile_number_layout); firstName = view.findViewById(R.id.first_name); firstName.addTextChangedListener(textWatcher); firstName.setOnFocusChangeListener(onFocusChangeListener); lastName = view.findViewById(R.id.last_name); lastName.addTextChangedListener(textWatcher); lastName.setOnFocusChangeListener(onFocusChangeListener); nickName = view.findViewById(R.id.nick_name); nickName.addTextChangedListener(textWatcher); nickName.setOnFocusChangeListener(onFocusChangeListener); mobileNumber = view.findViewById(R.id.mobile_number); mobileNumber.requestFocus();/*from w ww . j a v a2 s. c o m*/ YonaActivity.getActivity().showKeyboard(mobileNumber); mobileNumber.addTextChangedListener(new YonaPhoneWatcher(mobileNumber, getActivity(), null)); firstnameLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { YonaActivity.getActivity().showKeyboard(firstName); } }); lastNameLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { YonaActivity.getActivity().showKeyboard(lastName); } }); mobileNumberLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { YonaActivity.getActivity().showKeyboard(mobileNumber); } }); nickNameLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { YonaActivity.getActivity().showKeyboard(nickName); } }); mobileNumber.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { goToNext(); } return false; } }); profileImage = view.findViewById(R.id.profileImage); updateProfileImage = view.findViewById(R.id.updateProfileImage); profileImageTxt = view.findViewById(R.id.profileIcon); profileEditMode(); }
From source file:com.activiti.android.ui.fragments.form.picker.IdmPickerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getArguments() != null) { onRetrieveParameters(getArguments()); }//from w ww . jav a2 s .c o m // Create View setRootView(inflater.inflate(R.layout.fr_idm_picker, container, false)); // Init list init(getRootView(), emptyListMessageId); gv.setChoiceMode(GridView.CHOICE_MODE_SINGLE); setListShown(true); searchView = UIUtils.setActionBarCustomView(getActivity(), R.layout.person_picker_header, true); View searchBack = searchView.findViewById(R.id.search_back); searchBack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getActivity().getSupportFragmentManager().popBackStackImmediate(); } }); if (keywords != null && !keywords.isEmpty()) { search(keywords); } else { // Speech to Text hasTextToSpeech = FeatureUtils.hasSpeechToText(getActivity()); speechToText = (ImageButton) searchView.findViewById(R.id.search_microphone); if (hasTextToSpeech) { speechToText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { speechToText(); } }); } else { speechToText.setVisibility(View.GONE); } searchAction = (ImageButton) searchView.findViewById(R.id.search_start); searchAction.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (searchForm.getText().length() > 0) { keywords = searchForm.getText().toString(); search(keywords); } else { // TODO Snackbar } } }); searchAction.setVisibility(View.GONE); // Init form search searchForm = (EditText) searchView.findViewById(R.id.search_query); searchForm.requestFocus(); UIUtils.showKeyboard(getActivity(), searchForm); searchForm.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchForm.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) { if (s.length() == 0) { searchAction.setVisibility(View.GONE); if (hasTextToSpeech) { speechToText.setVisibility(View.VISIBLE); } } else { speechToText.setVisibility(View.GONE); searchAction.setVisibility(View.VISIBLE); } } }); searchForm.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null && (event.getAction() == KeyEvent.ACTION_DOWN) && ((actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) || (actionId == EditorInfo.IME_ACTION_DONE))) { if (searchForm.getText().length() > 0) { keywords = searchForm.getText().toString(); search(keywords); } else { // TODO Snackbar } return true; } return false; } }); } if (getMode() == MODE_PICK) { Button cancel = UIUtils.initCancel(getRootView(), R.string.general_action_cancel); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (getDialog() != null) { getDialog().dismiss(); } else { getFragmentManager().popBackStack(); } } }); } else { hide(R.id.validation_panel); } return getRootView(); }
From source file:org.wheelmap.android.fragment.LoginDialogFragment.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (EditorInfo.IME_ACTION_DONE == actionId) { if (checkInputFields(v)) { login();/*from ww w .j av a 2 s.com*/ } return true; } return false; }
From source file:com.example.fragment.PrimitiveFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { /** Animation <------------------------------------------------------> */ // ?/*from ww w . j av a 2s . c om*/ this.mShapeWidth = (int) (Factory.getMaxWidthI() / 4); this.mPaddingW = (float) (this.mShapeWidth / 2); this.mPaddingH = (float) (this.mShapeWidth / 2); String padding = getString(R.dimen.padding_m); // xml???padding10???????? String[] paddingArray = padding.split("\\Q.\\E"); this.mImageWidth = this.mShapeWidth - (int) (Integer.parseInt(paddingArray[0]) * Factory.getDensity()) * 2; // this.mImageWidth = this.mShapeWidth - (int)(10 * Factory.getDensity()) * 2; /** Layout <---------------------------------------------------------> */ // Inflate the layout containing a title and body text. mRootView = (ViewGroup) inflater.inflate(R.layout.primitive_fragment, container, false); // ? FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); ((FrameLayout) mRootView.findViewById(R.id.FLBackLayer)).setLayoutParams(layoutParams); // ? FrameLayout.LayoutParams layoutParamsForFrame = new FrameLayout.LayoutParams(this.mShapeWidth, this.mShapeWidth); ((RelativeLayout) mRootView.findViewById(R.id.RLFrameLayer)).setLayoutParams(layoutParamsForFrame); // ? RelativeLayout.LayoutParams layoutParamsForImage = new RelativeLayout.LayoutParams(this.mImageWidth, this.mImageWidth); // layoutParamsForImage.setMargins(100, 300, 0, 0); ((ImageView) mRootView.findViewById(R.id.IBBackImage)).setLayoutParams(layoutParamsForImage); // ? RelativeLayout.LayoutParams layoutParamsForText = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); ((TextView) mRootView.findViewById(R.id.TVText)).setLayoutParams(layoutParamsForText); ((TextView) mRootView.findViewById(R.id.TVText)) .setText(getString(R.string.title_template_step, mPageNumber + 1)); // testAnimation((float)mPageNumber * mShapeWidth, Factory.getMaxHeightF() - mShapeWidth); /** Animation Factory <----------------------------------------------- */ AnimeFactory.setSrc(100.0f * (float) mPageNumber, 0.0f); AnimeFactory.setVelocity(2.0f * (float) (mPageNumber + 1), 0.0f); AnimeFactory.setAccelerate(0.0f, 0.80f); AnimeFactory.setBoundary(Factory.getMaxWidthF(), Factory.getMaxHeightF()); mAnimeItemList = AnimeFactory.makeAnimetion(); mIsAlive = true; move(0.0f, 0.0f); // ?? /** Animation Factory -----------------------------------------------> */ /** */ this.mGroupTitle = (EditText) mRootView.findViewById(R.id.groupTitle); this.mGroupTitle.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { refreshImage(null); } return false; } }); // 1. ?????? mGroupTitle.setFocusableInTouchMode(false); // 2. ? mGroupTitle.clearFocus(); /** Restore Latest State <-------------------------------------------- */ // ? restoreLatest(savedInstanceState); return mRootView; }