Skip to content

Commit

Permalink
Merge pull request #88 from StepicOrg/release/1.39
Browse files Browse the repository at this point in the history
Release/1.39
  • Loading branch information
KirillMakarov authored Jul 25, 2017
2 parents 8dc965c + c8e0826 commit 5505fef
Show file tree
Hide file tree
Showing 30 changed files with 208 additions and 91 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
applicationId "org.stepic.droid"
minSdkVersion rootProject.androidMinSdkVersion
targetSdkVersion rootProject.androidTargetSdkVersion
versionCode 164
versionName "1.37"
versionCode 165
versionName "1.39"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
92 changes: 39 additions & 53 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="org.stepic.droid"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.stepic.droid"
android:installLocation="auto">

<uses-permission android:name="android.permission.INTERNET"/>
Expand Down Expand Up @@ -31,26 +31,27 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/AppTheme"
tools:replace="allowBackup, supportsRtl"
>
tools:replace="allowBackup, supportsRtl">

<meta-data android:name="asset_statements" android:resource="@string/asset_statements"/>
<meta-data
android:name="asset_statements"
android:resource="@string/asset_statements"/>

<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>

<activity
android:name="org.stepic.droid.ui.activities.SplashActivity"
android:theme="@style/AppTheme.BrandedLaunch"
android:noHistory="true">
</activity>
android:noHistory="true"
android:theme="@style/AppTheme.BrandedLaunch"/>

<activity-alias
android:name="org.stepic.droid.view.activities.SplashActivity"
android:targetActivity="org.stepic.droid.ui.activities.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
</intent-filter>
Expand Down Expand Up @@ -81,21 +82,17 @@
<activity
android:name="org.stepic.droid.ui.activities.LoginActivity"
android:launchMode="singleTop"
android:theme="@style/AppTheme.LoginLaunchRegistration">
</activity>
android:theme="@style/AppTheme.LoginLaunchRegistration"/>

<activity
android:name="org.stepic.droid.ui.activities.MainFeedActivity"
android:label="@string/my_courses_title"
android:launchMode="singleTask">
<meta-data
android:name="android.app.default_searchable"
android:value=".ui.activities.CourseSearchResultActivity"/>
</activity>

<activity
android:name=".ui.activities.CourseDetailActivity"
android:label="@string/course_info_title">
<activity android:name=".ui.activities.CourseDetailActivity">

<intent-filter
android:autoVerify="true"
Expand All @@ -119,7 +116,6 @@

<activity
android:name=".ui.activities.SectionActivity"
android:label="@string/syllabus_title"
android:parentActivityName=".ui.activities.MainFeedActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
Expand All @@ -145,7 +141,6 @@

<activity
android:name=".ui.activities.StepsActivity"
android:label="@string/steps_title"
android:parentActivityName=".ui.activities.UnitsActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
Expand Down Expand Up @@ -209,9 +204,7 @@

</activity>

<activity
android:name=".ui.activities.UnitsActivity"
android:label="@string/units_lessons_title"/>
<activity android:name=".ui.activities.UnitsActivity"/>

<receiver
android:name="org.stepic.droid.receivers.DownloadCompleteReceiver"
Expand All @@ -237,24 +230,16 @@
</intent-filter>
</receiver>

<service
android:name="org.stepic.droid.services.NewUserAlarmService"/>
<service
android:name="org.stepic.droid.services.StreakAlarmService"/>
<service
android:name="org.stepic.droid.services.LoadService"/>
<service
android:name="org.stepic.droid.services.DeleteService"/>
<service
android:name="org.stepic.droid.services.ViewPusher"/>
<service
android:name="org.stepic.droid.services.CancelLoadingService"/>
<service
android:name="org.stepic.droid.services.UpdateWithApkService"/>
<service android:name="org.stepic.droid.services.NewUserAlarmService"/>
<service android:name="org.stepic.droid.services.StreakAlarmService"/>
<service android:name="org.stepic.droid.services.LoadService"/>
<service android:name="org.stepic.droid.services.DeleteService"/>
<service android:name="org.stepic.droid.services.ViewPusher"/>
<service android:name="org.stepic.droid.services.CancelLoadingService"/>
<service android:name="org.stepic.droid.services.UpdateWithApkService"/>

<activity
android:name=".ui.activities.CourseSearchResultActivity"
android:label="@string/search_title"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
Expand All @@ -266,7 +251,6 @@

<activity
android:name=".ui.activities.TextFeedbackActivity"
android:label="@string/feedback_title"
android:parentActivityName="org.stepic.droid.ui.activities.MainFeedActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
Expand All @@ -278,26 +262,22 @@
android:name=".ui.activities.VideoActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:hardwareAccelerated="true"
android:label="@string/video_title"
android:theme="@style/AppTheme.VideoPlayer"/>

<service
android:name=".notifications.StepicFcmListenerService">
<service android:name=".notifications.StepicFcmListenerService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>

<service
android:name=".notifications.StepicInstanceIdService">
<service android:name=".notifications.StepicInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>

<activity
android:name=".ui.activities.SettingsActivity"
android:label="@string/settings_title"
android:launchMode="singleTop"
android:parentActivityName=".ui.activities.MainFeedActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
Expand All @@ -313,7 +293,6 @@

<activity
android:name=".ui.activities.FeedbackActivity"
android:label="@string/feedback_title"
android:launchMode="singleTop"
android:parentActivityName=".ui.activities.MainFeedActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
Expand All @@ -325,7 +304,6 @@

