@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Intent sharedIntent = getIntent();
    final String action = sharedIntent.getAction();

    ArrayList<Uri> uris = null;
    if (Intent.ACTION_SEND.equals(action)) {
      Uri uri = sharedIntent.getParcelableExtra(Intent.EXTRA_STREAM);
      if (null != uri) {
        uris = new ArrayList<Uri>();
        uris.add(uri);
      }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
      uris = sharedIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    }

    if (null != uris && !uris.isEmpty()) {
      PhotoUploadController controller =
          PhotupApplication.getApplication(this).getPhotoUploadController();
      for (Uri uri : uris) {
        controller.addSelection(PhotoUpload.getSelection(uri));
      }
    }

    Intent intent = new Intent(this, PhotoSelectionActivity.class);
    intent.putExtra(PhotoSelectionActivity.EXTRA_DEFAULT_TAB, PhotoSelectionActivity.TAB_SELECTED);
    startActivity(intent);

    finish();
  }
  private List<String> getFileList(Intent intent) {
    ArrayList<String> list = new ArrayList<String>();

    if (Intent.ACTION_SEND.equals(intent.getAction())) {
      Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
      if (uri != null) {
        String path = getRealPathFromURI(uri);
        list.add(path);
      } else {
        Toast.makeText(this, "Unable get SEND media: " + uri, Toast.LENGTH_LONG).show();
      }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
      if (intent.hasExtra(Intent.EXTRA_STREAM) == false) {
        Toast.makeText(this, "Unable get SEND_MULTI media: empty payload", Toast.LENGTH_LONG)
            .show();
        return Collections.emptyList();
      }

      ArrayList<Parcelable> urls = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);

      for (Parcelable p : urls) {
        Uri uri = (Uri) p;

        String path = getRealPathFromURI(uri);
        list.add(path);
      }
    }
    return list;
  }
 private boolean receivedIntent(Intent i) {
   return Constants.ACTION_SHORTCUT.equals(i.getAction())
       || Constants.ACTION_NOTIFICATION_CLICK.equals(i.getAction())
       || Constants.ACTION_WIDGET.equals(i.getAction())
       || Constants.ACTION_TAKE_PHOTO.equals(i.getAction())
       || ((Intent.ACTION_SEND.equals(i.getAction())
               || Intent.ACTION_SEND_MULTIPLE.equals(i.getAction())
               || Constants.INTENT_GOOGLE_NOW.equals(i.getAction()))
           && i.getType() != null)
       || i.getAction().contains(Constants.ACTION_NOTIFICATION_CLICK);
 }
Beispiel #4
0
 private void openMainActivity() {
   Intent previousIntent = getIntent();
   if (Intent.ACTION_SEND.equals(previousIntent.getAction())
       || Intent.ACTION_SEND_MULTIPLE.equals(previousIntent.getAction())) {
     Intent intent = new Intent(previousIntent);
     intent.setClass(this, SearchableActivity.class);
     startActivity(intent);
   } else {
     Intent intent = new Intent(getApplicationContext(), MainActivity.class);
     startActivity(intent);
   }
   finish();
 }
Beispiel #5
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
      if ("text/plain".equals(type)) {
        handleSendText(intent);
      } else if (type.startsWith("image/")) {
        handleSendImage(intent);
      }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
      if (type.startsWith("image/")) {
        handleSendMultipleImages(intent);
      }
    } else {

    }
  }
  /**
   * 响应从图片分享进入的事件
   *
   * @param intent
   */
  private void respondExternal(Intent intent) {
    currentFragment = (TalkPubFragment) mFragment.get();

    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
      if ("text/plain".equals(type)) {
        handleSendText(intent); // Handle text being sent
      } else if (type.startsWith("image/")) {
        handleSendImage(intent); // Handle single image being sent
      }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
      if (type.startsWith("image/")) {
        handleSendMultipleImages(intent); // Handle multiple images
        // being sent
      }
    } else {
      // Handle other intents, such as being started from the home screen
    }
  }
