@Override
  public void onBackPressed() {
    // If the note has been deleted, just return
    if (IsDeleted) {
      setResult(RESULT_CANCELED);
      finish();
      return;
    }

    // Save it to original file
    HelperFunctions.SaveBmpPicture(ContentView.getFingerPaint(), EditOneNote.NoteFilePath);
    // Update database record
    NotesDb.UpdateOneNote(EditOneNote);

    // Update the specific alarm if user has changed the notify time
    if (!Pre_UseNotifyTime.equals(EditOneNote.Use_NotifyTime)) {
      // From Y(use notify) to N(don't use notify), User cancels alarm
      if (EditOneNote.Use_NotifyTime.equals(ProjectConst.No)) {
        Log.d(ProjectConst.TAG, "EditNoteActivity: delete alarm");
        Alarms.DeleteOneAlarm(this, EditOneNote.NoteRowId);
      }
      // From N(don't use notify) to Y(use notify), add one alarm
      if (EditOneNote.Use_NotifyTime.equals(ProjectConst.Yes)) {
        Log.d(ProjectConst.TAG, "EditNoteActivity: add alarm");
        NotesDb.UpdateNoteNotifyRingTime(EditOneNote.NoteRowId, EditOneNote.NotifyTime);
        Alarms.AddOneAlarm(this);
      }
    } else {
      // User changes the notify time
      if (EditOneNote.Use_NotifyTime.equals(ProjectConst.Yes)
          && HelperFunctions.CmpDatePrefix2(Pre_NotifyTime, EditOneNote.NotifyTime) != 0) {
        Log.d(ProjectConst.TAG, "EditNoteActivity: update alarm");
        NotesDb.UpdateNoteNotifyRingTime(EditOneNote.NoteRowId, EditOneNote.NotifyTime);
        Alarms.UpdateOneAlarm(this, EditOneNote.NoteRowId);
      }
    }

    // Refresh widget note list
    HelperFunctions.RefreshWidgetNoteList(this, NotesDb.GetAllNotes());
    // Refresh 1x1 widget
    if (EditOneNote.WidgetId != 0)
      HelperFunctions.Refresh1x1Widget(
          this,
          EditOneNote.WidgetId,
          EditOneNote.NoteTitle,
          EditOneNote.NoteRowId,
          EditOneNote.DrawableResIdx,
          EditOneNote.Password.length() > 0,
          EditOneNote.NoteType);
    // Show toast to notify user settings have been saved
    Toast.makeText(this, getString(R.string.notesavingtip), Toast.LENGTH_SHORT).show();
    // Return to main activity
    Intent ReturnBackData = new Intent();
    ReturnBackData.putExtra(OneNote.KEY_TITLE, EditOneNote.NoteTitle);
    ReturnBackData.putExtra(OneNote.KEY_INDEX, EditOneNote.PosIdx);
    ReturnBackData.putExtra(OneNote.KEY_DRAWABLE_ID, EditOneNote.DrawableResIdx);
    setResult(RESULT_OK, ReturnBackData);
    finish();
  }
  /**
   * Sets alarm on ACTION_BOOT_COMPLETED. Resets alarm on TIME_SET, TIMEZONE_CHANGED 接受开机启动完成的广播,
   * 设置闹钟,当时区改变也设置
   */
  @Override
  public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.v("wangxianming", "AlarmInitReceiver" + action);

    // Remove the snooze alarm after a boot.
    if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
      Alarms.saveSnoozeAlert(context, -1, -1);
    }

    Alarms.disableExpiredAlarms(context);
    Alarms.setNextAlert(context);
  }
  // Attempt to snooze this alert.
  private void snooze() {
    // Do not snooze if the snooze button is disabled.
    if (!findViewById(R.id.snooze).isEnabled()) {
      dismiss(false);
      return;
    }
    // final String snooze =
    //        PreferenceManager.getDefaultSharedPreferences(this)
    //        .getString(SettingsActivity.KEY_ALARM_SNOOZE, DEFAULT_SNOOZE);
    final String snooze =
        PreferenceManager.getDefaultSharedPreferences(this).getString("", DEFAULT_SNOOZE);
    int snoozeMinutes = Integer.parseInt(snooze);

    final long snoozeTime = System.currentTimeMillis() + (1000 * 60 * snoozeMinutes);
    Alarms.saveSnoozeAlert(AlarmAlertFullScreen.this, mAlarm.id, snoozeTime);

    // Get the display time for the snooze and update the notification.
    final Calendar c = Calendar.getInstance();
    c.setTimeInMillis(snoozeTime);

    // Append (snoozed) to the label.
    String label = mAlarm.getLabelOrDefault(this);
    label = getString(R.string.alarm_notify_snooze_label, label);

    // Notify the user that the alarm has been snoozed.
    Intent cancelSnooze = new Intent(this, AlarmReceiver.class);
    cancelSnooze.setAction(Alarms.CANCEL_SNOOZE);
    cancelSnooze.putExtra(Alarms.ALARM_ID, mAlarm.id);
    PendingIntent broadcast = PendingIntent.getBroadcast(this, mAlarm.id, cancelSnooze, 0);
    NotificationManager nm = getNotificationManager();
    Notification n = new Notification(R.drawable.stat_notify_alarm, label, 0);
    n.setLatestEventInfo(
        this,
        label,
        getString(R.string.alarm_notify_snooze_text, Alarms.formatTime(this, c)),
        broadcast);
    n.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONGOING_EVENT;
    nm.notify(mAlarm.id, n);

    String displayTime = getString(R.string.alarm_alert_snooze_set, snoozeMinutes);
    // Intentionally log the snooze time for debugging.
    Log.v(TAG, displayTime);

    // Display the snooze minutes in a toast.
    Toast.makeText(AlarmAlertFullScreen.this, displayTime, Toast.LENGTH_LONG).show();
    stopService(new Intent(Alarms.ALARM_ALERT_ACTION));
    finish();
  }
 @Override
 protected void onResume() {
   super.onResume();
   // If the alarm was deleted at some point, disable snooze.
   if (Alarms.getAlarm(getContentResolver(), mAlarm.id) == null) {
     Button snooze = (Button) findViewById(R.id.snooze);
     snooze.setEnabled(false);
   }
 }
