Example usage for android.widget ToggleButton setChecked

List of usage examples for android.widget ToggleButton setChecked

Introduction

In this page you can find the example usage for android.widget ToggleButton setChecked.

Prototype

@Override
    public void setChecked(boolean checked) 

Source Link

Usage

From source file:com.quaap.audiometer.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    pref = getApplicationContext().getSharedPreferences("main", MODE_PRIVATE);
    mMeterView = (MeterView) findViewById(R.id.meterLayout);

    mMicLevelReader = new MicLevelReader(this, LevelMethod.dBFS);

    ImageButton show_ctrls = (ImageButton) findViewById(R.id.show_ctrls);
    show_ctrls.setOnClickListener(new View.OnClickListener() {
        @Override// w  w  w  .ja va2 s.c  o m
        public void onClick(View view) {
            ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls);
            ctrls.showNext();
        }
    });
    ImageButton hide_ctrls = (ImageButton) findViewById(R.id.hide_ctrls);
    hide_ctrls.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls);
            ctrls.showPrevious();
        }
    });

    final SeekBar scaleCtrl = (SeekBar) findViewById(R.id.scaleCtrl);

    scaleCtrl.setProgress(pref.getInt("scaleCtrl", scaleCtrl.getProgress()));

    setScale();

    scaleCtrl.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            setScale();
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    final ToggleButton onoff = (ToggleButton) findViewById(R.id.toggleButton);

    onoff.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (onoff.isChecked()) {
                if (!startit()) {
                    onoff.setChecked(false);
                }
            } else {
                stopit();
            }
        }
    });

    LevelMethod levM = LevelMethod.valueOf(pref.getString("levelMethod", LevelMethod.dBFS.toString()));

    final Spinner levelType = (Spinner) findViewById(R.id.levelType);
    ArrayAdapter<LevelMethod> levelTypeAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_spinner_dropdown_item, LevelMethod.values());
    levelType.setAdapter(levelTypeAdapter);

    levelType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            LevelMethod lmeth = (LevelMethod) adapterView.getSelectedItem();
            levelMethodChanged(lmeth);

        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    levelType.setSelection(levelTypeAdapter.getPosition(levM));

    levelMethodChanged((LevelMethod) levelType.getSelectedItem());
    checkMicrophoneAccess();
}

From source file:de.uni_weimar.mheinz.androidtouchscope.TouchScopeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_touch_scope);

    Toolbar toolbar = (Toolbar) findViewById(R.id.scope_toolbar);
    setSupportActionBar(toolbar);/*  w ww .j a  va  2  s . c o  m*/

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    //     assert mDrawerLayout != null;
    //     mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }

    createDrawerToggle(toolbar);
    mDrawerLayout.addDrawerListener(mDrawerToggle);

    // disables touch-to-open
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    assert toolbar != null;
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mDrawerLayout.openDrawer(GravityCompat.START);
        }
    });

    mLeftDrawer = (NavigationView) findViewById(R.id.left_drawer);
    assert mLeftDrawer != null;
    mLeftDrawer.setNavigationItemSelectedListener(mLeftDrawerSelectedListener);

    mRightMenu = (LinearLayout) findViewById(R.id.right_menu);

    mHostView = (HostView) findViewById(R.id.hostView);
    mHostView.setOnDoCommand(new OnDataChangedInterface.OnDataChanged() {
        @Override
        public void doCommand(ScopeInterface.Command command, int channel, Object specialData) {
            if (mActiveScope != null) {
                mActiveScope.doCommand(command, channel, true, specialData);
            }
        }
    });

    mScopeView = (ScopeView) findViewById(R.id.scopeView);
    mMeasurementView = mHostView.getMeasureView();

    mLearningView = (LearningView) findViewById(R.id.learningView);

    ToggleButton runStopButton = (ToggleButton) findViewById(R.id.buttonRunStop);
    assert runStopButton != null;
    runStopButton.setChecked(true);

    // test if it is emulator
    initScope(!Build.FINGERPRINT.contains("generic"));
}

From source file:de.uni_weimar.mheinz.androidtouchscope.TouchScopeActivity.java