Beispiel #7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.app);

    // Set up a broadcast receiver to receive results
    IntentFilter filter = new IntentFilter();
    filter.addAction(PostResponseReceiver.ACTION_PROGRESS);
    filter.addAction(PostResponseReceiver.ACTION_RESULT);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    receiver = new PostResponseReceiver();
    registerReceiver(receiver, filter);

    Intent intent = getIntent();
    String action = intent.getAction();

    // If we are handling a share intent, pass along the intent
    if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
      doPost(intent);
    }
  }
  private void handleIntent(Intent intent) {
    String action = intent.getAction();
    String type = intent.getType();
    getAllAlbums();
    if (Intent.ACTION_SEARCH.equals(action)) {
      String query = intent.getStringExtra(SearchManager.QUERY);
      Log.d("CMPE137", "Query: " + query);
      mSendPhoto = false;
    } else {
      mSendPhoto = true;

      if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.startsWith("image/")) {
          handleSendImage(intent); // Handle single image being sent
        }
      } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        if (type.startsWith("image/")) {
          handleSendMultipleImages(intent); // Handle multiple images being sent
        }
      }
    }
  }
  protected void handleSendEvent() {
    // Get intent, action and MIME type
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
      if ("text/plain".equals(type)) {

        // Handle text being sent
        String url = extractUrlFromText(intent.getStringExtra(Intent.EXTRA_TEXT));
        if (url == null || url == "") finish();

        etUrl.setText(url);

      } else if (type.startsWith("image/")) {; // Handle single image being sent
      }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
      if (type.startsWith("image/")) {; // Handle multiple images being sent
      }
    } else {
      // Handle other intents, such as being started from the home screen
    }
  }
Beispiel #10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    // Get intent, action and MIME type
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
      if ("text/plain".equals(type)) {
        handleSendText(intent); // Handle text being sent
      } else if (type.startsWith("image/")) {
        handleSendImage(intent); // Handle single image being sent
      }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
      if (type.startsWith("image/")) {
        handleSendMultipleImages(intent); // Handle multiple images being sent
      }
    } else {
      // Handle other intents, such as being started from the home screen
    }
  }
  void initPage() {
    Intent intent = getIntent();
    if (intent != null) {

      // カメラ画面を呼び出した際のURIを復旧
      String v = intent.getStringExtra(PrefKey.EXTRA_CAPTURE_URI);
      if (v != null) this.capture_uri = Uri.parse(v);

      String action = intent.getAction();
      if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
        try {
          ArrayList<UploadItem> tmp = new ArrayList<UploadItem>();
          for (Parcelable p : intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM)) {
            String path = MushroomHelper.uri_to_path(env, (Uri) p);
            if (path != null) tmp.add(new UploadItem(env, path));
          }
          upload_list_adapter.replace(tmp);
        } catch (Throwable ex) {
          env.report_ex(ex);
        }
      }
    }
    updateUploadButtonStatus();
  }
