Merge pull request #1646 from nextcloud/notificationWarning

Notifications: close snackbar when showing drawer
This commit is contained in:
Andy Scherzinger 2017-10-20 20:15:23 +02:00 committed by GitHub
commit c293cd8fbc
2 changed files with 51 additions and 19 deletions

View file

@ -240,6 +240,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
new Handler().post(pendingRunnable);
pendingRunnable = null;
}
closeDrawer();
}
/** Called when a drawer has settled in a completely open state. */

View file

@ -107,6 +107,7 @@ public class NotificationsActivity extends FileActivity {
private Unbinder unbinder;
private NotificationListAdapter adapter;
private Snackbar snackbar = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -143,33 +144,62 @@ public class NotificationsActivity extends FileActivity {
}
});
Context context = getApplicationContext();
String pushUrl = context.getResources().getString(R.string.push_server_url);
setupPushWarning();
setupContent();
}
if (pushUrl.isEmpty()) {
Snackbar.make(emptyContentContainer, R.string.push_notifications_not_implemented,
Snackbar.LENGTH_INDEFINITE).show();
private void setupPushWarning() {
if (snackbar != null) {
if (!snackbar.isShown()) {
snackbar.show();
}
} else {
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
Context context = getApplicationContext();
String pushUrl = context.getResources().getString(R.string.push_server_url);
boolean usesOldLogin = arbitraryDataProvider.getBooleanValue(account.name,
AccountUtils.ACCOUNT_USES_STANDARD_PASSWORD);
if (usesOldLogin) {
Snackbar.make(emptyContentContainer, R.string.push_notifications_old_login,
Snackbar.LENGTH_INDEFINITE).show();
if (pushUrl.isEmpty()) {
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_not_implemented,
Snackbar.LENGTH_INDEFINITE);
} else {
String pushValue = arbitraryDataProvider.getValue(account.name, PushUtils.KEY_PUSH);
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
if (pushValue == null || pushValue.isEmpty()) {
Snackbar.make(emptyContentContainer, R.string.push_notifications_temp_error,
Snackbar.LENGTH_INDEFINITE).show();
boolean usesOldLogin = arbitraryDataProvider.getBooleanValue(account.name,
AccountUtils.ACCOUNT_USES_STANDARD_PASSWORD);
if (usesOldLogin) {
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_old_login,
Snackbar.LENGTH_INDEFINITE);
} else {
String pushValue = arbitraryDataProvider.getValue(account.name, PushUtils.KEY_PUSH);
if (pushValue == null || pushValue.isEmpty()) {
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_temp_error,
Snackbar.LENGTH_INDEFINITE);
}
}
}
}
setupContent();
if (snackbar != null && !snackbar.isShown()) {
snackbar.show();
}
}
}
@Override
public void openDrawer() {
super.openDrawer();
if (snackbar != null && snackbar.isShown()) {
snackbar.dismiss();
}
}
@Override
public void closeDrawer() {
super.closeDrawer();
setupPushWarning();
}
public void onDestroy() {