Android Open Source - android-class Wiki Note Editor






From Project

Back to project page android-class.

License

The source code is released under:

MIT License

If you think the Android project android-class 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

/* 
 * Copyright (C) 2008 Google Inc.//from w ww  .j a  v a 2 s  . c o  m
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.wikinotes;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.google.android.wikinotes.db.WikiNote;

/**
 * Wikinote editor activity. This is a very simple activity that allows the user
 * to edit a wikinote using a text editor and confirm or cancel the changes. The
 * title and body for the wikinote to edit are passed in using the extras bundle
 * and the onFreeze() method provisions for those values to be stored in the
 * icicle on a lifecycle event, so that the user retains control over whether
 * the changes are committed to the database.
 */
public class WikiNoteEditor extends Activity {

    protected static final String ACTIVITY_RESULT =
      "com.google.android.wikinotes.EDIT";
    private EditText mNoteEdit;
    private String mWikiNoteTitle;

    @Override
    protected void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  setContentView(R.layout.wiki_note_edit);

  mNoteEdit = (EditText) findViewById(R.id.noteEdit);

  // Check to see if the icicle has body and title values to restore
  String wikiNoteText =
          icicle == null ? null : icicle.getString(WikiNote.Notes.BODY);
  String wikiNoteTitle =
          icicle == null ? null : icicle.getString(WikiNote.Notes.TITLE);

  // If not, check to see if the extras bundle has these values passed in
  if (wikiNoteTitle == null) {
      Bundle extras = getIntent().getExtras();
      wikiNoteText =
        extras == null ? null : extras
                .getString(WikiNote.Notes.BODY);
      wikiNoteTitle =
        extras == null ? null : extras
                .getString(WikiNote.Notes.TITLE);
  }

  // If we have no title information, this is an invalid intent request
  if (TextUtils.isEmpty(wikiNoteTitle)) {
      // no note title - bail
      setResult(RESULT_CANCELED);
      finish();
      return;
  }

  mWikiNoteTitle = wikiNoteTitle;

  // but if the body is null, just set it to empty - first edit of this
  // note
  wikiNoteText = wikiNoteText == null ? "" : wikiNoteText;

  // set the title so we know which note we are editing
  setTitle(getString(R.string.wiki_editing, wikiNoteTitle));

  // set the note body to edit
  mNoteEdit.setText(wikiNoteText);

  // set listeners for the confirm and cancel buttons
  ((Button) findViewById(R.id.confirmButton))
          .setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            Intent i = new Intent();
            i.putExtra(ACTIVITY_RESULT, mNoteEdit.getText()
                    .toString());
            setResult(RESULT_OK, i);
            finish();
        }
          });

  ((Button) findViewById(R.id.cancelButton))
          .setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            setResult(RESULT_CANCELED);
            finish();
        }
          });
  if (!getSharedPreferences(Eula.PREFERENCES_EULA,
          Activity.MODE_PRIVATE)
      .getBoolean(Eula.PREFERENCE_EULA_ACCEPTED, false)) {
      Eula.showEula(this);
  }
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putString(WikiNote.Notes.TITLE, mWikiNoteTitle);
  outState.putString(WikiNote.Notes.BODY, mNoteEdit.getText().toString());
    }
}




Java Source Code List

