Ejemplo n.º 1
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();

    int position = mList.getSelectedItemPosition();
    if ((position >= 0) && (position != (mList.getCount() - 1))) {
      // Selected one slide.
      if (position > 0) {
        menu.add(0, MENU_MOVE_UP, 0, R.string.move_up).setIcon(R.drawable.ic_menu_move_up);
      }

      if (position < (mSlideListAdapter.getCount() - 1)) {
        menu.add(0, MENU_MOVE_DOWN, 0, R.string.move_down).setIcon(R.drawable.ic_menu_move_down);
      }
      if (mSlideshowModel.size() < SlideshowEditor.MAX_SLIDE_NUM) {
        menu.add(0, MENU_ADD_SLIDE, 0, R.string.add_slide).setIcon(R.drawable.ic_menu_add_slide);
      }

      menu.add(0, MENU_REMOVE_SLIDE, 0, R.string.remove_slide)
          .setIcon(android.R.drawable.ic_menu_delete);
    } else {
      if (mSlideshowModel.size() < SlideshowEditor.MAX_SLIDE_NUM) {
        menu.add(0, MENU_ADD_SLIDE, 0, R.string.add_slide).setIcon(R.drawable.ic_menu_add_slide);
      }
    }

    menu.add(0, MENU_DISCARD_SLIDESHOW, 0, R.string.discard_slideshow)
        .setIcon(R.drawable.ic_menu_delete_played);

    return true;
  }
Ejemplo n.º 2
0
 private void adjustAddSlideVisibility() {
   if (mSlideshowModel.size() >= SlideshowEditor.MAX_SLIDE_NUM) {
     mAddSlideItem.setVisibility(View.GONE);
   } else {
     mAddSlideItem.setVisibility(View.VISIBLE);
   }
 }
  private void showLayoutSelectorDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.ic_mms_layout);

    String title = getResources().getString(R.string.layout_selector_title);
    builder.setTitle(title + (mPosition + 1) + "/" + mSlideshowModel.size());

    LayoutSelectorAdapter adapter = new LayoutSelectorAdapter(this);
    builder.setAdapter(
        adapter,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            switch (which) {
              case 0: // Top text.
                mSlideshowEditor.changeLayout(LayoutModel.LAYOUT_TOP_TEXT);
                break;
              case 1: // Bottom text.
                mSlideshowEditor.changeLayout(LayoutModel.LAYOUT_BOTTOM_TEXT);
                break;
            }
            dialog.dismiss();
          }
        });

    builder.show();
  }
 public void onClick(View v) {
   // Validate mPosition
   if (mPosition >= 0 && mPosition < mSlideshowModel.size()) {
     mSlideshowEditor.removeSlide(mPosition);
     int size = mSlideshowModel.size();
     if (size > 0) {
       if (mPosition >= size) {
         mPosition--;
       }
       showCurrentSlide();
     } else {
       finish();
       return;
     }
   }
 }
  private void showDurationDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.ic_mms_duration);
    String title = getResources().getString(R.string.duration_selector_title);
    builder.setTitle(title + (mPosition + 1) + "/" + mSlideshowModel.size());

    builder.setItems(
        R.array.select_dialog_items,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            if ((which >= 0) && (which < NUM_DIRECT_DURATIONS)) {
              mSlideshowEditor.changeDuration(mPosition, (which + 1) * 1000);
            } else {
              Intent intent = new Intent(SlideEditorActivity.this, EditSlideDurationActivity.class);
              intent.putExtra(EditSlideDurationActivity.SLIDE_INDEX, mPosition);
              intent.putExtra(EditSlideDurationActivity.SLIDE_TOTAL, mSlideshowModel.size());
              intent.putExtra(
                  EditSlideDurationActivity.SLIDE_DUR,
                  mSlideshowModel.get(mPosition).getDuration() / 1000); // in seconds
              startActivityForResult(intent, REQUEST_CODE_CHANGE_DURATION);
            }
            dialog.dismiss();
          }
        });

    builder.show();
  }
Ejemplo n.º 6
0
  public static int getAttachmentType(SlideshowModel model) {
    if (model == null) {
      return WorkingMessage.TEXT;
    }

    int numberOfSlides = model.size();
    if (numberOfSlides > 1) {
      return WorkingMessage.SLIDESHOW;
    } else if (numberOfSlides == 1) {
      // Only one slide in the slide-show.
      SlideModel slide = model.get(0);
      if (slide.hasVideo()) {
        return WorkingMessage.VIDEO;
      }

      if (slide.hasAudio() && slide.hasImage()) {
        return WorkingMessage.SLIDESHOW;
      }

      if (slide.hasAudio()) {
        return WorkingMessage.AUDIO;
      }

      if (slide.hasImage()) {
        return WorkingMessage.IMAGE;
      }

      if (slide.hasText()) {
        return WorkingMessage.TEXT;
      }
    }

    return WorkingMessage.TEXT;
  }
