Skip to content

Commit

Permalink
Merge pull request #75 from StepicOrg/release/1.28
Browse files Browse the repository at this point in the history
Release/1.28
  • Loading branch information
KirillMakarov authored Feb 27, 2017
2 parents 2f2aa04 + 43a6898 commit 9cec608
Show file tree
Hide file tree
Showing 77 changed files with 1,405 additions and 441 deletions.
11 changes: 7 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
applicationId "org.stepic.droid"
minSdkVersion minSdk
targetSdkVersion 25
versionCode 121
versionName "1.27.2"
versionCode 123
versionName "1.28.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
Expand Down Expand Up @@ -141,8 +141,8 @@ dependencies {

compile 'joda-time:joda-time:2.8'

compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'

compile 'com.squareup:otto:1.3.8'

Expand Down Expand Up @@ -189,6 +189,9 @@ dependencies {
}

compile 'com.caverock:androidsvg:1.2.1'

compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.graphics.Point;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.method.LinkMovementMethod;
Expand Down Expand Up @@ -53,8 +54,6 @@

public class LaunchActivity extends BackToExitActivityBase {

public final static String FROM_MAIN_FEED_FLAG = "from_main_feed";

@BindView(R.id.sign_up_btn_activity_launch)
View signUpButton;

Expand All @@ -73,6 +72,7 @@ public class LaunchActivity extends BackToExitActivityBase {
@BindString(R.string.terms_message_launch)
String termsMessageHtml;

@Nullable
private GoogleApiClient googleApiClient;
private ProgressDialog progressLogin;
private ProgressHandler progressHandler;
Expand Down Expand Up @@ -118,15 +118,17 @@ public void onClick(View v) {
.requestScopes(new Scope(Scopes.EMAIL), new Scope(Scopes.PROFILE))
.requestServerAuthCode(serverClientId)
.build();
googleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Toast.makeText(LaunchActivity.this, R.string.connectionProblems, Toast.LENGTH_SHORT).show();
}
} /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addApi(AppIndex.API).build();
if (checkPlayServices()) {
googleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Toast.makeText(LaunchActivity.this, R.string.connectionProblems, Toast.LENGTH_SHORT).show();
}
} /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addApi(AppIndex.API).build();
}

initSocialRecycler(googleApiClient);

Expand Down Expand Up @@ -189,7 +191,7 @@ public void onError(FacebookException exception) {

}

