Skip to content

Commit

Permalink
Merge pull request #109 from StepicOrg/release/1.43
Browse files Browse the repository at this point in the history
Release/1.43
  • Loading branch information
KirillMakarov authored Sep 21, 2017
2 parents 43d9812 + f348452 commit f6dd9e1
Show file tree
Hide file tree
Showing 119 changed files with 2,257 additions and 852 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ buildsystem/secret.gradle filter=git-crypt diff=git-crypt
fastlane/Fastfile filter=git-crypt diff=git-crypt
googleplayprovider.json filter=git-crypt diff=git-crypt
app/src/prodSb/google-services.json filter=git-crypt diff=git-crypt
app/src/sb/google-services.json filter=git-crypt diff=git-crypt
.gitattributes !filter !diff
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ maka-vlc/

/fastlane/report.xml
/fastlane/README.md

reports
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Stepik for Android
Build Status: <a href="https://tc.stepik.org/viewType.html?buildTypeId=Stepic_StepicMobile_Android_GooglePlay&guest=1"><img src="https://tc.stepik.org/app/rest/builds/buildType:(id:Stepic_StepicMobile_Android_GooglePlay)/statusIcon"/></a>

Mobile application of [Stepik.org][1].
Code Coverage: [![codecov](https://codecov.io/gh/StepicOrg/stepik-android/branch/master/graph/badge.svg)](https://codecov.io/gh/StepicOrg/stepik-android)


Mobile application of [Stepik][1].

## Store
New version of Stepic App is now available on Google Play
Expand Down
81 changes: 33 additions & 48 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply from: '../code_quality_tools/jacoco.gradle'
apply from: '../code_quality_tools/findbugs.gradle'
apply from: '../code_quality_tools/checkstyle.gradle'
apply from: '../code_quality_tools/pmd.gradle'

def globalConf = rootProject.ext
android {
Expand Down Expand Up @@ -42,37 +46,12 @@ android {
vectorDrawables.useSupportLibrary = true
}

flavorDimensions "type", "instance"

productFlavors {
sb {
applicationId "org.stepic.droid.sb"
dimension "instance"
applicationIdSuffix '.sb'
}
classic {
applicationId "org.stepic.droid"
dimension "instance"
}

development {
//auto detecting in Android Studio is not working, because of declarations
//of multidex + shrinking resource, it is not compiling with -PdevBuild trick
//tested on Android Studio 2.3.2
minSdkVersion 21
//get Error:Execution failed for task ':app:transformClassesWithDexForDevelopmentDebug'.
//> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
//without it.
multiDexEnabled true
dimension "type"
}

prod {
dimension "type"
}

}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

android.applicationVariants.all { variant ->
Expand Down Expand Up @@ -106,7 +85,10 @@ android {
}

lintOptions {
abortOnError false
warningsAsErrors false // after fixing existing errors set to true for fixing warnings
abortOnError false // after fixing existing errors set to true for failing fast
lintConfig rootProject.file('lint.xml')
htmlOutput rootProject.file("reports/lint/lint.html")
}

buildTypes {
Expand All @@ -117,16 +99,19 @@ android {
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'

testCoverageEnabled = true
}
debug {
minifyEnabled false
useProguard false
minifyEnabled true
useProguard true
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
versionNameSuffix "DEV"
}

testCoverageEnabled = true
}

//the apk of this type is signed by old prod keys
//it makes apk testable (sign in, smart lock, etc are worked).
Expand Down Expand Up @@ -163,10 +148,10 @@ dependencies {

compile 'de.hdodenhof:circleimageview:2.1.0'

compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'

compile 'joda-time:joda-time:2.8'
Expand All @@ -186,24 +171,24 @@ dependencies {

compile 'org.jsoup:jsoup:1.8.3'

compile 'com.google.firebase:firebase-messaging:10.2.4'
compile "com.google.firebase:firebase-appindexing:10.2.4"
compile 'com.google.android.gms:play-services-auth:10.2.4'
compile 'com.google.firebase:firebase-core:10.2.4'
compile 'com.google.firebase:firebase-crash:10.2.4'
compile 'com.google.firebase:firebase-config:10.2.4'
compile "com.google.firebase:firebase-messaging:${rootProject.firebaseVersion}"
compile "com.google.firebase:firebase-appindexing:${rootProject.firebaseVersion}"
compile "com.google.android.gms:play-services-auth:${rootProject.firebaseVersion}"
compile "com.google.firebase:firebase-core:${rootProject.firebaseVersion}"
compile "com.google.firebase:firebase-crash:${rootProject.firebaseVersion}"
compile "com.google.firebase:firebase-config:${rootProject.firebaseVersion}"

compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.facebook.android:facebook-android-sdk:4.17.0'
compile 'com.vk:androidsdk:1.6.5'
compile 'com.jakewharton.timber:timber:4.3.1'
compile 'com.jakewharton.timber:timber:4.5.1'

compile 'com.github.javiersantos:MaterialStyledDialogs:2.0'
compile 'biz.kasual:materialnumberpicker:1.2.1'

compile 'com.github.chrisbanes:PhotoView:1.3.1'

compile 'com.github.h6ah4i:android-advancedrecyclerview:feature~support_libraries_v26-SNAPSHOT'
compile 'com.github.h6ah4i:android-advancedrecyclerview:develop-SNAPSHOT'

compile 'com.android.support.constraint:constraint-layout:1.0.2'

Expand All @@ -215,11 +200,11 @@ dependencies {
//add echo player for video (change playback speed supported)
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.1'

oldReleaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.2'
androidTestCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.2'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.2'
oldReleaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${rootProject.leakCanaryVersion}"
testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${rootProject.leakCanaryVersion}"
androidTestCompile "com.squareup.leakcanary:leakcanary-android-no-op:${rootProject.leakCanaryVersion}"
debugCompile "com.squareup.leakcanary:leakcanary-android:${rootProject.leakCanaryVersion}"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${rootProject.leakCanaryVersion}"

// Required -- JUnit 4 framework
testCompile 'junit:junit:4.12'
Expand All @@ -228,7 +213,7 @@ dependencies {

androidTestCompile 'org.hamcrest:hamcrest-library:1.3'

androidTestCompile 'com.android.support:support-annotations:26.0.1'
androidTestCompile 'com.android.support:support-annotations:26.1.0'

androidTestCompile('com.android.support.test:runner:0.5') {
exclude group: 'com.android.support'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public void loginActivityTest() {
onView(withId(R.id.signInWithEmail))
.perform(scrollTo(), click());

onView(withId(R.id.loginText))
onView(withId(R.id.loginField))
.perform(scrollTo(), replaceText("[email protected]"), closeSoftKeyboard());

onView(allOf(withId(R.id.loginText), withText("[email protected]")))
onView(allOf(withId(R.id.loginField), withText("[email protected]")))
.perform(pressImeActionButton());

onView(withId(R.id.passwordEditText))
onView(withId(R.id.passwordField))
.perform(scrollTo(), replaceText("qwerty123"), closeSoftKeyboard());

onView(withId(R.id.loginButton))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import android.app.Activity
import android.app.ProgressDialog
import android.content.Intent
import android.content.IntentSender
import android.graphics.Point
import android.os.Build
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.text.method.LinkMovementMethod
import android.support.v7.widget.GridLayoutManager
import android.text.Spannable
import android.text.SpannableString
import android.view.View
import android.widget.Toast
import com.facebook.CallbackManager
import com.facebook.FacebookCallback
Expand All @@ -26,6 +28,7 @@ import com.vk.sdk.VKAccessToken
import com.vk.sdk.VKCallback
import com.vk.sdk.VKSdk
import com.vk.sdk.api.VKError
import jp.wasabeef.recyclerview.animators.FadeInDownAnimator
import kotlinx.android.synthetic.main.activity_launch.*
import org.stepic.droid.R
import org.stepic.droid.analytic.Analytic
Expand All @@ -34,16 +37,17 @@ import org.stepic.droid.core.LoginFailType
import org.stepic.droid.core.ProgressHandler
import org.stepic.droid.core.presenters.LoginPresenter
import org.stepic.droid.core.presenters.contracts.LoginView
import org.stepic.droid.fonts.FontType
import org.stepic.droid.model.AuthData
import org.stepic.droid.social.SocialManager
import org.stepic.droid.ui.adapters.SocialAuthAdapter
import org.stepic.droid.ui.decorators.SpacesItemDecorationHorizontal
import org.stepic.droid.ui.dialogs.LoadingProgressDialog
import org.stepic.droid.util.AppConstants
import org.stepic.droid.util.DpPixelsHelper
import org.stepic.droid.util.ProgressHelper
import org.stepic.droid.util.getMessageFor
import timber.log.Timber
import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan
import uk.co.chrisjenx.calligraphy.TypefaceUtils
import javax.inject.Inject


Expand All @@ -52,14 +56,11 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {
private val TAG = "LaunchActivity"
val wasLogoutKey = "wasLogoutKey"
private val resolvingAccountKey = "resolvingAccountKey"
private val socialAdapterStateKey = "socialAdapterStateKey"
}

private val requestFromSmartLockCode = 314

val termsMessageHtml: String by lazy {
resources.getString(R.string.terms_message_launch)
}

private var googleApiClient: GoogleApiClient? = null
private var progressLogin: ProgressDialog? = null
private lateinit var progressHandler: ProgressHandler
Expand All @@ -77,12 +78,6 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {

resolvingWasShown = savedInstanceState?.getBoolean(resolvingAccountKey) ?: false

findCoursesButton.setOnClickListener {
analytic.reportEvent(Analytic.Interaction.CLICK_FIND_COURSE_LAUNCH)
screenManager.showFindCourses(this@LaunchActivity)
this@LaunchActivity.finish()
}

launchSignUpButton.setOnClickListener {
analytic.reportEvent(Analytic.Interaction.CLICK_SIGN_UP)
screenManager.showRegistration(this@LaunchActivity, courseFromExtra)
Expand All @@ -109,10 +104,22 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {
.build()
}

initSocialRecycler(googleApiClient)
val recyclerState = savedInstanceState?.getSerializable(socialAdapterStateKey)
if (recyclerState is SocialAuthAdapter.State) {
initSocialRecycler(googleApiClient, recyclerState)
} else {
initSocialRecycler(googleApiClient)
}

val signInString = getString(R.string.sign_in)
val signInWithSocial = getString(R.string.sign_in_with_social_suffix)

val spannableSignIn = SpannableString(signInString + signInWithSocial)
val typefaceSpan = CalligraphyTypefaceSpan(TypefaceUtils.load(assets, fontsProvider.provideFontPath(FontType.medium)))

spannableSignIn.setSpan(typefaceSpan, 0, signInString.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)

termsPrivacyLaunchTextView.movementMethod = LinkMovementMethod.getInstance()
termsPrivacyLaunchTextView.text = textResolver.fromHtml(termsMessageHtml)
signInText.text = spannableSignIn

progressHandler = object : ProgressHandler {
override fun activate() {
Expand Down Expand Up @@ -172,34 +179,47 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {
}
}

private fun initSocialRecycler(googleApiClient: GoogleApiClient?) {
val pixelForPadding = DpPixelsHelper.convertDpToPixel(4f, this)//pixelForPadding * (count+1)
val widthOfItem = resources.getDimension(R.dimen.height_of_social)//width == height
val count = SocialManager.SocialType.values().size
val widthOfAllItems = widthOfItem * count + pixelForPadding * (count + 1)
private fun initSocialRecycler(googleApiClient: GoogleApiClient?, state: SocialAuthAdapter.State = SocialAuthAdapter.State.NORMAL) {
socialListRecyclerView.layoutManager = GridLayoutManager(this, 3)

val display = windowManager.defaultDisplay
val size = Point()
display.getSize(size)
val widthOfScreen = size.x
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
socialListRecyclerView.itemAnimator = FadeInDownAnimator()
socialListRecyclerView.itemAnimator.removeDuration = 0
}

val adapter = SocialAuthAdapter(this, googleApiClient, state)
showMore.setOnClickListener {
showMore.visibility = View.GONE
showLess.visibility = View.VISIBLE
adapter.showMore()
}

showLess.setOnClickListener {
showLess.visibility = View.GONE
showMore.visibility = View.VISIBLE
adapter.showLess()
}

socialListRecyclerView.addItemDecoration(SpacesItemDecorationHorizontal(pixelForPadding.toInt()))//30 is ok
val layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
if (widthOfScreen > widthOfAllItems) {
val padding = (widthOfScreen - widthOfAllItems).toInt() / 2
socialListRecyclerView.setPadding(padding, 0, 0, 0)
when(state) {
SocialAuthAdapter.State.EXPANDED -> {
showLess.visibility = View.VISIBLE
showMore.visibility = View.GONE
}
SocialAuthAdapter.State.NORMAL -> {
showMore.visibility = View.VISIBLE
showLess.visibility = View.GONE
}
}

socialListRecyclerView.layoutManager = layoutManager
socialListRecyclerView.adapter = SocialAuthAdapter(this, googleApiClient)
socialListRecyclerView.adapter = adapter
}

override fun onDestroy() {
loginPresenter.detachView(this)
signInWithEmail.setOnClickListener(null)
launchSignUpButton.setOnClickListener(null)
findCoursesButton.setOnClickListener(null)
showMore.setOnClickListener(null)
showLess.setOnClickListener(null)
if (isFinishing) {
App.componentManager().releaseLoginComponent(TAG)
}
Expand Down Expand Up @@ -381,6 +401,11 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {

override fun onSaveInstanceState(outState: Bundle?) {
outState?.putBoolean(resolvingAccountKey, resolvingWasShown)

val adapter = socialListRecyclerView.adapter
if (adapter is SocialAuthAdapter) {
outState?.putSerializable(socialAdapterStateKey, adapter.state)
}
super.onSaveInstanceState(outState)
}

Expand Down
Loading

0 comments on commit f6dd9e1

Please sign in to comment.