Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #99 from alexstyl/develop
Browse files Browse the repository at this point in the history
Release 8.0
  • Loading branch information
alexstyl authored Apr 23, 2017
2 parents d546fab + 93b5057 commit b35cdfa
Show file tree
Hide file tree
Showing 142 changed files with 1,829 additions and 571 deletions.
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.fabric.tools:gradle:1.21.5'
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -25,9 +25,4 @@ task clean(type: Delete) {
delete rootProject.buildDir
}

ext {
androidCompileSdkVersion = 24
androidBuildToolsVersion = '24.0.2'
androidVersionCode = 68
androidVersionName = '7.2'
}

1 change: 0 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ android {
minSdkVersion 16
buildConfigField 'String', 'MIXPANEL_TOKEN', '\"' + mixpanelKey + "\""
}
buildToolsVersion '25.0.0'
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.app.PendingIntent;
import android.content.Context;

import com.alexstyl.specialdates.util.Utils;

public final class AlarmManagerCompat {
private final AlarmManager alarmManager;

Expand All @@ -19,7 +17,7 @@ private AlarmManagerCompat(AlarmManager alarmManager) {
}

public void setExact(int type, long triggerAtmillis, PendingIntent operation) {
if (Utils.hasKitKat()) {
if (Version.hasKitKat()) {
alarmManager.setExact(type, triggerAtmillis, operation);
} else {
alarmManager.set(AlarmManager.RTC, triggerAtmillis, operation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public AndroidDimensionResources(Resources resources) {
public int getPixelSize(@DimenRes int id) {
return resources.getDimensionPixelSize(id);
}

}
41 changes: 41 additions & 0 deletions common/src/main/java/com/alexstyl/android/Version.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.alexstyl.android;

import android.os.Build;

/**
* This class contains static utility methods.
*/
public final class Version {

// Prevents instantiation.
private Version() {
}

public static boolean hasJellyBean() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
}

/**
* Emulate the as operator of C#. If the object can be cast to type it will
* be casted. If not this returns null.
*/
public static <T> T as(Class<T> type, Object o) {
if (type.isInstance(o)) {
return type.cast(o);
}
return null;
}

public static boolean hasKitKat() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
}

/**
* Uses static final constants to detect if the device's platform version is
* Lollipop or later.
*/
public static boolean hasLollipop() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import android.view.View;
import android.widget.TimePicker;

import com.alexstyl.specialdates.R;
import com.alexstyl.specialdates.common.R;

public class TimePreference extends DialogPreference {
private int lastHour = 0;
Expand Down
11 changes: 11 additions & 0 deletions common/src/main/java/com/alexstyl/android/widget/AppWidgetId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.alexstyl.android.widget;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
* A id of a Widget
*/
@Retention(RetentionPolicy.SOURCE)
public @interface AppWidgetId {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import android.util.AttributeSet;
import android.widget.RelativeLayout;

import com.alexstyl.specialdates.R;
import com.alexstyl.specialdates.common.R;

public class ForegroundRelativeLayout extends RelativeLayout {
private Drawable mForeground;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.alexstyl.resources;

import android.support.annotation.DimenRes;
import android.support.annotation.Px;

public interface DimensionResources {
@Px
int getPixelSize(@DimenRes int id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import com.alexstyl.specialdates.events.peopleevents.EventType;

public interface Analytics {
@Deprecated
void trackAction(Action action);

@Deprecated
void trackAction(ActionWithParameters event);

void trackScreen(Screen screen);
Expand Down Expand Up @@ -35,4 +37,8 @@ public interface Analytics {
void trackDailyReminderDisabled();

void trackDailyReminderTimeUpdated(TimeOfDay timeOfDay);

void trackWidgetAdded(Widget widget);

void trackWidgetRemoved(Widget widget);
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ public void trackDailyReminderTimeUpdated(TimeOfDay timeOfDay) {
mixpanel.track("daily reminder time updated", properties);
}

@Override
public void trackWidgetAdded(Widget widget) {
mixpanel.track("widget_added", widgetNameOf(widget));
}

private static JSONObject widgetNameOf(Widget widget) {
JSONObject properties = new JSONObject();
try {
properties.put("widget_name", widget.getWidgetName());
return properties;
} catch (JSONException e) {
e.printStackTrace();
}
return properties;
}

@Override
public void trackWidgetRemoved(Widget widget) {
mixpanel.track("widget_removed", widgetNameOf(widget));
}

private static JSONObject createJSONfor(ActionWithParameters event) {
JSONObject properties = new JSONObject();
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.alexstyl.specialdates.analytics;

public enum Widget {
UPCOMING_EVENTS_SCROLLING("upcoming_events_scrolling"),
UPCOMING_EVENTS_SIMPLE("upcoming_events_simple");

private final String widgetName;

Widget(String widgetName) {
this.widgetName = widgetName;
}

public String getWidgetName() {
return widgetName;
}
}
13 changes: 13 additions & 0 deletions common/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ForegroundLinearLayout">
<attr name="android:foreground" />
<attr name="android:foregroundInsidePadding" />
<attr name="android:foregroundGravity" />
</declare-styleable>

<declare-styleable name="ForegroundImageView">
<attr name="android:foreground" />
</declare-styleable>

</resources>
7 changes: 6 additions & 1 deletion common/versions.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
ext {
android_support_version = '25.1.1'
android_support_version = '25.3.1'
play_services_version = '10.0.1'

androidCompileSdkVersion = 25
androidBuildToolsVersion = '25.0.2'
androidVersionCode = 70
androidVersionName = '8.0'
}

1 change: 0 additions & 1 deletion mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ android {
testOptions {
unitTests.returnDefaultValues = true
}
buildToolsVersion '25.0.0'
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
import android.widget.DatePicker;
import android.widget.Toast;

import com.alexstyl.specialdates.ExternalWidgetRefresher;
import com.alexstyl.specialdates.R;
import com.alexstyl.specialdates.contact.actions.IntentAction;
import com.alexstyl.specialdates.dailyreminder.DailyReminderDebugPreferences;
import com.alexstyl.specialdates.dailyreminder.DailyReminderIntentService;
import com.alexstyl.specialdates.date.Date;
import com.alexstyl.specialdates.events.peopleevents.DebugPeopleEventsUpdater;
import com.alexstyl.specialdates.dailyreminder.DailyReminderIntentService;
import com.alexstyl.specialdates.ui.base.MementoPreferenceFragment;
import com.alexstyl.specialdates.util.Utils;
import com.alexstyl.specialdates.wear.WearSyncService;
import com.alexstyl.specialdates.widgetprovider.TodayWidgetProvider;
import com.alexstyl.specialdates.util.AppUtils;
import com.alexstyl.specialdates.wear.WearSyncWidgetRefresher;

import java.util.Calendar;

Expand All @@ -45,7 +45,7 @@ public boolean onPreferenceClick(Preference preference) {
findPreference(R.string.key_debug_refresh_widget).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
TodayWidgetProvider.updateWidgets(getActivity());
ExternalWidgetRefresher.get(getActivity()).refreshAllWidgets();
Toast.makeText(getActivity(), "Widget(s) refreshed", Toast.LENGTH_SHORT).show();
return true;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ public boolean onPreferenceClick(Preference preference) {
findPreference(R.string.key_debug_trigger_wear_service).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
WearSyncService.startService(getActivity());
new WearSyncWidgetRefresher(getActivity()).refreshWidget();
return true;
}
});
Expand All @@ -118,7 +118,7 @@ public String getName() {
return "date debug";
}
};
Utils.openIntentSafely(getActivity(), i);
AppUtils.openIntentSafely(getActivity(), i);
}

private final DatePickerDialog.OnDateSetListener onDailyReminderDateSelectedListener = new DatePickerDialog.OnDateSetListener() {
Expand Down
28 changes: 22 additions & 6 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
</activity>

<activity
android:name="com.alexstyl.specialdates.widgetprovider.UpcomingWidgetConfigureActivity"
android:name=".upcoming.widget.today.UpcomingWidgetConfigureActivity"
android:label="@string/Configure_widget"
android:noHistory="true">
<intent-filter>
Expand All @@ -147,7 +147,7 @@
android:exported="false" />

<receiver
android:name="com.alexstyl.specialdates.receiver.EventReceiver"
android:name="com.alexstyl.specialdates.DeviceConfigurationUpdatedReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.LOCALE_CHANGED" />
Expand All @@ -164,22 +164,38 @@
</receiver>

<receiver
android:name="com.alexstyl.specialdates.widgetprovider.TodayWidgetProvider"
android:name=".upcoming.widget.today.TodayAppWidgetProvider"
android:exported="false"
android:label="@string/label_widget_textonly">
android:label="@string/widget_upcoming_title_simple">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>

<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info_simple" />
android:resource="@xml/widget_info_upcoming_events_simple" />
</receiver>

<receiver
android:name=".upcoming.widget.list.UpcomingEventsScrollingAppWidgetProvider"
android:label="@string/widget_upcoming_title_list">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>

<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info_upcoming_events_list" />
</receiver>

<service
android:name=".upcoming.widget.list.UpcomingEventsRemoteViewService"
android:permission="android.permission.BIND_REMOTEVIEWS" />

<provider
android:name=".events.peopleevents.StaticEventsContentProvider"
android:authorities="com.alexstyl.specialdates.peopleeventsprovider"
android:exported="false"
android:exported="true"
android:grantUriPermissions="true"
android:label="Events Provider" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.alexstyl.android.preferences;

public @interface PreferenceKeyId {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.alexstyl.specialdates;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
* A {@linkplain BroadcastReceiver} that keeps track whether the user has updated some option on their device external to Memento which can affect the app.
*/
public class DeviceConfigurationUpdatedReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
ExternalWidgetRefresher externalWidgetRefresher = ExternalWidgetRefresher.get(context.getApplicationContext());

String action = intent.getAction();
if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
ErrorTracker.updateLocaleUsed();
externalWidgetRefresher.refreshAllWidgets();
} else if (Intent.ACTION_DATE_CHANGED.equals(action)) {
externalWidgetRefresher.refreshAllWidgets();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import com.alexstyl.specialdates.analytics.Analytics;
import com.alexstyl.specialdates.analytics.Screen;
import com.alexstyl.specialdates.util.Utils;
import com.alexstyl.specialdates.util.AppUtils;
import com.novoda.simplechromecustomtabs.SimpleChromeCustomTabs;

public class ExternalNavigator {
Expand Down Expand Up @@ -79,7 +79,7 @@ public boolean canGoToEmailSupport() {

public void toEmailSupport() {
try {
Intent intent = Utils.getSupportEmailIntent(activity);
Intent intent = AppUtils.getSupportEmailIntent(activity);
activity.startActivity(intent);
analytics.trackScreen(Screen.EMAIL_SUPPORT);
} catch (ActivityNotFoundException ex) {
Expand Down
Loading

0 comments on commit b35cdfa

Please sign in to comment.