public void reset() { if (null != mScrollText) { mScrollText.setVisibility(View.GONE); } if (null != mImageView) { mImageView.setVisibility(View.GONE); } if (null != mAudioPlayer) { stopAudio(); } if (null != mVideoView) { stopVideo(); mVideoView.setVisibility(View.GONE); } if (null != mTextView) { mTextView.setVisibility(View.GONE); } if (mScrollViewPort != null) { mScrollViewPort.scrollTo(0, 0); mScrollViewPort.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0, 0)); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = activity.getActionBar(); View view = actionBar.getCustomView(); ImageView title_image = (ImageView) view.findViewById(R.id.title_image); title_image.setBackgroundResource(R.drawable.substancea_cs); ScrollView sv = new ScrollView(activity); sv.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); sv.setFillViewport(true); LinearLayout lay = new LinearLayout(activity); lay.setOrientation(LinearLayout.VERTICAL); lay.setBackgroundColor(Color.WHITE); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); sv.addView(lay, params); // setContentView(sv); search_lay.setOnClickListener(searchLis); search_btn.setOnClickListener(searchLis); showLinelay = new LinearLayout(activity); ((LinearLayout) showLinelay).setOrientation(LinearLayout.VERTICAL); lay.addView(showLinelay, params); initNet(); loadData(new RequestPram()); }
public View inflateViews() { mScrollView = new ScrollView(getActivity()); ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mScrollView.setLayoutParams(scrollParams); mLogView = new LogView(getActivity()); ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; mLogView.setLayoutParams(logParams); mLogView.setClickable(true); mLogView.setFocusable(true); mLogView.setTypeface(Typeface.MONOSPACE); // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! int paddingDips = 16; double scale = getResources().getDisplayMetrics().density; int paddingPixels = (int) ((paddingDips * (scale)) + .5); mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); mLogView.setCompoundDrawablePadding(paddingPixels); mLogView.setGravity(Gravity.BOTTOM); mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); mScrollView.addView(mLogView); return mScrollView; }
private View createView() { ArrayList<String> addrs = getNetworkAddresses(); ScrollView parent = new ScrollView(this); int fill = LinearLayout.LayoutParams.FILL_PARENT; int wrap = LinearLayout.LayoutParams.WRAP_CONTENT; LinearLayout.LayoutParams fillAll = new LinearLayout.LayoutParams(fill, fill); parent.setLayoutParams(fillAll); layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new LinearLayout.LayoutParams(fill, wrap)); parent.addView(layout); text(R.string.desc_setup_wifi, 20); text(R.string.desc_goto_settings); text(R.string.desc_enable_kbd); text(R.string.desc_toch_input_field); text(R.string.desc_change_input_method); text("", 15); if (addrs.size() == 0) { text("Enable wifi or GPRS/3G", 20); } else if (addrs.size() == 1) { text(getString(R.string.desc_connect_to_one, addrs.get(0), port), 20); } else { text(R.string.desc_connect_to_any); for (String addr : addrs) { text("http://" + addr + ":" + port, 20); } } text(R.string.desc_warn); text("", 15); text(R.string.desc_alt_usb_cable, 20); text(R.string.desc_adb_from_sdk); text(getString(R.string.desc_cmdline, port, port), 15); text(getString(R.string.desc_connect_local, port), 15); return parent; }
private void setLayoutFunction() { Typeface FONT = Typeface.createFromAsset(getAssets(), "fonts/KIT45.TTF"); // SET LAYOUT android.view.ViewGroup.LayoutParams L_headLayout = headLayout.getLayoutParams(); android.view.ViewGroup.LayoutParams L_imgWave = imgWave.getLayoutParams(); android.view.ViewGroup.LayoutParams L_BackBT = BackBT.getLayoutParams(); android.view.ViewGroup.LayoutParams L_typeButton = typeButton.getLayoutParams(); android.view.ViewGroup.LayoutParams L_Title = Linear_Title.getLayoutParams(); android.view.ViewGroup.LayoutParams L_Checkin = checkinBT.getLayoutParams(); android.view.ViewGroup.LayoutParams L_scDesc = scDesc.getLayoutParams(); L_headLayout.height = dx(15); L_imgWave.height = dx(10); L_BackBT.height = dx(10); L_typeButton.height = dx(10); L_typeButton.width = dx(24); L_Checkin.height = dx(20); // L_Checkin .width = dx(20); L_scDesc.height = dx(30); L_Title.height = dx(17); if (dx(20) > 100) { L_Checkin.height = 100; } BackBT.setPadding(dx(3), 0, 0, 0); typeButton.setPadding(0, 0, dx(3), 0); Linear_Title.setPadding(0, dx(2), 0, dx(2)); headLayout.setLayoutParams(L_headLayout); imgWave.setLayoutParams(L_imgWave); BackBT.setLayoutParams(L_BackBT); typeButton.setLayoutParams(L_typeButton); scDesc.setLayoutParams(L_scDesc); // FONT // txtTitle .setTextSize(dx(4)); // txtDesc .setTextSize(dx(3)); }
public void drawDetailPopup() { ScrollView scv = new ScrollView(this); scv.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); scv.setMinimumHeight(100); LinearLayout parentLinear = new LinearLayout(this); parentLinear.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); parentLinear.setOrientation(LinearLayout.VERTICAL); scv.addView(parentLinear); LinearLayout linear; TextView tv; linear = new LinearLayout(this); linear.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); linear.setOrientation(LinearLayout.HORIZONTAL); parentLinear.addView(linear); // property name tv = new TextView(this); tv.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); // tv.setWidth(80); tv.setPadding(5, 5, 5, 5); // tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); tv.setText(getResources().getString(R.string.update0001)); tv.setTextColor(Color.CYAN); linear.addView(tv); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getResources().getString(R.string.main_updateinfo)); builder.setIcon(android.R.drawable.ic_menu_info_details); builder.setView(scv); builder.setPositiveButton("OK", null); builder.show(); }
/** 初始化 */ private void init() { DisplayMetrics dm = new DisplayMetrics(); ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(dm); mDensity = dm.density; mWidth = dm.widthPixels; mFragmentManager = ((FragmentActivity) getContext()).getSupportFragmentManager(); mContainerScrollView = new NoScrollView(getContext()); mContainerLinearLayout = new LinearLayout(getContext()); LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); mContainerScrollView.setLayoutParams(layoutParams); mContainerLinearLayout.setLayoutParams(layoutParams); mContainerScrollView.addView(mContainerLinearLayout); addView(mContainerScrollView); mContainerScrollView.setVerticalScrollBarEnabled(false); mContainerLinearLayout.setOrientation(LinearLayout.VERTICAL); }
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); final LinearLayout testBed = new LinearLayout(this); testBed.setOrientation(LinearLayout.VERTICAL); testBed.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize(); final Display display = getWindowManager().getDefaultDisplay(); final int screenWidth = display.getWidth(); final int screenHeight = display.getHeight(); final View tiny = new View(this); tiny.setId(R.id.a); tiny.setBackgroundColor(0xFFFF0000); tiny.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenHeight)); final View large = new View(this); large.setId(R.id.b); large.setBackgroundColor(0xFF00FF00); // Compute the height of the view assuming a cache size based on ARGB8888 final int height = 2 * (cacheSize / 2) / screenWidth; large.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, height)); final ScrollView scroller = new ScrollView(this); scroller.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); testBed.addView(tiny); testBed.addView(large); scroller.addView(testBed); setContentView(scroller); }
@SuppressWarnings("deprecation") public VerticalScrollAutoSelector(Context context, AttributeSet attrs) { super(context, attrs); mContentScrollView = new ScrollView(context); LinearLayout.LayoutParams linearLP = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mContentScrollView.setLayoutParams(linearLP); mContentScrollView.setVerticalScrollBarEnabled(false); addView(mContentScrollView); mStartBlankView = new TextView(context); mEndBlankView = new TextView(context); mItemLayoutParams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mItemsContainer = new LinearLayout(context); mItemsContainer.setOrientation(LinearLayout.VERTICAL); mItemsContainer.setGravity(Gravity.CENTER); mItemsContainer.setLayoutParams(mItemLayoutParams); mContentScrollView.addView(mItemsContainer); mContentScrollView.setOnTouchListener(new ScrollViewOnTouchListener()); }
public AddPlayersToGameView(Context context) { this.context = context; mainScrollView = new ScrollView(context); mainScrollView.setFillViewport(true); mainScrollView.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); LinearLayout mainView = new LinearLayout(context); mainView.setGravity(Gravity.CENTER_HORIZONTAL); LinearLayout.LayoutParams mainLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); mainLayoutParams.leftMargin = UIConstants.MARGIN_SIZE; mainLayoutParams.rightMargin = UIConstants.MARGIN_SIZE; mainView.setLayoutParams(mainLayoutParams); BackgroundUtil.setBackground(mainView); mainView.setOrientation(LinearLayout.VERTICAL); mainScrollView.addView(mainView); TextView title = new TextView(context); title.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); title.setText("Add Players"); title.setTextSize(UIConstants.TEXT_TITLE_SIZE); title.setTextColor(UIConstants.TEXT_COLOR); title.setGravity(Gravity.CENTER_HORIZONTAL); mainView.addView(title); LinearLayout controlView = new LinearLayout(context); controlView.setGravity(Gravity.CENTER_HORIZONTAL); LinearLayout.LayoutParams controlViewLayouParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); controlViewLayouParams.leftMargin = UIConstants.MARGIN_SIZE; controlViewLayouParams.rightMargin = UIConstants.MARGIN_SIZE; controlView.setLayoutParams(controlViewLayouParams); controlView.setOrientation(LinearLayout.HORIZONTAL); mainView.addView(controlView); Button firstDoneButton = new Button(context); firstDoneButton.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, UIConstants.BUTTON_HEIGHT)); firstDoneButton.setText("Done"); firstDoneButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { doneButtonListenerManager.notifyListeners(); } }); controlView.addView(firstDoneButton); allPlayersTable = new TableLayout(context); allPlayersTable.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); allPlayersTable.setGravity(Gravity.CENTER_HORIZONTAL); TableLayout.LayoutParams allPlayersTableLayoutParams = new TableLayout.LayoutParams( TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT); allPlayersTableLayoutParams.leftMargin = UIConstants.MARGIN_SIZE; allPlayersTableLayoutParams.rightMargin = UIConstants.MARGIN_SIZE; allPlayersTable.setLayoutParams(allPlayersTableLayoutParams); allPlayersTable.setColumnStretchable(1, true); mainView.addView(allPlayersTable); Button secondDoneButton = new Button(context); secondDoneButton.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, UIConstants.BUTTON_HEIGHT)); secondDoneButton.setText("Done"); secondDoneButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { doneButtonListenerManager.notifyListeners(); } }); controlView.addView(secondDoneButton); }
protected void onCreate(Bundle savedInstanceState) { final FotoBot fb = (FotoBot) getApplicationContext(); super.onCreate(savedInstanceState); fb.LoadSettings(); // fb.logger.fine("Tab_Foto_Activity"); Log.d(LOG_TAG, "Tab3: onCreate"); // final FotoBot fb = (FotoBot) getApplicationContext(); Display display = getWindowManager().getDefaultDisplay(); screenWidth = display.getWidth(); screenHeight = display.getHeight(); // Main Container (Vertical LinearLayout) LinearLayout FullFrame = new LinearLayout(this); FullFrame.setOrientation(LinearLayout.VERTICAL); FullFrame.setPadding(5, 5, 5, 5); FullFrame.setBackgroundColor(Color.rgb(192, 192, 192)); LinearLayout.LayoutParams lpFull_Frame = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); FullFrame.setLayoutParams(lpFull_Frame); FullFrame.setMinimumHeight(fb.Working_Area_Height - fb.menuheight); // FullFrame.setBackgroundColor(Color.WHITE); // setContentView(FullFrame); // ------------------------------------------------------------------------------------------------ // JPEG сжатие // Контейнер для JPG сжатие RelativeLayout linLayout_JPEG_Compression = new RelativeLayout(this); // linLayout_JPEG_Compression.setOrientation(LinearLayout.HORIZONTAL); RelativeLayout.LayoutParams lpView = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams lpView_m = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams lpView_et = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); linLayout_JPEG_Compression.setBackgroundColor(Color.rgb(192, 192, 192)); // Контейнер для пояснение LinearLayout linLayout_JPEG_Compression_notes = new LinearLayout(this); linLayout_JPEG_Compression_notes.setOrientation(LinearLayout.HORIZONTAL); linLayout_JPEG_Compression_notes.setBackgroundColor(Color.rgb(192, 192, 192)); // Контейнер для разделителя LinearLayout linLayout_JPEG_Compression_divider = new LinearLayout(this); linLayout_JPEG_Compression_divider.setOrientation(LinearLayout.HORIZONTAL); linLayout_JPEG_Compression_divider.setPadding(5, 9, 5, 9); // Название TextView tv_JPEG_Compression = new TextView(this); tv_JPEG_Compression.setTypeface(Typeface.DEFAULT_BOLD); tv_JPEG_Compression.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size); tv_JPEG_Compression.setTextColor(Color.BLACK); tv_JPEG_Compression.setText(getResources().getString(R.string.jpeg_compression)); tv_JPEG_Compression.setWidth((screenWidth - padding) / 100 * 80); tv_JPEG_Compression.setLayoutParams(lpView); tv_JPEG_Compression.setTypeface(Typeface.DEFAULT_BOLD); lpView.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_JPEG_Compression.getId()); tv_JPEG_Compression.setLayoutParams(lpView); linLayout_JPEG_Compression.addView(tv_JPEG_Compression); // Ввод данных editText_JPEG_Compression = new EditText(this); editText_JPEG_Compression.setLayoutParams(lpView_et); String jpg = Integer.toString(fb.JPEG_Compression); editText_JPEG_Compression.setText(jpg); editText_JPEG_Compression.setTextColor(Color.rgb(50, 100, 150)); ViewGroup.LayoutParams lp = editText_JPEG_Compression.getLayoutParams(); lp.width = (screenWidth - padding) / 100 * 20; editText_JPEG_Compression.setLayoutParams(lp); // editText_JPEG_Compression.setGravity(Gravity.RIGHT); lpView_m.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, editText_JPEG_Compression.getId()); editText_JPEG_Compression.setLayoutParams(lpView_m); linLayout_JPEG_Compression.addView(editText_JPEG_Compression); // Заметка для JPEG сжатия TextView tv_JPEG_Compression_note = new TextView(this); tv_JPEG_Compression_note.setTypeface(null, Typeface.NORMAL); tv_JPEG_Compression_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2); tv_JPEG_Compression_note.setTextColor(Color.BLACK); tv_JPEG_Compression_note.setText( getResources().getString(R.string.jpeg_compression_description)); // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99); tv_JPEG_Compression_note.setLayoutParams(lpView); // tv_JPEG_Compression_note.setTextColor(Color.GRAY); tv_JPEG_Compression_note.setPadding(5, 9, 5, 9); linLayout_JPEG_Compression_notes.addView(tv_JPEG_Compression_note); // Разделитель View line_JPEG_Compression = new View(this); line_JPEG_Compression.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 1)); line_JPEG_Compression.setBackgroundColor(Color.rgb(210, 210, 210)); line_JPEG_Compression.getLayoutParams().height = 3; linLayout_JPEG_Compression_divider.addView(line_JPEG_Compression); // ------------------------------------------------------------------------------------------------ // Метод обработки фото // Контейнер для метода RelativeLayout linLayout_Photo_Processing_Method = new RelativeLayout(this); // linLayout_Photo_Processing_Method.setOrientation(LinearLayout.HORIZONTAL); linLayout_Photo_Processing_Method.setBackgroundColor(Color.rgb(192, 192, 192)); RelativeLayout.LayoutParams lpView_m1 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams lpView_m2 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // LinearLayout.LayoutParams lpView = new // LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, // LinearLayout.LayoutParams.WRAP_CONTENT); // LinearLayout.LayoutParams lpView_et = new // LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, // LinearLayout.LayoutParams.WRAP_CONTENT); // Контейнер для пояснение LinearLayout linLayout_Photo_Processing_Method_notes = new LinearLayout(this); linLayout_Photo_Processing_Method_notes.setOrientation(LinearLayout.HORIZONTAL); linLayout_Photo_Processing_Method_notes.setBackgroundColor(Color.rgb(192, 192, 192)); // Контейнер для разделителя LinearLayout linLayout_Photo_Processing_Method_divider = new LinearLayout(this); linLayout_Photo_Processing_Method_divider.setOrientation(LinearLayout.HORIZONTAL); linLayout_Photo_Processing_Method_divider.setPadding(5, 9, 5, 9); // Название TextView tv_Photo_Processing_Method = new TextView(this); tv_Photo_Processing_Method.setTypeface(Typeface.DEFAULT_BOLD); tv_Photo_Processing_Method.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size); tv_Photo_Processing_Method.setTextColor(Color.BLACK); tv_Photo_Processing_Method.setText(getResources().getString(R.string.photo_processing_method)); // tv_Photo_Processing_Method.setWidth((screenWidth - padding) / 100 * 80); // tv_Photo_Processing_Method.setLayoutParams(lpView); tv_Photo_Processing_Method.setTypeface(Typeface.DEFAULT_BOLD); lpView_m1.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Processing_Method.getId()); lpView_m1.width = (screenWidth - padding) / 100 * 60; tv_Photo_Processing_Method.setLayoutParams(lpView_m1); linLayout_Photo_Processing_Method.addView(tv_Photo_Processing_Method); // Список spinnerArray_ppm = new ArrayList<String>(); spinnerArray_ppm.add("Hardware"); spinnerArray_ppm.add("Software"); spinner_ppm = new Spinner(this); ArrayAdapter<String> spinnerArrayAdapter_ppm = new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray_ppm); spinner_ppm.setAdapter(spinnerArrayAdapter_ppm); spinner_ppm.setSelection(getIndex(spinner_ppm, fb.Photo_Post_Processing_Method)); spinner_ppm.setMinimumWidth((screenWidth - padding) / 100 * 50); spinner_ppm.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (spinnerArray_ppm.get(i) == "Hardware") { tv_Photo_Size_s.setVisibility(View.GONE); spinner_Software.setVisibility(View.GONE); tv_Photo_Size_h.setVisibility(View.VISIBLE); spinner_Hardware.setVisibility(View.VISIBLE); linLayout_Photo_Size_h_notes.setVisibility(View.VISIBLE); linLayout_Photo_Size_s_notes.setVisibility(View.GONE); } else { tv_Photo_Size_s.setVisibility(View.VISIBLE); spinner_Software.setVisibility(View.VISIBLE); tv_Photo_Size_h.setVisibility(View.GONE); spinner_Hardware.setVisibility(View.GONE); linLayout_Photo_Size_h_notes.setVisibility(View.GONE); linLayout_Photo_Size_s_notes.setVisibility(View.VISIBLE); } } // If no option selected public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); lpView_m2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_ppm.getId()); lpView_m2.width = (screenWidth - padding) / 100 * 40; spinner_ppm.setLayoutParams(lpView_m2); linLayout_Photo_Processing_Method.addView(spinner_ppm); // Заметка для метода TextView tv_Photo_Processing_Method_note = new TextView(this); tv_Photo_Processing_Method_note.setTypeface(null, Typeface.NORMAL); tv_Photo_Processing_Method_note.setTextSize( TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2); tv_Photo_Processing_Method_note.setTextColor(Color.BLACK); tv_Photo_Processing_Method_note.setText( getResources().getString(R.string.photo_processing_method_dscription)); // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99); tv_Photo_Processing_Method_note.setLayoutParams(lpView); // tv_Photo_Processing_Method_note.setTextColor(Color.GRAY); tv_Photo_Processing_Method_note.setPadding(5, 9, 5, 9); linLayout_Photo_Processing_Method_notes.addView(tv_Photo_Processing_Method_note); // ------------------------------------------------------------------------------------------------ // Параметры изображения // Контейнер для метода RelativeLayout linLayout_Photo_Size = new RelativeLayout(this); // linLayout_Photo_Size.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams lpView_photo_size = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams lpView_photo_size_et = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams lpView_m3 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams lpView_m4 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams lpView_m5 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams lpView_m6 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); linLayout_Photo_Size.setBackgroundColor(Color.rgb(192, 192, 192)); // Контейнер для пояснение linLayout_Photo_Size_h_notes = new LinearLayout(this); linLayout_Photo_Size_h_notes.setOrientation(LinearLayout.HORIZONTAL); linLayout_Photo_Size_h_notes.setBackgroundColor(Color.rgb(192, 192, 192)); // Контейнер для пояснение linLayout_Photo_Size_s_notes = new LinearLayout(this); linLayout_Photo_Size_s_notes.setOrientation(LinearLayout.HORIZONTAL); linLayout_Photo_Size_s_notes.setBackgroundColor(Color.rgb(192, 192, 192)); // Контейнер для разделителя LinearLayout linLayout_Photo_Size_divider = new LinearLayout(this); linLayout_Photo_Processing_Method_divider.setOrientation(LinearLayout.HORIZONTAL); linLayout_Photo_Processing_Method_divider.setPadding(5, 9, 5, 9); // Масштаб фото tv_Photo_Size_h = new TextView(this); tv_Photo_Size_h.setTypeface(Typeface.DEFAULT_BOLD); tv_Photo_Size_h.setTextSize(14); tv_Photo_Size_h.setTextColor(Color.BLACK); tv_Photo_Size_h.setText(getResources().getString(R.string.photo_scale)); // tv_Photo_Size_h.setWidth((screenWidth - padding) / 100 * 80); tv_Photo_Size_h.setLayoutParams(lpView_photo_size); lpView_m3.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Size_h.getId()); lpView_m3.width = (screenWidth - padding) / 100 * 60; tv_Photo_Size_h.setLayoutParams(lpView_m3); linLayout_Photo_Size.addView(tv_Photo_Size_h); // Коэффициенты масштабирования ArrayList<String> spinnerArray_Hardware = new ArrayList<String>(); spinnerArray_Hardware.add("1/16"); spinnerArray_Hardware.add("1/8"); spinnerArray_Hardware.add("1/4"); spinnerArray_Hardware.add("1/2"); spinnerArray_Hardware.add("1"); spinner_Hardware = new Spinner(this); spinnerArrayAdapter_Hardware = new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray_Hardware); spinner_Hardware.setAdapter(spinnerArrayAdapter_Hardware); spinner_Hardware.setSelection(getIndex(spinner_Hardware, fb.Image_Scale)); // spinner_Hardware.setMinimumWidth((screenWidth - padding) / 100 * 20); // spinner_Hardware.setGravity(Gravity.RIGHT); lpView_m4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_Hardware.getId()); lpView_m4.width = (screenWidth - padding) / 100 * 40; spinner_Hardware.setLayoutParams(lpView_m4); linLayout_Photo_Size.addView(spinner_Hardware); // Размер фото tv_Photo_Size_s = new TextView(this); tv_Photo_Size_s.setTypeface(Typeface.DEFAULT_BOLD); tv_Photo_Size_s.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size); tv_Photo_Size_s.setTextColor(Color.BLACK); tv_Photo_Size_s.setText(getResources().getString(R.string.photo_resolution)); // tv_Photo_Size_s.setWidth((screenWidth - padding) / 100 * 80); tv_Photo_Size_s.setLayoutParams(lpView_photo_size); lpView_m5.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Size_s.getId()); lpView_m5.width = (screenWidth - padding) / 100 * 60; tv_Photo_Size_s.setLayoutParams(lpView_m5); linLayout_Photo_Size.addView(tv_Photo_Size_s); // Доступные разрешения ArrayList<String> spinnerArray = new ArrayList<String>(); Camera.Size mSize = null; int fe_w = (int) fb.camera_resolutions.get(0).width; int fe_h = (int) fb.camera_resolutions.get(0).height; float fe_s, fe_z; fe_z = (float) fe_w / (float) fe_h; for (Camera.Size size : fb.camera_resolutions) { fe_w = (int) size.width; fe_h = (int) size.height; fe_s = (float) fe_w / (float) fe_h; if (Math.abs(fe_s - fe_z) < 0.01f) { spinnerArray.add(size.width + "x" + size.height); } } spinner_Software = new Spinner(this); spinnerArrayAdapter1 = new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray); spinner_Software.setAdapter(spinnerArrayAdapter1); spinner_Software.setSelection(getIndex(spinner_Software, fb.Image_Size)); // spinner_Software.setMinimumWidth((screenWidth - padding) / 100 * 20); // spinner_Software.setGravity(Gravity.RIGHT); lpView_m6.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_Software.getId()); lpView_m6.width = (screenWidth - padding) / 100 * 40; spinner_Software.setLayoutParams(lpView_m6); linLayout_Photo_Size.addView(spinner_Software); // Заметка для Hardware TextView tv_Photo_Size_h_note = new TextView(this); tv_Photo_Size_h_note.setTypeface(null, Typeface.NORMAL); tv_Photo_Size_h_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2); tv_Photo_Size_h_note.setTextColor(Color.BLACK); tv_Photo_Size_h_note.setText("Hardware"); // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99); tv_Photo_Size_h_note.setLayoutParams(lpView); // tv_Photo_Size_h_note.setTextColor(Color.GRAY); tv_Photo_Size_h_note.setPadding(5, 9, 5, 9); linLayout_Photo_Size_h_notes.addView(tv_Photo_Size_h_note); // Заметка для Software TextView tv_Photo_Size_s_note = new TextView(this); tv_Photo_Size_s_note.setTypeface(null, Typeface.NORMAL); tv_Photo_Size_s_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2); tv_Photo_Size_s_note.setTextColor(Color.BLACK); tv_Photo_Size_s_note.setText("Software"); // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99); tv_Photo_Size_s_note.setLayoutParams(lpView); // tv_Photo_Size_s_note.setTextColor(Color.GRAY); tv_Photo_Size_s_note.setPadding(5, 9, 5, 9); linLayout_Photo_Size_s_notes.addView(tv_Photo_Size_s_note); // Разделитель View line_Photo_Size = new View(this); line_Photo_Size.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 1)); line_Photo_Size.setBackgroundColor(Color.rgb(210, 210, 210)); line_Photo_Size.getLayoutParams().height = 3; linLayout_Photo_Size_divider.addView(line_Photo_Size); // ------------------------------------------------------------------------------------------------ // Вспышка // Flash Container RelativeLayout linLayout_Flash = new RelativeLayout(this); // linLayout_Flash.setOrientation(LinearLayout.HORIZONTAL); RelativeLayout.LayoutParams lpView_Flash = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams lpView_Flash_m = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams lpView_et_Flash = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); linLayout_Flash.setBackgroundColor(Color.rgb(192, 192, 192)); // Flash TextView TextView tv_Flash = new TextView(this); tv_Flash.setText(getResources().getString(R.string.flash)); tv_Flash.setWidth((screenWidth - padding) / 100 * 90); tv_Flash.setLayoutParams(lpView_Flash); tv_Flash.setTypeface(Typeface.DEFAULT_BOLD); tv_Flash.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size); tv_Flash.setTextColor(Color.BLACK); lpView_Flash.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Flash.getId()); tv_Flash.setLayoutParams(lpView_Flash); linLayout_Flash.addView(tv_Flash); // CheckBox checkBox_Flash = new CheckBox(this); checkBox_Flash.setChecked(fb.Use_Flash); lpView_Flash_m.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, checkBox_Flash.getId()); checkBox_Flash.setLayoutParams(lpView_Flash_m); linLayout_Flash.addView(checkBox_Flash); // Second Container (Horizontal LinearLayout) LinearLayout linLayout2 = new LinearLayout(this); linLayout2.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams lpView2 = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams lpViewbutton = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); linLayout2.setGravity(Gravity.BOTTOM | Gravity.CENTER); // linLayout2.setLayoutParams(lpView2); // ------------------------------------------------------------------------------------------------ // Buttons // Container LinearLayout linLayout_Buttons = new LinearLayout(this); linLayout_Buttons.setOrientation(LinearLayout.HORIZONTAL); linLayout_Buttons.setGravity(Gravity.BOTTOM | Gravity.CENTER); LinearLayout.LayoutParams lpViewbutton1 = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f); LinearLayout.LayoutParams lpViewbutton2 = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f); lpViewbutton1.setMargins(0, 0, 5, 0); LinearLayout.LayoutParams lpView3 = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); linLayout_Buttons.setLayoutParams(lpView3); linLayout_Buttons.setBackgroundColor(Color.rgb(192, 192, 192)); linLayout_Buttons.setPadding(15, 15, 15, 15); linLayout_Buttons.setBaselineAligned(false); linLayout_Buttons.setGravity(Gravity.BOTTOM); // Apply Button btn = new Button(this); btn.setText(getResources().getString(R.string.apply_button)); btn.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); btn.setBackgroundColor(Color.rgb(90, 89, 91)); btn.setTextColor(Color.rgb(250, 250, 250)); btn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); btn.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { btn.setBackgroundColor(Color.rgb(90, 90, 90)); } else if (event.getAction() == MotionEvent.ACTION_DOWN) { btn.setBackgroundColor(Color.rgb(128, 128, 128)); } return false; } }); btn.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); if (checkBox_Flash.isChecked()) { editor.putBoolean("Use_Flash", true); } else { editor.putBoolean("Use_Flash", false); } String input = editText_JPEG_Compression.getText().toString(); editor.putString( "Photo_Post_Processing_Method", spinner_ppm.getSelectedItem().toString()); editor.putInt( "JPEG_Compression", Integer.parseInt(editText_JPEG_Compression.getText().toString())); editor.putString("Image_Scale", spinner_Hardware.getSelectedItem().toString()); editor.putString("Image_Size", spinner_Software.getSelectedItem().toString()); // Save the changes in SharedPreferences editor.commit(); // commit changes } }); // GoTo Main Page Button btn_mp = new Button(this); btn_mp.setText(getResources().getString(R.string.back_button)); btn_mp.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); btn_mp.setBackgroundColor(Color.rgb(90, 89, 91)); btn_mp.setTextColor(Color.rgb(250, 250, 250)); // lpViewbutton2.setMargins(5,5,5,5); btn_mp.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); btn_mp.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { btn_mp.setBackgroundColor(Color.rgb(90, 90, 90)); } else if (event.getAction() == MotionEvent.ACTION_DOWN) { btn_mp.setBackgroundColor(Color.rgb(128, 128, 128)); } return false; } }); btn_mp.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent intent; intent = new Intent(v.getContext(), MainActivity.class); startActivity(intent); } }); linLayout_Buttons.addView(btn, lpViewbutton1); linLayout_Buttons.addView(btn_mp, lpViewbutton2); FullFrame.addView(linLayout_JPEG_Compression); FullFrame.addView(linLayout_JPEG_Compression_notes); // FullFrame.addView(linLayout_JPEG_Compression_divider); FullFrame.addView(linLayout_Photo_Processing_Method); FullFrame.addView(linLayout_Photo_Processing_Method_notes); FullFrame.addView(linLayout_Photo_Size); FullFrame.addView(linLayout_Photo_Size_h_notes); FullFrame.addView(linLayout_Photo_Size_s_notes); // FullFrame.addView(linLayout_Photo_Size_divider); FullFrame.addView(linLayout_Flash); FullFrame.addView(linLayout_Buttons); ScrollView m_Scroll = new ScrollView(this); m_Scroll.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); m_Scroll.addView( FullFrame, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); setContentView(m_Scroll); }
@SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (isP(_P.secrecy) && !ENC) { setTitle("Initializing " + Main.name + "..."); return; } Intent caller = getIntent(); if (caller != null) { try { String tmp = caller.getStringExtra(_I.Main_setAbsoluteFolder.name()); if (tmp == null) { finish(); return; } setAbsoluteFolder(tmp); tmp = caller.getStringExtra(_I.Main_setFolderShowname.name()); if (tmp == null) { finish(); return; } setFolderShowname(tmp); } catch (Exception e) { e.printStackTrace(); return; } } WatchImpl.enable = false; l1 = new RelativeLayout(this); int xi = 0; while (true) { if (!checkFiles(xi)) break; xi++; } if (xi > max) max = xi; thetexts = new Vector<InnerEdit>(max + 5); ScrollView sv = new ScrollView(this); l1.addView(sv); RelativeLayout.LayoutParams sv_lp = (RelativeLayout.LayoutParams) sv.getLayoutParams(); sv_lp.width = RelativeLayout.LayoutParams.MATCH_PARENT; sv_lp.height = RelativeLayout.LayoutParams.WRAP_CONTENT; sv_lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); sv.setLayoutParams(sv_lp); l2 = new LinearLayout(this); l2.setOrientation(LinearLayout.VERTICAL); l2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); sv.addView(l2); ArrayList<String> vals = null; ArrayList<Integer> ids = null; int newone = -1; int focusone = -1; if (caller != null) { if (caller.getBooleanExtra("OKAY", false)) { vals = caller.getStringArrayListExtra("vals"); ids = caller.getIntegerArrayListExtra("ids"); newone = caller.getIntExtra("newone", -1); focusone = caller.getIntExtra("curfocus", -1); } } if (newone > 0) max = newone + 1; setTitle(title(max)); for (int i = 0; i < max; i++) { EditText t2 = new EditText(this); t2.setId(i); t2.setOnFocusChangeListener( new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) curfocus = (EditText) v; } }); t2.setImeOptions(EditorInfo.IME_ACTION_DONE); t2.setOnEditorActionListener(one); InnerEdit in = new InnerEdit(t2); thetexts.add(in); t2.addTextChangedListener(new WatchImpl(in)); l2.addView(t2, 0); if (ids != null && ids.contains(i)) { String tmp = vals.get(ids.indexOf(i)); if (tmp != null) t2.setText(tmp); else t2.setText("err"); in.changed = true; } else { if (checkFiles(i)) { String x = loadFiles(i); t2.setText(x); } else { t2.setText(""); } } if (focusone >= 0) { if (i == focusone) t2.requestFocus(); } else { if (i == max - 1) t2.requestFocus(); } } WatchImpl.enable = true; Button b1 = new Button(this); b1.setText(" Save "); b1.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { int ctr = 0; for (int i = 0; i < max; i++) { if (thetexts.get(i).changed || !checkFiles(i)) { storeFiles(i, thetexts.get(i).edit.getText().toString()); ctr++; thetexts.get(i).changed = false; } } Toast.makeText(me, "Saved (" + ctr + ")", Toast.LENGTH_SHORT).show(); } }); Button b2 = new Button(this); b2.setText(" Add "); b2.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { EditText t2 = new EditText(me); t2.setOnFocusChangeListener( new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) curfocus = (EditText) v; } }); t2.setImeOptions(EditorInfo.IME_ACTION_DONE); t2.setOnEditorActionListener(one); l2.addView(t2, 0); t2.setId(max); max++; InnerEdit in = new InnerEdit(t2, true); thetexts.add(in); t2.addTextChangedListener(new WatchImpl(in)); setTitle(title(max)); t2.requestFocus(); } }); Button b3 = new Button(this); b3.setText("Save & Exit"); b3.setOnClickListener( new OnClickListener() { // TODO: reduce redundancy @Override public void onClick(View v) { int ctr = 0; for (int i = 0; i < max; i++) { if (thetexts.get(i).changed || !checkFiles(i)) { storeFiles(i, thetexts.get(i).edit.getText().toString()); ctr++; thetexts.get(i).changed = false; } } if (ctr > 0) Toast.makeText(me, "Saved (" + ctr + ")", Toast.LENGTH_SHORT).show(); else Toast.makeText(me, "Quick Exit", Toast.LENGTH_SHORT).show(); finish(); } }); Button b4 = new Button(this); b4.setText("Return"); b4.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < max; i++) { if (thetexts.get(i).changed || !checkFiles(i)) { Toast.makeText(me, "unsaved data", Toast.LENGTH_SHORT).show(); return; } } startActivity(new Intent(me, Startup.class)); finish(); } }); HorizontalScrollView hori = new HorizontalScrollView(this); LinearLayout ll_hori = new LinearLayout(this); ll_hori.setOrientation(LinearLayout.HORIZONTAL); ll_hori.addView(b1); ll_hori.addView(b3); ll_hori.addView(b2); ll_hori.addView(b4); hori.addView(ll_hori); l1.addView(hori); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); hori.setLayoutParams(lp); hori.setId(121232); sv_lp = (RelativeLayout.LayoutParams) sv.getLayoutParams(); sv_lp.addRule(RelativeLayout.ABOVE, hori.getId()); sv.setLayoutParams(sv_lp); BitmapDrawable bd = new BitmapDrawable( getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.back_base)); bd.setTileModeXY(TileMode.MIRROR, TileMode.REPEAT); l1.setBackgroundDrawable(bd); setContentView(l1); }
public void initView() { if (UserInfo.isLogin) { if (UserInfo.isEmptyShopCar == false) { contentScrollView = (ScrollView) mainActivity.findViewById(R.id.scroll_content); RelativeLayout.LayoutParams scrollLayoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, CommonUtils.getScreenPixHeight(getActivity()) - CommonUtils.dp2px(getActivity(), 170)); scrollLayoutParams.addRule(RelativeLayout.BELOW, R.id.layout_title); // contentScrollView.setLayoutParams(n) contentScrollView.setLayoutParams(scrollLayoutParams); layout = (LinearLayout) mainActivity.findViewById(R.id.layout_content); for (int i = 0; i < mShops.size(); i++) { DetailCarShop shop = mShops.get(i); final CarShopContentView carShopContentView = new CarShopContentView(mainActivity); contentViews.add(carShopContentView); final AQuery contentAQuery = new AQuery(carShopContentView); contentAQuery.id(R.id.img_product_photo).image(shop.getProductPhoto(), false, true); contentAQuery .id(R.id.img_shop_select) .clicked( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AQuery selectAQuery = new AQuery(v); if (carShopContentView.isSelected) { selectAQuery.image(R.drawable.carshop_uncheck); carShopContentView.isSelected = false; /** 减掉总金额 */ DetailCarShop selectShop = mShops.get(carShopContentView.index); all = all - selectShop.getProductPrice() * selectShop.getProductNumber(); /** 隐藏控件 */ contentAQuery.id(R.id.text_product_min_calc).invisible(); callAQuery.id(R.id.text_calc_all).text("合计:¥" + decimalFormat.format(all)); } else { selectAQuery.image(R.drawable.carshop_check); carShopContentView.isSelected = true; /** 加上总金额 */ DetailCarShop selectShop = mShops.get(carShopContentView.index); all = all + selectShop.getProductPrice() * selectShop.getProductNumber(); /** 显示控件 */ contentAQuery.id(R.id.text_product_min_calc).visible(); callAQuery.id(R.id.text_calc_all).text("合计:¥" + decimalFormat.format(all)); } } }); contentAQuery .id(R.id.text_delete) .clicked( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // 向服务器发送删除请求 // DetailCarShop serviceDeleteCarShop=new DetailCarShop(); Map<String, String> params = new HashMap<String, String>(); // 客户端提供userID和productID params.put("command", "3"); params.put("userID", String.valueOf(UserInfo.userID)); params.put( "productID", String.valueOf(mShops.get(carShopContentView.index).getProductID())); params.put("unit", mShops.get(carShopContentView.index).getProductUnit()); aQuery.ajax( URLForService.CARSHOPSERVICE, params, JSONObject.class, CartFragment.this, "responseDeleteCarShop"); // 载入进度条对话框 showLoadingDialog(); currentCarShopContentView = carShopContentView; } }); contentAQuery.id(R.id.text_product_name).text(shop.getProductName()); // 获取单位 if ("袋".equals(shop.getProductUnit())) { contentAQuery.id(R.id.text_product_price).text("¥" + shop.getProductBagPrice() + "/袋"); } else { contentAQuery.id(R.id.text_product_price).text("¥" + shop.getProductPrice() + "/斤"); } // contentAQuery.id(R.id.text_product_price).text("¥"+shop.getProductPrice()+"/斤"); contentAQuery .id(R.id.edit_number) .text("" + shop.getProductNumber()) .clicked( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub orignNumber = mShops.get(carShopContentView.index).getProductNumber(); final EditText numberEditText = new EditText(mainActivity); numberEditText.setInputType(InputType.TYPE_CLASS_NUMBER); numberEditText.setText("" + orignNumber); new AlertDialog.Builder(mainActivity) .setTitle("输入商品数量") .setView(numberEditText) .setPositiveButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub try { // dialog.dismiss(); int num = Integer.parseInt( numberEditText.getText().toString().trim()); if (num > 0) { dialog.dismiss(); // 修改服务器中数据库中的数据 Map<String, String> params = new HashMap<String, String>(); params.put("command", "1"); params.put("userID", String.valueOf(UserInfo.userID)); params.put( "productID", String.valueOf( mShops.get(carShopContentView.index).getProductID())); params.put( "productNumber", String.valueOf(num - orignNumber)); aQuery.ajax( URLForService.CARSHOPSERVICE, params, JSONObject.class, CartFragment.this, "responseChangeProductNumber"); showLoadingDialog(); currentCarShopContentView = carShopContentView; currentShopNumber = num; currentAQuery = contentAQuery; } else { Toast.makeText( getActivity(), "输入的商品数量至少为1", Toast.LENGTH_SHORT) .show(); } } catch (Exception e) { Toast.makeText(getActivity(), "输入错误", Toast.LENGTH_SHORT) .show(); } } }) .setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.dismiss(); } }) .show(); } }); contentAQuery .id(R.id.text_product_min_calc) .text( "小计:¥" + decimalFormat.format(shop.getProductPrice() * shop.getProductNumber())); carShopContentView.isSelected = true; carShopContentView.index = i; // contentAQuery.id(R.id.text_) // carShopContentView.findViewById(R.id.img_product_photo) // carShopContentView.fin layout.addView(carShopContentView); } callAQuery = new AQuery(mainActivity); callAQuery.id(R.id.img_select_all).invisible(); callAQuery.id(R.id.text_select_all).invisible(); callAQuery .id(R.id.text_go_call) .clicked( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub boolean isSelected = false; if (contentViews.isEmpty()) { Toast.makeText(getActivity(), "购物车为空", Toast.LENGTH_SHORT).show(); return; } else { for (int i = 0; i < contentViews.size(); i++) { isSelected = isSelected || contentViews.get(i).isSelected; } if (isSelected == false) { Toast.makeText(getActivity(), "未选中任何商品", Toast.LENGTH_SHORT).show(); return; } } Intent intent = new Intent(mainActivity, CommitOrderActivity.class); /** 传递商品总金额 */ intent.putExtra("productMoney", all); String productIDs = ""; String productNums = ""; String units = ""; /** 传递订单商品ID和数量 */ // System.out.println(contentViews.size()); for (int i = 0; i < contentViews.size(); i++) { /** 如果这个控件被选中 */ if (contentViews.get(i).isSelected) { // mShops[contentViews.get(i).index] DetailCarShop detail = mShops.get(contentViews.get(i).index); productIDs += (String.valueOf(detail.getProductID()) + ";"); productNums += (detail.getProductNumber() + ";"); units += (detail.getProductUnit() + ";"); // p } } intent.putExtra("productIDs", productIDs); intent.putExtra("productNums", productNums); intent.putExtra("unit", units); intent.putExtra("fromType", "2"); mainActivity.startActivityForResult(intent, 3); mainActivity.overridePendingTransition( R.anim.activity_enter_right, R.anim.activity_enter_left); } }); for (int i = 0; i < mShops.size(); i++) { DetailCarShop detail = mShops.get(i); all += detail.getProductPrice() * detail.getProductNumber(); callAQuery.id(R.id.text_calc_all).text("合计:¥" + decimalFormat.format(all)); } } else { cartNoDataTextView = (TextView) mainActivity.findViewById(R.id.text_cart_no_data); } } else { // 用户未登录 aQuery .id(R.id.btn_login_carshop) .clicked( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // OPUtils.startActivityForResult(activity, otherClass, requestCode) Intent intent = new Intent(mainActivity, LoginActivity.class); mainActivity.startActivityForResult(intent, 5); mainActivity.overridePendingTransition( R.anim.activity_enter_right, R.anim.activity_enter_left); } }); // btn_login_carshop } }
// 创建通知详细信息界面 @SuppressLint("NewApi") private View createView(final String title, String message, final String uri) { final LinearLayout linearLayout = new LinearLayout(this); scrollView = new ScrollView(this); // linearLayout.setBackgroundColor(0xffeeeeee); Resources res = getResources(); // 设置背景图 Drawable dw = res.getDrawable(R.drawable.bg3); linearLayout.setBackgroundDrawable(dw); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setPadding(5, 5, 5, 5); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); linearLayout.setLayoutParams(layoutParams); TextView textTitle = new TextView(this); textTitle.setText(title); textTitle.setTextSize(21); // textTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); textTitle.setTypeface(Typeface.DEFAULT, Typeface.BOLD); textTitle.setTextColor(0xffffff00); textTitle.setGravity(Gravity.CENTER); titleParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); titleParams.setMargins(5, 5, 5, 10); textTitle.setLayoutParams(titleParams); linearLayout.addView(textTitle); // 首先判断uri,如果uri包含video说明是视频信息,转入视频界面 // 如果是视频信息 if (message.startsWith("传来的是视频")) { Log.i("xiaobingo", "进入视频"); WebView messageDetial = new WebView(this); messageDetial.getSettings().setJavaScriptEnabled(true); messageDetial.getSettings().setAllowFileAccess(true); messageDetial.getSettings().setPluginsEnabled(true); messageDetial.getSettings().setSupportZoom(true); messageDetial.getSettings().setAppCacheEnabled(true); String former = message.split("xiaobingo")[0]; String after = message.split("xiaobingo")[1]; System.out.println("afterString:" + after); int urlStart = former.indexOf("=") + 1; rtmpUrl = former.substring(urlStart); fileName = after; // 视频直播 if (rtmpUrl.contains("live")) { msgEnd = fileName.indexOf(".flv"); fileName = fileName.substring(0, msgEnd); // 直播视频不加后缀 } // 视频点播 else { fileName = "flv:" + fileName; // flv:倒霉熊02.flv } Log.i("xiaobingo", "message是:" + message); Log.i("xiaobingo", "rtmpUrl是:" + rtmpUrl); Log.i("xiaobingo", "fileName:" + fileName); String htmlCode = "<embed " + "type=\"application/x-shockwave-flash\"" + "id=\"player1\" " + "name=\"player1\" " + "src=\"http://push.pkusz.edu.cn" + "/mediaplayer.swf\"" + "width=\"" + mobileWidth + "\"" + " height=\"" + mobileHeight / 2 + "\"" + " flashvars=@FILESRC@" + "allowfullscreen=\"true\"" + "allowscripaccess=\"always\"" + "/> "; Log.i("xiaobingo", "htmlCode:" + htmlCode); bodyHtml = htmlCode; bodyHtml = bodyHtml.replaceAll("@FILESRC@", "\"file=" + fileName + "&streamer=" + rtmpUrl + "\""); messageDetial.loadDataWithBaseURL( "http://127.0.0.1", htmlPre + bodyHtml + htmlPost, "text/html", "UTF-8", null); videoParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); videoParams.setMargins(1, 3, 3, 5); scrollView.setLayoutParams(videoParams); scrollView.addView(messageDetial); } else { TextView textDetails = new TextView(this); textDetails.setText(message); textDetails.setTextSize(17); // textTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); textDetails.setTextColor(0xeeffeeee); textDetails.setGravity(Gravity.FILL); contentParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, (int) (mobileHeightPix * 0.7)); contentParams.setMargins(5, 3, 5, 5); scrollView.setLayoutParams(contentParams); scrollView.addView(textDetails); } linearLayout.addView(scrollView); // 点击详细按钮,连接到url,这里还须保存通知历史记录 Button okButton = new Button(this); okButton.setText("查看详细"); okButton.setTextSize(16); // okButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD); okButton.setTextColor(0xff6699ff); Drawable dr = res.getDrawable(R.drawable.button3); okButton.setBackgroundDrawable(dr); okButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { Intent intent; if (uri != null && uri.length() > 0 && (uri.startsWith("http:") || uri.startsWith("https:") || uri.startsWith("tel:") || uri.startsWith("geo:"))) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity"); } else { intent = new Intent().setClassName(callbackActivityPackageName, callbackActivityClassName); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); // intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); // intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); } NotificationDetailsActivity.this.startActivity(intent); NotificationDetailsActivity.this.finish(); } }); // 回复button事件 final Button btn_response = new Button(this); btn_response.setText("我要留言"); btn_response.setTextSize(16); // btn_response.setTypeface(Typeface.DEFAULT, Typeface.BOLD); btn_response.setTextColor(0xff6699ff); btn_response.setBackgroundDrawable(dr); LinearLayout buttonLayout = new LinearLayout(this); buttonLayout.setGravity(Gravity.CENTER); buttonLayout.addView(okButton); // 添加“查看详细”按钮 buttonLayout.addView(btn_response); // 添加“我要留言”按钮 buttonParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); buttonParams.setMargins(3, 3, 3, 3); buttonLayout.setLayoutParams(buttonParams); // innerLayout.setGravity(1); linearLayout.addView(buttonLayout); // 我要留言事件 final EditText responseText = new EditText(this); responseText.setWidth((int) (mobileWidthPix * 0.6)); Button btn_send = new Button(this); btn_send.setText("留言"); btn_send.setTextSize(16); btn_send.setTypeface(Typeface.DEFAULT, Typeface.BOLD); btn_send.setTextColor(0xff6699ff); btn_send.setBackgroundDrawable(dr); responseLayout = new LinearLayout(this); responseLayout.setGravity(Gravity.CENTER); responseLayout.addView(responseText); responseLayout.addView(btn_send); responseParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, (int) (mobileHeightPix * 0.12)); responseParams.setMargins(3, 3, 3, 3); responseLayout.setLayoutParams(responseParams); btn_response.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // button点击一次,显示留言区 if (!flag) { contentParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, (int) (mobileHeightPix * 0.6)); contentParams.setMargins(5, 3, 5, 5); scrollView.setLayoutParams(contentParams); linearLayout.addView(responseLayout); } // button再点击一次,去除留言区 else { contentParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, (int) (mobileHeightPix * 0.7)); contentParams.setMargins(5, 3, 5, 5); scrollView.setLayoutParams(contentParams); linearLayout.removeView(responseLayout); } flag = !flag; } }); // 发送留言button事件 btn_send.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String myResponse = responseText.getText().toString(); String androidpnURL = "http://219.223.222.232/bbs-api/?"; /*--拼接POST字符串--*/ StringBuilder parameter = new StringBuilder(); parameter.append("action=newreply"); parameter.append("&tid="); Log.d("notificationUri", "notificationUri is:" + notificationUri); parameter.append(notificationUri.substring(notificationUri.indexOf("&tid=") + 5)); parameter.append("&message="); parameter.append(myResponse); parameter.append("&username=admin&password=123"); // androidpnURL += "action=newreply"; // androidpnURL += "&tid=58&message="; // androidpnURL += myResponse; // androidpnURL += "&username=admin&password=123"; // parameter.append("&androidName=admin&"); // parameter.append(originSharedPrefs.getString(Constants.XMPP_USERNAME, // "未知用户")); // parameter.append("&reply="); // parameter.append(myResponse); /*--End--*/ Log.i("LoginActivity", androidpnURL); String resp = GetPostUtil.send("POST", androidpnURL, parameter); Log.i("LoginActivity", "resp:" + resp); responseText.setText(""); // 清空留言区 } }); // linearLayout.setGravity(Gravity.BOTTOM); return linearLayout; }
private void setSheetItems() { if (sheetItemList == null || sheetItemList.size() <= 0) { return; } int size = sheetItemList.size(); if (size >= 7) { LayoutParams params = (LayoutParams) sLayout_content.getLayoutParams(); params.height = display.getHeight() / 2; sLayout_content.setLayoutParams(params); } for (int i = 1; i <= size; i++) { final int index = i; SheetItem sheetItem = sheetItemList.get(i - 1); String strItem = sheetItem.name; SheetItemColor color = sheetItem.color; final OnSheetItemClickListener listener = sheetItem.itemClickListener; TextView textView = new TextView(context); textView.setText(strItem); textView.setTextSize(18); textView.setGravity(Gravity.CENTER); if (size == 1) { if (showTitle) { textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector); } else { textView.setBackgroundResource(R.drawable.actionsheet_single_selector); } } else { if (showTitle) { if (i >= 1 && i < size) { textView.setBackgroundResource(R.drawable.actionsheet_middle_selector); } else { textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector); } } else { if (i == 1) { textView.setBackgroundResource(R.drawable.actionsheet_top_selector); } else if (i < size) { textView.setBackgroundResource(R.drawable.actionsheet_middle_selector); } else { textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector); } } } if (color == null) { textView.setTextColor(Color.parseColor(SheetItemColor.Blue.getName())); } else { textView.setTextColor(Color.parseColor(color.getName())); } float scale = context.getResources().getDisplayMetrics().density; int height = (int) (45 * scale + 0.5f); textView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height)); textView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { listener.onClick(index); dialog.dismiss(); } }); lLayout_content.addView(textView); } }
public void setTextRegion(int left, int top, int width, int height) { // Ignore any requirement of layout change once we are in MMS conformance mode. if (mScrollText != null && !mConformanceMode) { mScrollText.setLayoutParams(new LayoutParams(width, height, left, top)); } }
public void displayAccounts() { accounts = b2evolution.DB.getAccounts(this); HashMap<?, ?> notificationOptions = b2evolution.DB.getNotificationOptions(this); boolean sound = false, vibrate = false, light = false, taglineValue = false; String tagline = ""; if (notificationOptions != null) { if (notificationOptions.get("sound").toString().equals("1")) { sound = true; } if (notificationOptions.get("vibrate").toString().equals("1")) { vibrate = true; } if (notificationOptions.get("light").toString().equals("1")) { light = true; } if (notificationOptions.get("tagline_flag").toString().equals("1")) { taglineValue = true; } tagline = notificationOptions.get("tagline").toString(); } if (accounts.size() > 0) { ScrollView sv = new ScrollView(this); sv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); sv.setBackgroundColor(Color.parseColor("#FFFFFFFF")); LinearLayout layout = new LinearLayout(this); layout.setPadding(14, 14, 14, 14); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.LEFT); final LinearLayout cbLayout = new LinearLayout(this); cbLayout.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); cbLayout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams section1Params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); section1Params.setMargins(0, 0, 0, 20); LinearLayout section1 = new LinearLayout(this); section1.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg)); section1.setLayoutParams(section1Params); section1.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams headerParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); headerParams.setMargins(1, 1, 1, 0); TextView textView = new TextView(this); textView.setLayoutParams(headerParams); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setPadding(0, 4, 0, 4); textView.setShadowLayer(1, 0, 2, Color.parseColor("#FFFFFFFF")); textView.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg_header)); textView.setText(" " + getResources().getText(R.string.comment_notifications)); section1.addView(textView); LinearLayout.LayoutParams cbParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); cbParams.setMargins(4, 0, 0, 6); for (int i = 0; i < accounts.size(); i++) { HashMap<?, ?> curHash = (HashMap<?, ?>) accounts.get(i); String curBlogName = curHash.get("blogName").toString(); String accountID = curHash.get("id").toString(); int runService = Integer.valueOf(curHash.get("runService").toString()); accountNames.add(i, curBlogName); final CheckBox checkBox = new CheckBox(this); checkBox.setTextColor(Color.parseColor("#444444")); checkBox.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); checkBox.setText(EscapeUtils.unescapeHtml(curBlogName)); checkBox.setId(Integer.valueOf(accountID)); checkBox.setLayoutParams(cbParams); if (runService == 1) { checkBox.setChecked(true); } cbLayout.addView(checkBox); } if (cbLayout.getChildCount() > 0) { section1.addView(cbLayout); } // add spinner and buttons TextView textView2 = new TextView(this); LinearLayout.LayoutParams labelParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); labelParams.setMargins(8, 0, 0, 0); textView2.setLayoutParams(labelParams); textView2.setTextColor(Color.parseColor("#444444")); textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView2.setText(getResources().getText(R.string.notifications_interval)); section1.addView(textView2); final Spinner sInterval = new Spinner(this); LinearLayout.LayoutParams spinnerParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); spinnerParams.setMargins(4, 0, 4, 10); sInterval.setLayoutParams(spinnerParams); ArrayAdapter<Object> sIntervalArrayAdapter = new ArrayAdapter<Object>( this, R.layout.spinner_textview, new String[] { "5 Minutes", "10 Minutes", "15 Minutes", "30 Minutes", "1 Hour", "3 Hours", "6 Hours", "12 Hours", "Daily" }); sIntervalArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sInterval.setAdapter(sIntervalArrayAdapter); String interval = b2evolution.DB.getInterval(this); if (interval != "") { sInterval.setSelection(sIntervalArrayAdapter.getPosition(interval)); } section1.addView(sInterval); final LinearLayout nOptionsLayout = new LinearLayout(this); nOptionsLayout.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); nOptionsLayout.setOrientation(LinearLayout.VERTICAL); CheckBox soundCB = new CheckBox(this); soundCB.setTag("soundCB"); soundCB.setTextColor(Color.parseColor("#444444")); soundCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); soundCB.setText(getResources().getText(R.string.notification_sound)); soundCB.setLayoutParams(cbParams); soundCB.setChecked(sound); nOptionsLayout.addView(soundCB); CheckBox vibrateCB = new CheckBox(this); vibrateCB.setTag("vibrateCB"); vibrateCB.setTextColor(Color.parseColor("#444444")); vibrateCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); vibrateCB.setText(getResources().getText(R.string.notification_vibrate)); vibrateCB.setLayoutParams(cbParams); vibrateCB.setChecked(vibrate); nOptionsLayout.addView(vibrateCB); CheckBox lightCB = new CheckBox(this); lightCB.setTag("lightCB"); lightCB.setTextColor(Color.parseColor("#444444")); lightCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); lightCB.setText(getResources().getText(R.string.notification_blink)); lightCB.setLayoutParams(cbParams); lightCB.setChecked(light); nOptionsLayout.addView(lightCB); section1.addView(nOptionsLayout); layout.addView(section1); final LinearLayout section2 = new LinearLayout(this); section2.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg)); section2.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams section2Params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); section2Params.setMargins(0, 0, 0, 20); section2.setLayoutParams(section2Params); section2.setPadding(0, 0, 0, 10); TextView section2lbl = new TextView(this); section2lbl.setLayoutParams(headerParams); section2lbl.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); section2lbl.setTypeface(Typeface.DEFAULT_BOLD); section2lbl.setShadowLayer(1, 0, 2, Color.parseColor("#FFFFFFFF")); section2lbl.setPadding(0, 4, 0, 4); section2lbl.setText(" " + getResources().getText(R.string.post_signature)); section2lbl.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg_header)); section2.addView(section2lbl); CheckBox taglineCB = new CheckBox(this); taglineCB.setTag("taglineCB"); taglineCB.setTextColor(Color.parseColor("#444444")); taglineCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); taglineCB.setText(getResources().getText(R.string.add_tagline)); taglineCB.setLayoutParams(cbParams); taglineCB.setChecked(taglineValue); section2.addView(taglineCB); EditText taglineET = new EditText(this); LinearLayout.LayoutParams taglineParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); taglineParams.setMargins(4, 0, 4, 4); taglineET.setLayoutParams(taglineParams); if (tagline != null) { if (tagline.equals("")) { if (BlackBerryUtils.getInstance().isBlackBerry()) taglineET.setText(getResources().getText(R.string.posted_from_blackberry)); else taglineET.setText(getResources().getText(R.string.posted_from)); } else { taglineET.setText(tagline); } } taglineET.setMinLines(2); section2.addView(taglineET); layout.addView(section2); final LinearLayout section3 = new LinearLayout(this); section3.setOrientation(LinearLayout.HORIZONTAL); section3.setGravity(Gravity.RIGHT); LinearLayout.LayoutParams section3Params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); section3Params.setMargins(0, 0, 0, 20); section3.setLayoutParams(section3Params); final Button cancel = new Button(this); LinearLayout.LayoutParams cancelParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); cancelParams.setMargins(0, 0, 10, 0); cancel.setLayoutParams(cancelParams); cancel.setBackgroundDrawable(getResources().getDrawable(R.drawable.b2evo_button_small)); cancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); cancel.setText(getResources().getText(R.string.cancel)); cancel.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { finish(); } }); section3.addView(cancel); final Button save = new Button(this); save.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT)); save.setBackgroundDrawable(getResources().getDrawable(R.drawable.b2evo_button_small)); save.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); save.setText(getResources().getText(R.string.save)); save.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { boolean sound = false, vibrate = false, light = false, tagValue = false; checkCtr = 0; int listItemCount = cbLayout.getChildCount(); for (int i = 0; i < listItemCount; i++) { CheckBox cbox = (CheckBox) cbLayout.getChildAt(i); int id = cbox.getId(); if (cbox.isChecked()) { checkCtr++; b2evolution.DB.updateNotificationFlag(id, true); Log.i("CommentService", "Service enabled for " + cbox.getText()); } else { b2evolution.DB.updateNotificationFlag(id, false); } } int noOptionsItemCount = nOptionsLayout.getChildCount(); for (int i = 0; i < noOptionsItemCount; i++) { CheckBox cbox = (CheckBox) nOptionsLayout.getChildAt(i); if (cbox.getTag().equals("soundCB")) { sound = cbox.isChecked(); } else if (cbox.getTag().equals("vibrateCB")) { vibrate = cbox.isChecked(); } else if (cbox.getTag().equals("lightCB")) { light = cbox.isChecked(); } } CheckBox tagFlag = (CheckBox) section2.getChildAt(1); tagValue = tagFlag.isChecked(); EditText taglineET = (EditText) section2.getChildAt(2); String taglineText = taglineET.getText().toString(); b2evolution.DB.updateNotificationSettings( sInterval.getSelectedItem().toString(), sound, vibrate, light, tagValue, taglineText); if (checkCtr > 0) { String updateInterval = sInterval.getSelectedItem().toString(); int UPDATE_INTERVAL = 3600000; // configure time interval if (updateInterval.equals("5 Minutes")) { UPDATE_INTERVAL = 300000; } else if (updateInterval.equals("10 Minutes")) { UPDATE_INTERVAL = 600000; } else if (updateInterval.equals("15 Minutes")) { UPDATE_INTERVAL = 900000; } else if (updateInterval.equals("30 Minutes")) { UPDATE_INTERVAL = 1800000; } else if (updateInterval.equals("1 Hour")) { UPDATE_INTERVAL = 3600000; } else if (updateInterval.equals("3 Hours")) { UPDATE_INTERVAL = 10800000; } else if (updateInterval.equals("6 Hours")) { UPDATE_INTERVAL = 21600000; } else if (updateInterval.equals("12 Hours")) { UPDATE_INTERVAL = 43200000; } else if (updateInterval.equals("Daily")) { UPDATE_INTERVAL = 86400000; } Intent intent = new Intent(Preferences.this, CommentBroadcastReceiver.class); PendingIntent pIntent = PendingIntent.getBroadcast(Preferences.this, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.setRepeating( AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), UPDATE_INTERVAL, pIntent); } else { Intent stopIntent = new Intent(Preferences.this, CommentBroadcastReceiver.class); PendingIntent stopPIntent = PendingIntent.getBroadcast(Preferences.this, 0, stopIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.cancel(stopPIntent); Intent service = new Intent(Preferences.this, CommentService.class); stopService(service); } finish(); } }); section3.addView(save); layout.addView(section3); sv.addView(layout); setContentView(sv); } }