示例#5
0
  private long saveAlarm() {
    Alarm alarm = new Alarm();
    alarm.id = mId;
    alarm.enabled = mEnabledPref.isChecked();
    alarm.hour = mHour;
    alarm.minutes = mMinutes;
    alarm.daysOfWeek = mRepeatPref.getDaysOfWeek();
    alarm.vibrate = mVibratePref.isChecked();
    alarm.label = mLabel.getText();
    alarm.alert = mAlarmPref.getAlert();

    long time;
    if (alarm.id == -1) {
      time = Alarms.addAlarm(this, alarm);
      // addAlarm populates the alarm with the new id. Update mId so that
      // changes to other preferences update the new alarm.
      mId = alarm.id;
    } else {
      time = Alarms.setAlarm(this, alarm);
    }
    return time;
  }
  @Override
  protected void onResume() {
    super.onResume();
    Log.d(TAG, "=====>onResume");
    // If the alarm was deleted at some point, disable snooze.
    if (Alarms.getAlarm(getContentResolver(), mAlarm.id) == null) {
      // Button snooze = (Button) findViewById(R.id.snooze);
      // snooze.setEnabled(false);
    }
    // if (Configer.ISCONNECT) {
    // } else {

    startServer();
    // }
  }
  @Override
  protected void onCreate(Bundle icicle) {
    requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);
    super.onCreate(icicle);
    setContentView(R.layout.layout_test);

    mAlarm = getIntent().getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
    // sign changed by reason
    // ToDo why here it needs to get alarm for another time
    mAlarm = Alarms.getAlarm(getContentResolver(), mAlarm.id);

    /** Pop-up unlock fragment according to unlock type */
    Log.d("yummywakeup", "Alarm will infalte fragment " + mAlarm.unlockType);
    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = manager.beginTransaction();
    UnlockFragment unlockFragment =
        UnlockFragmentFactory.create(mAlarm.unlockType, mAlarm.unlockDiffLevel);
    fragmentTransaction.replace(R.id.fg_alarm, unlockFragment);
    fragmentTransaction.commit();

    // Get the volume/camera button behavior setting
    final String vol =
        PreferenceManager.getDefaultSharedPreferences(this)
            .getString(PreferenceKeys.KEY_VOLUME_BEHAVIOR, DEFAULT_VOLUME_BEHAVIOR);
    mVolumeBehavior = Integer.parseInt(vol);

    final Window win = getWindow();
    win.addFlags(
        WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    // Turn on the screen unless we are being launched from the AlarmAlert
    // subclass.
    if (!getIntent().getBooleanExtra(SCREEN_OFF, false)) {
      win.addFlags(
          WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
              | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
              | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
    }

    // Register to get the alarm killed/snooze/dismiss intent.
    IntentFilter filter = new IntentFilter(Alarms.ALARM_KILLED);
    filter.addAction(Alarms.ALARM_DISMISS_ACTION);
    registerReceiver(mReceiver, filter);
  }
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Log.d(TAG, "=====>onCreate");
    mAlarm = getIntent().getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
    // sign changed by reason
    mAlarm = Alarms.getAlarm(getContentResolver(), mAlarm.id);

    // Get the volume/camera button behavior setting
    final String vol =
        PreferenceManager.getDefaultSharedPreferences(this)
            .getString(SettingsActivity.KEY_VOLUME_BEHAVIOR, DEFAULT_VOLUME_BEHAVIOR);
    mVolumeBehavior = Integer.parseInt(vol);

    requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);

    final Window win = getWindow();
    win.addFlags(
        WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    // Turn on the screen unless we are being launched from the AlarmAlert
    // subclass.
    if (!getIntent().getBooleanExtra(SCREEN_OFF, false)) {
      win.addFlags(
          WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
              | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
              | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
    }

    updateLayout();

    // Register to get the alarm killed/snooze/dismiss intent.
    IntentFilter filter = new IntentFilter(Alarms.ALARM_KILLED);
    filter.addAction(Alarms.ALARM_SNOOZE_ACTION);
    filter.addAction(Alarms.ALARM_DISMISS_ACTION);
    registerReceiver(mReceiver, filter);
  }
示例#9
0
  @Override
  public void onReceive(Context context, Intent intent) {
    if (Alarms.ALARM_KILLED.equals(intent.getAction())) {
      // The alarm has been killed, update the notification
      updateNotification(
          context,
          (Alarm) intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA),
          intent.getIntExtra(Alarms.ALARM_KILLED_TIMEOUT, -1));
      return;
    } else if (Alarms.CANCEL_SNOOZE.equals(intent.getAction())) {
      Alarms.saveSnoozeAlert(context, -1, -1);
      return;
    }

    Alarm alarm = null;
    // Grab the alarm from the intent. Since the remote AlarmManagerService
    // fills in the Intent to add some extra data, it must unparcel the
    // Alarm object. It throws a ClassNotFoundException when unparcelling.
    // To avoid this, do the marshalling ourselves.
    final byte[] data = intent.getByteArrayExtra(Alarms.ALARM_RAW_DATA);
    if (data != null) {
      Parcel in = Parcel.obtain();
      in.unmarshall(data, 0, data.length);
      in.setDataPosition(0);
      alarm = Alarm.CREATOR.createFromParcel(in);
    }

    if (alarm == null) {
      Log.v("AlarmReceiver failed to parse the alarm from the intent");
      return;
    }

    // Intentionally verbose: always log the alarm time to provide useful
    // information in bug reports.
    long now = System.currentTimeMillis();
    SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.SSS aaa");
    Log.v(
        "AlarmReceiver.onReceive() id "
            + alarm.id
            + " setFor "
            + format.format(new Date(alarm.time)));

    if (now > alarm.time + STALE_WINDOW * 1000) {
      if (Log.LOGV) {
        Log.v("AlarmReceiver ignoring stale alarm");
      }
      return;
    }

    // Maintain a cpu wake lock until the AlarmAlert and AlarmKlaxon can
    // pick it up.
    AlarmAlertWakeLock.acquireCpuWakeLock(context);

    /* Close dialogs and window shade */
    Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    context.sendBroadcast(closeDialogs);

    // Decide which activity to start based on the state of the keyguard.
    Class c = AlarmAlert.class;
    KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    if (km.inKeyguardRestrictedInputMode()) {
      // Use the full screen activity for security.
      c = AlarmAlertFullScreen.class;
    }

    /*
     * launch UI, explicitly stating that this is not due to user action so
     * that the current app's notification management is not disturbed
     */
    // ÐÞ¸Ä
    // Intent alarmAlert = new Intent(context, c);
    Intent test = new Intent(context, CalcScreen.class);
    test.putExtra(Alarms.ALARM_RAW_DATA, data);
    test.putExtra(Alarms.ALARM_ID, alarm.id);
    // test.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    // alarmAlert.putExtra(Alarms.ALARM_INTENT_EXTRA, alarm);
    // alarmAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
    // | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
    // context.startActivity(alarmAlert);
    test.putExtra(Alarms.ALARM_INTENT_EXTRA, alarm);
    test.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
    context.startActivity(test);

    // Disable the snooze alert if this alarm is the snooze.
    Alarms.disableSnoozeAlert(context, alarm.id);
    // Disable this alarm if it does not repeat.
    if (!alarm.daysOfWeek.isRepeatSet()) {
      // ÐÞ¸Ä
      Alarms.enableAlarm(context, alarm.id, false);
    } else {
      // Enable the next alert if there is one. The above call to
      // enableAlarm will call setNextAlert so avoid calling it twice.
      Alarms.setNextAlert(context);
    }

    // Play the alarm alert and vibrate the device.
    Intent playAlarm = new Intent(Alarms.ALARM_ALERT_ACTION);
    playAlarm.putExtra(Alarms.ALARM_INTENT_EXTRA, alarm);
    context.startService(playAlarm);

    // Trigger a notification that, when clicked, will show the alarm alert
    // dialog. No need to check for fullscreen since this will always be
    // launched from a user action.
    Intent notify = new Intent(context, AlarmAlert.class);
    notify.putExtra(Alarms.ALARM_INTENT_EXTRA, alarm);
    PendingIntent pendingNotify = PendingIntent.getActivity(context, alarm.id, notify, 0);

    // Use the alarm's label or the default label as the ticker text and
    // main text of the notification.
    String label = alarm.getLabelOrDefault(context);
    Notification n = new Notification(R.drawable.stat_notify_alarm, label, alarm.time);
    n.setLatestEventInfo(
        context, label, context.getString(R.string.alarm_notify_text), pendingNotify);
    n.flags |= Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONGOING_EVENT;
    n.defaults |= Notification.DEFAULT_LIGHTS;

    // Send the notification using the alarm id to easily identify the
    // correct notification.
    NotificationManager nm = getNotificationManager(context);
    nm.notify(alarm.id, n);
  }
