Skip to content

Commit

Permalink
Merge branch 'release/1.56'
Browse files Browse the repository at this point in the history
  • Loading branch information
eadm committed Apr 5, 2018
2 parents e329d9c + 126850d commit ef58504
Show file tree
Hide file tree
Showing 143 changed files with 1,482 additions and 440 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import kotlinx.android.synthetic.main.fragment_adaptive_rating.*
import kotlinx.android.synthetic.main.error_no_connection_with_button.*
import org.stepic.droid.R
import org.stepic.droid.adaptive.ui.adapters.AdaptiveRatingAdapter
import org.stepic.droid.base.App
Expand Down Expand Up @@ -47,7 +48,7 @@ class AdaptiveRatingFragment: FragmentBase(), AdaptiveRatingView {

override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

error.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent))
recycler.layoutManager = LinearLayoutManager(context)

val divider = DividerItemDecoration(context, DividerItemDecoration.VERTICAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.PopupWindow
import kotlinx.android.synthetic.main.error_no_connection_with_button.*
import kotlinx.android.synthetic.main.fragment_recommendations.*
import org.stepic.droid.R
import org.stepic.droid.adaptive.ui.adapters.QuizCardsAdapter
Expand Down Expand Up @@ -67,6 +68,7 @@ class RecommendationsFragment : FragmentBase(), RecommendationsView {

override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
error.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent))