<activity
android:name=".ui.activities.AboutAppActivity"
android:label="@string/about_app"
android:launchMode="singleTop"
android:parentActivityName=".ui.activities.SettingsActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
Expand All @@ -336,7 +314,6 @@

<activity
android:name=".ui.activities.StoreManagementActivity"
android:label="@string/space_management_title"
android:launchMode="singleTop"
android:parentActivityName=".ui.activities.SettingsActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
Expand All @@ -353,7 +330,6 @@

<activity
android:name=".ui.activities.CommentsActivity"
android:label="@string/comments_title"
android:launchMode="singleTop"
android:parentActivityName=".ui.activities.StepsActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
Expand All @@ -364,7 +340,6 @@

<activity
android:name=".ui.activities.NewCommentActivity"
android:label="@string/new_comment_title"
android:parentActivityName=".ui.activities.CommentsActivity"
android:windowSoftInputMode="adjustResize|stateHidden">
<!-- Parent activity meta-data to support 4.0 and lower -->
Expand All @@ -375,7 +350,6 @@

<activity
android:name=".ui.activities.FilterActivity"
android:label="@string/filter_title"
android:parentActivityName=".ui.activities.MainFeedActivity"
android:windowSoftInputMode="adjustResize|stateHidden">
<!-- Parent activity meta-data to support 4.0 and lower -->
Expand All @@ -386,7 +360,6 @@

<activity
android:name=".ui.activities.ProfileActivity"
android:label="@string/profile_title"
android:windowSoftInputMode="adjustResize|stateHidden">
<!-- Parent activity meta-data to support 4.0 and lower -->
<intent-filter
Expand Down Expand Up @@ -424,12 +397,25 @@
android:name=".ui.activities.PhotoViewActivity"
android:theme="@style/AppTheme.PhotoView"/>

<uses-library android:name="com.sec.android.app.multiwindow" android:required="false"/>
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true"/>
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W" android:value="632dp"/>
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H" android:value="598dp"/>
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W" android:value="632dp"/>
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H" android:value="598dp"/>
<uses-library
android:name="com.sec.android.app.multiwindow"
android:required="false"/>

<meta-data
android:name="com.sec.android.support.multiwindow"
android:value="true"/>
<meta-data
android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W"
android:value="632dp"/>
<meta-data
android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H"
android:value="598dp"/>
<meta-data
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W"
android:value="632dp"/>
<meta-data
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H"
android:value="598dp"/>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.stepic.droid.core.presenters
import org.stepic.droid.analytic.Analytic
import org.stepic.droid.concurrency.MainHandler
import org.stepic.droid.core.presenters.contracts.LessonView
import org.stepic.droid.di.step.StepScope
import org.stepic.droid.di.lesson.LessonScope
import org.stepic.droid.model.Lesson
import org.stepic.droid.model.Section
Expand Down Expand Up @@ -31,14 +30,13 @@ class LessonPresenter
private val sharedPreferenceHelper: SharedPreferenceHelper,
private val analytic: Analytic) : PresenterBase<LessonView>() {

var lesson: Lesson? = null
private set
private var lesson: Lesson? = null

var isLoading = AtomicBoolean(false)
private var isLoading = AtomicBoolean(false)

var unit: Unit? = null
private var unit: Unit? = null

var section: Section? = null
private var section: Section? = null

val stepList = ArrayList<Step>()

Expand All @@ -52,14 +50,22 @@ class LessonPresenter
fromPreviousLesson: Boolean = false,
section: Section? = null) {

if (isLoading.get()) {
return
}

if (lesson != null) {
//already loaded if THIS.Lesson != null -> show
view?.onLessonUnitPrepared(lesson, unit, this.section)
view?.showSteps(fromPreviousLesson, defaultStepPositionStartWithOne)
if (this.stepList.isEmpty()) {
if (isLoading.compareAndSet(false, true)) {
threadPoolExecutor.execute {
try {
loadSteps(defaultStepPositionStartWithOne, fromPreviousLesson)
} finally {
isLoading.set(false)
}
}
}
}
else{
view?.showSteps(fromPreviousLesson, defaultStepPositionStartWithOne)
}
return
}

Expand Down Expand Up @@ -143,6 +149,13 @@ class LessonPresenter
}
}

if (!isStepsShown && it.steps?.isEmpty() ?: true) {
mainHandler.post {
view?.onEmptySteps()
}
return
}

// and try to update from internet
var response: Response<StepResponse>? = null
try {
Expand Down Expand Up @@ -328,5 +341,4 @@ class LessonPresenter
// unit can be null for lesson, which is not in Course
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@ class VideoLengthPresenter
private val mainHandler: MainHandler,
private val videoResolver: VideoResolver,
private val videoLengthResolver: VideoLengthResolver) : PresenterBase<VideoLengthView>() {
var cachedFormat: String? = null

companion object {
private val millisecondsInSecond = 1000L
}

private var cachedFormat: String? = null

fun fetchLength(video: Video?, thumbnailPath: String?) {
cachedFormat?.let {
view?.onVideoLengthDetermined(it, thumbnailPath)
return
}

video?.let {
if (it.duration <= 0) {
return@let
}

//the duration from server
val printable = TimeUtil.getFormattedVideoTime(video.duration * millisecondsInSecond)
cachedFormat = printable
view?.onVideoLengthDetermined(printable, thumbnailPath)
return
}

threadPoolExecutor.execute {
val path = videoResolver.resolveVideoUrl(video)
val millis = videoLengthResolver.determineLengthInMillis(path)
Expand Down
Loading

0 comments on commit 5505fef

Please sign in to comment.