public void onAuto(View view) {
    mLearningView.doAnim(LearningView.Controls.AUTO_BUTTON);

    final ToggleButton button = (ToggleButton) view;
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override//from   w w w .j av a  2  s. co m
        public void run() {
            if (mActiveScope != null)
                mActiveScope.doCommand(ScopeInterface.Command.DO_AUTO, 0, true, button.isChecked());

            Log.i(TAG, "Auto Completed");
            button.setChecked(false);
        }
    }, 0);

    mCursorStruct.cursorMode = CursorStruct.CursorMode.OFF;
    setCursorModeState(CursorStruct.CursorMode.OFF);
    mScopeView.setCursorsState(mCursorStruct);
}

From source file:ca.ualberta.cs.shoven_habittracker.EditHabitActivity.java

public Schedule initializeFields(WeeklyScheduleController controller, Habit habit, Schedule schedule) {
    setTitle("Edit Habit");

    EditText habitNameEditText = (EditText) findViewById(R.id.editHabitNameEditText);
    EditText habitCommentEditText = (EditText) findViewById(R.id.editCommentEditText);
    habitNameEditText.setText(habit.getName());
    habitCommentEditText.setText(habit.getComment());

    Collection<Integer> habitSchedule = controller.getHabitSchedule(habit).getSchedule();
    ToggleButton sundayToggle = (ToggleButton) findViewById(R.id.editSundayToggleButton);
    ToggleButton mondayToggle = (ToggleButton) findViewById(R.id.editMondayToggleButton);
    ToggleButton tuesdayToggle = (ToggleButton) findViewById(R.id.editTuesdayToggleButton);
    ToggleButton wednesdayToggle = (ToggleButton) findViewById(R.id.editWednesdayToggleButton);
    ToggleButton thursdayToggle = (ToggleButton) findViewById(R.id.editThursdayToggleButton);
    ToggleButton fridayToggle = (ToggleButton) findViewById(R.id.editFridayToggleButton);
    ToggleButton saturdayToggle = (ToggleButton) findViewById(R.id.editSaturdayToggleButton);
    if (habitSchedule.contains(0)) {
        sundayToggle.setChecked(true);
        schedule.addToSchedule(0);//  w w  w .  jav a 2s .co  m
    }
    if (habitSchedule.contains(1)) {
        mondayToggle.setChecked(true);
        schedule.addToSchedule(1);
    }
    if (habitSchedule.contains(2)) {
        tuesdayToggle.setChecked(true);
        schedule.addToSchedule(2);
    }
    if (habitSchedule.contains(3)) {
        wednesdayToggle.setChecked(true);
        schedule.addToSchedule(3);
    }
    if (habitSchedule.contains(4)) {
        thursdayToggle.setChecked(true);
        schedule.addToSchedule(4);
    }
    if (habitSchedule.contains(5)) {
        fridayToggle.setChecked(true);
        schedule.addToSchedule(5);
    }
    if (habitSchedule.contains(6)) {
        saturdayToggle.setChecked(true);
        schedule.addToSchedule(6);
    }
    return schedule;
}

From source file:com.towson.wavyleaf.Sighting.java

public void onToggle(View view) {

    //loop through all children in radiogroup.  In this case, two lin layouts
    for (int i = 0; i < rg.getChildCount(); i++) {
        View child = rg.getChildAt(i);

        //if child is lin layout (we already know all children are lin layouts)
        if (child instanceof LinearLayout) {

            //then loop through three toggles
            for (int j = 0; j < ((ViewGroup) child).getChildCount(); j++) {
                final ToggleButton tog = (ToggleButton) ((ViewGroup) child).getChildAt(j);

                //have only one togglebutton selected at one time
                if (tog != view)
                    tog.setChecked(false);
            }//from   w w w.j a v  a 2s. c o  m
        }
    }

    // Determine text to set to textview
    switch (view.getId()) {
    case R.id.bu_1:
        tvper_summary.setText("0%");
        etarea.setText("0");
        break;
    case R.id.bu_2:
        tvper_summary.setText("1-10%");
        etarea.setText("");
        break;
    case R.id.bu_3:
        tvper_summary.setText("10-25%");
        etarea.setText("");
        break;
    case R.id.bu_4:
        tvper_summary.setText("25-50%");
        etarea.setText("");
        break;
    case R.id.bu_5:
        tvper_summary.setText("50-75%");
        etarea.setText("");
        break;
    case R.id.bu_6:
        tvper_summary.setText("75-100%");
        etarea.setText("");
        break;
    default:
        tvper_summary.setText("");
    }
}

