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

Commit

Permalink
Fixes #433, Fixed disappearing ProgressDialog on touch
Browse files Browse the repository at this point in the history
made the branch even with master

on selecting refres from overflow menu,progress dialog appears only if connected to network
  • Loading branch information
DravitLochan committed Mar 7, 2017
1 parent b596202 commit e51a751
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
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);
}
}

0 comments on commit e51a751

Please sign in to comment.