Skip to content

Commit

Permalink
Merge pull request #120 from StepicOrg/release/1.44
Browse files Browse the repository at this point in the history
Release/1.44
  • Loading branch information
KirillMakarov authored Oct 5, 2017
2 parents 58b402c + a086fa8 commit 6aaf113
Show file tree
Hide file tree
Showing 119 changed files with 3,396 additions and 1,797 deletions.
15 changes: 10 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ android {
applicationId "org.stepic.droid"
minSdkVersion rootProject.androidMinSdkVersion
targetSdkVersion rootProject.androidTargetSdkVersion
versionCode 173
versionName "1.43"
versionCode 176
versionName "1.44.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down Expand Up @@ -105,7 +105,7 @@ android {
useProguard true
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
'proguard-rules.pro', 'proguard-rules-dev.pro'
versionNameSuffix "DEV"

testCoverageEnabled = true
Expand All @@ -120,6 +120,11 @@ android {
signingConfig signingConfigs.oldRelease
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

kapt {
Expand Down Expand Up @@ -195,8 +200,8 @@ dependencies {
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'

//add echo player for video (change playback speed supported)
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.1'
//add exo player for video (change playback speed supported)
compile 'com.google.android.exoplayer:exoplayer-core:r2.5.3'

oldReleaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${rootProject.leakCanaryVersion}"
testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${rootProject.leakCanaryVersion}"
Expand Down
2 changes: 2 additions & 0 deletions app/proguard-rules-dev.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#keep names, but may shrink for reducing number of methods for avoiding 64K problem
-dontobfuscate
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.stepic.droid.ui.activities
import android.app.Activity
import android.app.ProgressDialog
import android.content.Intent
import android.content.IntentSender
import android.os.Build
import android.os.Bundle
import android.support.v7.widget.GridLayoutManager
Expand All @@ -18,12 +17,7 @@ import com.facebook.login.LoginManager
import com.facebook.login.LoginResult
import com.google.android.gms.auth.api.Auth
import com.google.android.gms.auth.api.credentials.Credential
import com.google.android.gms.auth.api.credentials.CredentialRequest
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.Scopes
import com.google.android.gms.common.api.CommonStatusCodes
import com.google.android.gms.common.api.GoogleApiClient
import com.google.android.gms.common.api.Scope
import com.vk.sdk.VKAccessToken
import com.vk.sdk.VKCallback
import com.vk.sdk.VKSdk
Expand All @@ -45,27 +39,22 @@ import org.stepic.droid.ui.dialogs.LoadingProgressDialog
import org.stepic.droid.util.AppConstants
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


class LaunchActivity : BackToExitActivityBase(), LoginView {
class LaunchActivity : SmartLockActivityBase(), LoginView {
companion object {
private val TAG = "LaunchActivity"
val wasLogoutKey = "wasLogoutKey"
private val resolvingAccountKey = "resolvingAccountKey"
private val socialAdapterStateKey = "socialAdapterStateKey"
}

private val requestFromSmartLockCode = 314

private var googleApiClient: GoogleApiClient? = null
private var progressLogin: ProgressDialog? = null
private lateinit var progressHandler: ProgressHandler
private lateinit var callbackManager: CallbackManager
private var resolvingWasShown = false

@Inject
lateinit var loginPresenter: LoginPresenter
Expand All @@ -76,8 +65,6 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {
App.componentManager().loginComponent(TAG).inject(this)
overridePendingTransition(R.anim.no_transition, R.anim.slide_out_to_bottom)

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

launchSignUpButton.setOnClickListener {
analytic.reportEvent(Analytic.Interaction.CLICK_SIGN_UP)
screenManager.showRegistration(this@LaunchActivity, courseFromExtra)
Expand All @@ -88,27 +75,15 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {
screenManager.showLogin(this@LaunchActivity, courseFromExtra, null)
}


if (checkPlayServices()) {
val serverClientId = config.googleServerClientId
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(Scope(Scopes.EMAIL), Scope(Scopes.PROFILE))
.requestServerAuthCode(serverClientId)
.build()
googleApiClient = GoogleApiClient.Builder(this)
.enableAutoManage(this) {
Toast.makeText(this@LaunchActivity, R.string.connectionProblems, Toast.LENGTH_SHORT).show()
}
.addApi(Auth.CREDENTIALS_API)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build()
}
initGoogleApiClient(true, GoogleApiClient.OnConnectionFailedListener {
Toast.makeText(this@LaunchActivity, R.string.connectionProblems, Toast.LENGTH_SHORT).show()
})

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

val signInString = getString(R.string.sign_in)
Expand Down Expand Up @@ -179,7 +154,7 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {
}
}

private fun initSocialRecycler(googleApiClient: GoogleApiClient?, state: SocialAuthAdapter.State = SocialAuthAdapter.State.NORMAL) {
private fun initSocialRecycler(state: SocialAuthAdapter.State = SocialAuthAdapter.State.NORMAL) {
socialListRecyclerView.layoutManager = GridLayoutManager(this, 3)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Expand Down Expand Up @@ -241,41 +216,7 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {
overridePendingTransition(R.anim.no_transition, R.anim.slide_out_to_bottom)
}

private fun requestCredentials() {
val credentialRequest = CredentialRequest.Builder()
.setPasswordLoginSupported(true)
.build()

Auth.CredentialsApi.request(googleApiClient, credentialRequest).setResultCallback { credentialRequestResult ->
if (credentialRequestResult.status.isSuccess) {
// Successfully read the credential without any user interaction, this
// means there was only a single credential and the user has auto
// sign-in enabled.
analytic.reportEvent(Analytic.SmartLock.READ_CREDENTIAL_WITHOUT_INTERACTION)
onCredentialRetrieved(credentialRequestResult.credential)
} else {
if (credentialRequestResult.status.statusCode == CommonStatusCodes.RESOLUTION_REQUIRED) {
// Prompt the user to choose a saved credential; do not show the hint
// selector.
try {
if (!resolvingWasShown) {
analytic.reportEvent(Analytic.SmartLock.PROMPT_TO_CHOOSE_CREDENTIALS)
resolvingWasShown = true
credentialRequestResult.status.startResolutionForResult(this, requestFromSmartLockCode)
}
} catch (e: IntentSender.SendIntentException) {
Timber.e(e, "STATUS: Failed to send resolution.")
}

} else {
Timber.d("STATUS: Failed to send resolution.")
// The user must create an account or sign in manually.
}
}
}
}

private fun onCredentialRetrieved(credential: Credential) {
override fun onCredentialRetrieved(credential: Credential) {
val accountType = credential.accountType
if (accountType == null) {
// Sign the user in with information from the Credential.
Expand All @@ -284,17 +225,6 @@ class LaunchActivity : BackToExitActivityBase(), LoginView {
}

public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == requestFromSmartLockCode) {
if (resultCode == Activity.RESULT_OK && data != null) {
analytic.reportEvent(Analytic.SmartLock.LAUNCH_CREDENTIAL_RETRIEVED_PROMPT)
val credential = data.getParcelableExtra<Credential>(Credential.EXTRA_KEY)
onCredentialRetrieved(credential)
} else {
analytic.reportEvent(Analytic.SmartLock.LAUNCH_CREDENTIAL_CANCELED_PROMPT)
Timber.d("Credential Read not ok: canceled or no internet")
}
}

if (VKSdk.onActivityResult(requestCode, resultCode, data, object : VKCallback<VKAccessToken> {
override fun onResult(result: VKAccessToken) {
loginPresenter.loginWithNativeProviderCode(result.accessToken, SocialManager.SocialType.vk, result.email)
Expand Down Expand Up @@ -400,8 +330,6 @@ 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)
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@
android:name=".ui.activities.CertificatesActivity">
</activity>

<activity
android:name=".ui.activities.CourseListActivity">
</activity>

<activity
android:name=".ui.activities.PhotoViewActivity"
android:theme="@style/AppTheme.PhotoView"/>
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/org/stepic/droid/analytic/Analytic.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@

public interface Analytic {

interface CoursesCarousel {
String EMPTY_ENROLLED_SHOWN = "courses_carousel_empty_enrolled";
String EMPTY_ENROLLED_CLICK = "courses_carousel_empty_enrolled_clicked";

String NO_INTERNET_SHOWN = "courses_carousel_no_internet";
String NO_INTERNET_CLICK = "courses_carousel_no_internet_click";
}

interface FastContinue {
String EMPTY_COURSES_SHOWN = "fast_continue_empty_courses";
String EMPTY_COURSES_CLICK = "fast_continue_empty_courses_click";

String NO_INTERNET_SHOWN = "fast_continue_no_internet";
String NO_INTERNET_CLICK = "fast_continue_no_internet_click";

String AUTH_SHOWN = "fast_continue_auth";
String AUTH_CLICK = "fast_continue_auth_click";
}

interface Rating {
String SHOWN = "app_rate_shown"; //on shown dialog
String APP_RATE = "app_rate"; //number of stars, that user chosen, may multiple by session
Expand Down Expand Up @@ -205,6 +224,7 @@ interface Error {
String FAIL_PUSH_STEP_VIEW = "fail_push_step_view";
String NO_INTERNET_EXISTING_ATTEMPTS = "no_internet_existing_attempts";
String DOWNLOAD_ID_NEGATIVE = "download_id_negative";
String DOWNLOAD_FAILED = "download_failed";
String STREAK_ON_STEP_SOLVED = "streak_on_step_solved";
String GOOGLE_SERVICES_TOO_OLD = "google_services_too_old";
String VIDEO_PATH_WAS_NULL_WITH_INTERNET = "video_path_was_null_internet_enabled";
Expand All @@ -228,6 +248,8 @@ interface Error {
String CANT_PARSE_QUALITY = "cant_parse_quality";
String JOIN_FAILED = "error_join_failed"; //#Apps-580
String UNIT_CACHED_LESSON_NO = "error_unit_cached_lesson_not";
@Nullable
String FEATURED_EMPTY = "error_featured_empty";
}

interface Web {
Expand Down Expand Up @@ -295,6 +317,8 @@ interface Comments {
}

interface Steps {
String SUBMISSION_CREATED = "submission_created";
String SUBMISSION_CREATED_TYPE = "type";
String CORRECT_SUBMISSION_FILL = "submission_correct_fill"; // it can be existing submission, use in chain.
String WRONG_SUBMISSION_FILL = "submission_wrong_fill";
String SHARE_OPEN_IN_BROWSER = "step_share_open_in_browser";
Expand Down Expand Up @@ -375,6 +399,12 @@ interface Streak {
String GET_NON_ZERO_STREAK_NOTIFICATION = "streak_get_non_zero_notification";
String GET_ZERO_STREAK_NOTIFICATION = "streak_get_zero_notification";
String GET_NO_INTERNET_NOTIFICATION = " streak_get_no_internet_notification";

String NOTIFICATION_TYPE_PARAM = "type";

enum NotificationType {
zero, noInternet, solvedToday, notSolvedToday
}
}

interface Shortcut {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void onStart() {
isScreenCreated = false;
needFilter = false;
courses.clear();
courseListPresenter.refreshData(getCourseType(), needFilter, false);
courseListPresenter.refreshData(getCourseType(), needFilter, true);
} else {
//load if not
courseListPresenter.downloadData(getCourseType(), needFilter);
Expand Down Expand Up @@ -197,7 +197,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
courses.clear();
coursesAdapter.notifyDataSetChanged();
courseListPresenter.reportCurrentFiltersToAnalytic(getCourseType());
courseListPresenter.refreshData(getCourseType(), needFilter, false);
courseListPresenter.refreshData(getCourseType(), needFilter, true);
}
}

Expand Down Expand Up @@ -278,18 +278,16 @@ public void onDetach() {

@Override
public void onFailDropCourse(@NotNull Course droppedCourse) {
long courseId = -1L;
courseId = droppedCourse.getCourseId();
long courseId = droppedCourse.getCourseId();
getAnalytic().reportEvent(Analytic.Web.DROP_COURSE_FAIL, courseId + "");
Toast.makeText(getContext(), R.string.internet_problem, Toast.LENGTH_LONG).show();
}

@Override
public void onSuccessDropCourse(@NotNull Course droppedCourse) {
long courseId = -1L;
courseId = droppedCourse.getCourseId();
long courseId = droppedCourse.getCourseId();
getAnalytic().reportEvent(Analytic.Web.DROP_COURSE_SUCCESSFUL, courseId + "");
Toast.makeText(getContext(), getContext().getString(R.string.you_dropped) + " " + droppedCourse.getTitle(), Toast.LENGTH_LONG).show();
Toast.makeText(getContext(), getContext().getString(R.string.you_dropped, droppedCourse.getTitle()), Toast.LENGTH_LONG).show();
if (getCourseType() == Table.enrolled) { //why here was e.getCourseType?
courses.remove(droppedCourse);
coursesAdapter.notifyDataSetChanged();
Expand Down
19 changes: 2 additions & 17 deletions app/src/main/java/org/stepic/droid/base/FragmentBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import android.view.animation.Animation
import android.view.inputmethod.InputMethodManager
import butterknife.ButterKnife
import butterknife.Unbinder
import org.stepic.droid.R
import org.stepic.droid.analytic.Analytic
import org.stepic.droid.concurrency.MainHandler
import org.stepic.droid.configuration.Config
Expand All @@ -24,7 +23,6 @@ import org.stepic.droid.preferences.UserPreferences
import org.stepic.droid.storage.CancelSniffer
import org.stepic.droid.storage.IDownloadManager
import org.stepic.droid.storage.operations.DatabaseFacade
import org.stepic.droid.ui.activities.contracts.BottomNavigationViewRoot
import org.stepic.droid.ui.util.CloseIconHolder
import org.stepic.droid.util.resolvers.CoursePropertyResolver
import org.stepic.droid.util.resolvers.text.TextResolver
Expand Down Expand Up @@ -111,9 +109,7 @@ open class FragmentBase : Fragment() {
val view = this.activity.currentFocus
if (view != null) {
val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
if (imm.isAcceptingText) {
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
}

Expand Down Expand Up @@ -171,22 +167,11 @@ open class FragmentBase : Fragment() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
activity?.window?.decorView?.background = null
} else {
//we use it for old version of device
@Suppress("DEPRECATION")
activity?.window?.decorView?.setBackgroundDrawable(null)
}
}

/**
* Apply margin if activity has bottom navigation bar
*/
protected fun applyBottomMarginForRootView() {
activity as? BottomNavigationViewRoot ?: return
val rootView: ViewGroup = getRootView() ?: throw IllegalStateException("For using applyBottomMarginForRootView, you should override getRootView() in your fragment.")

val layoutParams = rootView.layoutParams as ViewGroup.MarginLayoutParams

layoutParams.bottomMargin = resources.getDimensionPixelSize(R.dimen.bottom_navigation_height)
}

protected open fun getRootView(): ViewGroup? = null
}
Loading

0 comments on commit 6aaf113

Please sign in to comment.