public void setTitle() {
    Preferences.loadSettings(this);
    if ((Preferences.activeMapName != null) && (!TextUtils.isEmpty(Preferences.activeMapName))) {

      getSupportActionBar().setTitle(Preferences.activeMapName);
    }
  }
Пример #2
0
 /**
  * Check if a deployment is the active one
  *
  * @param id - map's id
  * @return boolean
  */
 public boolean isMapActive(long id) {
   Preferences.loadSettings(this);
   if (Preferences.activeDeployment == id) {
     return true;
   }
   return false;
 }
Пример #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    actionBar.setDisplayHomeAsUpEnabled(false);
    registerForContextMenu(listView);
    this.dialog = new ProgressDialog(this);
    this.dialog.setCancelable(true);
    this.dialog.setIndeterminate(true);
    this.dialog.setMessage(getString(R.string.please_wait));
    // load current settings
    Preferences.loadSettings(this);
    // filter map list
    if (view != null) {
      view.mSearchMap.addTextChangedListener(
          new TextWatcher() {

            public void afterTextChanged(Editable arg0) {}

            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

            public void onTextChanged(CharSequence s, int start, int before, int count) {

              if (!(TextUtils.isEmpty(s.toString()))) {
                filter = s.toString();
                mHandler.post(filterMapList);
              } else {
                mHandler.post(fetchMapList);
              }
            }
          });
    }
  }
Пример #4
0
  /**
   * Check if an ushahidi deployment has changed it's HTTP protocol to HTTPS or not. Then update if
   * it has.
   *
   * @param context - the calling activity.
   */
  public void updateDomain() {

    Preferences.loadSettings(context);

    StringBuilder uriBuilder = new StringBuilder(Preferences.domain);
    uriBuilder.append("/api?task=version");
    uriBuilder.append("&resp=json");

    try {
      response = GetURL(uriBuilder.toString());
      if (response != null) {

        final int statusCode = response.getStatusLine().getStatusCode();

        if (statusCode == 200) {

          jsonString = GetText(response);
          log(String.format("%s %s ", "Update domain", jsonString));
          JSONObject jsonObject = new JSONObject(jsonString);
          String changedDomain = jsonObject.getJSONObject("payload").getString("domain");

          Preferences.domain = changedDomain;

          // save changes
          Preferences.saveSettings(context);
        }
      }

    } catch (IOException e) {
      log(CLASS_TAG, e);
    } catch (JSONException e) {
      log(CLASS_TAG, e);
    }
  }
Пример #5
0
  public boolean checkForCheckin() {

    Preferences.loadSettings(context);

    updateDomain();

    StringBuilder uriBuilder = new StringBuilder(Preferences.domain);
    uriBuilder.append("/api?task=version");
    uriBuilder.append("&resp=json");

    try {
      response = GetURL(uriBuilder.toString());

      if (response == null) {
        log("Dome " + Preferences.domain);
        return false;
      }

      final int statusCode = response.getStatusLine().getStatusCode();

      if (statusCode == 200) {
        jsonString = GetText(response);
        log("jack " + jsonString + " domains " + Preferences.domain);
        JSONObject jsonObject = new JSONObject(jsonString);
        int checkinStatus = jsonObject.getJSONObject("payload").getInt("checkins");
        log("Checkin status " + checkinStatus);
        if (checkinStatus == 1) {
          return true;
        }
        return false;
      }
      return false;
    } catch (IOException e) {

      return false;
    } catch (JSONException e) {

      return false;
    }
  }