Ejemplo n.º 7
0
  private void addNewSlide() {
    if (mSlideshowEditor.addNewSlide()) {
      // add successfully
      mSlideListAdapter.notifyDataSetChanged();

      // Select the new slide.
      mList.requestFocus();
      mList.setSelection(mSlideshowModel.size() - 1);
    } else {
      Toast.makeText(this, R.string.cannot_add_slide_anymore, Toast.LENGTH_SHORT).show();
    }
  }
Ejemplo n.º 8
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int position = mList.getSelectedItemPosition();

    switch (item.getItemId()) {
      case MENU_MOVE_UP:
        if ((position > 0) && (position < mSlideshowModel.size())) {
          mSlideshowEditor.moveSlideUp(position);
          mSlideListAdapter.notifyDataSetChanged();
          mList.setSelection(position - 1);
        }
        break;
      case MENU_MOVE_DOWN:
        if ((position >= 0) && (position < mSlideshowModel.size() - 1)) {
          mSlideshowEditor.moveSlideDown(position);
          mSlideListAdapter.notifyDataSetChanged();
          mList.setSelection(position + 1);
        }
        break;
      case MENU_REMOVE_SLIDE:
        if ((position >= 0) && (position < mSlideshowModel.size())) {
          mSlideshowEditor.removeSlide(position);
          mSlideListAdapter.notifyDataSetChanged();
        }
        break;
      case MENU_ADD_SLIDE:
        addNewSlide();
        break;
      case MENU_DISCARD_SLIDESHOW:
        // delete all slides from slideshow.
        mSlideshowEditor.removeAllSlides();
        mSlideListAdapter.notifyDataSetChanged();
        finish();
        break;
    }

    return true;
  }
Ejemplo n.º 9
0
 private void initSlideList() throws MmsException {
   cleanupSlideshowModel();
   mSlideshowModel = SlideshowModel.createFromMessageUri(this, mUri);
   mSlideshowModel.registerModelChangedObserver(mModelChangedObserver);
   mSlideshowEditor = new SlideshowEditor(this, mSlideshowModel);
   if ((mSlideshowModel.size() == 0)) {
     boolean b = getSharedPreferences("SetDefaultLayout", 0).getBoolean("SetDefaultLayout", true);
     if (b) {
       mSlideshowEditor.changeLayout(LayoutModel.LAYOUT_BOTTOM_TEXT);
     } else {
       getSharedPreferences("SetDefaultLayout", 0)
           .edit()
           .putBoolean("SetDefaultLayout", true)
           .commit();
     }
   }
   mSlideListAdapter = new SlideListAdapter(this, R.layout.slideshow_edit_item, mSlideshowModel);
   mList.setAdapter(mSlideListAdapter);
 }
 private void updateTitle() {
   setTitle(getString(R.string.slide_show_part, (mPosition + 1), mSlideshowModel.size()));
 }
 public void onClick(View v) {
   if (mPosition < mSlideshowModel.size() - 1) {
     mPosition++;
     showCurrentSlide();
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_slide_activity);

    mSlideView = (BasicSlideEditorView) findViewById(R.id.slide_editor_view);
    mSlideView.setOnTextChangedListener(mOnTextChangedListener);

    mPreSlide = (ImageButton) findViewById(R.id.pre_slide_button);
    mPreSlide.setOnClickListener(mOnNavigateBackward);

    mNextSlide = (ImageButton) findViewById(R.id.next_slide_button);
    mNextSlide.setOnClickListener(mOnNavigateForward);

    mPreview = (Button) findViewById(R.id.preview_button);
    mPreview.setOnClickListener(mOnPreview);

    mReplaceImage = (Button) findViewById(R.id.replace_image_button);
    mReplaceImage.setOnClickListener(mOnReplaceImage);

    mRemoveSlide = (Button) findViewById(R.id.remove_slide_button);
    mRemoveSlide.setOnClickListener(mOnRemoveSlide);

    mTextEditor = (EditText) findViewById(R.id.text_message);
    mTextEditor.setFilters(new InputFilter[] {new LengthFilter(MmsConfig.getMaxTextLimit())});

    mDone = (Button) findViewById(R.id.done_button);
    mDone.setOnClickListener(mDoneClickListener);

    initActivityState(savedInstanceState, getIntent());

    try {
      mSlideshowModel = SlideshowModel.createFromMessageUri(this, mUri);
      // Confirm that we have at least 1 slide to display
      if (mSlideshowModel.size() == 0) {
        Log.e(TAG, "Loaded slideshow is empty; can't edit nothingness, exiting.");
        finish();
        return;
      }
      // Register an observer to watch whether the data model is changed.
      mSlideshowModel.registerModelChangedObserver(mModelChangedObserver);
      mSlideshowEditor = new SlideshowEditor(this, mSlideshowModel);
      mPresenter =
          (SlideshowPresenter)
              PresenterFactory.getPresenter(
                  "SlideshowPresenter", this, mSlideView, mSlideshowModel);

      // Sanitize mPosition
      if (mPosition >= mSlideshowModel.size()) {
        mPosition = Math.max(0, mSlideshowModel.size() - 1);
      } else if (mPosition < 0) {
        mPosition = 0;
      }

      showCurrentSlide();
    } catch (MmsException e) {
      Log.e(TAG, "Create SlideshowModel failed!", e);
      finish();
      return;
    }
  }