示例#10
0
  /**
   * Set an alarm. Requires an Alarms.ALARM_ID to be passed in as an extra. FIXME: Pass an Alarm
   * object like every other Activity.
   */
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Override the default content view.
    setContentView(R.layout.set_alarm);

    addPreferencesFromResource(R.xml.alarm_prefs);

    // Get each preference so we can retrieve the value later.
    mLabel = (EditTextPreference) findPreference("label");
    mLabel.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          public boolean onPreferenceChange(Preference p, Object newValue) {
            String val = (String) newValue;
            // Set the summary based on the new label.
            p.setSummary(val);
            if (val != null && !val.equals(mLabel.getText())) {
              // Call through to the generic listener.
              return SetAlarm.this.onPreferenceChange(p, newValue);
            }
            return true;
          }
        });
    mEnabledPref = (CheckBoxPreference) findPreference("enabled");
    mEnabledPref.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          public boolean onPreferenceChange(Preference p, Object newValue) {
            // Pop a toast when enabling alarms.
            if (!mEnabledPref.isChecked()) {
              popAlarmSetToast(SetAlarm.this, mHour, mMinutes, mRepeatPref.getDaysOfWeek());
            }
            return SetAlarm.this.onPreferenceChange(p, newValue);
          }
        });
    mTimePref = findPreference("time");
    mAlarmPref = (AlarmPreference) findPreference("alarm");
    mAlarmPref.setOnPreferenceChangeListener(this);
    mVibratePref = (CheckBoxPreference) findPreference("vibrate");
    mVibratePref.setOnPreferenceChangeListener(this);
    mRepeatPref = (RepeatPreference) findPreference("setRepeat");
    mRepeatPref.setOnPreferenceChangeListener(this);

    Intent i = getIntent();
    mId = i.getIntExtra(Alarms.ALARM_ID, -1);
    if (true) {
      Log.v("wangxianming", "In SetAlarm, alarm id = " + mId);
    }

    Alarm alarm = null;
    if (mId == -1) {
      // No alarm id means create a new alarm.
      alarm = new Alarm();
    } else {
      /* load alarm details from database */
      alarm = Alarms.getAlarm(getContentResolver(), mId);
      // Bad alarm, bail to avoid a NPE.
      if (alarm == null) {
        finish();
        return;
      }
    }
    mOriginalAlarm = alarm;

    updatePrefs(mOriginalAlarm);

    // We have to do this to get the save/cancel buttons to highlight on
    // their own.
    getListView().setItemsCanFocus(true);

    // Attach actions to each button.
    Button b = (Button) findViewById(R.id.alarm_save);
    b.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            saveAlarm();
            finish();
          }
        });
    final Button revert = (Button) findViewById(R.id.alarm_revert);
    revert.setEnabled(false);
    revert.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            int newId = mId;
            updatePrefs(mOriginalAlarm);
            // "Revert" on a newly created alarm should delete it.
            if (mOriginalAlarm.id == -1) {
              Alarms.deleteAlarm(SetAlarm.this, newId);
            } else {
              saveAlarm();
            }
            revert.setEnabled(false);
          }
        });
    b = (Button) findViewById(R.id.alarm_delete);
    if (mId == -1) {
      b.setEnabled(false);
    } else {
      b.setOnClickListener(
          new View.OnClickListener() {
            public void onClick(View v) {
              deleteAlarm();
            }
          });
    }

    // The last thing we do is pop the time picker if this is a new alarm.
    if (mId == -1) {
      // Assume the user hit cancel
      mTimePickerCancelled = true;
      showTimePicker();
    }
  }
