Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recent version of build and gradle tools #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:3.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,5 +19,9 @@ buildscript {
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
8 changes: 4 additions & 4 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "de.esailors.android.widget.scratch.example"
Expand All @@ -37,7 +37,7 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':scratchdroid')
compile 'com.android.support:appcompat-v7:22.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':scratchdroid')
implementation 'com.android.support:appcompat-v7:22.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public boolean onNavigationItemSelected(int itemPosition, long itemId) {
case 2:
newFragment = new ScratchCompletedListenerFragment();
break;
case 3:
newFragment = new ScratchCustomFragment();
break;
}

getSupportFragmentManager().beginTransaction()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Copyright (c) 2015 eSailors IT Solutions GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/

package de.esailors.android.widget.scratch.example;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.ToggleButton;

import de.esailors.android.widget.scratch.CustomScratchPath;
import de.esailors.android.widget.scratch.ScratchView;

public class ScratchCustomFragment extends Fragment implements ScratchView.OnScratchCompletedListener {

private static final String TAG = "ScratchCompleted";

private ScratchView scratchViewWithDefaultScratchRegion;
private ScratchView scratchViewWithCustomScratchRegion;
private TextView label;

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

View content = inflater.inflate(R.layout.fragment_scratch_completed, container, false);
scratchViewWithDefaultScratchRegion = (ScratchView) content.findViewById(R.id.scratch_completed_scratch_view);
scratchViewWithCustomScratchRegion = (ScratchView) content.findViewById(R.id.scratch_completed_custom_scratch_region_scratch_view);
label = (TextView) content.findViewById(R.id.scratch_completed_label);
String wonSymbol = "linkedin";
Bitmap mergedImg = getImagesForCard(wonSymbol);
Drawable d = new BitmapDrawable(getResources(), mergedImg);
scratchViewWithDefaultScratchRegion.setOnScratchCompletedListener(this);
scratchViewWithCustomScratchRegion.setOnScratchCompletedListener(this)
.setCustomScratchPath(getCustomScratchPath())
.setScratchBackground(d);

content.findViewById(R.id.scratch_completed_toggle_debug).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

boolean on = ((ToggleButton) v).isChecked();

// make custom scratch region visible if true
scratchViewWithCustomScratchRegion.setDebug(on);
scratchViewWithDefaultScratchRegion.setDebug(on);
}
});

return content;
}

private Bitmap getImagesForCard(String winsymbol){
Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(),R.drawable.badoo);//assign your bitmap;
Bitmap bitmap2 = BitmapFactory.decodeResource(getResources(),R.drawable.behance);//assign your bitmap;
Bitmap bitmap3 = BitmapFactory.decodeResource(getResources(),R.drawable.facebook);//assign your bitmap;
Bitmap bitmap4 = BitmapFactory.decodeResource(getResources(), R.drawable.linkedin);//assign your bitmap;
Bitmap bitmap5 = BitmapFactory.decodeResource(getResources(), R.drawable.google_plus);//assign your bitmap;
Bitmap bitmap6 = BitmapFactory.decodeResource(getResources(), R.drawable.dribbble);//assign your bitmap;


Bitmap[] listBmp= {bitmap1, bitmap2, bitmap3, bitmap4, bitmap5, bitmap6};

Bitmap mergedImg = mergeMultiple(listBmp);

return mergedImg;
}

private Bitmap mergeMultiple(Bitmap[] parts){
int width = parts[0].getWidth() * 3;
int height = parts[0].getHeight() * 2;
Bitmap result = Bitmap.createBitmap(parts[0].getWidth() * 3, parts[0].getHeight() * 2, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
for (int i = 0; i < parts.length; i++) {
canvas.drawBitmap(parts[i], parts[i].getWidth() * (i % 3), parts[i].getHeight() * (i % 2), paint);
}
return result;
}

private CustomScratchPath getCustomScratchPath() {

CustomScratchPath p = new CustomScratchPath(293f, 108f);

float appleWidth = 30,
appleHeight = 35;

// first apple;
float left = 134,
top = 53;

p.addRect(left, top,
left + appleWidth,
top + appleHeight, Path.Direction.CW);

// second apple
left = 241;
top = 57f;

p.addRect(left, top,
left + appleWidth,
top + appleHeight, Path.Direction.CW);

return p;
}

@Override
public void onScratchCompleted(ScratchView scratchView) {

if (scratchView == ScratchCustomFragment.this.scratchViewWithDefaultScratchRegion) {
Log.d(TAG, "FULL SCRATCH COMPLETED!");
label.setText("FULL SCRATCH COMPLETED!");
} else if (scratchView == scratchViewWithCustomScratchRegion) {
Log.d("ScratchCompleted", "APPLES SCRATCH COMPLETED!");
label.setText("APPLES SCRATCH COMPLETED!");
scratchViewWithCustomScratchRegion.scratchAll();
}
}
}
Binary file added example/src/main/res/drawable/badoo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/behance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/deviantart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/dribbble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/flickr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/google_plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/instagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/lastfm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/pinterest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/soundcloud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/swarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/tumblr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/drawable/vk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions example/src/main/res/layout/fragment_scratch_custom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">

<de.esailors.android.widget.scratch.ScratchView
android:id="@+id/scratch_completed_scratch_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:sv_scratch_background_drawable="@drawable/scratch_card_bg"
app:sv_scratch_foreground_drawable="@drawable/repeatable_texture"
app:sv_scratch_foreground_repeat="true"
app:sv_scratch_radius="30dp"
/>

<TextView
android:id="@+id/scratch_completed_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
/>

<de.esailors.android.widget.scratch.ScratchView
android:id="@+id/scratch_completed_custom_scratch_region_scratch_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:sv_scratch_background_drawable="@drawable/scratch_card_bg"
app:sv_scratch_foreground_drawable="@drawable/repeatable_texture"
app:sv_scratch_foreground_repeat="true"
app:sv_scratch_radius="30dp"
/>

<ToggleButton
android:id="@+id/scratch_completed_toggle_debug"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textOff="Debug off"
android:textOn="Debug on"/>

</LinearLayout>
1 change: 1 addition & 0 deletions example/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<item>Fill Foreground</item>
<item>Drawable Foreground</item>
<item>ScratchCompleted Listener</item>
<item>Scratch Custom</item>
</string-array>
</resources>
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Tue Dec 18 13:51:36 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6 changes: 3 additions & 3 deletions scratchdroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 8
Expand All @@ -34,6 +34,6 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:22.0.0'
}
4 changes: 1 addition & 3 deletions scratchdroid/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

<application
android:allowBackup="true"
android:label="@string/app_name"
>

android:label="@string/app_name">
</application>

</manifest>