From source file:org.mythtv.client.ui.MainMenuFragment.java

@Override
public void onResume() {
    super.onResume();

    // get connected location profile
    LocationProfile profile = this.mLocationProfileDaoHelper.findConnectedProfile(this.getActivity());

    // check if we have a connected profile
    if (null == profile) {

        // auto connected to the first profile found
        List<LocationProfile> profiles = mLocationProfileDaoHelper.findAll(getActivity());
        if (profiles.size() > 0) {
            profile = profiles.get(0);/*from www.java2 s  .c o m*/

            // mLocationProfileDaoHelper.setConnectedLocationProfile(
            // getActivity(), profile.getId() );
            isConnected = true;
        } else {
            isConnected = false;
        }
    } else {
        isConnected = true;
    }

    // get away/home toggle
    ToggleButton toggleIsAway = (ToggleButton) this.getActivity().findViewById(R.id.toggleButtonIsAway);
    toggleIsAway.setOnCheckedChangeListener(this.homeAwayCheckedChanged);

    // set away/home toggle based on the connected location profile
    if (null != profile && null != toggleIsAway) {
        toggleIsAway.setChecked(profile.getType() == LocationProfile.LocationType.AWAY);
    }

    // if frontend list is empty start a scan.
    if (frontends.isEmpty()) {
        scanForFrontends();
    }

    if (isConnected) {

        DateTime etag = mEtagDaoHelper.findDateByEndpointAndDataId(getActivity(), profile,
                ChannelEndpoint.GET_CHANNEL_INFO_LIST.name(), "");
        if (null != etag) {

            DateTime now = DateUtils.convertUtc(new DateTime(System.currentTimeMillis()));
            if (now.getMillis() - etag.getMillis() > 86400000) {
                if (!mRunningServiceHelper.isServiceRunning(getActivity(),
                        "org.mythtv.service.channel.ChannelDownloadService")) {
                    getActivity().startService(new Intent(ChannelDownloadService.ACTION_DOWNLOAD));
                }
            }

        } else {
            if (!mRunningServiceHelper.isServiceRunning(getActivity(),
                    "org.mythtv.service.channel.ChannelDownloadService")) {
                getActivity().startService(new Intent(ChannelDownloadService.ACTION_DOWNLOAD));
            }
        }

    }
}

From source file:com.concavenp.artistrymuse.fragments.ProjectDetailsFragment.java