tryAgain.setOnClickListener {
recommendationsPresenter.retry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
public void showEmptyScreen(boolean isShown) {
if (isShown) {
if (getCourseType() == Table.enrolled) {
setBackgroundColorToRootView(R.color.old_cover);
emptyCoursesView.setVisibility(View.VISIBLE);
if (getSharedPreferenceHelper().getAuthResponseFromStore() != null) { //// TODO: 23.12.16 optimize it and do on background thread
//logged
Expand All @@ -150,13 +149,11 @@ public void showEmptyScreen(boolean isShown) {
}
emptySearch.setVisibility(View.GONE);
} else {
setBackgroundColorToRootView(R.color.old_cover);
emptyCoursesView.setVisibility(View.GONE);
emptySearch.setVisibility(View.VISIBLE);
}
swipeRefreshLayout.setVisibility(View.GONE);
} else {
setBackgroundColorToRootView(R.color.new_cover);
emptySearch.setVisibility(View.GONE);
emptyCoursesView.setVisibility(View.GONE);
swipeRefreshLayout.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class NotificationListPresenter
}
return false
} else {
if (!isLoading) {
view?.onNeedShowNotifications(notificationList)
}
//do nothing we loading or already loaded
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public int getNotificationsCount() {
@Override
public GenericViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Timber.d("createViewHolder of NotificationAdapter, viewType = %d", viewType);
final Context context = parent.getContext();
if (viewType == HEADER_VIEW_TYPE) {
View view = LayoutInflater.from(context).inflate(R.layout.notification_list_header_item, parent, false);
return new HeaderViewHolder(view);
Expand Down Expand Up @@ -190,7 +191,7 @@ public long getHeaderId(int position) {
@NotNull
@Override
public DateHeaderViewHolder onCreateHeaderViewHolder(@NotNull ViewGroup parent) {
return new DateHeaderViewHolder(LayoutInflater.from(context).inflate(R.layout.notification_date_header, parent, false));
return new DateHeaderViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.notification_date_header, parent, false));
}

@Override
Expand Down Expand Up @@ -334,7 +335,7 @@ private void setCommentNotificationIcon(Notification notification) {
.load(avatarUri)
.into(notificationIcon);
} else {
Glide.with(context)
Glide.with(context.getApplicationContext())
.load(userAvatarUrl)
.asBitmap()
.placeholder(placeholderUserIcon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.widget.FrameLayout;
import android.widget.TextView;

import org.jetbrains.annotations.Contract;
import org.stepic.droid.R;
import org.stepic.droid.base.App;
import org.stepic.droid.core.ScreenManager;
Expand Down Expand Up @@ -67,16 +68,19 @@ public LatexSupportableEnhancedFrameLayout(Context context, AttributeSet attrs)
}

@LayoutRes
@Contract(pure = true)
protected int getViewRes() {
return R.layout.latex_supportabe_enhanced_view;
}

@IdRes
@Contract(pure = true)
protected int getTextViewId() {
return R.id.textView;
}

@IdRes
@Contract(pure = true)
protected int getWebViewId() {
return R.id.webView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ package org.stepic.droid.ui.custom

import android.util.AttributeSet
import android.content.Context
import org.jetbrains.annotations.Contract
import org.stepic.droid.R

class LatexSupportableExpandableFrameLayout
@JvmOverloads
constructor(context: Context, attrs: AttributeSet? = null): LatexSupportableEnhancedFrameLayout(context, attrs) {
@Contract(pure = true)
override fun getViewRes() = R.layout.latex_supportable_expandable_view

@Contract(pure = true)
override fun getTextViewId() = R.id.expandableTextView

@Contract(pure = true)
override fun getWebViewId() = R.id.htmlView
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.empty_certificates.*
import kotlinx.android.synthetic.main.fragment_certificates.*
import kotlinx.android.synthetic.main.need_auth_placeholder.*
import kotlinx.android.synthetic.main.empty_login.*
import kotlinx.android.synthetic.main.progress_bar_on_empty_screen.*
import kotlinx.android.synthetic.main.report_problem_layout.*
import kotlinx.android.synthetic.main.error_no_connection.*
import org.stepic.droid.R
import org.stepic.droid.base.App
import org.stepic.droid.base.FragmentBase
Expand Down Expand Up @@ -72,6 +72,8 @@ class CertificatesFragment : FragmentBase(),

authAction.setOnClickListener { screenManager.showLaunchScreen(activity) }

goToCatalog.setOnClickListener { screenManager.showCatalog(activity) }

certificateSwipeRefresh.setOnRefreshListener(this)

certificatePresenter.attachView(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import android.view.*
import android.widget.Toast
import kotlinx.android.synthetic.main.empty_comments.*
import kotlinx.android.synthetic.main.fragment_comments.*
import kotlinx.android.synthetic.main.internet_fail_clickable.*
import kotlinx.android.synthetic.main.progress_bar_on_empty_screen.*
import kotlinx.android.synthetic.main.error_no_connection.*
import org.stepic.droid.R
import org.stepic.droid.analytic.Analytic
import org.stepic.droid.base.App
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public static CourseDetailFragment newInstance(long courseId) {
@BindView(R.id.course_not_found)
View courseNotFoundView;

@BindView(R.id.goToCatalog)
View goToCatalog;

@BindDrawable(R.drawable.general_placeholder)
Drawable coursePlaceholder;

Expand Down Expand Up @@ -139,8 +142,11 @@ public static CourseDetailFragment newInstance(long courseId) {
@BindDrawable(R.drawable.video_placeholder_drawable)
Drawable videoPlaceholder;

@BindView(R.id.reportProblem)
View reportInternetProblem;
@BindView(R.id.error)
View errorView;

@BindView(R.id.tryAgain)
View tryAgain;

ImageView courseIcon;

Expand Down Expand Up @@ -215,7 +221,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
hideSoftKeypad();
instructorAdapter = new InstructorAdapter(instructorsList, getActivity());
instructorsCarousel.setAdapter(instructorAdapter);
courseNotFoundView.setOnClickListener(new View.OnClickListener() {
goToCatalog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getSharedPreferenceHelper().getAuthResponseFromStore() != null) {
Expand All @@ -242,7 +248,7 @@ public void onClick(View v) {
tryToShowCourse();
}
};
reportInternetProblem.setOnClickListener(onClickReportListener);
tryAgain.setOnClickListener(onClickReportListener);

header.setVisibility(View.GONE); //hide while we don't have the course
footer.setVisibility(View.GONE);
Expand Down Expand Up @@ -277,7 +283,7 @@ private void initFooter(LayoutInflater layoutInflater) {


private void tryToShowCourse() {
reportInternetProblem.setVisibility(View.GONE); // now we try show -> it is not visible
errorView.setVisibility(View.GONE); // now we try show -> it is not visible
course = getArguments().getParcelable(AppConstants.KEY_COURSE_BUNDLE);
if (course == null) {
//it is not from our activity
Expand Down Expand Up @@ -306,7 +312,7 @@ public void onCourseFound(@NotNull Course foundCourse) {

public void initScreenByCourse() {
//todo HIDE LOADING AND ERRORS
reportInternetProblem.setVisibility(View.GONE);
errorView.setVisibility(View.GONE);
courseNotFoundView.setVisibility(View.GONE);
//
header.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -432,7 +438,7 @@ public void onClick(View v) {
public void onCourseUnavailable(long courseId) {
if (course == null) {
getAnalytic().reportEvent(Analytic.Interaction.COURSE_USER_TRY_FAIL, courseId + "");
reportInternetProblem.setVisibility(View.GONE);
errorView.setVisibility(View.GONE);
courseNotFoundView.setVisibility(View.VISIBLE);
}
}
Expand All @@ -441,8 +447,8 @@ public void onCourseUnavailable(long courseId) {
public void onInternetFailWhenCourseIsTriedToLoad() {
if (course == null) {
courseNotFoundView.setVisibility(View.GONE);
reportInternetProblem.setVisibility(View.VISIBLE);
reportInternetProblem.setOnClickListener(onClickReportListener);
errorView.setVisibility(View.VISIBLE);
tryAgain.setOnClickListener(onClickReportListener);
}
}

Expand Down Expand Up @@ -497,8 +503,8 @@ public void onDestroyView() {
courseJoinerPresenter.detachView(this);
courseFinderPresenter.detachView(this);
courseDetailAnalyticPresenter.detachView(this);
reportInternetProblem.setOnClickListener(null);
courseNotFoundView.setOnClickListener(null);
tryAgain.setOnClickListener(null);
goToCatalog.setOnClickListener(null);
instructorAdapter = null;
joinCourseView.setOnClickListener(null);
continueCourseView.setOnClickListener(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
Expand Down Expand Up @@ -91,6 +90,9 @@ public abstract class CourseListFragmentBase extends FragmentBase
@BindView(R.id.empty_search)
protected ViewGroup emptySearch;

@BindView(R.id.goToCatalog)
protected Button goToCatalog;

protected List<Course> courses;
protected CoursesAdapter coursesAdapter;

Expand Down Expand Up @@ -177,18 +179,26 @@ public void onClick(View v) {
public void onClick(View v) {
Activity parent = getActivity();
if (parent == null || !(parent instanceof RootScreen)) {
return;
}
getAnalytic().reportEvent(Analytic.Interaction.CLICK_FIND_COURSE_EMPTY_SCREEN);
if (getSharedPreferenceHelper().getAuthResponseFromStore() == null) {
getAnalytic().reportEvent(Analytic.Anonymous.BROWSE_COURSES_CENTER);
getScreenManager().showCatalog(getContext());
} else {
getAnalytic().reportEvent(Analytic.Interaction.CLICK_FIND_COURSE_EMPTY_SCREEN);
if (getSharedPreferenceHelper().getAuthResponseFromStore() == null) {
getAnalytic().reportEvent(Analytic.Anonymous.BROWSE_COURSES_CENTER);
}
((RootScreen) parent).showCatalog();
}
((RootScreen) parent).showCatalog();
}
});
joiningListenerClient.subscribe(this);
continueCoursePresenter.attachView(this);
droppingPresenter.attachView(this);

goToCatalog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
screenManager.showCatalog(getContext());
}
});
}

@Override
Expand Down Expand Up @@ -234,7 +244,6 @@ public void showLoading() {
reportConnectionProblem.setVisibility(View.GONE);

if (courses.isEmpty()) {
setBackgroundColorToRootView(R.color.new_cover);
ProgressHelper.activate(swipeRefreshLayout);
coursesAdapter.showLoadingFooter(false);
} else if (swipeRefreshLayout != null && !swipeRefreshLayout.isRefreshing()) {
Expand All @@ -252,7 +261,6 @@ public void showEmptyCourses() {
ProgressHelper.dismiss(swipeRefreshLayout);
reportConnectionProblem.setVisibility(View.GONE);
if (courses.isEmpty()) {
setBackgroundColorToRootView(R.color.old_cover);
showEmptyScreen(true);
getLocalReminder().remindAboutApp();
}
Expand All @@ -267,7 +275,6 @@ public void showConnectionProblem() {
if (courses == null || courses.isEmpty()) {
//screen is clear due to error connection
showEmptyScreen(false);
setBackgroundColorToRootView(R.color.old_cover);
reportConnectionProblem.setVisibility(View.VISIBLE);
}
}
Expand All @@ -277,7 +284,6 @@ public final void showCourses(@NonNull List<Course> courses) {
ProgressHelper.dismiss(progressBarOnEmptyScreen);
ProgressHelper.dismiss(swipeRefreshLayout);
coursesAdapter.showLoadingFooter(false);
setBackgroundColorToRootView(R.color.new_cover);
reportConnectionProblem.setVisibility(View.GONE);
showEmptyScreen(false);
List<Course> finalCourses;
Expand Down Expand Up @@ -338,10 +344,6 @@ public void onSuccessJoin(@Nullable Course joinedCourse) {
updateEnrollment(joinedCourse, joinedCourse.getEnrollment());
}

protected final void setBackgroundColorToRootView(@ColorRes int colorRes) {
rootView.setBackgroundColor(ColorUtil.INSTANCE.getColorArgb(colorRes, getContext()));
}

@Override
public final void onUserHasNotPermissionsToDrop() {
Toast.makeText(getContext(), R.string.cant_drop, Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public static DownloadsFragment newInstance() {
@BindView(R.id.authAction)
Button authUserButton;

@BindView(R.id.goToCatalog)
Button goToCatalog;

private DownloadsAdapter downloadAdapter;
private List<CachedVideo> cachedVideoList;
private ConcurrentHashMap<Long, Lesson> stepIdToLesson;
Expand Down Expand Up @@ -164,6 +167,13 @@ public void onClick(View v) {
ProgressHelper.activate(progressBar);
}

goToCatalog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
screenManager.showCatalog(getContext());
}
});

loadingProgressDialog = new LoadingProgressDialog(getContext());
downloadsListenerClient.subscribe(this);
videoMovedListenerClient.subscribe(this);
Expand Down
Loading

0 comments on commit ef58504

Please sign in to comment.