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

Commit e51a751

Browse files
committed
Fixes #433, Fixed disappearing ProgressDialog on touch
made the branch even with master on selecting refres from overflow menu,progress dialog appears only if connected to network
1 parent b596202 commit e51a751

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

app/src/main/java/com/zulip/android/activities/LoginActivity.java

+4
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ private boolean isUrlValid(String url) {
271271

272272
private void showBackends(String httpScheme, String serverURL) {
273273
commonProgressDialog.showWithMessage(getString(R.string.connecting_to_server));
274+
commonProgressDialog.setCancelable(false);
274275
// if server url does not end with "/", then append it
275276
if (!serverURL.endsWith("/")) {
276277
serverURL = serverURL + "/";
@@ -498,13 +499,15 @@ public void onClick(View v) {
498499
switch (v.getId()) {
499500
case R.id.google_sign_in_button:
500501
commonProgressDialog.showWithMessage(getString(R.string.signing_in));
502+
commonProgressDialog.setCancelable(false);
501503
setupGoogleSignIn();
502504
break;
503505
case R.id.zulip_login:
504506
if (!isInputValid()) {
505507
return;
506508
}
507509
commonProgressDialog.showWithMessage(getString(R.string.signing_in));
510+
commonProgressDialog.setCancelable(false);
508511
String username = mUserName.getText().toString();
509512
String password = mPassword.getText().toString();
510513
getServices()
@@ -559,6 +562,7 @@ public void onFailure(Call<LoginResponse> call, Throwable t) {
559562
case R.id.local_server_button:
560563
if (!isInputValidForDevAuth()) return;
561564
commonProgressDialog.showWithMessage(getString(R.string.signing_in));
565+
commonProgressDialog.setCancelable(false);
562566
AsyncDevGetEmails asyncDevGetEmails = new AsyncDevGetEmails(LoginActivity.this);
563567
asyncDevGetEmails.setCallback(new ZulipAsyncPushTask.AsyncTaskCompleteListener() {
564568
@Override

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import android.graphics.Bitmap;
2323
import android.graphics.PorterDuff;
2424
import android.graphics.drawable.Drawable;
25+
import android.net.ConnectivityManager;
26+
import android.net.NetworkInfo;
2527
import android.net.Uri;
2628
import android.os.Build;
2729
import android.os.Bundle;
@@ -2081,8 +2083,14 @@ public void onClick(
20812083
break;
20822084
case R.id.refresh:
20832085
Log.w("menu", "Refreshed manually by user. We shouldn't need this.");
2084-
commonProgressDialog.showWithMessage(getString(R.string.refreshing));
2085-
onRefresh();
2086+
if (!isNetworkAvailable()) {
2087+
Toast.makeText(ZulipActivity.this, R.string.toast_no_internet_connection, Toast.LENGTH_SHORT).show();
2088+
commonProgressDialog.dismiss();
2089+
} else {
2090+
commonProgressDialog.showWithMessage(getString(R.string.refreshing));
2091+
commonProgressDialog.setCancelable(false);
2092+
onRefresh();
2093+
}
20862094
break;
20872095
case R.id.today:
20882096
//check user selected Today or One Day Before
@@ -2141,6 +2149,7 @@ private void setNightMode(@AppCompatDelegate.NightMode int nightMode) {
21412149
*/
21422150
private void logout() {
21432151
commonProgressDialog.showWithMessage(getString(R.string.logging_out));
2152+
commonProgressDialog.setCancelable(false);
21442153
this.logged_in = false;
21452154
final String serverUrl = app.getServerHostUri();
21462155

@@ -2358,4 +2367,11 @@ public MessageListFragment getCurrentMessageList() {
23582367
public enum Flag {
23592368
RESET_DATABASE,
23602369
}
2370+
2371+
private boolean isNetworkAvailable() {
2372+
ConnectivityManager connectivityManager
2373+
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
2374+
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
2375+
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
2376+
}
23612377
}

app/src/main/java/com/zulip/android/util/CommonProgressDialog.java

+4
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ public boolean isShowing() {
3737
public void setMessage(String message) {
3838
progressDialog.setMessage(message);
3939
}
40+
41+
public void setCancelable(boolean cancelable) {
42+
progressDialog.setCancelable(cancelable);
43+
}
4044
}

0 commit comments

Comments
 (0)