>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
-
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<category android:name="android.intent.category.DEFAULT" >
</category>
- <data android:mimeType="*/*" >
+ <data android:mimeType="*/*" android:scheme="content">
</data>
- </intent-filter>
+
+ <data android:mimeType="*/*" android:scheme="file">
+ </data>
+ </intent-filter>
</activity>
<activity
android:name=".ui.activity.Preferences"
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ownCloud Android client application
+
+ Copyright (C) 2012-2014 ownCloud Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2,
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/list_item"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ android:paddingStart="16dip"
+ android:paddingEnd="16dip"
+ android:paddingRight="16dip"
+ android:paddingLeft="16dip"
+ android:minWidth="196dip"
+ android:background="?android:attr/activatedBackgroundIndicator"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:duplicateParentState="true" >
+
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="40dip"
+ android:layout_height="40dip"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="8dip"
+ android:layout_marginRight="8dip"
+ android:duplicateParentState="true" />
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceLargePopupMenu"
+ android:duplicateParentState="true"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ownCloud Android client application
+
+ Copyright (C) 2012-2014 ownCloud Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2,
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/list_item"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ android:paddingRight="16dip"
+ android:paddingLeft="16dip"
+ android:minWidth="196dip"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:duplicateParentState="true" >
+
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="40dip"
+ android:layout_height="40dip"
+ android:layout_gravity="center_vertical"
+ android:layout_marginRight="8dip"
+ android:duplicateParentState="true" />
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:duplicateParentState="true"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
<string name="wait_a_moment">Wait a moment</string>
<string name="filedisplay_unexpected_bad_get_content">"Unexpected problem ; please select the file from a different app"</string>
<string name="filedisplay_no_file_selected">No file was selected</string>
+ <string name="activity_chooser_title">Send link to …</string>
<string name="oauth_check_onoff">Login with oAuth2</string>
<string name="oauth_login_connection">Connecting to oAuth2 server…</string>
public void openFile(OCFile file);
+ public void shareFileWithLink(OCFile file);
}
package com.owncloud.android.ui.activity;
+import org.apache.http.protocol.HTTP;
+
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture;
import android.accounts.OperationCanceledException;
+import android.support.v4.app.DialogFragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.MimeTypeMap;
+import android.widget.Toast;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.owncloud.android.MainApp;
import com.owncloud.android.lib.accounts.OwnCloudAccount;
import com.owncloud.android.lib.network.webdav.WebdavUtils;
+import com.owncloud.android.ui.dialog.ActivityChooserDialog;
import com.owncloud.android.utils.Log_OC;
public static final String EXTRA_WAITING_TO_PREVIEW = "com.owncloud.android.ui.activity.WAITING_TO_PREVIEW";
public static final String EXTRA_FROM_NOTIFICATION= "com.owncloud.android.ui.activity.FROM_NOTIFICATION";
- public static final String TAG = FileActivity.class.getSimpleName();
+ public static final String TAG = FileActivity.class.getSimpleName();
+
+ private static final String FTAG_CHOOSER_DIALOG = "CHOOSER_DIALOG";
/** OwnCloud {@link Account} where the main {@link OCFile} handled by the activity is located. */
Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
}
}
+
+ /*
+ public void shareFileWithLink(OCFile file) {
+ if (file != null) {
+
+ Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
+ intentToShareLink.putExtra(Intent.EXTRA_TEXT, "https://fake.url.lolo");
+ intentToShareLink.setType(HTTP.PLAIN_TEXT_TYPE);
+
+ Intent chooserIntent = Intent.createChooser(intentToShareLink, getString(R.string.action_share_file));
+ startActivity(chooserIntent);
+
+ } else {
+ Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
+ }
+ }
+ */
+
+ public void shareFileWithLink(OCFile file) {
+ if (isSharedSupported()) {
+ if (file != null) {
+
+ // Create the Share - TODO integrate before or after the chooser menu
+ //CreateShareOperation createShare = new CreateShareOperation(file.getRemotePath(), ShareType.PUBLIC_LINK, "", false, "", 1);
+ //createShare.execute(getStorageManager(), this, this, mHandler, this);
+
+ // TODO Get the link --> when the operation is finished
+ String link = "https://fake.url.lolo";
+
+ Intent intent = createShareWithLinkIntent(link);
+ String[] packagesToExclude = new String[] { getPackageName() };
+ DialogFragment chooserDialog = ActivityChooserDialog.newInstance(intent, packagesToExclude);
+ chooserDialog.show(getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
+
+ } else {
+ Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
+ }
+
+ } else {
+ // Show a Message
+ Toast t = Toast.makeText(this, getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
+ t.show();
+ }
+ }
+
+ private Intent createShareWithLinkIntent(String link) {
+ Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
+ intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
+ intentToShareLink.setType(HTTP.PLAIN_TEXT_TYPE);
+ return intentToShareLink;
+ }
+
}
import com.owncloud.android.lib.operations.common.OnRemoteOperationListener;
import com.owncloud.android.lib.operations.common.RemoteOperation;
import com.owncloud.android.lib.operations.common.RemoteOperationResult;
-import com.owncloud.android.lib.operations.common.ShareType;
import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode;
import com.owncloud.android.operations.CreateShareOperation;
import com.owncloud.android.operations.RemoveFileOperation;
}
-
- public void shareFileWithLink(OCFile file) {
-
- if (isSharedSupported()) {
- // Create the Share
- CreateShareOperation createShare = new CreateShareOperation(file.getRemotePath(), ShareType.PUBLIC_LINK, "", false, "", 1);
- createShare.execute(getStorageManager(), this, this, mHandler, this);
-
- // TODO
- // Get the link --> when the operation is finished
-
- } else {
- // Show a Message
- Toast t = Toast.makeText(this, getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
- t.show();
-
- }
- }
-
}
--- /dev/null
+/* ownCloud Android client application
+ * Copyright (C) 2012-2014 ownCloud Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.ui.dialog;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+import android.widget.TextView;
+
+import com.actionbarsherlock.app.SherlockDialogFragment;
+import com.owncloud.android.R;
+import com.owncloud.android.utils.Log_OC;
+
+/**
+ * Dialog showing a list activities able to resolve a given Intent,
+ * filtering out the activities matching give package names.
+ *
+ * @author David A. Velasco
+ */
+public class ActivityChooserDialog extends SherlockDialogFragment {
+
+ private final static String TAG = ActivityChooserDialog.class.getSimpleName();
+ private final static String ARG_INTENT = ActivityChooserDialog.class.getSimpleName() + ".ARG_INTENT";
+ private final static String ARG_PACKAGES_TO_EXCLUDE = ActivityChooserDialog.class.getSimpleName() + ".ARG_PACKAGES_TO_EXCLUDE";
+
+ private ListAdapter mAdapter;
+
+ public static ActivityChooserDialog newInstance(Intent intent, String[] packagesToExclude/*OnConflictDecisionMadeListener listener*/) {
+ ActivityChooserDialog f = new ActivityChooserDialog();
+ Bundle args = new Bundle();
+ args.putParcelable(ARG_INTENT, intent);
+ args.putStringArray(ARG_PACKAGES_TO_EXCLUDE, packagesToExclude);
+ f.setArguments(args);
+ return f;
+ }
+
+ public ActivityChooserDialog() {
+ super();
+ Log_OC.d(TAG, "constructor");
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ Intent intent = getArguments().getParcelable(ARG_INTENT);
+ String[] packagesToExclude = getArguments().getStringArray(ARG_PACKAGES_TO_EXCLUDE);
+ List<String> packagesToExcludeList = Arrays.asList(packagesToExclude != null ? packagesToExclude : new String[0]);
+
+ PackageManager pm= getSherlockActivity().getPackageManager();
+ List<ResolveInfo> activities = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
+ Iterator<ResolveInfo> it = activities.iterator();
+ ResolveInfo resolveInfo;
+ while (it.hasNext()) {
+ resolveInfo = it.next();
+ if (packagesToExcludeList.contains(resolveInfo.activityInfo.packageName.toLowerCase())) {
+ it.remove();
+ }
+ }
+ Collections.sort(activities, new ResolveInfo.DisplayNameComparator(pm));
+ mAdapter = new ActivityAdapter(getSherlockActivity(), pm, activities);
+
+ return new AlertDialog.Builder(getSherlockActivity())
+ .setTitle(R.string.activity_chooser_title)
+ .setAdapter(mAdapter, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // The 'which' argument contains the index position
+ // of the selected item
+ }
+ })
+ .create();
+ }
+
+
+ class ActivityAdapter extends ArrayAdapter<ResolveInfo> {
+
+ private PackageManager mPackageManager;
+
+ ActivityAdapter(Context context, PackageManager pm, List<ResolveInfo> apps) {
+ //super(context, android.R.layout.activity_list_item, apps);
+ super(context, R.layout.activity_row, apps);
+ this.mPackageManager = pm;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = newView(parent);
+ }
+ bindView(position, convertView);
+ return convertView;
+ }
+
+ private View newView(ViewGroup parent) {
+ return(((LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.activity_row, parent, false));
+ //return(((LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(android.R.layout.activity_list_item, parent, false));
+ }
+
+ private void bindView(int position, View row) {
+ TextView label = (TextView) row.findViewById(R.id.title);
+ //TextView label = (TextView) row.findViewById(android.R.id.text1);
+ label.setText(getItem(position).loadLabel(mPackageManager));
+ ImageView icon = (ImageView) row.findViewById(R.id.icon);
+ //ImageView icon = (ImageView) row.findViewById(android.R.id.icon);
+ icon.setImageDrawable(getItem(position).loadIcon(mPackageManager));
+ }
+ }
+
+}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_share_file: {
- mContainerActivity.shareFileWithLink(getFile());
+ mContainerActivity.shareFileWithLink(getFile());
return true;
}
case R.id.action_open_file_with: {
mTargetFile = (OCFile) mAdapter.getItem(info.position);
switch (item.getItemId()) {
case R.id.action_share_file: {
- mContainerActivity.shareFileWithLink(mTargetFile);
+ mContainerActivity.shareFileWithLink(mTargetFile);
return true;
}
case R.id.action_rename_file: {
}
}
- @Override
- public void shareFileWithLink(OCFile file) {
-
- }
-
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
+ case R.id.action_share_file: {
+ //shareFileWithLink(getFile());
+ return true;
+ }
case R.id.action_open_file_with: {
openFile();
return true;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
+ case R.id.action_share_file: {
+ //shareFileWithLink(getFile());
+ return true;
+ }
case R.id.action_open_file_with: {
openFile();
return true;