Android Open Source - KangarooImageSearch Settings Activity

From Project

Back to project page KangarooImageSearch.


The source code is released under:

MIT License

If you think the Android project KangarooImageSearch 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.nickrasband.kangarooimagesearchv2;
//from ww  w. j  a v a 2  s.  c  om
import java.util.Locale;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.widget.EditText;
import android.widget.Spinner;

public class SettingsActivity extends Activity {
  private SettingsData settingsData;
  private EditText etSiteFilter;
  private Spinner spinnerImageType;
  private Spinner spinnerImageSize;
  private Spinner spinnerColorFilter;
  protected void onCreate(Bundle savedInstanceState) {
    // Retrieve settings from main activity.
    Intent data = getIntent();
    settingsData = (SettingsData)data.getSerializableExtra("settings");
  // Get references to views and set their initial values.
  private void setSettingsValues() {
    // Create references to spinner views.
    spinnerImageType = (Spinner)findViewById(;
    spinnerImageSize = (Spinner)findViewById(;
    spinnerColorFilter = (Spinner)findViewById(;
    // Set the selected spinner item.
    int index = settingsData.getImageTypeIndex();
    if (index != -1)
    index = settingsData.getColorFilterIndex();
    if (index != -1)
    index = settingsData.getImageSizeIndex();
    if (index != -1)
    // Initialize the site search field.
    etSiteFilter = (EditText)findViewById(;
    public void onBackPressed() {
      // TODO - make sure this is a valid domain.
      String site = etSiteFilter.getText().toString();
      if (site != null) {
        settingsData.siteSearch = site;
      else {
        site = "";
      // Set the settings data values.
      settingsData.imageColor = spinnerColorFilter.getSelectedItem().toString().toLowerCase(Locale.US);
      settingsData.imageSize = spinnerImageSize.getSelectedItem().toString().toLowerCase(Locale.US);
      settingsData.imageType = spinnerImageType.getSelectedItem().toString().toLowerCase(Locale.US);
      Intent data = new Intent();
      data.putExtra("settings", settingsData);
      setResult(RESULT_OK, data);

  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);
    return true;


Java Source Code List