private void init() { setHardwareAccelerated(true); boolean hasShot = getContext() .getSharedPreferences(PREFS_SHOWCASE_INTERNAL, Context.MODE_PRIVATE) .getBoolean("hasShot" + getConfigOptions().showcaseId, false); if (hasShot && mOptions.shotType == TYPE_ONE_SHOT) { // The showcase has already been shot once, so we don't need to do anything setVisibility(View.GONE); mIsRedundant = true; return; } mShowcaseRadius = mMetricScale * INNER_CIRCLE_RADIUS; setOnTouchListener(this); if (!mOptions.noButton && mEndButton.getParent() == null) { RelativeLayout.LayoutParams lps = getConfigOptions().buttonLayoutParams; if (lps == null) { lps = (LayoutParams) generateDefaultLayoutParams(); lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); int margin = ((Number) (mMetricScale * 12)).intValue(); lps.setMargins(margin, margin, margin, margin); } mEndButton.setLayoutParams(lps); mEndButton.setText(mButtonText != null ? mButtonText : getResources().getString(R.string.ok)); if (!mHasCustomClickListener) { mEndButton.setOnClickListener(this); } addView(mEndButton); } }
public void testColorNewColorButtonChangesStandard() { int numberOfColorsToTest = 20; assertTrue("Waiting for DrawingSurface", mSolo.waitForView(DrawingSurface.class, 1, TIMEOUT)); mSolo.clickOnView(mButtonTopColor); mSolo.sleep(COLOR_PICKER_DIALOGUE_APPERANCE_DELAY); TypedArray presetColors = getActivity().getResources().obtainTypedArray(R.array.preset_colors); numberOfColorsToTest = Math.min(numberOfColorsToTest, presetColors.length()); for (int counterColors = 0; counterColors < numberOfColorsToTest; counterColors++) { Log.d(PaintroidApplication.TAG, "test color # " + counterColors); Button colorButton = mSolo.getButton(counterColors); if (!(colorButton.getParent() instanceof TableRow)) { Log.d( PaintroidApplication.TAG, "button parent is no table row: " + colorButton.getParent()); continue; } mSolo.clickOnButton(counterColors); mSolo.sleep(200); int colorColor = presetColors.getColor(counterColors, 0); String buttonNewColorName = getActivity().getResources().getString(R.string.done); Button button = mSolo.getButton(buttonNewColorName); Drawable drawable = button.getBackground(); int buttonTextColor = button.getCurrentTextColor(); Bitmap bitmap = drawableToBitmap(drawable, button.getWidth(), button.getHeight()); int buttonColor = bitmap.getPixel(1, 1); assertEquals("New Color button has unexpected color", colorColor, buttonColor); assertTrue( "Button textcolor and backgroundcolor ar the same", buttonColor != buttonTextColor); assertTrue( "Unexpected text color in butten text", (buttonTextColor == Color.BLACK || buttonTextColor == Color.WHITE)); assertTrue( "Color not set yet", colorColor == mTopBar.getCurrentTool().getDrawPaint().getColor()); bitmap.recycle(); bitmap = null; } }
private void init() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setLayerType(LAYER_TYPE_SOFTWARE, null); } else { setDrawingCacheEnabled(true); } boolean hasShot = getContext() .getSharedPreferences(PREFS_SHOWCASE_INTERNAL, Context.MODE_PRIVATE) .getBoolean("hasShot" + getConfigOptions().showcaseId, false); if (hasShot && mOptions.shotType == TYPE_ONE_SHOT) { // The showcase has already been shot once, so we don't need to do anything setVisibility(View.GONE); isRedundant = true; return; } showcase = getContext().getResources().getDrawable(R.drawable.cling); showcaseRadius = metricScale * INNER_CIRCLE_RADIUS; PorterDuffXfermode mBlender = new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY); setOnTouchListener(this); mPaintTitle = new Paint(); mPaintTitle.setColor(titleTextColor); mPaintTitle.setShadowLayer(2.0f, 0f, 2.0f, Color.DKGRAY); mPaintTitle.setTextSize(24 * metricScale); mPaintTitle.setAntiAlias(true); mPaintDetail = new TextPaint(); mPaintDetail.setColor(detailTextColor); mPaintDetail.setShadowLayer(2.0f, 0f, 2.0f, Color.DKGRAY); mPaintDetail.setTextSize(16 * metricScale); mPaintDetail.setAntiAlias(true); mEraser = new Paint(); mEraser.setColor(0xFFFFFF); mEraser.setAlpha(0); mEraser.setXfermode(mBlender); mEraser.setAntiAlias(true); if (!mOptions.noButton && mEndButton.getParent() == null) { RelativeLayout.LayoutParams lps = (LayoutParams) generateDefaultLayoutParams(); lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); int margin = ((Number) (metricScale * 12)).intValue(); lps.setMargins(margin, margin, margin, margin); lps.height = LayoutParams.WRAP_CONTENT; lps.width = LayoutParams.WRAP_CONTENT; mEndButton.setLayoutParams(lps); mEndButton.setText(buttonText != null ? buttonText : getResources().getString(R.string.ok)); if (!hasCustomClickListener) mEndButton.setOnClickListener(this); addView(mEndButton); } }
private void init() { setOnTouchListener(this); if (mEndButton.getParent() == null) { int margin = (int) getResources().getDimension(R.dimen.button_margin); RelativeLayout.LayoutParams lps = (LayoutParams) generateDefaultLayoutParams(); lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); lps.setMargins(margin, margin, margin, margin); mEndButton.setLayoutParams(lps); mEndButton.setText(android.R.string.ok); if (!hasCustomClickListener) { mEndButton.setOnClickListener(this); } addView(mEndButton); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.spot_page_layout); // initialize everything now mTitle = (TextView) findViewById(R.id.txtTitle); mRating = (TextView) findViewById(R.id.txtOverallRating); mLevel = (TextView) findViewById(R.id.txtPoRating); mDist = (TextView) findViewById(R.id.txtDistance); mDifficulty = (TextView) findViewById(R.id.txtDiffRating); mImage = (ImageView) findViewById(R.id.imgThumbnail); gridview = (GridView) findViewById(R.id.gridviewPictures); Lat = (TextView) findViewById(R.id.lat); Lon = (TextView) findViewById(R.id.lon); Bundle showData = getIntent().getExtras(); spot_id = showData.getString("spot_id"); url = showData.getString("url"); // TODO: should be null -- "lol" == no image overall = showData.getString("overall"); difficulty = showData.getString("difficulty"); bust = showData.getString("bust"); title = showData.getString("title"); distance = showData.getString("distance"); isSecret = showData.getString("isSecret"); lat = showData.getString("lat"); lon = showData.getString("lon"); mTitle.setText(title); mRating.setText(overall); mLevel.setText(bust); mDifficulty.setText(difficulty); mDist.setText(distance + " mi"); Lat.setText(lat); Lon.setText(lon); // for now just sets the title // Spot.getSpotInfoByID(this, spot_id, context); // Get and populate header photo for the spot // Spot.getTopPhotoBySpotID(context, spot_id, this); // Get size int size = Image.convertDpToPixel(90, context); // TODO: get better way of doing this if (url != null && !url.equals("null") && !url.equals("lol")) { Picasso.with(context) .load(url) .centerCrop() .resize(size, size) .placeholder(R.drawable.ic_empty_sec) .into(mImage); } else { Picasso.with(context) .load(R.drawable.ic_no_images) .centerCrop() .resize(size, size) .placeholder(R.drawable.ic_empty_sec) .into(mImage); } // create buttons Button viewMapButton = (Button) findViewById(R.id.viewMapButton); Button uploadPhotosButton = (Button) findViewById(R.id.uploadPhotoButton); Button commentsButton = (Button) findViewById(R.id.commentsButton); Button uploadCommentButton = (Button) findViewById(R.id.uploadCommentButton); // Button favoritesButton = (Button) findViewById(R.id.favoritesButton); Button shareButton = (Button) findViewById(R.id.shareButton); // If the spot isn't secret then no need to have a share button if (isSecret.equals("False") || isSecret.equals("false")) { ((ViewManager) shareButton.getParent()).removeView(shareButton); } else { shareButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { Bundle bundleData = new Bundle(); bundleData.putString("spot_id", spot_id); Intent intent = new Intent(SpotPage.this, ShareUserList.class); intent.putExtras(bundleData); startActivity(intent); } }); } viewMapButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { Bundle bundleData = new Bundle(); TextView Lat = (TextView) findViewById(R.id.lat); TextView Lon = (TextView) findViewById(R.id.lon); String lon = (String) Lon.getText(); String lat = (String) Lat.getText(); // Toast.makeText(context, "lat = " + lat + " and lon = " + lon, // Toast.LENGTH_LONG).show(); bundleData.putString("lat", lat); bundleData.putString("lon", lon); Intent intent = new Intent(SpotPage.this, ActionBarActivity.class); intent.putExtras(bundleData); startActivity(intent); } }); uploadPhotosButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { User.checkLoggedIn(getApplicationContext(), spot_id, "Image"); // Bundle bundleData = new Bundle(); // bundleData.putString("spot_id", spot_id); // Intent intent = new Intent(SpotPage.this, AddImage.class); // intent.putExtras(bundleData); // startActivityForResult(intent, 0); } }); uploadCommentButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { User.checkLoggedIn(getApplicationContext(), spot_id, "Comment"); // Bundle bundleData = new Bundle(); // bundleData.putString("spot_id", spot_id); // // Intent intent = new Intent(SpotPage.this, AddComment.class); // // intent.putExtras(bundleData); // startActivity(intent); } }); /* favoritesButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent(SpotPage.this, ActionBarActivity.class); startActivity(intent); } }); */ commentsButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { // add spot_id to the new intent and start it Bundle bundleData = new Bundle(); bundleData.putString("spot_id", spot_id); Intent intent = new Intent(SpotPage.this, ListViewComments.class); intent.putExtras(bundleData); startActivity(intent); } }); // Send task to get images // imagesArray = new ArrayList<HashMap<String, String>>(); // Spot.getPhotosBySpotID(gridview, dataAdapter, imagesArray, context, spot_id); // Open full screen image // TODO: better full screen view gridview.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Intent intent = new Intent(SpotPage.this, ViewImage.class); if (imagesArray.size() > 0) { HashMap<String, String> image = imagesArray.get(position); String url = image.get("url"); String display_name = image.get("display_name"); String rider_name = image.get("rider_name"); intent.putExtra("url", url); intent.putExtra("rider_name", rider_name); intent.putExtra("display_name", display_name); startActivity(intent); } else { // TODO: possible error message } } }); /* //TO AVOID SCROLLING LAGS boolean pauseOnScroll = false; // or true boolean pauseOnFling = true; // or false PauseOnScrollListener listener = new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling); gridview.setOnScrollListener(listener); */ }