Android Open Source - dashclock-gerrit Server Fragment






From Project

Back to project page dashclock-gerrit.

License

The source code is released under:

Apache License

If you think the Android project dashclock-gerrit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.plusonelabs.dashclock.gerrit.prefs;
/*w  ww.jav  a2 s .  c  o m*/
import static com.plusonelabs.dashclock.gerrit.prefs.GerritPreferences.*;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.plusonelabs.dashclock.gerrit.R;

public class ServerFragment extends Fragment {

  private SecurePreferences prefs;
  private EditText textServerUrl;
  private EditText textUsername;
  private EditText textPassword;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    prefs = GerritPreferences.getSecurePreferences(getActivity().getApplicationContext());
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.settings_server, null, false);
  }

  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    textServerUrl = (EditText) getActivity().findViewById(R.id.settings_server_server_url);
    textUsername = (EditText) getActivity().findViewById(R.id.settings_server_username);
    textPassword = (EditText) getActivity().findViewById(R.id.settings_server_password);
  }

  @Override
  public void onResume() {
    super.onResume();
    textServerUrl.setText(prefs.getString(SERVER_URL));
    textUsername.setText(prefs.getString(SERVER_USERNAME));
    textPassword.setText(prefs.getString(SERVER_PASSWORD));
  }

  @Override
  public void onPause() {
    super.onPause();
    putInPreferences(SERVER_URL, getText(textServerUrl));
    putInPreferences(SERVER_USERNAME, getText(textUsername));
    putInPreferences(SERVER_PASSWORD, getText(textPassword));
  }

  private void putInPreferences(String key, String value) {
    if (value == null || value.isEmpty()) {
      prefs.removeValue(key);
    } else {
      prefs.put(key, value);
    }
  }

  private String getText(EditText editText) {
    String text = editText.getText().toString().trim();
    return text;
  }
}




Java Source Code List

com.plusonelabs.dashclock.gerrit.Change.java
com.plusonelabs.dashclock.gerrit.GerritDashClockExtension.java
com.plusonelabs.dashclock.gerrit.GerritEndpoint.java
com.plusonelabs.dashclock.gerrit.Gerrit.java
com.plusonelabs.dashclock.gerrit.QueryBuilder.java
com.plusonelabs.dashclock.gerrit.SettingsActivity.java
com.plusonelabs.dashclock.gerrit.TestActivity.java
com.plusonelabs.dashclock.gerrit.auth.AnonymousAuthenticationProvider.java
com.plusonelabs.dashclock.gerrit.auth.AuthenticationProvider.java
com.plusonelabs.dashclock.gerrit.auth.BasicAuthWithCookieAuthenticationProvider.java
com.plusonelabs.dashclock.gerrit.prefs.AboutFragment.java
com.plusonelabs.dashclock.gerrit.prefs.DisplayFragment.java
com.plusonelabs.dashclock.gerrit.prefs.GerritPreferences.java
com.plusonelabs.dashclock.gerrit.prefs.SecurePreferences.java
com.plusonelabs.dashclock.gerrit.prefs.ServerFragment.java
com.plusonelabs.dashclock.gerrit.util.ParamCheck.java
com.plusonelabs.dashclock.gerrit.util.StringUtil.java
com.plusonelabs.dashclock.gerrit.util.UrlUtil.java