Skip to content

Commit

Permalink
Merge branch 'release/1.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitletondor committed May 22, 2017
2 parents daf2ccf + 2116df8 commit addf4c9
Show file tree
Hide file tree
Showing 43 changed files with 1,133 additions and 683 deletions.
7 changes: 1 addition & 6 deletions Android/EasyBudget/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 35 additions & 63 deletions Android/EasyBudget/app/app.iml

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions Android/EasyBudget/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ buildscript {
}

dependencies {
classpath 'io.fabric.tools:gradle:1.21.5'
classpath 'io.fabric.tools:gradle:1.21.6'
}
}

Expand All @@ -36,15 +36,15 @@ repositories {
}

android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
applicationId "com.benoitletondor.easybudgetapp"
minSdkVersion 16
targetSdkVersion 24
versionCode 42
versionName "1.4"
targetSdkVersion 25
versionCode 45
versionName "1.5.2"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
Expand Down Expand Up @@ -75,17 +75,17 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:percent:24.0.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
compile 'com.google.android.gms:play-services-analytics:9.2.0'
compile 'com.google.android.gms:play-services-appinvite:9.2.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:percent:25.3.1'
compile 'com.google.android.gms:play-services-gcm:10.2.4'
compile 'com.google.android.gms:play-services-analytics:10.2.4'
compile 'com.google.android.gms:play-services-appinvite:10.2.4'
compile 'com.roomorama:caldroid:3.0.1'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'me.relex:circleindicator:1.2.1@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { transitive = true; }
compile 'com.batch.android:batch-sdk:1.5.3'
compile 'me.relex:circleindicator:1.2.2@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true; }
compile 'com.batch.android:batch-sdk:1.8.0'
}
16 changes: 14 additions & 2 deletions Android/EasyBudget/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@

<data android:scheme="easybudget"/>
</intent-filter>

<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name=".view.MonthlyReportActivity"
Expand All @@ -78,9 +82,9 @@
android:screenOrientation="portrait"
android:theme="@style/AppThemeNoActionBar"/>
<activity
android:name=".view.MonthlyExpenseEditActivity"
android:name=".view.RecurringExpenseEditActivity"
android:configChanges="locale|keyboardHidden|orientation|screenSize"
android:label="@string/title_activity_monthly_expense_add"
android:label="@string/title_activity_recurring_expense_add"
android:screenOrientation="portrait"
android:theme="@style/AppThemeNoActionBar"/>
<activity
Expand Down Expand Up @@ -115,6 +119,14 @@
</intent-filter>
</receiver>

<service
android:name="com.batch.android.BatchPushInstanceIDService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>

<!-- Notif services -->
<service android:name=".notif.DailyNotifOptinService"/>
<service android:name=".notif.MonthlyReportNotifService"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ public class BuildVersion
* 05/03/2016
*/
public final static int VERSION_1_3_1 = 40;
/**
* Android Nougat compatibility and bug fixes for premium users
* 01/07/2016
*/
public final static int VERSION_1_4 = 42;
/**
* PlayStore promo codes and weekly, bi-weekly and yearly recurring entries
* 21/05/2017
*/
public final static int VERSION_1_5_2 = 45;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@

import android.app.Activity;
import android.app.Application;
import android.app.PendingIntent;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AlertDialog;

import com.batch.android.Batch;
import com.batch.android.BatchUnlockListener;
import com.batch.android.Config;
import com.batch.android.Offer;
import com.batch.android.PushNotificationType;
import com.benoitletondor.easybudgetapp.helper.CurrencyHelper;
import com.benoitletondor.easybudgetapp.helper.Logger;
import com.benoitletondor.easybudgetapp.helper.ParameterKeys;
import com.benoitletondor.easybudgetapp.helper.Parameters;

import com.benoitletondor.easybudgetapp.helper.UIHelper;
import com.benoitletondor.easybudgetapp.helper.UserHelper;
import com.benoitletondor.easybudgetapp.iab.IabBroadcastReceiver;
Expand All @@ -53,19 +54,19 @@
import com.crashlytics.android.Crashlytics;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.google.android.gms.analytics.Logger.LogLevel;
import com.google.android.gms.analytics.Tracker;

import io.fabric.sdk.android.Fabric;

import java.net.URLEncoder;
import java.util.Calendar;
import java.util.Currency;
import java.util.Date;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;

import io.fabric.sdk.android.Fabric;

/**
* EasyBudget application. Implements GA tracking, Batch set-up, Crashlytics set-up && iab.
*
Expand Down Expand Up @@ -446,6 +447,27 @@ private boolean shouldShowPremiumPopup()
return new Date().after(cal.getTime());
}

/**
* Show the 1.5 app update notification
*/
private void show1_5UpdateNotif()
{
NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_push)
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText(getResources().getString(R.string.recurring_update_notification))
.setStyle(new NotificationCompat.BigTextStyle().bigText(getResources().getString(R.string.recurring_update_notification)))
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.accent))
.setAutoCancel(true)
.setContentIntent(PendingIntent.getActivity(
this,
0,
new Intent(this, MainActivity.class),
PendingIntent.FLAG_CANCEL_CURRENT));