Ejemplo n.º 13
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mHandler = new Handler();
    /// M: Code analyze 004, new feature, Slideshow Plugin(unknown) @{
    initPlugin(this);
    /// @}
    // Play slide-show in full-screen mode.
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    setContentView(R.layout.slideshow);

    Intent intent = getIntent();
    Uri msg = intent.getData();
    final SlideshowModel model;

    try {
      model = SlideshowModel.createFromMessageUri(this, msg);
      mSlideCount = model.size();
      /** M: Confirm that we have at least 1 supported_slide to display @{ */
      if (mSlideCount == 0) {
        Toast.makeText(this, getString(R.string.unsupport_media_type), Toast.LENGTH_SHORT).show();
        throw new MmsException();
      }
      /** @} */
    } catch (MmsException e) {
      Log.e(TAG, "Cannot present the slide show.", e);
      finish();
      return;
    }
    mSlideView = (SlideView) findViewById(R.id.slide_view);

    /// M: Code analyze 003, fix bug ALPS00119632, present slide return
    /// (mActivityRunning=false) when SlideshowActivity stop @{
    mPresenter =
        (SlideshowPresenter)
            PresenterFactory.getPresenter("SlideshowPresenter", this, mSlideView, model);
    /// @}

    mRotate = true;

    /// M: Code analyze 005, fix bug ALPS00071669, Handel delay problem
    /// when progress bar update @{
    mSmilPlayer = SmilPlayer.getPlayer();
    initMediaController();
    mSlideView.setMediaController(mMediaController);
    mSlideView.setActivity(this);
    mSlideView.setMmsSlideShowPlugin(mMmsSlideShowPlugin);
    // Use SmilHelper.getDocument() to ensure rebuilding the
    /// M: entire SMIL document.
    mSmilDoc = SmilHelper.getDocument(model);
    /// @}
    mHandler.post(
        new Runnable() {
          private boolean isRotating() {
            return mSmilPlayer.isPausedState()
                || mSmilPlayer.isPlayingState()
                || mSmilPlayer.isPlayedState();
          }

          public void run() {
            if (isMMSConformance(mSmilDoc)) {
              int imageLeft = 0;
              int imageTop = 0;
              int textLeft = 0;
              int textTop = 0;
              /// M: Code analyze 006, fix bug ALPS00300308, Modified Text layout @{
              int textWidth = 0;
              int textHeight = 0;
              /// @}
              LayoutModel layout = model.getLayout();
              if (layout != null) {
                RegionModel imageRegion = layout.getImageRegion();
                if (imageRegion != null) {
                  imageLeft = imageRegion.getLeft();
                  imageTop = imageRegion.getTop();
                }
                RegionModel textRegion = layout.getTextRegion();
                if (textRegion != null) {
                  textLeft = textRegion.getLeft();
                  textTop = textRegion.getTop();
                }
              }
              /// M: Code analyze 006, fix bug ALPS00300308, Modified Text layout @{
              mSlideView.enableMMSConformanceMode(
                  textLeft, textTop, textWidth, textHeight, imageLeft, imageTop);
              /// @}
            } else {
              /// M: init page divider view
              mSlideView.initPageDivider();
            }
            if (DEBUG) {
              ByteArrayOutputStream ostream = new ByteArrayOutputStream();
              SmilXmlSerializer.serialize(mSmilDoc, ostream);
              if (LOCAL_LOGV) {
                Log.v(TAG, ostream.toString());
              }
            }

            // Add event listener.
            ((EventTarget) mSmilDoc)
                .addEventListener(
                    SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, SlideshowActivity.this, false);

            mSmilPlayer.init(mSmilDoc);
            if (isRotating()) {
              mSmilPlayer.reload();
            } else {
              /// M: Code analyze 002, fix bug ALPS00111374, (CMCC feature) pause / not auto play
              /// but need prepareToPlay when enter the slideshow activity @{
              if (mMmsSlideShowPlugin.getInitialPlayState() == IMmsSlideShow.PLAY_AS_PAUSE) {
                mSmilPlayer.prepareToPlay();
                bNeedResume = true;
                mSmilPlayerController.pause();
              } else {
                mSmilPlayer.play();
                bNeedResume = true;
              }
              /// @}
            }
          }
        });
  }