Skip to content

Commit

Permalink
Merge pull request #134 from ItsCalebJones/dev
Browse files Browse the repository at this point in the history
Merge 2.6.3 to Master.
  • Loading branch information
ItsCalebJones committed Oct 12, 2018
2 parents 9b69463 + c7c23cd commit 5e1c28a
Show file tree
Hide file tree
Showing 78 changed files with 2,227 additions and 743 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ ext {
app = [
versionMajor : 2,
versionMinor : 6,
versionPatch : 2

versionPatch : 3
]
// Sdk and tools
minSdkVersion = 19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public final class Constants {

public static String FORECAST_IO_BASE_URL = "https://api.forecast.io/";
public static String API_BASE_URL = "https://spacelaunchnow.me/";
public static String API_DEBUG_BASE_URL = "http://10.0.2.2:8000/";
// public static String API_DEBUG_BASE_URL = "http://10.0.2.2:8000/";
public static String API_DEBUG_BASE_URL = "https://dev.spacelaunchnow.me/";
public static String LIBRARY_BASE_URL = "https://launchlibrary.net/";
public static String DEBUG_BASE_URL = "https://launchlibrary.net/";
public static String NEWS_BASE_URL = "https://api.spaceflightnewsapi.net";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,24 @@ public Call<Launch> getLaunchById(int launchID, Callback<Launch> callback) {
return call;
}

public Call<LaunchResponse> getNextUpcomingLaunchesMini(int limit, int offset, Callback<LaunchResponse> callback) {
Call<LaunchResponse> call = spaceLaunchNowService.getUpcomingLaunches(limit, offset, "list", null, null, null);
public Call<LaunchResponse> getNextUpcomingLaunchesForWidgets(int limit, int offset, Callback<LaunchResponse> callback) {
Call<LaunchResponse> call = spaceLaunchNowService.getUpcomingLaunches(limit, offset, "detailed", null, null, null, null, null);

call.enqueue(callback);

return call;
}

public Call<LaunchResponse> getNextUpcomingLaunches(int limit, int offset, Callback<LaunchResponse> callback) {
Call<LaunchResponse> call = spaceLaunchNowService.getUpcomingLaunches(limit, offset, "detailed", null, null, null);
public Call<LaunchResponse> getNextUpcomingLaunches(int limit, int offset, String location_ids, String lsp_ids, Callback<LaunchResponse> callback) {
Call<LaunchResponse> call = spaceLaunchNowService.getUpcomingLaunches(limit, offset, "detailed", null, null, null, lsp_ids, location_ids);

call.enqueue(callback);

return call;
}

public Call<LaunchResponse> getUpcomingLaunches(int limit, int offset, String search, String lspName, Integer launchId, Callback<LaunchResponse> callback) {
Call<LaunchResponse> call = spaceLaunchNowService.getUpcomingLaunches(limit, offset, "detailed", search, lspName, launchId);
Call<LaunchResponse> call = spaceLaunchNowService.getUpcomingLaunches(limit, offset, "detailed", search, lspName, launchId, null, null);

call.enqueue(callback);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ Call<LaunchResponse> getUpcomingLaunches(@Query("limit") int amount, @Query("off
Call<LaunchResponse> getUpcomingLaunches(@Query("limit") int amount, @Query("offset") int offset,
@Query("mode") String mode, @Query("search") String search,
@Query("lsp__name") String lspName,
@Query("launcher_config__id") Integer launcherId);
@Query("launcher_config__id") Integer launcherId,
@Query("lsp__ids") String lspIds,
@Query("location__ids") String locationIds);

@Headers({"User-Agent: SpaceLaunchNow-" + BuildConfig.VERSION_NAME})
@GET(version + "/launch/upcoming/")
Expand Down
8 changes: 6 additions & 2 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ dependencies {
implementation "com.google.android.gms:play-services-ads:$rootProject.playServicesVersion"
implementation "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"

implementation 'com.pixplicity.easyprefs:library:1.9.0'

// Architecture and Tools
implementation 'com.jonathanfinerty.once:once:1.2.2'
implementation 'org.greenrobot:eventbus:3.1.1'
Expand All @@ -243,9 +245,11 @@ dependencies {

implementation 'com.github.ItsCalebJones:GDPRDialog:54231db'

implementation 'com.andkulikov:transitionseverywhere:1.8.0'

implementation 'com.android.support:support-v4:27.1.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.github.jrvansuita:MaterialAbout:0.2.1'
implementation 'com.github.jrvansuita:MaterialAbout:0.2.3'
implementation 'com.github.mukeshsolanki:MarkdownView-Android:1.0.4'
implementation 'com.jaredrummler:colorpicker:1.0.1'
implementation 'com.andkulikov:transitionseverywhere:1.7.7'
Expand All @@ -264,7 +268,7 @@ dependencies {

// If you want to use the GPU Filters
implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
implementation('com.mikepenz:materialdrawer:6.0.2@aar') {
implementation ("com.mikepenz:materialdrawer:6.0.6@aar") {
transitive = true
}

Expand Down
12 changes: 11 additions & 1 deletion mobile/src/main/assets/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ A space launch tracker for Android using data from the Launch Library API.
## Changelog
#### Updated 6-11-2018
---
### Version 2.6.2 (Latest)
### Version 2.6.3 (Latest)
#### Overview
Add In Flight and Launch Success notification types and other small fixes.

#### Changelog
* Add new notifications for in-flight and success.
* Redid the notification system to make it easier for adding new types.
* Made it easier to edit notification channels on Android 8 and above.
* Links to Translator application directly in the application.

### Version 2.6.2
#### Overview
Finally, SpaceX landing information! It's a long time coming but its finally here.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Application;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.net.Uri;
Expand All @@ -27,6 +28,7 @@
import com.michaelflisar.gdprdialog.GDPR;
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;
import com.mikepenz.materialdrawer.util.DrawerImageLoader;
import com.pixplicity.easyprefs.library.Prefs;
import com.twitter.sdk.android.core.DefaultLogger;
import com.twitter.sdk.android.core.Twitter;
import com.twitter.sdk.android.core.TwitterAuthConfig;
Expand All @@ -44,6 +46,7 @@
import me.calebjones.spacelaunchnow.content.database.ListPreferences;
import me.calebjones.spacelaunchnow.content.database.SwitchPreferences;
import me.calebjones.spacelaunchnow.content.jobs.DataJobCreator;
import me.calebjones.spacelaunchnow.content.jobs.SyncCalendarJob;
import me.calebjones.spacelaunchnow.content.jobs.SyncJob;
import me.calebjones.spacelaunchnow.content.jobs.SyncWearJob;
import me.calebjones.spacelaunchnow.content.jobs.UpdateWearJob;
Expand Down Expand Up @@ -77,6 +80,7 @@ public void onCreate() {
context = this;
firebaseMessaging = FirebaseMessaging.getInstance();

setupAndCheckOnce();
setupAds();
setupPreferences();
setupCrashlytics();
Expand All @@ -87,7 +91,6 @@ public void onCreate() {
setupTheme();
setupDrawableLoader();
checkSubscriptions();
setupAndCheckOnce();
setupNotificationChannels();
setupTwitter();
}
Expand Down Expand Up @@ -235,14 +238,18 @@ private void restorePurchases() {
}
}


private void setupPreferences() {
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
sharedPreference = ListPreferences.getInstance(this);
switchPreferences = SwitchPreferences.getInstance(this);
new Prefs.Builder()
.setContext(this)
.setMode(ContextWrapper.MODE_PRIVATE)
.setPrefsName(getPackageName())
.setUseDefaultSharedPreference(true)
.build();
}


private void setupForecast() {
ForecastConfiguration configuration =
new ForecastConfiguration.Builder(getResources().getString(R.string.forecast_io_key))
Expand All @@ -251,7 +258,6 @@ private void setupForecast() {
ForecastClient.create(configuration);
}


private void setupNotification() {
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree(), new CrashlyticsTree(context));
Expand All @@ -263,8 +269,92 @@ private void setupNotification() {
firebaseMessaging.subscribeToTopic("production");
firebaseMessaging.unsubscribeFromTopic("debug");
}
migrateNotifications();

boolean notificationEnabled = Prefs.getBoolean("notificationEnabled", true);
boolean netstampChanged = Prefs.getBoolean("netstampChanged", true);
boolean webcastOnly = Prefs.getBoolean("webcastOnly", false);
boolean twentyFourHour = Prefs.getBoolean("twentyFourHour", true);
boolean oneHour = Prefs.getBoolean("oneHour", true);
boolean tenMinutes = Prefs.getBoolean("tenMinutes", true);
boolean oneMinute = Prefs.getBoolean("oneMinute", true);
boolean inFlight = Prefs.getBoolean("inFlight", true);
boolean success = Prefs.getBoolean("success", true);

if (notificationEnabled) {
firebaseMessaging.subscribeToTopic("notificationEnabled");
} else {
firebaseMessaging.unsubscribeFromTopic("notificationEnabled");
}

if (netstampChanged) {
firebaseMessaging.subscribeToTopic("netstampChanged");
} else {
firebaseMessaging.unsubscribeFromTopic("netstampChanged");
}

if (webcastOnly) {
firebaseMessaging.subscribeToTopic("webcastOnly");
} else {
firebaseMessaging.unsubscribeFromTopic("webcastOnly");
}

if (twentyFourHour) {
firebaseMessaging.subscribeToTopic("twentyFourHour");
} else {
firebaseMessaging.unsubscribeFromTopic("twentyFourHour");
}

if (oneHour) {
firebaseMessaging.subscribeToTopic("oneHour");
} else {
firebaseMessaging.unsubscribeFromTopic("oneHour");
}

if (tenMinutes) {
firebaseMessaging.subscribeToTopic("tenMinutes");
} else {
firebaseMessaging.unsubscribeFromTopic("tenMinutes");
}

if (inFlight) {
firebaseMessaging.subscribeToTopic("inFlight");
} else {
firebaseMessaging.unsubscribeFromTopic("inFlight");
}

if (success) {
firebaseMessaging.subscribeToTopic("success");
} else {
firebaseMessaging.unsubscribeFromTopic("success");
}

if (oneMinute) {
firebaseMessaging.subscribeToTopic("oneMinute");
} else {
firebaseMessaging.unsubscribeFromTopic("oneMinute");
}

}

private void migrateNotifications() {
if (!Once.beenDone("migrateNotifications")) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean notificationEnabled = prefs.getBoolean("notifications_new_message", true);
boolean netstampChanged = prefs.getBoolean("notifications_launch_imminent_updates", true);
boolean webcastOnly = prefs.getBoolean("notifications_new_message_webcast", false);
boolean twentyFourHour = prefs.getBoolean("notifications_launch_day", true);
boolean oneHour = prefs.getBoolean("notifications_launch_imminent", true);
boolean tenMinutes = prefs.getBoolean("notifications_launch_minute", true);

Prefs.putBoolean("notificationEnabled", notificationEnabled);
Prefs.putBoolean("netstampChanged", netstampChanged);
Prefs.putBoolean("webcastOnly", webcastOnly);
Prefs.putBoolean("twentyFourHour", twentyFourHour);
Prefs.putBoolean("oneHour", oneHour);
Prefs.putBoolean("tenMinutes", tenMinutes);
}
}

private void setupCrashlytics() {
/*
Expand All @@ -291,12 +381,12 @@ private void setupCrashlytics() {
}).start();
}


private void startJobs() {
new Thread(() -> {
SyncJob.schedulePeriodicJob(context);
SyncWearJob.scheduleJob();
UpdateWearJob.scheduleJobNow();
SyncCalendarJob.scheduleDailyJob();
}).start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.preference.PreferenceManager;
import android.provider.CalendarContract;

import com.pixplicity.easyprefs.library.Prefs;

import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmResults;
Expand Down Expand Up @@ -35,15 +37,17 @@ public CalendarSyncManager(Context context) {
if (calendarItem != null) {
calendarUtil = new CalendarUtility(calendarItem);
} else {
sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean("calendar_sync_state", false);
editor.apply();
Prefs.putBoolean("calendar_sync_state", false);

switchPreferences.setCalendarStatus(false);
}
}

public void resyncCalendarItem(){
calendarItem = mRealm.where(CalendarItem.class).findFirst();
calendarUtil = new CalendarUtility(calendarItem);
}

public void syncAllEevnts() {
if (calendarUtil != null) {
handleActionSyncAll();
Expand Down Expand Up @@ -120,12 +124,7 @@ private void handleActionDeleteAll() {
for (final Launch launchRealm : launches) {
int success = calendarUtil.deleteEvent(context, launchRealm);
if (success > 0) {
mRealm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
launchRealm.setEventID(null);
}
});
mRealm.executeTransaction(realm -> launchRealm.setEventID(null));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
package me.calebjones.spacelaunchnow.common;

import android.app.ActivityManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;

import java.util.TimeZone;

import io.realm.Realm;
import me.calebjones.spacelaunchnow.R;
import me.calebjones.spacelaunchnow.utils.analytics.Analytics;
import timber.log.Timber;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package me.calebjones.spacelaunchnow.content.data;

import android.content.Context;
import android.net.Uri;

import java.util.List;
import java.util.Set;

import io.realm.Realm;
import me.calebjones.spacelaunchnow.content.data.next.NextLaunchDataRepository;
import me.calebjones.spacelaunchnow.content.database.ListPreferences;
import me.calebjones.spacelaunchnow.content.services.NextLaunchTracker;
import me.calebjones.spacelaunchnow.data.models.Constants;
import me.calebjones.spacelaunchnow.data.models.main.Launch;
import me.calebjones.spacelaunchnow.data.models.Result;
import me.calebjones.spacelaunchnow.data.networking.DataClient;
import me.calebjones.spacelaunchnow.data.networking.error.ErrorUtil;
Expand Down Expand Up @@ -69,8 +62,8 @@ public boolean isRunning() {

public void getNextUpcomingLaunchesMini() {
isNextLaunches = true;
Timber.i("Running getNextUpcomingLaunchesMini");
DataClient.getInstance().getNextUpcomingLaunchesMini(20, 0, new Callback<LaunchResponse>() {
Timber.i("Running getNextUpcomingLaunchesForWidgets");
DataClient.getInstance().getNextUpcomingLaunchesForWidgets(20, 0, new Callback<LaunchResponse>() {
@Override
public void onResponse(Call<LaunchResponse> call, Response<LaunchResponse> response) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public void deleteLaunch(int id) {
.equalTo("id", id)
.findFirst();
if (previous != null) {
previous.deleteFromRealm();
mRealm.executeTransaction(realm -> previous.deleteFromRealm());
}
}
}

0 comments on commit 5e1c28a

Please sign in to comment.