private void updateUserDetails(User model) {

    mUserModel = model;/*  w  w w.  java 2  s  .  com*/

    // If there is model data then show the details otherwise tell the user to choose something
    if (mUserModel != null) {

        // The favorite/unfavorite toggle button
        final ToggleButton favoriteButton = getView().findViewById(R.id.favorite_un_favorite_toggleButton);

        // Determine the initial state of the button given the user's list of "favorites"
        final Map<String, Favorite> favorites = mUserModel.getFavorites();

        // Set the initial state of the button
        if (favorites.containsKey(mUidForDetails)) {

            favoriteInQuestion = favorites.get(mUidForDetails);

            favoriteButton.setChecked(true);

        } else {

            favoriteInQuestion = null;

            favoriteButton.setChecked(false);

        }

        favoriteButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                if (isChecked) {

                    // The new object that will be added to the DB
                    favoriteInQuestion = new Favorite();
                    favoriteInQuestion.setFavoritedDate(new Date().getTime());
                    favoriteInQuestion.setRating(new Random().nextDouble() * 10.0);
                    favoriteInQuestion.setUid(mUidForDetails);

                    // Add the Project in question to the map of projects the user has favorited
                    mDatabase.child(USERS.getType()).child(getUid()).child(User.FAVORITES).child(mUidForDetails)
                            .setValue(favoriteInQuestion);

                    // Create a has map of the values updates to the Project in question
                    Map<String, Object> childUpdates = new HashMap<>();

                    // Update the ratings count for the project in question
                    int ratingCount = mProjectInQuestionModel.getRatingsCount() + 1;
                    childUpdates.put(
                            getString(R.string.firebase_separator) + PROJECTS.getType()
                                    + getString(R.string.firebase_separator) + mUidForDetails
                                    + getString(R.string.firebase_separator) + Project.RATINGS_COUNT,
                            ratingCount);

                    // Update the rating for the project in question
                    double newRating = ((mProjectInQuestionModel.getRating()
                            * mProjectInQuestionModel.getRatingsCount()) + favoriteInQuestion.getRating())
                            / ratingCount;
                    childUpdates.put(getString(R.string.firebase_separator) + PROJECTS.getType()
                            + getString(R.string.firebase_separator) + mUidForDetails
                            + getString(R.string.firebase_separator) + Project.RATING, newRating);

                    // Update the Favorited count
                    int favoritedCount = mProjectInQuestionModel.getFavorited() + 1;
                    childUpdates.put(
                            getString(R.string.firebase_separator) + PROJECTS.getType()
                                    + getString(R.string.firebase_separator) + mUidForDetails
                                    + getString(R.string.firebase_separator) + Project.FAVORITED,
                            favoritedCount);

                    // Update the Project in question
                    mDatabase.updateChildren(childUpdates);

                } else {

                    // Only perform the operation if it appears that we have favorited this project before
                    if (favoriteInQuestion != null) {

                        // Create a has map of the values updates to the Project in question
                        Map<String, Object> childUpdates = new HashMap<>();

                        // Update the ratings count for the project in question
                        int ratingCount = mProjectInQuestionModel.getRatingsCount() - 1;
                        childUpdates.put(
                                getString(R.string.firebase_separator) + PROJECTS.getType()
                                        + getString(R.string.firebase_separator) + mUidForDetails
                                        + getString(R.string.firebase_separator) + Project.RATINGS_COUNT,
                                ratingCount);

                        // Update the rating for the project in question
                        double newRating = ((mProjectInQuestionModel.getRating()
                                * mProjectInQuestionModel.getRatingsCount()) - favoriteInQuestion.getRating())
                                / ratingCount;
                        if (Double.isNaN(newRating)) {
                            newRating = 0.0;
                        }
                        childUpdates.put(getString(R.string.firebase_separator) + PROJECTS.getType()
                                + getString(R.string.firebase_separator) + mUidForDetails
                                + getString(R.string.firebase_separator) + Project.RATING, newRating);

                        // Update the Favorited count
                        int favoritedCount = mProjectInQuestionModel.getFavorited() - 1;
                        childUpdates.put(
                                getString(R.string.firebase_separator) + PROJECTS.getType()
                                        + getString(R.string.firebase_separator) + mUidForDetails
                                        + getString(R.string.firebase_separator) + Project.FAVORITED,
                                favoritedCount);

                        // Update the Project in question
                        mDatabase.updateChildren(childUpdates);

                        // Remove the favorite object in question from the map of people the user is following
                        mDatabase.child(USERS.getType()).child(getUid()).child(User.FAVORITES)
                                .child(mUidForDetails).removeValue();

                        // Clear out the local storage of the favorite object
                        favoriteInQuestion = null;

                    }

                }

            }

        });

    }

}

From source file:org.openremote.android.console.AppSettingsActivity.java

/**
 * Check if Client Authentication is enabled on the server if so 
 * enable to SSL button in the GUI/*ww  w  .  j a v a  2  s .  c o m*/
 */
