Skip to content

Commit

Permalink
refactor gtm
Browse files Browse the repository at this point in the history
  • Loading branch information
amine-labassi committed Feb 11, 2020
1 parent f139886 commit a00a8ea
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 62 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.Intent;
import android.os.Bundle;

import com.batch.android.Batch;
import com.bayardpresse.android.BuildConfig;
import com.bayardpresse.android.R;
import com.bayardpresse.stickers.mortelleadele.model.PackStore;
Expand Down Expand Up @@ -60,7 +59,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Batch.onNewIntent(this, intent);
// Batch.onNewIntent(this, intent);
}

@Override
Expand Down Expand Up @@ -92,7 +91,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
Toast.makeText(this, "Oups !!!", Toast.LENGTH_LONG).show();
}
Bundle bundle = new Bundle();
bundle.putString("title", "pack : #" + pack.name + "#");
bundle.putString("title", "pack : " + pack.name);
bundle.putString("action", "download complete");
mFirebaseAnalytics.logEvent("download_WA", bundle);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;

import com.bayardpresse.android.R;
import com.bayardpresse.stickers.mortelleadele.model.PackStore;
import com.bayardpresse.stickers.mortelleadele.model.StickerPack;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.Toolbar;

import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;

import com.bayardpresse.android.R;
import com.bayardpresse.stickers.mortelleadele.model.PackStore;
import com.bayardpresse.stickers.mortelleadele.model.StickerPack;

public class ItemDetailFragment extends Fragment {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.RecyclerView;

import com.batch.android.Batch;
import com.bayardpresse.android.R;
import com.bayardpresse.stickers.mortelleadele.model.PackStore;
import com.bayardpresse.stickers.mortelleadele.model.StickerPack;
Expand Down Expand Up @@ -48,7 +47,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Batch.onNewIntent(this, intent);
// Batch.onNewIntent(this, intent);
}

@Override
Expand Down Expand Up @@ -106,7 +105,7 @@ public void onClick(View view) {
intent.putExtra(ItemDetailFragment.ARG_ITEM_ID, item.identifier);

Bundle bundle = new Bundle();
bundle.putString("title", "pack : #" + item.name + "#");
bundle.putString("title", "pack : " + item.name);
bundle.putString("action", "clic : acces pack");
mFirebaseAnalytics.logEvent("navigation", bundle);
context.startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
package com.bayardpresse.stickers.mortelleadele;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;

import com.batch.android.Batch;
import com.batch.android.BatchActivityLifecycleHelper;
import com.batch.android.Config;
import androidx.appcompat.app.AppCompatActivity;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;

public class MainActivity extends AppCompatActivity {

public static final int REQUEST_GOOGLE_PLAY_SERVICES = 1972;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this);
//checkPlayServices();
startPacksListActivity();
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Batch.onNewIntent(this, intent);
// Batch.onNewIntent(this, intent);
}

private void startPacksListActivity() {
Intent intent = new Intent(getApplicationContext(), ItemListActivity.class);
this.startActivity(intent);
}

private boolean checkPlayServices() {
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
int result = googleAPI.isGooglePlayServicesAvailable(this);
if(result != ConnectionResult.SUCCESS) {
if(googleAPI.isUserResolvableError(result)) {
googleAPI.getErrorDialog(this, result, REQUEST_GOOGLE_PLAY_SERVICES).show();
}
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bayardpresse.stickers.mortelleadele;

import android.app.Application;
import android.graphics.BitmapFactory;

import com.batch.android.Batch;
import com.batch.android.BatchActivityLifecycleHelper;
Expand All @@ -12,9 +13,11 @@ public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Batch.setConfig(new Config("DEV5DC15302BF169FA02064B6CBF57"));
Batch.setConfig(new Config("DEV5DC15302BF169FA02064B6CBF57")); // dev
// Batch.setConfig(new Config("5DC15302BEE52642400FB488F1459C")); // live
Batch.Push.setNotificationsColor(0xFF00FF00);
Batch.Push.setSmallIconResourceId(R.drawable.ic_small_notif);
Batch.Push.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher_background));
registerActivityLifecycleCallbacks(new BatchActivityLifecycleHelper());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
Expand Down Expand Up @@ -68,44 +67,41 @@ public View getView(int position, @Nullable View convertView, @NonNull final Vie
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setPadding(8, 8, 8, 8);
imageView.setAdjustViewBounds(true);
imageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
try {
ImageView iv = (ImageView) v;
Context ctx = v.getContext();

AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
animation1.setDuration(3000);
animation1.setStartOffset(50);
animation1.setFillAfter(true);
iv.startAnimation(animation1);

Sticker _sticker = (Sticker) iv.getTag();
InputStream ais = context.getAssets().open(pack.identifier + "/" + _sticker.imageFileName.replace("webp", "png"));
File targetFile = new File(context.getCacheDir(), _sticker.imageFileName.replace("webp", "png"));
FileUtils.copyInputStreamToFile(ais, targetFile);
Uri uri = FileProvider.getUriForFile(context, BuildConfig.FILE_PROVIDER_AUTHORITY, targetFile);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Intent chooserIntent = Intent.createChooser(shareIntent, "Partager le sticker");
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

Bundle bundle = new Bundle();
bundle.putString("title", "pack : #" + pack.name + "# - #" + _sticker.imageFileName + "#");
bundle.putString("action", "clic : partage sticker");
mFirebaseAnalytics.logEvent("partage", bundle);

ctx.startActivity(chooserIntent);
} catch (Exception e) {
e.printStackTrace();
}
return true;
imageView.setOnTouchListener((v, event) -> {
try {
ImageView iv = (ImageView) v;
Context ctx = v.getContext();

AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
animation1.setDuration(3000);
animation1.setStartOffset(50);
animation1.setFillAfter(true);
iv.startAnimation(animation1);

Sticker _sticker = (Sticker) iv.getTag();
InputStream ais = context.getAssets().open(pack.identifier + "/" + _sticker.imageFileName.replace("webp", "png"));
File targetFile = new File(context.getCacheDir(), _sticker.imageFileName.replace("webp", "png"));
FileUtils.copyInputStreamToFile(ais, targetFile);
Uri uri = FileProvider.getUriForFile(context, BuildConfig.FILE_PROVIDER_AUTHORITY, targetFile);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Intent chooserIntent = Intent.createChooser(shareIntent, "Partager le sticker");
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

Bundle bundle = new Bundle();
bundle.putString("title", "pack : " + pack.name + " - " + _sticker.imageFileName);
bundle.putString("action", "clic : partage sticker");
mFirebaseAnalytics.logEvent("partage", bundle);

ctx.startActivity(chooserIntent);
} catch (Exception e) {
e.printStackTrace();
}
return true;
});
}
else
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout-w900dp/item_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:baselineAligned="false"
android:divider="?android:attr/dividerHorizontal"
android:divider="?attr/dividerHorizontal"
android:orientation="horizontal"
android:showDividers="middle"
tools:context="com.bayardpresse.stickers.mortelleadele.ItemListActivity">
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:padding="@dimen/banner_padding"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:src="@drawable/banner"/>
app:srcCompat="@drawable/banner"/>

<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
Expand Down

0 comments on commit a00a8ea

Please sign in to comment.