示例#11
0
 /**
  * Display a toast that tells the user how long until the alarm goes off. This helps prevent
  * "am/pm" mistakes.
  */
 static void popAlarmSetToast(Context context, int hour, int minute, Alarm.DaysOfWeek daysOfWeek) {
   popAlarmSetToast(context, Alarms.calculateAlarm(hour, minute, daysOfWeek).getTimeInMillis());
 }
示例#12
0
 private void updateTime() {
   Log.v("wangxianming", "updateTime " + mId);
   mTimePref.setSummary(Alarms.formatTime(this, mHour, mMinutes, mRepeatPref.getDaysOfWeek()));
 }
示例#13
0
 private void setDateFormat() {
   mFormat = Alarms.get24HourMode(getContext()) ? Alarms.M24 : M12;
   mAmPm.setShowAmPm(mFormat == M12);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.editscrawnote);

    // Initialize & open database
    NotesDb = new NoteDbAdapter(this);
    NotesDb.open();

    // Paint objects
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(0xFFFF0000);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(6);

    mEmboss = new EmbossMaskFilter(new float[] {1, 1, 1}, 0.4f, 6, 3.5f);

    mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL);

    // Controls
    ContentView = (FingerPaintView) findViewById(R.id.scraw_content);
    FootPanel = (LinearLayout) findViewById(R.id.foot_btn_panel);
    EditPanel = (LinearLayout) findViewById(R.id.edit_panel);
    NotifyTimeLabel = (TextView) findViewById(R.id.notifytime_text);
    Button ClrPick = (Button) findViewById(R.id.sel_pen_clr);
    Button Emboss = (Button) findViewById(R.id.emboss);
    Button Blur = (Button) findViewById(R.id.blur);
    Button Erase = (Button) findViewById(R.id.erase);
    Button SrcTop = (Button) findViewById(R.id.srctop);
    Button EditBtn = (Button) findViewById(R.id.editnotebtn);
    TextView DelPrompt = (TextView) findViewById(R.id.notedel_prompt);

    // Get parameters from intent
    EditOneNote = new OneNote(OneNote.ScrawlNote);
    Bundle Parameters = getIntent().getExtras();
    if (Parameters != null) {
      String Source = Parameters.getString(ProjectConst.KEY_SOURCE);
      int RowId = Parameters.getInt(OneNote.KEY_ROWID);
      // It is from notification
      if (Source.equals(ProjectConst.ALARM_ALERT_ACTION)) {
        // We are from notify alarm, so since it has been in edit note activity
        // Stop playing music service
        // Stop notify alarm and set next one
        Intent StopService = new Intent(ProjectConst.ALARM_NOTIFY_RING);
        stopService(StopService);
        Alarms.DeleteOneAlarm(this, RowId);
        // Remove notification on bar
        NotificationManager notificationManager =
            (NotificationManager) getSystemService(android.content.Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(RowId);

      } else if (Source.equals(ProjectConst.USERDEF_EDIT_ACTION)) {
        // if it is from user def view, to get position index in parent layout
        EditOneNote.PosIdx = Parameters.getInt(OneNote.KEY_INDEX);
      }

      // Initialize the note with database
      Cursor Note = NotesDb.GetOneNote(RowId);
      if (Note.getCount() == 1) EditOneNote.InitializatonFromDb(Note);
      else {
        IsDeleted = true;
        EditOneNote.NoteTitle = getString(R.string.note_hasdel_prompt);
        EditPanel.setVisibility(View.GONE);
        ContentView.setVisibility(View.GONE);
      }

      // Backup the notify time
      Pre_UseNotifyTime = EditOneNote.Use_NotifyTime;
      Pre_NotifyTime = EditOneNote.NotifyTime;

      // Set note title
      DelPrompt.setText(EditOneNote.NoteTitle);

      if (EditOneNote.Use_NotifyTime.equals(ProjectConst.Yes)
          && HelperFunctions.CmpDatePrefix2(EditOneNote.NotifyTime, Calendar.getInstance()) > 0)
        NotifyTimeLabel.setText(HelperFunctions.FormatCalendar2ReadableStr(EditOneNote.NotifyTime));
    }

    ContentView.InitFingerPaintView(
        HelperFunctions.CreateBgFromFile(EditOneNote.NoteFilePath),
        mPaint,
        NotePadPlus.ItemBgClr[EditOneNote.DrawableResIdx]);

    // Graphic edit
    ClrPick.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            new ColorPickerDialog(
                    EditScrawlNoteActivity.this, EditScrawlNoteActivity.this, mPaint.getColor())
                .show();
          }
        });

    Emboss.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            mPaint.setXfermode(null);
            mPaint.setAlpha(0xFF);
            if (mPaint.getMaskFilter() != mEmboss) {
              mPaint.setMaskFilter(mEmboss);
            } else {
              mPaint.setMaskFilter(null);
            }
          }
        });

    Blur.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            mPaint.setXfermode(null);
            mPaint.setAlpha(0xFF);
            if (mPaint.getMaskFilter() != mBlur) {
              mPaint.setMaskFilter(mBlur);
            } else {
              mPaint.setMaskFilter(null);
            }
          }
        });

    Erase.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            mPaint.setMaskFilter(null);
            mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
            mPaint.setColor(NotePadPlus.ItemBgClr[EditOneNote.DrawableResIdx]);
            // mPaint.setAlpha(100);
            // mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
          }
        });

    SrcTop.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // mPaint.setXfermode(null);
            // mPaint.setAlpha(0xFF);
            mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
            mPaint.setAlpha(0x80);
          }
        });

    // Edit button
    EditBtn.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            StartEditMode();
          }
        });
  }