Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Fixes #433, Fixed disappearing ProgressDialog on touch #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ private boolean isUrlValid(String url) {

private void showBackends(String httpScheme, String serverURL) {
commonProgressDialog.showWithMessage(getString(R.string.connecting_to_server));
commonProgressDialog.setCancelable(false);
// if server url does not end with "/", then append it
if (!serverURL.endsWith("/")) {
serverURL = serverURL + "/";
Expand Down Expand Up @@ -498,13 +499,15 @@ public void onClick(View v) {
switch (v.getId()) {
case R.id.google_sign_in_button:
commonProgressDialog.showWithMessage(getString(R.string.signing_in));
commonProgressDialog.setCancelable(false);
setupGoogleSignIn();
break;
case R.id.zulip_login:
if (!isInputValid()) {
return;
}
commonProgressDialog.showWithMessage(getString(R.string.signing_in));
commonProgressDialog.setCancelable(false);
String username = mUserName.getText().toString();
String password = mPassword.getText().toString();
getServices()
Expand Down Expand Up @@ -559,6 +562,7 @@ public void onFailure(Call<LoginResponse> call, Throwable t) {
case R.id.local_server_button:
if (!isInputValidForDevAuth()) return;
commonProgressDialog.showWithMessage(getString(R.string.signing_in));
commonProgressDialog.setCancelable(false);
AsyncDevGetEmails asyncDevGetEmails = new AsyncDevGetEmails(LoginActivity.this);
asyncDevGetEmails.setCallback(new ZulipAsyncPushTask.AsyncTaskCompleteListener() {
@Override
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/com/zulip/android/activities/ZulipActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -2081,8 +2083,14 @@ public void onClick(
break;
case R.id.refresh:
Log.w("menu", "Refreshed manually by user. We shouldn't need this.");
commonProgressDialog.showWithMessage(getString(R.string.refreshing));
onRefresh();
if (!isNetworkAvailable()) {
Toast.makeText(ZulipActivity.this, R.string.toast_no_internet_connection, Toast.LENGTH_SHORT).show();
commonProgressDialog.dismiss();
} else {
commonProgressDialog.showWithMessage(getString(R.string.refreshing));
commonProgressDialog.setCancelable(false);
onRefresh();
}
break;
case R.id.today:
//check user selected Today or One Day Before
Expand Down Expand Up @@ -2141,6 +2149,7 @@ private void setNightMode(@AppCompatDelegate.NightMode int nightMode) {
*/
private void logout() {
commonProgressDialog.showWithMessage(getString(R.string.logging_out));
commonProgressDialog.setCancelable(false);
this.logged_in = false;
final String serverUrl = app.getServerHostUri();

Expand Down Expand Up @@ -2358,4 +2367,11 @@ public MessageListFragment getCurrentMessageList() {
public enum Flag {
RESET_DATABASE,
}

private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ public boolean isShowing() {
public void setMessage(String message) {
progressDialog.setMessage(message);
}

public void setCancelable(boolean cancelable) {
progressDialog.setCancelable(cancelable);
}
}