com.android.alarmclock.AnalogAppWidgetProvider.java
com.android.alarmclock.DigitalAppWidgetProvider.java
com.android.alarmclock.DigitalAppWidgetService.java
com.android.alarmclock.DigitalWidgetViewsFactory.java
com.android.alarmclock.WidgetUtils.java
com.android.deskclock.AlarmAlertFullScreen.java
com.android.deskclock.AlarmAlertWakeLock.java
com.android.deskclock.AlarmAlert.java
com.android.deskclock.AlarmClock.java
com.android.deskclock.AlarmDatabaseHelper.java
com.android.deskclock.AlarmInitReceiver.java
com.android.deskclock.AlarmKlaxon.java
com.android.deskclock.AlarmListeners.java
com.android.deskclock.AlarmPreference.java
com.android.deskclock.AlarmProvider.java
com.android.deskclock.AlarmReceiver.java
com.android.deskclock.AlarmTimePickerDialogFragment.java
com.android.deskclock.AlarmUtils.java
com.android.deskclock.Alarm.java
com.android.deskclock.Alarms.java
com.android.deskclock.AnalogClock.java
com.android.deskclock.AndroidClockTextView.java
com.android.deskclock.AsyncHandler.java
com.android.deskclock.CircleButtonsLinearLayout.java
com.android.deskclock.CircleTimerView.java
com.android.deskclock.ClockFragment.java
com.android.deskclock.DeskClockFragment.java
com.android.deskclock.DeskClock.java
com.android.deskclock.DigitalClock.java
com.android.deskclock.DontPressWithParentLayout.java
com.android.deskclock.HandleSetAlarm.java
com.android.deskclock.LabelDialogFragment.java
com.android.deskclock.Log.java
com.android.deskclock.RepeatPreference.java
com.android.deskclock.ScreensaverActivity.java
com.android.deskclock.ScreensaverSettingsActivity.java
com.android.deskclock.Screensaver.java
com.android.deskclock.SetAlarm.java
com.android.deskclock.SettingsActivity.java
com.android.deskclock.SnoozeLengthDialog.java
com.android.deskclock.TimePicker.java
com.android.deskclock.TimerRingService.java
com.android.deskclock.TimerSetupView.java
com.android.deskclock.ToastMaster.java
com.android.deskclock.Utils.java
com.android.deskclock.ZeroTopPaddingTextView.java
com.android.deskclock.stopwatch.StopwatchFragment.java
com.android.deskclock.stopwatch.StopwatchService.java
com.android.deskclock.stopwatch.Stopwatches.java
com.android.deskclock.timer.CountingTimerView.java
com.android.deskclock.timer.TimerAlertFullScreen.java
com.android.deskclock.timer.TimerFragment.java
com.android.deskclock.timer.TimerListItem.java
com.android.deskclock.timer.TimerObj.java
com.android.deskclock.timer.TimerReceiver.java
com.android.deskclock.timer.TimerView.java
com.android.deskclock.timer.Timers.java
com.android.deskclock.widget.ActionableToastBar.java
com.android.deskclock.widget.EllipsizeLayout.java
com.android.deskclock.widget.multiwaveview.Ease.java
com.android.deskclock.widget.multiwaveview.GlowPadView.java
com.android.deskclock.widget.multiwaveview.PointCloud.java
com.android.deskclock.widget.multiwaveview.TargetDrawable.java
com.android.deskclock.widget.multiwaveview.Tweener.java
com.android.deskclock.widget.swipeablelistview.LogTag.java
com.android.deskclock.widget.swipeablelistview.LogUtils.java
com.android.deskclock.widget.swipeablelistview.SwipeHelper.java
com.android.deskclock.widget.swipeablelistview.SwipeLayout.java
com.android.deskclock.widget.swipeablelistview.SwipeableListView.java
com.android.deskclock.widget.swipeablelistview.Utils.java
com.android.deskclock.worldclock.CitiesActivity.java
com.android.deskclock.worldclock.Cities.java
com.android.deskclock.worldclock.CityObj.java
com.android.deskclock.worldclock.WorldClockAdapter.java
com.google.android.wikinotes.Eula.java
com.google.android.wikinotes.WikiActivityHelper.java
com.google.android.wikinotes.WikiNoteEditor.java
com.google.android.wikinotes.WikiNotesList.java
com.google.android.wikinotes.WikiNotes.java
com.google.android.wikinotes.db.WikiNote.java
com.google.android.wikinotes.db.WikiNotesProvider.java
com.mamlambo.article.simplecalc.MainActivity.java
course.examples.theanswer.TheAnswer.java
course.examples.theanswer.TheAnswer.java
us.clanryan.coursera.myfirstapp.MainActivity.java
us.clanryan.paceconverter.MainActivity.java