List of usage examples for android.widget ScrollView ScrollView
public ScrollView(Context context)
From source file:com.blueoxfords.peacecorpstinder.activities.MainActivity.java
public void getLegalInfo(View v) { String photoId = v.getTag() + ""; ImageRestClient.get().getInfoFromImageId(photoId, new Callback<ImageService.ImageInfoWrapper>() { @Override/*w w w . j a v a 2 s . c o m*/ public void success(ImageService.ImageInfoWrapper imageInfoWrapper, Response response) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.activity); ScrollView wrapper = new ScrollView(MainActivity.activity); LinearLayout infoLayout = new LinearLayout(MainActivity.activity); infoLayout.setOrientation(LinearLayout.VERTICAL); infoLayout.setPadding(35, 35, 35, 35); TextView imageOwner = new TextView(MainActivity.activity); imageOwner.setText(Html.fromHtml("<b>Image By: </b>" + imageInfoWrapper.photo.owner.username)); if (imageInfoWrapper.photo.owner.realname.length() > 0) { imageOwner.setText(imageOwner.getText() + " (" + imageInfoWrapper.photo.owner.realname + ")"); } infoLayout.addView(imageOwner); if (getLicenseUrl(Integer.parseInt(imageInfoWrapper.photo.license)).length() > 0) { TextView licenseLink = new TextView(MainActivity.activity); licenseLink.setText(Html .fromHtml("<a href=\"" + getLicenseUrl(Integer.parseInt(imageInfoWrapper.photo.license)) + "\"><b>Licensing</b></a>")); licenseLink.setMovementMethod(LinkMovementMethod.getInstance()); infoLayout.addView(licenseLink); } if (imageInfoWrapper.photo.urls.url.size() > 0) { TextView imageLink = new TextView(MainActivity.activity); imageLink.setText(Html.fromHtml("<a href=\"" + imageInfoWrapper.photo.urls.url.get(0)._content + "\"><b>Image Link</b></a>")); imageLink.setMovementMethod(LinkMovementMethod.getInstance()); infoLayout.addView(imageLink); } if (imageInfoWrapper.photo.title._content.length() > 0) { TextView photoTitle = new TextView(MainActivity.activity); photoTitle .setText(Html.fromHtml("<b>Image Title: </b>" + imageInfoWrapper.photo.title._content)); infoLayout.addView(photoTitle); } if (imageInfoWrapper.photo.description._content.length() > 0) { TextView description = new TextView(MainActivity.activity); description.setText(Html .fromHtml("<b>Image Description: </b>" + imageInfoWrapper.photo.description._content)); infoLayout.addView(description); } TextView contact = new TextView(MainActivity.activity); contact.setText( Html.fromHtml("<br><i>To remove this photo, please email pcorpsconnect@gmail.com</i>")); infoLayout.addView(contact); wrapper.addView(infoLayout); builder.setTitle("Photo Information"); builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.setView(wrapper); builder.create().show(); } @Override public void failure(RetrofitError error) { Log.i("testing", "could not retrieve legal/attribution info"); } }); }
From source file:eu.geopaparazzi.library.forms.views.GPictureView.java
/** * @param noteId the id of the note this image belows to. * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent/*from w w w . j a v a 2 s .c o m*/ * @param key key * @param value in case of pictures, the value are the ids of the image, semicolonseparated. * @param constraintDescription constraints */ public GPictureView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String key, String value, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); _value = value; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(key.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.take_picture); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences); String imageName = ImageUtilities.getCameraImageName(null); Intent cameraIntent = new Intent(activity, CameraActivity.class); cameraIntent.putExtra(LibraryConstants.PREFS_KEY_CAMERA_IMAGENAME, imageName); cameraIntent.putExtra(LibraryConstants.DATABASE_ID, noteId); if (gpsLocation != null) { cameraIntent.putExtra(LibraryConstants.LATITUDE, gpsLocation[1]); cameraIntent.putExtra(LibraryConstants.LONGITUDE, gpsLocation[0]); cameraIntent.putExtra(LibraryConstants.ELEVATION, gpsLocation[2]); } fragmentDetail.startActivityForResult(cameraIntent, requestCode); } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); scrollView.setLayoutParams(scrollLayoutParams); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); imageLayout.setLayoutParams(imageLayoutParams); imageLayout.setOrientation(LinearLayout.HORIZONTAL); scrollView.addView(imageLayout); try { refresh(activity); } catch (Exception e) { GPLog.error(this, null, e); } }
From source file:eu.geopaparazzi.library.forms.views.GSketchView.java
/** * @param noteId the id of the note this image belows to. * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent/* w ww.j a va 2 s .c om*/ * @param key key * @param value value * @param constraintDescription constraints */ public GSketchView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String key, String value, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); this.noteId = noteId; _value = value; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(key.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.draw_sketch); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences); Date currentDate = new Date(); String sketchImageName = ImageUtilities.getSketchImageName(currentDate); File tempDir = ResourcesManager.getInstance(getContext()).getTempDir(); File sketchFile = new File(tempDir, sketchImageName); /* * open markers for new sketch */ MarkersUtilities.launch(fragmentDetail, sketchFile, gpsLocation, requestCode); } catch (Exception e) { e.printStackTrace(); } } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.FILL_PARENT, 150); scrollView.setLayoutParams(scrollLayoutParams); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); imageLayout.setLayoutParams(imageLayoutParams); // imageLayout.setMinimumHeight(200); imageLayout.setOrientation(LinearLayout.HORIZONTAL); scrollView.addView(imageLayout); // scrollView.setFillViewport(true); try { refresh(activity); } catch (Exception e) { GPLog.error(this, null, e); } }
From source file:com.github.wakhub.monodict.activity.settings.DownloadsActivity.java
@ItemClick(android.R.id.list) void onClickListItem(int position) { final DownloadsItem item = listAdapter.getItem(position); TextView textView = new TextView(this); textView.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES); textView.setPadding((int) spaceRelax, (int) spaceRelax, (int) spaceRelax, (int) spaceRelax); textView.setText(String.format("%s\nsize: %s", item.getDescription(), item.getSize())); ScrollView scrollView = new ScrollView(this); scrollView.addView(textView);//from w w w .ja v a 2s . c o m new AlertDialog.Builder(this) .setPositiveButton(R.string.action_download, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { resultIntent.putExtra(RESULT_INTENT_ENGLISH, item.isEnglish()); resultIntent.putExtra(RESULT_INTENT_FILENAME, item.getName()); startDownload(item); } }).setNegativeButton(android.R.string.cancel, null).setIcon(R.drawable.ic_action_download) .setTitle(item.getName()).setView(scrollView).show(); }
From source file:com.ryan.ryanreader.activities.PostSubmitActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit); typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type); usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username); subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit); titleEdit = (EditText) layout.findViewById(R.id.post_submit_title); textEdit = (EditText) layout.findViewById(R.id.post_submit_body); if (getIntent() != null && getIntent().hasExtra("subreddit")) { final String subreddit = getIntent().getStringExtra("subreddit"); if (subreddit != null && subreddit.length() > 0 && !subreddit.equals("all") && subreddit.matches("\\w+")) { subredditEdit.setText(subreddit); }/*from w ww . ja va 2 s . c o m*/ } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) { titleEdit.setText(savedInstanceState.getString("post_title")); textEdit.setText(savedInstanceState.getString("post_body")); subredditEdit.setText(savedInstanceState.getString("subreddit")); typeSpinner.setSelection(savedInstanceState.getInt("post_type")); } final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts(); final ArrayList<String> usernames = new ArrayList<String>(); for (RedditAccount account : accounts) { if (!account.isAnonymous()) { usernames.add(account.username); } } if (usernames.size() == 0) { General.quickToast(this, R.string.error_toast_notloggedin); finish(); } usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames)); typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes)); // TODO remove the duplicate code here if (typeSpinner.getSelectedItem().equals("Link")) { textEdit.setHint("URL"); // TODO string textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); textEdit.setSingleLine(true); } else { textEdit.setHint("Self Text"); // TODO string textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_MULTI_LINE); textEdit.setSingleLine(false); } typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (typeSpinner.getSelectedItem().equals("Link")) { textEdit.setHint("URL"); // TODO string textEdit.setInputType( android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); textEdit.setSingleLine(true); } else { textEdit.setHint("Self Text"); // TODO string textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_MULTI_LINE); textEdit.setSingleLine(false); } } public void onNothingSelected(AdapterView<?> parent) { } }); final ScrollView sv = new ScrollView(this); sv.addView(layout); setContentView(sv); }
From source file:com.sastra.app.timetable.TimetableActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.timetable_main); Log.d(TAG, "Entered On Create"); ActionBar Bar = getActionBar();/* w ww. j ava 2 s .co m*/ Bar.setLogo(R.drawable.ic_launcher_1); //Bar.setTitle(""); // String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/SASTRA Timetable/files/test.txt"; SharedPreferences mPreferences = this.getSharedPreferences("AB", MODE_PRIVATE); boolean firstTime = mPreferences.getBoolean("firstTime", true); if (firstTime) { SharedPreferences.Editor editor = mPreferences.edit(); editor.putBoolean("firstTime", false); editor.commit(); Dialog d2 = new Dialog(this); d2.setTitle("HELP"); d2.setCanceledOnTouchOutside(true); TextView tv = new TextView(this); tv.setText( "This application can be used to store your timetable.First,click on Manage Subjects Icon(Wrench Icon) inorder to add all your subjects.Click on Add Subjects on top and enter the details of your subject.The fields that appear are optional and not manditory.Once you have added all the subjects,go back to the main screen and click on Add Classes icon(Plus Icon) to add the different classes to your timetable.The fields that appear are again optional and all of them need not be filled.You can long press on any particular subject to edit or delete them.You can delete all the informations using Delete All(Garbage Icon) option."); ScrollView sav = new ScrollView(this); sav.addView(tv); LayoutParams lap = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); d2.addContentView(sav, lap); d2.show(); } boolean enabled = true; Bar.setHomeButtonEnabled(enabled); //File database=getApplicationContext().getDatabasePath("massey.db"); // if (database.exists()) { data = new InternalDB(this); // } // add fragments mFragments = new ArrayList<Fragment>(); mFragments.add(Fragment.instantiate(this, MONDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, TUESDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, WEDNESDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, THURSDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, FRIDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, SATURDAYFRAGMENT)); // adapter mAdapter = new MainPagerAdapter(getSupportFragmentManager(), mFragments); // pager mPager = (ViewPager) findViewById(R.id.view_pager); mPager.setAdapter(mAdapter); // indicator mIndicator = (TitlePageIndicator) findViewById(R.id.title_indicator); //mIndicator.setBackgroundColor(0x0106000e); //mIndicator.setFooterColor(0xffffff); mIndicator.setTextColor(0xFF000000); mIndicator.setSelectedColor(0xFF000000); mIndicator.setViewPager(mPager); intent = new Intent(getApplicationContext(), AddSubjects.class);//intent = new Intent(getApplicationContext(), AddSubjects.class); builder = new AlertDialog.Builder(this); builder.setMessage("Are you sure you want to delete all lessons?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { data.open(); data.deleteAllHours(); data.close(); // update(); mAdapter.notifyDataSetChanged(); mAdapter.finishUpdate(mPager); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alert = builder.create(); builder2 = new AlertDialog.Builder(this); builder2.setMessage("Are you sure you want to delete this lesson?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { data.open(); data.deleteHour(OLDSName, OLDHDay, OLDHType, OLDHClass, OLDHStart, OLDHEnd); data.close(); //update(); mAdapter.notifyDataSetChanged(); mAdapter.finishUpdate(mPager); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alert2 = builder2.create(); //added addDialog = new Dialog(this); addDialog.setCancelable(false); action = "insert"; addDialog.setTitle("Add Class"); addDialog.setContentView(R.layout.timetable_addhour); HType = (EditText) addDialog.findViewById(R.id.typeEdit); HClass = (EditText) addDialog.findViewById(R.id.classroomEdit); arraydays = new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; HDay = (Spinner) addDialog.findViewById(R.id.day); arrayadapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, arraydays); arrayadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); HDay.setAdapter(arrayadapter); HDay.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { selectedDay = arraydays[position]; } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); fromDialog = new TimePickerDialog(this, fromTimeSetListener, 12, 0, true); toDialog = new TimePickerDialog(this, toTimeSetListener, 12, 0, true); //This place is important. SName = (Spinner) addDialog.findViewById(R.id.SName); SName.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { selectedSubject = (String) arraySubjects[position]; Log.d("AB", "We are inside the setOnItemSelectedListener for Sname : 264"); Log.d("AB", selectedSubject); } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); Button buttonFrom = (Button) addDialog.findViewById(R.id.buttonFrom); buttonFrom.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { fromDialog.show(); } }); Button buttonTo = (Button) addDialog.findViewById(R.id.buttonTo); buttonTo.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { toDialog.show(); } }); start = (TextView) addDialog.findViewById(R.id.start); end = (TextView) addDialog.findViewById(R.id.end); Button cancel = (Button) addDialog.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { addDialog.cancel(); fromDialog.updateTime(12, 0); toDialog.updateTime(12, 0); start.setText("--:--"); end.setText("--:--"); HType.setText(null); HClass.setText(null); } }); Button ok = (Button) addDialog.findViewById(R.id.ok); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { int HDay = SDay2IDay(selectedDay); if (action.equals("insert")) { data.open(); data.insertIntoHours(selectedSubject, HDay, HType.getText().toString(), HClass.getText().toString(), start.getText().toString(), end.getText().toString()); data.close(); } else if (action.equals("edit")) { data.open(); data.updateHours(OLDSName, OLDHType, OLDHClass, OLDHDay, OLDHStart, OLDHEnd, selectedSubject, HDay, HType.getText().toString(), HClass.getText().toString(), start.getText().toString(), end.getText().toString()); data.close(); } addDialog.cancel(); fromDialog.updateTime(12, 0); toDialog.updateTime(12, 0); start.setText("--:--"); end.setText("--:--"); HType.setText(null); HClass.setText(null); mAdapter.notifyDataSetChanged(); //update(); mAdapter.finishUpdate(mPager); } }); }
From source file:org.openremote.android.console.AppSettingsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setTitle(R.string.settings);/*from w w w . j a va 2 s .co m*/ this.autoMode = AppSettingsModel.isAutoMode(AppSettingsActivity.this); // The main layout contains all application configuration items. LinearLayout mainLayout = new LinearLayout(this); mainLayout .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mainLayout.setOrientation(LinearLayout.VERTICAL); mainLayout.setBackgroundColor(0); mainLayout.setTag(R.string.settings); loadingPanelProgress = new ProgressDialog(this); // The scroll view contains appSettingsView, and make the appSettingsView can be scrolled. ScrollView scroll = new ScrollView(this); scroll.setVerticalScrollBarEnabled(true); scroll.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1)); appSettingsView = new LinearLayout(this); appSettingsView .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); appSettingsView.setOrientation(LinearLayout.VERTICAL); appSettingsView.addView(createAutoLayout()); appSettingsView.addView(createChooseControllerLabel()); currentServer = ""; if (autoMode) { appSettingsView.addView(constructAutoServersView()); } else { appSettingsView.addView(constructCustomServersView()); } appSettingsView.addView(createChoosePanelLabel()); panelSelectSpinnerView = new PanelSelectSpinnerView(this); appSettingsView.addView(panelSelectSpinnerView); appSettingsView.addView(createCacheText()); appSettingsView.addView(createClearImageCacheButton()); appSettingsView.addView(createSSLLayout()); scroll.addView(appSettingsView); mainLayout.addView(scroll); mainLayout.addView(createDoneAndCancelLayout()); setContentView(mainLayout); initSSLState(); addOnclickListenerOnDoneButton(); addOnclickListenerOnCancelButton(); progressLayout = (LinearLayout) findViewById(R.id.choose_controller_progress); }
From source file:br.org.funcate.dynamicforms.views.GPictureView.java
/** * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent/* w ww . j a v a 2 s .c o m*/ * @param label label * @param pictures the value are the ids and binary data of the images. * @param constraintDescription constraints */ public GPictureView(final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String label, Map<String, Map<String, String>> pictures, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); thumbnailWidth = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_width); thumbnailHeight = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_height); mFragmentDetail = fragmentDetail; _pictures = pictures; PICTURE_VIEW_RESULT = requestCode; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setPadding(10, 5, 10, 5); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); String t = label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription; textView.setText(t); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.take_picture); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(activity, CameraActivity.class); cameraIntent.putExtra(FormUtilities.MAIN_APP_WORKING_DIRECTORY, fragmentDetail.getWorkingDirectory()); fragmentDetail.startActivityForResult(cameraIntent, requestCode); } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); scrollView.setLayoutParams(scrollLayoutParams); scrollView.setHorizontalScrollBarEnabled(true); scrollView.setOverScrollMode(HorizontalScrollView.OVER_SCROLL_ALWAYS); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageLayout.setLayoutParams(imageLayoutParams); imageLayout.setPadding(15, 5, 15, 5); imageLayout.setOrientation(LinearLayout.HORIZONTAL); imageLayout.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); scrollView.addView(imageLayout); updateValueForm(); try { refresh(activity); } catch (Exception e) { //GPLog.error(this, null, e); e.printStackTrace(); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
From source file:org.telegram.ui.TwoStepVerificationActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/*from w ww . j a v a 2 s . c om*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { processDone(); } } }); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ActionBarMenu menu = actionBar.createMenu(); doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); scrollView = new ScrollView(context); scrollView.setFillViewport(true); frameLayout.addView(scrollView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) scrollView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; scrollView.setLayoutParams(layoutParams); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); scrollView.addView(linearLayout); ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams(); layoutParams2.width = ScrollView.LayoutParams.MATCH_PARENT; layoutParams2.height = ScrollView.LayoutParams.WRAP_CONTENT; linearLayout.setLayoutParams(layoutParams2); titleTextView = new TextView(context); //titleTextView.setTextColor(0xff757575); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); linearLayout.addView(titleTextView); LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) titleTextView.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = Gravity.CENTER_HORIZONTAL; layoutParams3.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams3); 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); passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setTypeface(Typeface.DEFAULT); AndroidUtilities.clearCursorDrawable(passwordEditText); linearLayout.addView(passwordEditText); layoutParams3 = (LinearLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams3.topMargin = AndroidUtilities.dp(32); layoutParams3.height = AndroidUtilities.dp(36); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); layoutParams3.gravity = Gravity.TOP | Gravity.LEFT; layoutParams3.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams3); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_NEXT || i == EditorInfo.IME_ACTION_DONE) { processDone(); return true; } return false; } }); 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; } }); bottomTextView = new TextView(context); //bottomTextView.setTextColor(0xff757575); bottomTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); bottomTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); bottomTextView.setText(LocaleController.getString("YourEmailInfo", R.string.YourEmailInfo)); linearLayout.addView(bottomTextView); layoutParams3 = (LinearLayout.LayoutParams) bottomTextView.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP; layoutParams3.topMargin = AndroidUtilities.dp(30); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); bottomTextView.setLayoutParams(layoutParams3); LinearLayout linearLayout2 = new LinearLayout(context); linearLayout2.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL); linearLayout.addView(linearLayout2); layoutParams3 = (LinearLayout.LayoutParams) linearLayout2.getLayoutParams(); layoutParams3.width = LayoutHelper.MATCH_PARENT; layoutParams3.height = LayoutHelper.MATCH_PARENT; linearLayout2.setLayoutParams(layoutParams3); bottomButton = new TextView(context); bottomButton.setTextColor(0xff4d83b3); bottomButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); bottomButton.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM); bottomButton.setText(LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip)); bottomButton.setPadding(0, AndroidUtilities.dp(10), 0, 0); linearLayout2.addView(bottomButton); layoutParams3 = (LinearLayout.LayoutParams) bottomButton.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; layoutParams3.bottomMargin = AndroidUtilities.dp(14); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); bottomButton.setLayoutParams(layoutParams3); bottomButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (type == 0) { if (currentPassword.has_recovery) { needShowProgress(); TLRPC.TL_auth_requestPasswordRecovery req = new TLRPC.TL_auth_requestPasswordRecovery(); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { needHideProgress(); if (error == null) { final TLRPC.TL_auth_passwordRecovery res = (TLRPC.TL_auth_passwordRecovery) response; AlertDialog.Builder builder = new AlertDialog.Builder( getParentActivity()); builder.setMessage(LocaleController.formatString("RestoreEmailSent", R.string.RestoreEmailSent, res.email_pattern)); builder.setTitle( LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity( 1); fragment.currentPassword = currentPassword; fragment.currentPassword.email_unconfirmed_pattern = res.email_pattern; fragment.passwordSetState = 4; presentFragment(fragment); } }); Dialog dialog = showDialog(builder.create()); if (dialog != null) { dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); } } else { if (error.text.startsWith("FLOOD_WAIT")) { int time = Utilities.parseInt(error.text); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } showAlertWithText( LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); } else { showAlertWithText( LocaleController.getString("AppName", R.string.AppName), error.text); } } } }); } }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); } else { showAlertWithText( LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle), LocaleController.getString("RestorePasswordNoEmailText", R.string.RestorePasswordNoEmailText)); } } else { if (passwordSetState == 4) { showAlertWithText( LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle), LocaleController.getString("RestoreEmailTroubleText", R.string.RestoreEmailTroubleText)); } else { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("YourEmailSkipWarningText", R.string.YourEmailSkipWarningText)); builder.setTitle( LocaleController.getString("YourEmailSkipWarning", R.string.YourEmailSkipWarning)); builder.setPositiveButton( LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { email = ""; setNewPassword(false); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } } } }); if (type == 0) { progressView = new FrameLayout(context); frameLayout.addView(progressView); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; progressView.setLayoutParams(layoutParams); progressView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressView.setLayoutParams(layoutParams); listView = new ListView(context); listView.setDivider(null); listView.setEmptyView(progressView); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); 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 == setPasswordRow || i == changePasswordRow) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(1); fragment.currentPasswordHash = currentPasswordHash; fragment.currentPassword = currentPassword; presentFragment(fragment); } else if (i == setRecoveryEmailRow || i == changeRecoveryEmailRow) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(1); fragment.currentPasswordHash = currentPasswordHash; fragment.currentPassword = currentPassword; fragment.emailOnly = true; fragment.passwordSetState = 3; presentFragment(fragment); } else if (i == turnPasswordOffRow || i == abortPasswordRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("TurnPasswordOffQuestion", R.string.TurnPasswordOffQuestion)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { setNewPassword(true); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } } }); updateRows(); actionBar.setTitle(LocaleController.getString("TwoStepVerification", R.string.TwoStepVerification)); titleTextView.setText( LocaleController.getString("PleaseEnterCurrentPassword", R.string.PleaseEnterCurrentPassword)); } else if (type == 1) { setPasswordSetState(passwordSetState); } return fragmentView; }
From source file:jp.mau.twappremover.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { ScrollView contents = new ScrollView(this); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); contents.addView(layout);//from www .ja v a 2s .c o m AssetManager asm = getResources().getAssets(); String[] filelist = null; try { filelist = asm.list("licenses"); } catch (Exception ex) { ex.printStackTrace(); } if (filelist != null) { for (String file : filelist) { Gen.debug(file); InputStream is = null; BufferedReader br = null; String txt = ""; try { is = getAssets().open("licenses/" + file); br = new BufferedReader(new InputStreamReader(is)); String str; while ((str = br.readLine()) != null) { txt += str + "\n"; } } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (is != null) is.close(); } catch (Exception ex) { } try { if (br != null) br.close(); } catch (Exception ex) { } } TextView tv = new TextView(this); tv.setText(txt); layout.addView(tv); } } // final PopupView dialog = new PopupView(this); dialog.setDialog().setLabels(getString(R.string.activity_main_dlgtitle_oss), "") .setView(contents, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) .setCancelable(true) .setPositiveBtn(getString(R.string.activity_main_dlgbtn_oss), new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }).show(); return true; } return super.onOptionsItemSelected(item); }