Skip to content

Commit

Permalink
357
Browse files Browse the repository at this point in the history
  • Loading branch information
nsantacruz committed May 14, 2018
1 parent e3fad9d commit b78578f
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 13 deletions.
35 changes: 25 additions & 10 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
Expand Down Expand Up @@ -79,16 +79,31 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
Expand All @@ -97,14 +112,14 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="play-services-analytics-8.4.0" level="project" />
<orderEntry type="library" exported="" name="gridlayout-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="play-services-measurement-8.4.0" level="project" />
<orderEntry type="library" exported="" name="design-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-8.4.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-annotations:23.1.0@jar" level="project" />
<orderEntry type="library" exported="" name="com.android.support:design-23.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:gridlayout-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-measurement-8.4.0" level="project" />
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-analytics-8.4.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:recyclerview-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-basement-8.4.0" level="project" />
</component>
</module>
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.sefaria.sefaria"
minSdkVersion 14
targetSdkVersion 23
versionCode 354
versionName "3.54"
versionCode 357
versionName "3.57"
// Enabling multidex support
//multiDexEnabled true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.sefaria.sefaria.MenuElements.MenuDirectRef;
import org.sefaria.sefaria.Settings;
import org.sefaria.sefaria.Util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

public class DailyLearning {
Expand Down Expand Up @@ -128,10 +133,37 @@ private static ChapVersePath getChapVerses(String fullNumber){
return chapVersePath;
}

private static boolean shouldOverrideParsha() {
boolean isBeforeIsraelMeetsUS = false;
try {
SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
Date strDate = sdf.parse("12/05/2018");
Calendar dayIsraelMeetsUS = new GregorianCalendar();
dayIsraelMeetsUS.setTime(strDate);
isBeforeIsraelMeetsUS = Calendar.getInstance().after(dayIsraelMeetsUS);
if (isBeforeIsraelMeetsUS) {
String data = API.getDataFromURL("http://ip-api.com/json");
JSONObject response = new JSONObject(data);
return response.getString("countryCode").equals("IL");
} else {
return false;
}
} catch (API.APIException e) {
return false;
} catch (JSONException e) {
return false;
} catch (ParseException e) {
return false;
}

}

public static MenuDirectRef [] getParsha(Context context){
String todaysDate = getLongDate(1);
boolean shouldOverrideParsha = shouldOverrideParsha();

JSONArray weeks = null;
// todaysDate = "26-Sep-2020"; //fake date for testing
//todaysDate = "12-May-2018"; //fake date for testing
try {
//Log.d("DailyLearning", "getParsha..today: "+ todaysDate);
weeks = Util.openJSONArrayFromAssets("calendar/parshiot.json");
Expand All @@ -142,6 +174,16 @@ private static ChapVersePath getChapVerses(String fullNumber){
String parsha = week.getString("parasha");
String [] multiParshas = parsha.split("-"); // If it's a double parsha only get the first
String aliyah = week.getJSONArray("aliyot").getString(0);
if (shouldOverrideParsha && parsha.equals("Emor")) {
parsha = "Behar";
multiParshas = parsha.split("-");
aliyah = "Leviticus 25:1-25:18";
} else if (shouldOverrideParsha && parsha.equals("Behar-Bechukotai")) {
parsha = "Bechukotai";
multiParshas = parsha.split("-");
aliyah = "Leviticus 26:3-26:5";
}

String bookName = aliyah.replaceFirst("\\s[0-9]+.*$", "");
Book book = new Book(bookName);
Node node = getParshaFromSefar(book, multiParshas[0]);
Expand Down

0 comments on commit b78578f

Please sign in to comment.