Skip to content

Commit

Permalink
Merge pull request #167 from StepicOrg/release/1.47
Browse files Browse the repository at this point in the history
release 1.47
  • Loading branch information
KirillMakarov authored Nov 16, 2017
2 parents 3ee915c + 68d6124 commit bfb3bec
Show file tree
Hide file tree
Showing 251 changed files with 3,715 additions and 2,037 deletions.
4 changes: 2 additions & 2 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 193
versionName "1.46.4"
versionCode 197
versionName "1.47"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
1 change: 1 addition & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@

#for saving search view https://stackoverflow.com/questions/18407171/searchview-getactionview-returning-null
-keep class android.support.v7.widget.SearchView { *; }
-keep class org.stepic.droid.ui.custom.AutoCompleteSearchView { *; }

#keep configs names
-keep class org.stepic.droid.configuration.** { *; }
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,6 @@
android:value=".ui.activities.CommentsActivity"/>
</activity>

<activity
android:name=".ui.activities.FilterActivity"
android:parentActivityName=".ui.activities.MainFeedActivity"
android:windowSoftInputMode="adjustResize|stateHidden">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.activities.MainFeedActivity"/>
</activity>

<activity
android:name=".ui.activities.ProfileActivity"
android:windowSoftInputMode="adjustResize|stateHidden">
Expand Down
1 change: 1 addition & 0 deletions app/src/main/assets/wysiwyg.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@

