Merge pull request 'fix login button display when internet connection is available' (#21) from SD-217 into develop
Reviewed-on: #21
This commit is contained in:
commit
680dd0f803
@ -10,13 +10,19 @@ import android.content.ServiceConnection;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
|
import android.net.NetworkRequest;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -114,6 +120,17 @@ public class SDMobileActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
SM.Debug("##### onCREATE ##### with LANGUAGE " + AppParams.LANGUAGETMP);
|
SM.Debug("##### onCREATE ##### with LANGUAGE " + AppParams.LANGUAGETMP);
|
||||||
|
|
||||||
|
ConnectivityManager connectivityManager =
|
||||||
|
(ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
connectivityManager.registerDefaultNetworkCallback(networkCallback);
|
||||||
|
} else {
|
||||||
|
NetworkRequest request = new NetworkRequest.Builder()
|
||||||
|
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build();
|
||||||
|
connectivityManager.registerNetworkCallback(request, networkCallback);
|
||||||
|
}
|
||||||
|
|
||||||
AppParams.theme = AppParams.Theme.SAFEDISPATCH;
|
AppParams.theme = AppParams.Theme.SAFEDISPATCH;
|
||||||
if (AppParams.theme == AppParams.Theme.SAFENET)
|
if (AppParams.theme == AppParams.Theme.SAFENET)
|
||||||
this.setTheme(R.style.Theme_Safenet);
|
this.setTheme(R.style.Theme_Safenet);
|
||||||
@ -524,6 +541,22 @@ public class SDMobileActivity extends Activity {
|
|||||||
SM.Debug("##### onRESUME #####");
|
SM.Debug("##### onRESUME #####");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
|
||||||
|
@Override
|
||||||
|
public void onAvailable(Network network) {
|
||||||
|
// network available
|
||||||
|
Log.v("NetworkAvailability", "available");
|
||||||
|
if (tcp != null && !tcp.isConnectionUP)
|
||||||
|
saveIPandRestartTCP(AppParams.IP, AppParams.PORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLost(Network network) {
|
||||||
|
// network unavailable
|
||||||
|
Log.v("NetworkAvailability", "unavailable");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private void startTabActivity(long userID) {
|
private void startTabActivity(long userID) {
|
||||||
// good login - load activity
|
// good login - load activity
|
||||||
|
Loading…
Reference in New Issue
Block a user