Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  make: add reploy target
  upgrade to firebase analytics
  update constraint layout
  fix billing code response listner
  • Loading branch information
shalzz committed Apr 23, 2018
2 parents c7e79d5 + 3885189 commit 84fccb1
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 251 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ deploy: check-env
git push && git push --tags
git checkout dev

redeploy: check-env
git checkout dev
git push
git checkout master
git merge dev --no-edit
git tag -d $(TAG)
git push origin :refs/tags/$(TAG)
git tag -a $(TAG)
git push && git push --tags
git checkout dev

check-env:
ifndef TAG
$(error TAG is undefined)
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ android {
final AUTO_VALUE_GSON_VERSION = '0.7.0'
final AUTO_VALUE_PARCEL_VERSION = '0.2.5'

implementation "com.google.android.gms:play-services-analytics:9.4.0"
implementation 'com.google.firebase:firebase-core:15.0.0'

implementation "com.android.support:support-compat:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-core-utils:$SUPPORT_LIBRARY_VERSION"
Expand All @@ -153,7 +153,7 @@ android {
implementation "com.android.support:preference-v14:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.billingclient:billing:1.0'

implementation "android.arch.persistence:db:1.0.0"
Expand Down
20 changes: 10 additions & 10 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"project_info": {
"project_number": "266643851647",
"firebase_url": "https://upes-academics.firebaseio.com",
"project_id": "upes-academics",
"storage_bucket": "upes-academics.appspot.com"
"project_number": "808643328444",
"firebase_url": "https://college-academics.firebaseio.com",
"project_id": "college-academics",
"storage_bucket": "college-academics.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:266643851647:android:b118c157fb2148fb",
"mobilesdk_app_id": "1:808643328444:android:b118c157fb2148fb",
"android_client_info": {
"package_name": "com.shalzz.attendance"
}
},
"oauth_client": [
{
"client_id": "266643851647-ununrco4nr77ap7fhjn9actfs3lsq4p6.apps.googleusercontent.com",
"client_id": "808643328444-hcvnsn3js06i5dhlkpq07m5b6qi53s27.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDKrLXqVt9BQN8urcQOx1eqYGzeeWcOb7k"
"current_key": "AIzaSyDcpltDhcLpI3iap-4U_omcHows7RLRtOc"
}
],
"services": {
Expand All @@ -39,20 +39,20 @@
},
{
"client_info": {
"mobilesdk_app_id": "1:266643851647:android:e8a36c474a772de4",
"mobilesdk_app_id": "1:808643328444:android:e8a36c474a772de4",
"android_client_info": {
"package_name": "com.shalzz.attendance.debug"
}
},
"oauth_client": [
{
"client_id": "266643851647-ununrco4nr77ap7fhjn9actfs3lsq4p6.apps.googleusercontent.com",
"client_id": "808643328444-hcvnsn3js06i5dhlkpq07m5b6qi53s27.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDKrLXqVt9BQN8urcQOx1eqYGzeeWcOb7k"
"current_key": "AIzaSyDcpltDhcLpI3iap-4U_omcHows7RLRtOc"
}
],
"services": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import android.app.Application;
import android.content.Context;

import com.google.android.gms.analytics.Tracker;
import com.shalzz.attendance.injection.ApplicationContext;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.shalzz.attendance.data.remote.DataAPI;
import com.shalzz.attendance.injection.ApplicationContext;

import javax.inject.Named;
import javax.inject.Singleton;
Expand Down Expand Up @@ -69,8 +69,8 @@ DataAPI provideDataAPIService() {
@Provides
@Named("app")
@Singleton
synchronized Tracker provideTracker(@ApplicationContext Context context) {
return mock(Tracker.class);
synchronized FirebaseAnalytics provideTracker(@ApplicationContext Context context) {
return mock(FirebaseAnalytics.class);
}

}
31 changes: 0 additions & 31 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
<!-- Get permission for reliable local dispatching on non-Google Play devices. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- Remove permissions added by firebase -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" tools:node="remove" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" tools:node="remove" />
<permission android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" tools:node="remove"/>

<supports-screens
android:smallScreens="true"
android:normalScreens="true"
Expand Down Expand Up @@ -125,32 +119,7 @@
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

</activity>

<!-- Register AnalyticsReceiver and AnalyticsService to support background
dispatching on non-Google Play devices. -->
<receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>

<!-- Used for Google Play Store Campaign Measurement-->
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.CampaignTrackingService"
android:enabled="true"
android:exported="false" />

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class BillingManager implements PurchasesUpdatedListener {
* item was finished
*/
public interface BillingUpdatesListener {
void onBillingClientSetupFinished();
void onBillingClientSetupFinished(int code);
void onConsumeFinished(String token, @BillingResponse int result);
void onPurchasesUpdated(List<Purchase> purchases);
}
Expand All @@ -77,15 +77,14 @@ public BillingManager(Activity activity,
.subscribe(code -> {
Timber.d("First Connection. Response code: %d", code);
if (code == BillingResponse.OK) {
// Notify the listener that the billing client is ready.
mBillingUpdatesListener.onBillingClientSetupFinished();
// IAB is fully setup. Now get an inventory of stuff the user owns.
queryPurchases();
}
}));
}

private Observable<Integer> connect() {
// Notify the listener that the billing client is ready.
return Observable.create((ObservableOnSubscribe<Integer>) source -> {
if (source.isDisposed()) return;
if (mBillingClient.isReady()) {
Expand Down Expand Up @@ -113,7 +112,9 @@ public void onBillingServiceDisconnected() {
})
.retry()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
.observeOn(AndroidSchedulers.mainThread())
// Notify the listener that the billing client is ready.
.doOnNext(mBillingUpdatesListener::onBillingClientSetupFinished);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@
import android.app.Application;
import android.content.Context;

import com.google.android.gms.analytics.Tracker;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.shalzz.attendance.data.DataManager;
import com.shalzz.attendance.data.local.DatabaseHelper;
import com.shalzz.attendance.data.local.DbOpenHelper;
import com.shalzz.attendance.data.local.PreferencesHelper;
import com.shalzz.attendance.data.remote.DataAPI;
import com.shalzz.attendance.injection.ApplicationContext;
import com.shalzz.attendance.injection.module.ApplicationModule;
import com.shalzz.attendance.injection.module.NetworkModule;
import com.shalzz.attendance.data.remote.DataAPI;
import com.shalzz.attendance.sync.SyncService;
import com.shalzz.attendance.ui.settings.AboutSettingsFragment;
import com.shalzz.attendance.ui.settings.SettingsFragment;
import com.shalzz.attendance.data.local.PreferencesHelper;
import com.shalzz.attendance.utils.RxEventBus;

import javax.inject.Named;
Expand All @@ -49,7 +46,7 @@ public interface ApplicationComponent {
Context context();
Application application();
@Named("app")
Tracker tracker();
FirebaseAnalytics tracker();
DataAPI dataApi();
PreferencesHelper preferenceManager();
DatabaseHelper databaseHelper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@
import android.app.Application;
import android.content.Context;

import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
import com.shalzz.attendance.R;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.shalzz.attendance.injection.ApplicationContext;

import java.util.HashMap;

import javax.inject.Named;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
Expand All @@ -40,21 +35,6 @@ public class ApplicationModule {

private final Application mApplication;

/**
* Enum used to identify the tracker that needs to be used for tracking.
*
* A single tracker is usually enough for most purposes. In case you do need multiple trackers,
* storing them all in Application object helps ensure that they are created only once per
* application instance.
*/
public enum TrackerName {
APP_TRACKER, // Tracker used only in this app.
GLOBAL_TRACKER, // Tracker used by all the apps from a company. eg: roll-up tracking.
ECOMMERCE_TRACKER, // Tracker used by all ecommerce transactions from a company.
}

private HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();

public ApplicationModule(Application application) {
mApplication = application;
}
Expand All @@ -72,17 +52,7 @@ Context provideContext() {

@Provides
@Named("app")
synchronized Tracker provideTracker(@ApplicationContext Context context) {
TrackerName trackerId = TrackerName.APP_TRACKER;
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
Tracker t = analytics.newTracker(R.xml.app_tracker);
mTrackers.put(trackerId, t);
}
Tracker t = mTrackers.get(trackerId);
t.enableAdvertisingIdCollection(true);
t.enableExceptionReporting(false);
t.setAnonymizeIp(true);
return t;
synchronized FirebaseAnalytics provideTracker(@ApplicationContext Context context) {
return FirebaseAnalytics.getInstance(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
Expand Down Expand Up @@ -50,8 +51,7 @@
import com.bugsnag.android.Bugsnag;
import com.github.amlcurran.showcaseview.ShowcaseView;
import com.github.amlcurran.showcaseview.targets.ViewTarget;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.malinskiy.materialicons.IconDrawable;
import com.malinskiy.materialicons.Iconify;
import com.shalzz.attendance.R;
Expand Down Expand Up @@ -88,7 +88,7 @@ public class AttendanceListFragment extends Fragment implements
ExpandableListAdapter mAdapter;

@Inject @Named("app")
Tracker mTracker;
FirebaseAnalytics mTracker;

static class EmptyView {
@BindView(R.id.emptyStateImageView)
Expand Down Expand Up @@ -133,15 +133,10 @@ static class EmptyView {
@Nullable private StaggeredGridLayoutManager mGridLayoutManager;
private Context mContext;
private Unbinder unbinder;
public EmptyView mEmptyView = new EmptyView();
private Activity mActivity;

@Override
public void onStart() {
super.onStart();
private EmptyView mEmptyView = new EmptyView();

mTracker.setScreenName(getClass().getSimpleName());
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}

@Override
public View onCreateView( @NonNull LayoutInflater inflater, ViewGroup container,
Expand All @@ -150,7 +145,8 @@ public View onCreateView( @NonNull LayoutInflater inflater, ViewGroup container,
unbinder = ButterKnife.bind(this, mView);
ButterKnife.bind(mEmptyView, emptyView);

((MainActivity) getActivity()).activityComponent().inject(this);
mActivity = getActivity();
((MainActivity) mActivity).activityComponent().inject(this);
Bugsnag.setContext("AttendanceList");
mPresenter.attachView(this);

Expand Down Expand Up @@ -195,6 +191,11 @@ public View onCreateView( @NonNull LayoutInflater inflater, ViewGroup container,
return mView;
}

@Override
public void onStart() {
super.onStart();
mTracker.setCurrentScreen(mActivity, getClass().getSimpleName(), getClass().getName());
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
Expand All @@ -217,6 +218,9 @@ public boolean onQueryTextChange(String arg0) {
String filter = !TextUtils.isEmpty(arg0) ? arg0 : null;
clearSubjects();
mPresenter.loadAttendance(filter);
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.SEARCH_TERM, filter);
mTracker.logEvent(FirebaseAnalytics.Event.SEARCH, bundle);
return false;
}
});
Expand All @@ -233,10 +237,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
}
else if(item.getItemId() == R.id.menu_search) {
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Search")
.build());
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, item.getTitle().toString());
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Search");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "menu");
mTracker.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
}
return super.onOptionsItemSelected(item);
}
Expand Down
Loading

0 comments on commit 84fccb1

Please sign in to comment.