Beispiel #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ArrayList<String> dirStringList = new ArrayList<String>();

    setContentView(R.layout.share);
    TextView tv = (TextView) findViewById(R.id.filelist);
    TextView amount = (TextView) findViewById(R.id.amount_of_files);
    AutoCompleteTextView destination = (AutoCompleteTextView) findViewById(R.id.destination);
    Spinner exists = (Spinner) findViewById(R.id.exists);

    /* set default options */
    // ((CheckBox) findViewById(R.id.copy)).setChecked(false);

    /* get existing album(directory) list from ORION_ROOT */
    File rootDir = new File(ORION_ROOT);
    if (rootDir.exists() && rootDir.isDirectory()) {
      ArrayList<File> dirList = new ArrayList<File>(Arrays.asList(rootDir.listFiles()));
      Iterator<File> e = dirList.iterator();
      while (e.hasNext()) {
        dirStringList.add(((File) e.next()).getName());
      }
    }

    /* sort and insert default destinations. */
    Collections.sort(dirStringList);
    SimpleDateFormat nowFormatted = new SimpleDateFormat("yyyyMMdd");
    default_destination = nowFormatted.format(new Date()).toString();
    destination.setText(default_destination);
    /* remove default folder from 'existing album list'. but Camera */
    dirStringList.add(0, "<Camera>");

    /* make array and adapter for spinner and auto-completion. */
    String[] dirArray = new String[dirStringList.size()];
    dirStringList.toArray(dirArray);
    Log.i("gallorg", "existing dirs(array): " + Arrays.asList(dirArray).toString());

    /* disabling drop-down auto-completion.
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    		android.R.layout.simple_dropdown_item_1line, dirArray);
    destination.setAdapter(adapter);
    */
    ArrayAdapter<String> adapterSpinner =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, dirArray);
    exists.setAdapter(adapterSpinner);
    exists.setOnItemSelectedListener(this);

    /* get selected files and add it to src list (counting and debugging purpose.) */
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();

    if (Intent.ACTION_SEND.equals(intent.getAction())) {
      if (extras != null) {
        Uri fileUri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
        fileArray.add(UriUtils.getFileFromUri(fileUri, this));
        uriList.add(fileUri);
      } else {
        tv.append(", extras == null");
      }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
      if (extras != null) {
        ArrayList<Uri> uriArray = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
        uriList.addAll(uriArray);
        Iterator<Uri> e = uriArray.iterator();
        while (e.hasNext()) {
          fileArray.add(UriUtils.getFileFromUri((Uri) e.next(), this));
        }
      } else {
        tv.append(", extras == null");
      }
    }

    /* file list for debugging. */
    Iterator<File> e = fileArray.iterator();
    while (e.hasNext()) {
      File file = (File) e.next();
      if (file.exists() && file.isFile()) {
        tv.append("* " + file.getName());
      }
      tv.append("\n");
    }
    Log.d("gallorg", "selected content list: " + uriList.toString());
    Log.d("gallorg", "selected file list: " + fileArray.toString());

    /* display amount of selected files. */
    amount.setText(Integer.toString(fileArray.size()));

    /* button binding. */
    btnMove = (Button) findViewById(R.id.ok);
    btnCancel = (Button) findViewById(R.id.cancel);

    btnMove.setOnClickListener(this);
    btnCancel.setOnClickListener(this);
  }
Beispiel #13
0
  private void handleStartIntent() {
    Leg.i(TAG, "handleStartIntent");
    mStartIntent = getIntent();

    if (mStartIntent == null) {
      return;
    }

    String action = mStartIntent.getAction();
    String type = mStartIntent.getType();
    Leg.i(TAG, "action: " + action + ", type: " + type);

    if ("INNER_ACTION_PROCESSED".equals(action)) {
      return;
    }

    boolean sliding = mStartIntent.getBooleanExtra("com.example.tinyplayer.sliding", false);

    if (sliding) {
      // dismissSlidingController();
    }

    Intent newIntent = new Intent(mStartIntent);
    newIntent.setAction("INNER_ACTION_PROCESSED");
    setIntent(newIntent);
    // android.intent.action.MAIN

    mUris.clear();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
      Leg.i(TAG, "ACTION_SEND: " + type.toString());
      if (type.startsWith("image/")) {
        fetchUris(2, false, mStartIntent);

      } else if (type.startsWith("video/")) {
        fetchUris(1, false, mStartIntent);
      }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
      Leg.i(TAG, "ACTION_SEND_MULTIPLE: " + type.toString());
      if (type.startsWith("image/")) {
        fetchUris(2, true, mStartIntent);
        showSlidingController();
      } else if (type.startsWith("video/")) {
        fetchUris(1, true, mStartIntent);

      } else if (type.startsWith("*/")) {
        fetchUris(0, true, mStartIntent);
      }
    } else if ("INNER_ACTION_VIDEO_PICKED".equals(action)) {
      mUris.clear();
      Uri temp = mStartIntent.getData();
      if (temp != null) {
        mUris.add(temp);
      }
    }

    int size = mUris.size();
    Leg.i(TAG, "size of mUris: " + size);

    if (size >= 1) {
      evaluatePredict(START_PRD_START_INTENT);
    }
  }