NotificationManagerCompat.from(getApplicationContext()).notify(4014, notifBuilder.build());
}

/**
* Set-up Batch SDK config + lifecycle
*/
Expand Down Expand Up @@ -474,50 +496,6 @@ public void onActivityCreated(Activity activity, Bundle savedInstanceState)
@Override
public void onActivityStarted(final Activity activity)
{
Batch.Unlock.setUnlockListener(new BatchUnlockListener()
{
@Override
public void onRedeemAutomaticOffer(Offer offer)
{
boolean shouldShowPopup = true;

if (offer.containsFeature(UserHelper.BATCH_PREMIUM_FEATURE))
{
boolean alreadyPremium = UserHelper.isUserPremium(EasyBudget.this);
if (alreadyPremium) // Not show popup again if user is already premium
{
shouldShowPopup = false;
}

UserHelper.setBatchUserPremium(activity);
}

if (shouldShowPopup)
{
Map<String, String> additionalParameters = offer.getOfferAdditionalParameters();

String rewardMessage = additionalParameters.get("reward_message");
String rewardTitle = additionalParameters.get("reward_title");

if (rewardTitle != null && rewardMessage != null)
{
new AlertDialog.Builder(activity)
.setTitle(rewardTitle)
.setMessage(rewardMessage)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
}
})
.show();
}
}
}
});

Batch.onStart(activity);
}

Expand Down Expand Up @@ -602,6 +580,11 @@ private void onUpdate(int previousVersion, int newVersion)
MonthlyReportNotifService.showNotPremiumNotif(getApplicationContext());
}
}

if( newVersion == BuildVersion.VERSION_1_5_2 )
{
show1_5UpdateNotif();
}
}

// -------------------------------------->
Expand Down Expand Up @@ -666,6 +649,11 @@ private void onAppForeground(@NonNull Activity activity)
* Premium popup after rating complete
*/
showPremiumPopupIfNeeded(activity);

/*
* Update iap status if needed
*/
updateIAPStatusIfNeeded();
}

/**
Expand Down Expand Up @@ -782,6 +770,41 @@ private void setIabStatusAndNotify(@NonNull PremiumCheckStatus status)
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}

/**
* Update the current IAP status if already checked
*/
private void updateIAPStatusIfNeeded()
{
Logger.debug("updateIAPStatusIfNeeded: "+iabStatus);

if( iabStatus == PremiumCheckStatus.NOT_PREMIUM )
{
setIabStatusAndNotify(PremiumCheckStatus.CHECKING);
iabHelper.queryInventoryAsync(inventoryListener);
}
}

/**
* Launch the redeem promocode flow
*
* @param promocode the promocode to redeem
* @param activity the current activity
*/
public boolean launchRedeemPromocodeFlow(@NonNull String promocode, @NonNull Activity activity)
{
try
{
String url = "https://play.google.com/redeem?code=" + URLEncoder.encode(promocode, "UTF-8");
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
catch (Exception e)
{
Logger.error(false, "Error while redeeming promocode", e);
return false;
}
}

/**
* Launch the premium purchase flow
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ public static String getFormattedAmountValue(double amount)
* @param value the double value
* @return the corresponding int value (double * 100)
*/
public static int getDBValueForDouble(double value)
public static long getDBValueForDouble(double value)
{
String stringValue = getFormattedAmountValue(value);
if(BuildConfig.DEBUG_LOG) Logger.debug("getDBValueForDouble: "+stringValue);

int ceiledValue = (int) Math.ceil(value * 100);
long ceiledValue = (long) Math.ceil(value * 100);
double ceiledDoubleValue = ceiledValue / 100.d;

if( getFormattedAmountValue(ceiledDoubleValue).equals(stringValue) )
Expand All @@ -230,7 +230,7 @@ public static int getDBValueForDouble(double value)
return ceiledValue;
}

int normalValue = (int) value * 100;
long normalValue = (long) value * 100;
double normalDoubleValue = normalValue / 100.d;

if( getFormattedAmountValue(normalDoubleValue).equals(stringValue) )
Expand All @@ -239,7 +239,7 @@ public static int getDBValueForDouble(double value)
return normalValue;
}

int flooredValue = (int) Math.floor(value * 100);
long flooredValue = (long) Math.floor(value * 100);
if(BuildConfig.DEBUG_LOG) Logger.debug("getDBValueForDouble, return floored value: "+flooredValue);

return flooredValue;
Expand Down
Loading

0 comments on commit addf4c9

Please sign in to comment.