private void checkAuthentication() {
    final Handler checkHandler = new Handler() {
        public void handleMessage(Message msg) {
            final ToggleButton sslToggleButton = (ToggleButton) findViewById(R.id.ssl_toggle);
            if (msg.what == 1) {
                AppSettingsModel.enableSSL(AppSettingsActivity.this, true);
                sslToggleButton.setChecked(true);
                // show pin
                findViewById(R.id.ssl_pin_row).setVisibility(View.VISIBLE);
            } else {
                AppSettingsModel.enableSSL(AppSettingsActivity.this, false);
                sslToggleButton.setChecked(false);
                // hide pin
                findViewById(R.id.ssl_pin_row).setVisibility(View.GONE);
            }
        }
    };
    new Thread() {
        public void run() {
            if (this.checkAuthentication()) {
                checkHandler.sendEmptyMessage(1);
            } else {
                checkHandler.sendEmptyMessage(0);
            }
        }

        private boolean checkAuthentication() {
            boolean returnValue = false;

            if (!TextUtils.isEmpty(currentServer)) {
                try {
                    HttpRequestBase request = null;
                    HttpResponse response = null;
                    HttpParams params = new BasicHttpParams();

                    // set time-out at 3 seconds
                    HttpConnectionParams.setConnectionTimeout(params, 3 * 1000);
                    HttpConnectionParams.setSoTimeout(params, 3 * 1000);

                    HttpClient client = new DefaultHttpClient(params);
                    request = new HttpGet(new URL(currentServer + "/rest/authentication/check").toURI());

                    response = client.execute(request);

                    returnValue = (response.getStatusLine().getStatusCode() == 200) ? true : false;
                } catch (IOException e) {
                    returnValue = false;
                    Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Can't check authentication: ", e);
                } catch (IllegalArgumentException e) {
                    returnValue = false;
                    Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Can't check authentication: ", e);
                } catch (URISyntaxException e) {
                    returnValue = false;
                    Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Invalid URI: ", e);
                }
            }
            return returnValue;
        }
    }.start();
}

From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java

public void setToggleButtonInLayout(View layout) {
    ToggleButton tgbPedometer = (ToggleButton) layout.findViewById(R.id.tgbPedometer);
    tgbPedometer.setChecked(mShouldShowPedometer);
    tgbPedometer.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mShouldShowPedometer = isChecked;
            if (isChecked) {
                findViewById(R.id.llStepCount).setVisibility(View.VISIBLE);
                findViewById(R.id.txtExplanation).setVisibility(View.VISIBLE);
            } else {
                findViewById(R.id.llStepCount).setVisibility(View.INVISIBLE);
                if (mAlertService.IsRunningAlertService()) {
                    findViewById(R.id.txtExplanation).setVisibility(View.INVISIBLE);
                }//from   ww  w  .ja  v  a 2  s.  com
            }
        }
    });
}

