コード例 #1
0
ファイル: WiFiUtils.java プロジェクト: jonathan-caryl/iosched
 /**
  * Returns whether we should or should not offer to set up wifi. If asCard == true this will
  * decide whether or not to offer wifi setup actively (as a card, for instance). If asCard ==
  * false, this will return whether or not to offer wifi setup passively (in the overflow menu, for
  * instance).
  */
 public static boolean shouldOfferToSetupWifi(final Context context, boolean actively) {
   long now = UIUtils.getCurrentTime(context);
   if (now < Config.WIFI_SETUP_OFFER_START) {
     // too early to offer
     return false;
   }
   if (now > Config.CONFERENCE_END_MILLIS) {
     // too late
     return false;
   }
   if (!WiFiUtils.isWiFiEnabled(context)) {
     // no wifi, no offer
     return false;
   }
   if (!PrefUtils.isAttendeeAtVenue(context)) {
     // wifi setup not relevant
     return false;
   }
   if (WiFiUtils.isWiFiApConfigured(context)) {
     // already set up
     return false;
   }
   if (actively && PrefUtils.hasDeclinedWifiSetup(context)) {
     // user said no
     return false;
   }
   return true;
 }