Skip to content

Commit

Permalink
Be/misc enhancements (#73)
Browse files Browse the repository at this point in the history
* Show Toast confirming logout in settings
* Fix for 'no enrollments' notice not shown in 'My Courses'
  • Loading branch information
Ben-Noah Engelhaupt authored and Tobias Rohloff committed Jun 4, 2018
1 parent 108ec09 commit 4df0c58
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public interface LoadingStateInterface {

void showContent();

void hideContent();

void showBlockingProgress();

void showProgress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public void onRefresh() {
presenter.onRefresh();
}

@Override
public void hideContent() {
loadingStateHelper.hideContentView();
}

@Override
public void showContent() {
loadingStateHelper.showContentView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public void showContentView() {
contentView.setVisibility(View.VISIBLE);
}

public void hideContentView() {
contentView.setVisibility(View.GONE);
}

public boolean isContentViewVisible() {
return contentView.getVisibility() == View.VISIBLE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import de.xikolo.controllers.login.LoginActivityAutoBundle
import de.xikolo.events.LoginEvent
import de.xikolo.events.LogoutEvent
import de.xikolo.managers.UserManager
import de.xikolo.utils.ToastUtil
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
Expand Down Expand Up @@ -136,6 +137,7 @@ class SettingsFragment : PreferenceFragment() {
pref.title = getString(R.string.logout)
pref.setOnPreferenceClickListener { _ ->
UserManager.logout()
ToastUtil.show(R.string.toast_successful_logout);
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public void updateContent() {
courseList.clear();

if (!UserManager.isAuthorized()) {
getViewOrThrow().hideContent();
getViewOrThrow().showLoginRequiredMessage();
} else if (courseManager.countEnrollments(realm) == 0) {
getViewOrThrow().hideContent();
getViewOrThrow().showNoEnrollmentsMessage();
} else {
List<Course> subList = courseManager.listCurrentAndPastCoursesWithEnrollment(realm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ public void onSearch(final String query, boolean withEnrollment) {

protected RealmChangeListener<RealmResults<Course>> getCourseListChangeListener() {
return results -> {
if (results.size() > 0) {
getViewOrThrow().showContent();
updateContent();
}
getViewOrThrow().showContent();
updateContent();
};
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
<string name="toast_no_network">Bitte aktivieren Sie die Netzwerk-Verbindung.</string>
<string name="toast_please_log_in">Bitte melden Sie sich an.</string>
<string name="toast_log_in_failed">Anmeldung fehlgeschlagen. Bitte überprüfen Sie Ihre Zugangsdaten.</string>
<string name="toast_successful_logout">Erfolgreich abgemeldet.</string>
<string name="toast_file_already_downloaded">Datei bereits heruntergeladen.</string>
<string name="toast_no_external_write_access">Kein Schreibzugriff für externen Speicher.</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
<string name="toast_no_network">Please enable network connection.</string>
<string name="toast_please_log_in">Please login.</string>
<string name="toast_log_in_failed">Login failed. Please check your credentials.</string>
<string name="toast_successful_logout">Logged out successfully.</string>
<string name="toast_file_already_downloaded">File already downloaded.</string>
<string name="toast_no_external_write_access">No write access for external storage.</string>

Expand Down

0 comments on commit 4df0c58

Please sign in to comment.