From source file:net.sylvek.sharemyposition.ShareMyPosition.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    default://from w w w.ja va2 s.  c  o m
        return super.onCreateDialog(id);
    case MAP_DLG:
        final View sharedMapView = LayoutInflater.from(this).inflate(R.layout.sharedmap, null);
        final FrameLayout map = (FrameLayout) sharedMapView.findViewById(R.id.sharedmap);
        map.addView(this.sharedMap);
        final CheckBox latlonAddress = (CheckBox) sharedMapView.findViewById(R.id.add_lat_lon_location);
        final CheckBox geocodeAddress = (CheckBox) sharedMapView.findViewById(R.id.add_address_location);
        final RadioButton nourl = (RadioButton) sharedMapView.findViewById(R.id.add_no_url_location);
        final RadioButton url = (RadioButton) sharedMapView.findViewById(R.id.add_url_location);
        final RadioButton gmap = (RadioButton) sharedMapView.findViewById(R.id.add_native_location);
        final EditText body = (EditText) sharedMapView.findViewById(R.id.body);
        final ToggleButton track = (ToggleButton) sharedMapView.findViewById(R.id.add_track_location);

        latlonAddress.setChecked(pref.getBoolean(PREF_LAT_LON_CHECKED, true));
        geocodeAddress.setChecked(pref.getBoolean(PREF_ADDRESS_CHECKED, true));
        final boolean isUrl = pref.getBoolean(PREF_URL_CHECKED, true);
        final boolean isGmap = pref.getBoolean(PREF_GMAP_CHECKED, false);
        url.setChecked(isUrl);
        gmap.setChecked(isGmap);
        nourl.setChecked(!isUrl && !isGmap);
        body.setText(pref.getString(PREF_BODY_DEFAULT, getString(R.string.body)));
        track.setChecked(pref.getBoolean(PREF_TRACK_CHECKED, false));

        if (track.isChecked()) {
            latlonAddress.setEnabled(false);
            latlonAddress.setChecked(false);
            geocodeAddress.setEnabled(false);
            geocodeAddress.setChecked(false);
            url.setEnabled(false);
            url.setChecked(true);
            gmap.setEnabled(false);
            gmap.setChecked(false);
            nourl.setEnabled(false);
            nourl.setChecked(false);
        }

        track.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                latlonAddress.setEnabled(!isChecked);
                latlonAddress.setChecked(!isChecked);
                geocodeAddress.setEnabled(!isChecked);
                geocodeAddress.setChecked(!isChecked);
                url.setEnabled(!isChecked);
                url.setChecked(true);
                gmap.setEnabled(!isChecked);
                gmap.setChecked(!isChecked);
                nourl.setEnabled(!isChecked);
                nourl.setChecked(!isChecked);
            }
        });

        return new AlertDialog.Builder(this).setTitle(R.string.app_name).setView(sharedMapView)
                .setOnCancelListener(new OnCancelListener() {

                    @Override
                    public void onCancel(DialogInterface arg0) {
                        finish();
                    }
                }).setNeutralButton(R.string.options, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        /* needed to display neutral button */
                    }
                }).setPositiveButton(R.string.share_it, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        final boolean isLatLong = ((CheckBox) sharedMapView
                                .findViewById(R.id.add_lat_lon_location)).isChecked();
                        final boolean isGeocodeAddress = ((CheckBox) sharedMapView
                                .findViewById(R.id.add_address_location)).isChecked();
                        final boolean isUrl = ((RadioButton) sharedMapView.findViewById(R.id.add_url_location))
                                .isChecked();
                        final boolean isGmap = ((RadioButton) sharedMapView
                                .findViewById(R.id.add_native_location)).isChecked();
                        final EditText body = (EditText) sharedMapView.findViewById(R.id.body);
                        final boolean isTracked = ((ToggleButton) sharedMapView
                                .findViewById(R.id.add_track_location)).isChecked();
                        final String uuid = UUID.randomUUID().toString();

                        pref.edit().putBoolean(PREF_LAT_LON_CHECKED, isLatLong)
                                .putBoolean(PREF_ADDRESS_CHECKED, isGeocodeAddress)
                                .putBoolean(PREF_URL_CHECKED, isUrl).putBoolean(PREF_GMAP_CHECKED, isGmap)
                                .putString(PREF_BODY_DEFAULT, body.getText().toString())
                                .putBoolean(PREF_TRACK_CHECKED, isTracked).commit();

                        final Intent t = new Intent(Intent.ACTION_SEND);
                        t.setType("text/plain");
                        t.addCategory(Intent.CATEGORY_DEFAULT);
                        final Intent share = Intent.createChooser(t, getString(R.string.app_name));
                        final GeoPoint p = sharedMap.getMapCenter();

                        final String text = body.getText().toString();
                        share(p.getLatitude(), p.getLongitude(), t, share, text, isGeocodeAddress, isUrl,
                                isGmap, isLatLong, isTracked, uuid);
                    }
                }).create();
    case PROGRESS_DLG:
        final ProgressDialog dlg = new ProgressDialog(this);
        dlg.setTitle(getText(R.string.app_name));
        dlg.setMessage(getText(R.string.progression_desc));
        dlg.setIndeterminate(true);
        dlg.setCancelable(true);
        dlg.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        return dlg;
    case PROVIDERS_DLG:
        return new AlertDialog.Builder(this).setTitle(R.string.app_name).setCancelable(false)
                .setIcon(android.R.drawable.ic_menu_help).setMessage(R.string.providers_needed)
                .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }

                }).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent gpsProperty = new Intent(
                                android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(gpsProperty);
                    }
                }).create();
    }
}