private void initSocialRecycler(GoogleApiClient googleApiClient) {
private void initSocialRecycler(@Nullable GoogleApiClient googleApiClient) {
float pixelForPadding = DpPixelsHelper.convertDpToPixel(4f, this);//pixelForPadding * (count+1)
float widthOfItem = getResources().getDimension(R.dimen.height_of_social);//width == height
int count = SocialManager.SocialType.values().length;
Expand All @@ -212,18 +214,6 @@ private void initSocialRecycler(GoogleApiClient googleApiClient) {
socialRecyclerView.setAdapter(new SocialAuthAdapter(this, googleApiClient));
}

@Override
protected void onStart() {
super.onStart();
googleApiClient.connect();
}

@Override
protected void onStop() {
googleApiClient.disconnect();
super.onStop();
}

@Override
protected void onDestroy() {
signInTextView.setOnClickListener(null);
Expand Down Expand Up @@ -310,7 +300,9 @@ public void onFinish() {
new FailLoginSupplementaryHandler() {
@Override
public void onFailLogin(Throwable t) {
Auth.GoogleSignInApi.signOut(googleApiClient);
if (googleApiClient != null) {
Auth.GoogleSignInApi.signOut(googleApiClient);
}
}
}, getCourseFromExtra());
} else {
Expand All @@ -328,7 +320,7 @@ public void onBackPressed() {
boolean fromMainFeed;
int index = 0;
try {
fromMainFeed = getIntent().getExtras().getBoolean(FROM_MAIN_FEED_FLAG);
fromMainFeed = getIntent().getExtras().getBoolean(AppConstants.FROM_MAIN_FEED_FLAG);
index = getIntent().getExtras().getInt(MainFeedActivity.KEY_CURRENT_INDEX);
} catch (Exception ex) {
fromMainFeed = false;
Expand Down
Binary file modified app/src/main/assets/configs/config.json
Binary file not shown.
2 changes: 2 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 @@ -77,6 +77,7 @@ interface Interaction {
java.lang.String CLICK_FIND_COURSE_LAUNCH = "click_find_courses_launch";
java.lang.String USER_OPEN_IMAGE = "user_open_image";
java.lang.String SCREENSHOT = "screenshot";
java.lang.String GOOGLE_SOCIAL_IS_NOT_ENABLED = "google_social_is_not_enabled";
}

interface Screens {
Expand Down Expand Up @@ -171,6 +172,7 @@ interface Error {
String PENDING_INTENT_WAS_NULL = "pending_intent_null_streaks";
String FAIL_REFRESH_TOKEN_INLINE_GETTING = "fail_refresh_token_online_get";
java.lang.String COOKIE_WAS_EMPTY = "cookie_was_empty";
String FAIL_LOGOUT_WHEN_REFRESH = "refresh_fail_logout_social";
}

interface Web {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.ContextMenu;
Expand Down Expand Up @@ -37,10 +36,9 @@

import javax.inject.Inject;

import retrofit.Call;
import retrofit.Callback;
import retrofit.Response;
import retrofit.Retrofit;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public abstract class CoursesDatabaseFragmentBase extends CourseListFragmentBase implements FilterForCoursesView, OnBackClickListener {
private static final int FILTER_REQUEST_CODE = 776;
Expand Down Expand Up @@ -182,9 +180,8 @@ private void dropCourse(int position) {
Course localRef = course;

@Override
public void onResponse(Response<Void> response, Retrofit retrofit) {

new Handler().post(new Runnable() {
public void onResponse(Call<Void> call, Response<Void> response) {
threadPoolExecutor.execute(new Runnable() {
@Override
public void run() {
databaseFacade.deleteCourse(localRef, Table.enrolled);
Expand All @@ -201,7 +198,7 @@ public void run() {
}

@Override
public void onFailure(Throwable t) {
public void onFailure(Call<Void> call, Throwable t) {
bus.post(new FailDropCourseEvent(getCourseType(), localRef));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import javax.inject.Inject;

import butterknife.Unbinder;
import retrofit2.Retrofit;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

public abstract class FragmentActivityBase extends AppCompatActivity {
Expand All @@ -54,6 +55,9 @@ public abstract class FragmentActivityBase extends AppCompatActivity {

protected Unbinder unbinder;

@Inject
protected Retrofit retrofit;

@Inject
protected TextResolver textResolver;

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/stepic/droid/base/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.stetho.Stetho;
import com.vk.sdk.VKSdk;
import com.yandex.metrica.YandexMetrica;

Expand Down Expand Up @@ -39,6 +40,7 @@ public void onCreate() {
private void init() {
// refWatcher = LeakCanary.install(this);
application = this;
Stetho.initializeWithDefaults(this);

if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/java/org/stepic/droid/base/StepBaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
import javax.inject.Inject;

import butterknife.BindView;
import retrofit.Callback;
import retrofit.Response;
import retrofit.Retrofit;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public abstract class StepBaseFragment extends FragmentBase implements RouteStepView, AnonymousView {

Expand Down Expand Up @@ -236,9 +236,10 @@ public void onNewCommentWasAdded(NewCommentWasAddedOrUpdateEvent event) {
long[] arr = new long[]{step.getId()};

shell.getApi().getSteps(arr).enqueue(new Callback<StepResponse>() {

@Override
public void onResponse(Response<StepResponse> response, Retrofit retrofit) {
if (response.isSuccess()) {
public void onResponse(Call<StepResponse> call, Response<StepResponse> response) {
if (response.isSuccessful()) {
StepResponse stepResponse = response.body();
if (stepResponse != null && stepResponse.getSteps() != null && !stepResponse.getSteps().isEmpty()) {
final Step stepFromInternet = stepResponse.getSteps().get(0);
Expand All @@ -258,7 +259,7 @@ public void run() {
}

@Override
public void onFailure(Throwable t) {
public void onFailure(Call<StepResponse> call, Throwable t) {

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class ConfigRelease implements IConfig {
private static final java.lang.String TERMS_OF_SERVICE = "TERMS_OF_SERVICE";
private static final java.lang.String PRIVACY_POLICY = "PRIVACY_POLICY";
private static final java.lang.String MIXPANEL_TOKEN = "MIXPANEL_TOKEN";
private static final java.lang.String CSRF_COOKIE_NAME = "CSRF_COOKIE_NAME";
private static final java.lang.String SESSION_COOKIE_NAME = "SESSION_COOKIE_NAME";


@Inject
Expand Down Expand Up @@ -168,6 +170,16 @@ public String getMixpanelToken() {
return getString(MIXPANEL_TOKEN, null);
}

@Override
public String getCsrfTokenCookieName() {
return getString(CSRF_COOKIE_NAME, null);
}

@Override
public String getSessionCookieName() {
return getString(SESSION_COOKIE_NAME, null);
}

private String getString(String key) {
return getString(key, null);
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/stepic/droid/configuration/IConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public interface IConfig {
String getTermsOfServiceUrl();

String getMixpanelToken();

String getCsrfTokenCookieName ();

String getSessionCookieName();
}
28 changes: 14 additions & 14 deletions app/src/main/java/org/stepic/droid/core/CommentManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import org.stepic.droid.model.comments.Vote
import org.stepic.droid.preferences.SharedPreferenceHelper
import org.stepic.droid.web.CommentsResponse
import org.stepic.droid.web.IApi
import retrofit.Callback
import retrofit.Response
import retrofit.Retrofit
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import java.util.*
import javax.inject.Inject

Expand All @@ -27,10 +27,10 @@ class CommentManager {
lateinit var api: IApi

@Inject
lateinit var sharedPrefs : SharedPreferenceHelper
lateinit var sharedPrefs: SharedPreferenceHelper

private var discussionProxy : DiscussionProxy? = null
private val discussionOrderList : MutableList<Long> = ArrayList()
private var discussionProxy: DiscussionProxy? = null
private val discussionOrderList: MutableList<Long> = ArrayList()

private val maxOfParentInQuery = 10 // server supports 20, but we can change it
private val maxOfRepliesInQuery = 20 // we can't change it
Expand Down Expand Up @@ -149,7 +149,7 @@ class CommentManager {
} else {
//reply childIndex not found
parentCommentToSumOfCachedReplies[parentCommentId] = childIndex
for (indexForDelete in childIndex..parentComment.replies.size-1) {
for (indexForDelete in childIndex..parentComment.replies.size - 1) {
cachedCommentsSetMap.remove(parentComment.replies[indexForDelete])
}
break
Expand All @@ -162,9 +162,10 @@ class CommentManager {

fun loadCommentsByIds(idsForLoading: LongArray, fromReply: Boolean = false) {
api.getCommentsByIds(idsForLoading).enqueue(object : Callback<CommentsResponse> {
override fun onResponse(response: Response<CommentsResponse>?, retrofit: Retrofit?) {

if (response != null && response.isSuccess) {
override fun onResponse(call: Call<CommentsResponse>?, response: Response<CommentsResponse>?) {

if (response != null && response.isSuccessful) {
val stepicResponse = response.body()
if (stepicResponse != null) {
addComments(stepicResponse, fromReply)
Expand All @@ -176,7 +177,7 @@ class CommentManager {
}
}

override fun onFailure(t: Throwable?) {
override fun onFailure(call: Call<CommentsResponse>?, t: Throwable?) {
bus.post(InternetConnectionProblemInCommentsEvent(discussionProxyId))
}
})
Expand Down Expand Up @@ -280,10 +281,9 @@ class CommentManager {

fun resetAll(dP: DiscussionProxy? = null) {
parentIdToPositionInDiscussionMap.clear()
if (dP!=null) {
if (dP != null) {
setDiscussionProxy(dP)
}
else{
} else {
setDiscussionProxy(discussionProxy!!)
}
sumOfCachedParent = 0
Expand All @@ -301,7 +301,7 @@ class CommentManager {
return cachedCommentsSetMap[commentId]
}

fun clearAllLoadings(){
fun clearAllLoadings() {
commentIdIsLoading.clear()
repliesIdIsLoading.clear()
}
Expand Down
Loading

0 comments on commit 9cec608

Please sign in to comment.