img {
display: block;
max-width: 100%;
&.wysiwyg-float-left,
&.wysiwyg-float-right {
display: inline-block;
Expand Down
17 changes: 8 additions & 9 deletions app/src/main/java/org/stepic/droid/analytic/Analytic.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ interface Code {
interface Search {
String SEARCH_NULL = "search_null";
String SEARCH_QUERY = "search_with_query";
String SEARCH_OPENED = "search_opened";
String SEARCH_SUBMITTED = "search_submitted";
String SEARCH_SUGGESTION_CLICKED = "search_suggestion_clicked";
}

interface CoursesCarousel {
Expand Down Expand Up @@ -138,10 +141,12 @@ interface Interaction {
String CLICK_TERMS_OF_SERVICE = "click_terms_of_service";

String INVITE_DIALOG_DISMISSED = "invite_dialog_dismissed";

interface InviteDialogDismissType {
String LEAVE = "leave";
String SHARE = "share";
}

String INVITE_DIALOG_BROKEN = "invite_dialog_broken";

String SHOW_MATERIAL_DIALOG_INVITATION = "materdial_dialog_invite_shown";
Expand All @@ -150,13 +155,11 @@ interface InviteDialogDismissType {
String CLICK_PROFILE_BEFORE_LOADING = "click_profile_before_loading";
String JOIN_COURSE = "click_join_course";

String CLICK_FIND_COURSE_LAUNCH = "click_find_courses_launch";
String USER_OPEN_IMAGE = "user_open_image";
String SCREENSHOT = "screenshot";
String GOOGLE_SOCIAL_IS_NOT_ENABLED = "google_social_is_not_enabled";
String ACCEPT_DELETING_UNIT = "click_delete_unit_dialog";
String ACCEPT_DELETING_SECTION = "click_delete_section_dialog";
String CLICK_STREAK_DRAWER = "click_streak_drawer";
String SHOW_LAUNCH_SCREEN_AFTER_LOGOUT = "show_launch_screen_after_logout";
}

Expand All @@ -183,7 +186,7 @@ interface Screens {
String OPEN_LINK_IN_WEB = "open_link";

String USER_OPEN_MY_COURSES = "main_choice_my_courses";
String USER_OPEN_FIND_COURSES = "main_choice_find_courses";
String USER_OPEN_CATALOG = "main_choice_find_courses";
String USER_OPEN_DOWNLOADS = "main_choice_downloads";
String USER_OPEN_CERTIFICATES = "main_choice_certificates";
String USER_OPEN_FEEDBACK = "main_choice_feedback";
Expand Down Expand Up @@ -274,6 +277,7 @@ interface Error {
String UNIT_CACHED_LESSON_NO = "error_unit_cached_lesson_not";
String FEATURED_EMPTY = "error_featured_empty";
String TEMPLATE_WAS_NULL = "error_code_template_null";
String COURSE_COLLECTION_EMPTY = "course_collection_empty";
}

interface Web {
Expand Down Expand Up @@ -386,11 +390,6 @@ interface Certificate {
String OPEN_CERTIFICATE_FROM_NOTIFICATION_CENTER = "certificate_notification_center";
}

interface Filters {
String FILTERS_CANCELED = "filters_canceled";
String FILTERS_NEED_UPDATE = "filters_need_update";
}

interface Exam {
String START_EXAM = "exam_start";
String SHOW_EXAM = "exam_shown_on_bind_view";
Expand Down Expand Up @@ -436,7 +435,7 @@ enum NotificationType {

interface Shortcut {
String OPEN_PROFILE = "shortcut_open_profile";
String FIND_COURSES = "shortcut_find_courses";
String OPEN_CATALOG = "shortcut_find_courses";
}

interface Anonymous {
Expand Down
124 changes: 14 additions & 110 deletions app/src/main/java/org/stepic/droid/base/CoursesDatabaseFragmentBase.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package org.stepic.droid.base;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -18,44 +15,22 @@
import org.stepic.droid.analytic.Analytic;
import org.stepic.droid.core.dropping.contract.DroppingListener;
import org.stepic.droid.core.presenters.PersistentCourseListPresenter;
import org.stepic.droid.core.presenters.contracts.FilterForCoursesView;
import org.stepic.droid.model.Course;
import org.stepic.droid.storage.operations.Table;
import org.stepic.droid.ui.fragments.CourseListFragmentBase;
import org.stepic.droid.ui.util.BackButtonHandler;
import org.stepic.droid.ui.util.ContextMenuRecyclerView;
import org.stepic.droid.ui.util.OnBackClickListener;
import org.stepic.droid.util.AppConstants;
import org.stepic.droid.util.ContextMenuCourseUtil;

import java.util.List;

import javax.inject.Inject;

public abstract class CoursesDatabaseFragmentBase extends CourseListFragmentBase implements FilterForCoursesView, OnBackClickListener, DroppingListener {
private static final int FILTER_REQUEST_CODE = 776;

private boolean needFilter = false;

public abstract class CoursesDatabaseFragmentBase extends CourseListFragmentBase implements DroppingListener {
@Inject
PersistentCourseListPresenter courseListPresenter;

@Inject
Client<DroppingListener> droppingClient;

private BackButtonHandler backButtonHandler = null;
private boolean isScreenCreated;

@Override
public void onAttach(Context context) {
super.onAttach(context);

Activity rootActivity = getActivity();
if (rootActivity != null && rootActivity instanceof BackButtonHandler) {
backButtonHandler = ((BackButtonHandler) rootActivity);
backButtonHandler.setBackClickListener(this);
}
}

@Override
protected void injectComponent() {
Expand All @@ -67,36 +42,12 @@ protected void injectComponent() {
.inject(this);
}

@Override
protected void onReleaseComponent() {
App.Companion
.componentManager()
.releaseCourseGeneralComponent();
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
setRetainInstance(true);

isScreenCreated = true;
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.filter_courses_menu, menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_filter_menu:
getScreenManager().showFilterScreen(this, FILTER_REQUEST_CODE, getCourseType());
return true;
}

return super.onOptionsItemSelected(item);
}

@Override
Expand All @@ -111,16 +62,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
@Override
public void onStart() {
super.onStart();
if (isScreenCreated) {
//reset all data
isScreenCreated = false;
needFilter = false;
courses.clear();
courseListPresenter.refreshData(getCourseType(), needFilter, true);
} else {
//load if not
courseListPresenter.downloadData(getCourseType(), needFilter);
}
courseListPresenter.downloadData(getCourseType());
swipeRefreshLayout.setRefreshing(false);
}

Expand Down Expand Up @@ -182,27 +124,11 @@ private void showInfo(int position) {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == FragmentActivity.RESULT_OK) {
if (requestCode == AppConstants.REQUEST_CODE_DETAIL) {
Course course = data.getParcelableExtra(AppConstants.COURSE_ID_KEY);
int enrollment = data.getIntExtra(AppConstants.ENROLLMENT_KEY, 0);
if (course != null && enrollment != 0) {
updateEnrollment(course, enrollment);
}
}

if (requestCode == FILTER_REQUEST_CODE) {
getAnalytic().reportEvent(Analytic.Filters.FILTERS_NEED_UPDATE);
needFilter = true; // not last filter? check it
courses.clear();
coursesAdapter.notifyDataSetChanged();
courseListPresenter.refreshData(getCourseType(), needFilter, true);
}
}

if (resultCode == FragmentActivity.RESULT_CANCELED) {
if (requestCode == FILTER_REQUEST_CODE) {
getAnalytic().reportEvent(Analytic.Filters.FILTERS_CANCELED);
if (resultCode == FragmentActivity.RESULT_OK && requestCode == AppConstants.REQUEST_CODE_DETAIL) {
Course course = data.getParcelableExtra(AppConstants.COURSE_ID_KEY);
int enrollment = data.getIntExtra(AppConstants.ENROLLMENT_KEY, 0);
if (course != null && enrollment != 0) {
updateEnrollment(course, enrollment);
}
}
}
Expand Down Expand Up @@ -239,40 +165,13 @@ public void showEmptyScreen(boolean isShown) {

@Override
public void onNeedDownloadNextPage() {
courseListPresenter.loadMore(getCourseType(), needFilter);
}

@Override
public void clearAndShowLoading() {
courses.clear();
coursesAdapter.notifyDataSetChanged();
showLoading();
}

@Override
public void showFilteredCourses(@NotNull List<Course> filteredList) {
showCourses(filteredList);
courseListPresenter.loadMore(getCourseType());
}

@Override
public void onRefresh() {
getAnalytic().reportEvent(Analytic.Interaction.PULL_TO_REFRESH_COURSE);
courseListPresenter.refreshData(getCourseType(), needFilter, true);
}

@Override
public boolean onBackClick() {
getSharedPreferenceHelper().onTryDiscardFilters(getCourseType());
return false;
}

@Override
public void onDetach() {
if (backButtonHandler != null) {
backButtonHandler.removeBackClickListener(this);
backButtonHandler = null;
}
super.onDetach();
courseListPresenter.refreshData(getCourseType());
}

@Override
Expand Down Expand Up @@ -310,4 +209,9 @@ public void onSuccessDropCourse(@NotNull Course droppedCourse) {
showEmptyScreen(true);
}
}


@NotNull
@Override
protected abstract Table getCourseType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.stepic.droid.analytic.Analytic;
import org.stepic.droid.concurrency.MainHandler;
import org.stepic.droid.configuration.Config;
import org.stepic.droid.core.DefaultFilter;
import org.stepic.droid.core.ScreenManager;
import org.stepic.droid.core.ShareHelper;
import org.stepic.droid.fonts.FontsProvider;
Expand Down Expand Up @@ -61,9 +60,6 @@ public abstract class FragmentActivityBase extends AppCompatActivity {
@Inject
protected ShareHelper shareHelper;

@Inject
protected DefaultFilter defaultFilter;

@Inject
protected Config config;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.stepic.droid.code.data

import android.content.Context
import org.stepic.droid.R
import org.stepic.droid.di.AppSingleton
import javax.inject.Inject

@AppSingleton
class AutocompleteContainer
@Inject
constructor(context: Context) {
private val autocomplete = hashMapOf(
"cpp" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_cpp)),
"cs" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_cs)),
"css" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_css)),
"html" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_html)),
"java" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_java)),
"js" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_js)),
"php" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_php)),
"py" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_py)),
"rb" to AutocompleteDictionary(context.resources.getStringArray(R.array.autocomplete_words_rb))
)

fun getAutoCompleteForLangAndPrefix(lang: String, prefix: String): List<String> =
autocomplete[lang]?.getAutocompleteForPrefix(prefix) ?: emptyList()
}
Loading

0 comments on commit bfb3bec

Please sign in to comment.