diff --git a/res/layout/phone_book.xml b/res/layout/phone_book.xml
new file mode 100644
index 00000000000..e6ab47d65e2
--- /dev/null
+++ b/res/layout/phone_book.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java
index 343ede6f8a5..956367bf27f 100644
--- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java
+++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java
@@ -1887,6 +1887,7 @@ public OCCapability saveCapabilities(OCCapability capability){
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_EDITION, capability.getVersionEdition());
cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollinterval());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED, capability.getFilesSharingApiEnabled().getValue());
+ cv.put(ProviderTableMeta.CAPABILITIES_SHARING_INDIVIDUAL_RESTRICTION, capability.getmIndividualFileSharingRestriction().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED,
capability.getFilesSharingPublicEnabled().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED,
@@ -2028,6 +2029,9 @@ private OCCapability createCapabilityInstance(Cursor c) {
.getColumnIndex(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL)));
capability.setFilesSharingApiEnabled(CapabilityBooleanType.fromValue(c.getInt(c
.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED))));
+ capability.setmIndividualFileSharingRestriction
+ (CapabilityBooleanType.fromValue(c.getInt(c
+ .getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_INDIVIDUAL_RESTRICTION))));
capability.setFilesSharingPublicEnabled(CapabilityBooleanType.fromValue(c.getInt(c
.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED))));
capability.setFilesSharingPublicPasswordEnforced(CapabilityBooleanType.fromValue(c.getInt(c
diff --git a/src/com/owncloud/android/db/ProviderMeta.java b/src/com/owncloud/android/db/ProviderMeta.java
index fa143ac6c8b..cedbc07bb0d 100644
--- a/src/com/owncloud/android/db/ProviderMeta.java
+++ b/src/com/owncloud/android/db/ProviderMeta.java
@@ -33,7 +33,7 @@
public class ProviderMeta {
public static final String DB_NAME = "filelist";
- public static final int DB_VERSION = 20;
+ public static final int DB_VERSION = 21;
private ProviderMeta() {
}
@@ -123,6 +123,7 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String CAPABILITIES_SHARING_API_ENABLED = "sharing_api_enabled";
public static final String CAPABILITIES_SHARING_PUBLIC_ENABLED = "sharing_public_enabled";
public static final String CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED = "sharing_public_password_enforced";
+ public static final String CAPABILITIES_SHARING_INDIVIDUAL_RESTRICTION = "sharing_restrict_individual_file";
public static final String CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED =
"sharing_public_expire_date_enabled";
public static final String CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS =
diff --git a/src/com/owncloud/android/providers/FileContentProvider.java b/src/com/owncloud/android/providers/FileContentProvider.java
index 0a91bb8bb60..0b8b051ff17 100644
--- a/src/com/owncloud/android/providers/FileContentProvider.java
+++ b/src/com/owncloud/android/providers/FileContentProvider.java
@@ -836,6 +836,8 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("ALTER TABLE " + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
" ADD COLUMN " + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_MULTIPLE
+ " INTEGER " + " DEFAULT -1");
+
+
upgraded = true;
db.setTransactionSuccessful();
@@ -843,15 +845,19 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.endTransaction();
}
}
- if (oldVersion < 20 && newVersion >= 20) {
+ if (oldVersion <= 20 && newVersion >= 21) {
Log_OC.i("SQL", "Entering in the #20 ADD in onUpgrade");
db.beginTransaction();
try {
- db.execSQL("ALTER TABLE " + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
+/* db.execSQL("ALTER TABLE " + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
" ADD COLUMN " + ProviderTableMeta.
CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY + " INTEGER " +
- " DEFAULT -1");
+ " DEFAULT -1");*/
+
+ db .execSQL("ALTER TABLE " + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
+ " ADD COLUMN " + ProviderTableMeta.CAPABILITIES_SHARING_INDIVIDUAL_RESTRICTION + " INTEGER " +
+ " DEFAULT 0");
upgraded = true;
db.setTransactionSuccessful();
@@ -931,6 +937,7 @@ private void createCapabilitiesTable(SQLiteDatabase db){
+ ProviderTableMeta.CAPABILITIES_VERSION_EDITION + " TEXT, "
+ ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL + " INTEGER, "
+ ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED + " INTEGER, " // boolean
+ + ProviderTableMeta.CAPABILITIES_SHARING_INDIVIDUAL_RESTRICTION + " INTEGER, "
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED + " INTEGER, " // boolean
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED + " INTEGER, " // boolean
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED + " INTEGER, " // boolean
diff --git a/src/com/owncloud/android/ui/activity/PhoneBook.java b/src/com/owncloud/android/ui/activity/PhoneBook.java
new file mode 100644
index 00000000000..9259b2fec02
--- /dev/null
+++ b/src/com/owncloud/android/ui/activity/PhoneBook.java
@@ -0,0 +1,23 @@
+package com.owncloud.android.ui.activity;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.webkit.WebView;
+
+import com.owncloud.android.R;
+
+public class PhoneBook extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.phone_book);
+
+ WebView webView = (WebView) findViewById(R.id.Phonebook);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.getSettings().setDomStorageEnabled(true);
+ webView.loadUrl("https://phonebook.cern.ch/phonebook/");
+
+
+ }
+}
diff --git a/src/com/owncloud/android/ui/fragment/ShareFileFragment.java b/src/com/owncloud/android/ui/fragment/ShareFileFragment.java
index 245c83c57d0..f2b70882c4f 100644
--- a/src/com/owncloud/android/ui/fragment/ShareFileFragment.java
+++ b/src/com/owncloud/android/ui/fragment/ShareFileFragment.java
@@ -6,16 +6,16 @@
* @author Juan Carlos González Cabrero
* @author David González Verdugo
* Copyright (C) 2017 ownCloud GmbH.
- *
+ *
* 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 .
*/
@@ -39,7 +39,6 @@
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
-
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile;
@@ -63,36 +62,32 @@
/**
* Fragment for Sharing a file with sharees (users or groups) or creating
* a public link.
- *
+ *
* A simple {@link Fragment} subclass.
- *
+ *
* Activities that contain this fragment must implement the
* {@link ShareFragmentListener} interface
* to handle interaction events.
- *
+ *
* Use the {@link ShareFileFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ShareFileFragment extends Fragment
implements ShareUserListAdapter.ShareUserAdapterListener, SharePublicLinkListAdapter.
SharePublicLinkAdapterListener {
-
private static final String TAG = ShareFileFragment.class.getSimpleName();
private static final String DEFAULT_NAME_SUFFIX = " (%1$d)";
-
private static final String QUOTE_START = "\\Q";
private static final String QUOTE_END = "\\E";
private static final String DEFAULT_NAME_REGEX_SUFFIX = " \\((\\d+)\\)\\z";
- // matches suffix (end of the string with \z) in the form "(X)", where X is an integer of any length;
- // also captures the number to reference it later during the match;
- // reference in https://developer.android.com/reference/java/util/regex/Pattern.html#sum
-
/**
* The fragment initialization parameters
*/
private static final String ARG_FILE = "FILE";
+ // matches suffix (end of the string with \z) in the form "(X)", where X is an integer of any length;
+ // also captures the number to reference it later during the match;
+ // reference in https://developer.android.com/reference/java/util/regex/Pattern.html#sum
private static final String ARG_ACCOUNT = "ACCOUNT";
-
/**
* File to share, received as a parameter in construction time
*/
@@ -119,7 +114,7 @@ public class ShareFileFragment extends Fragment
private ShareUserListAdapter mUserGroupsAdapter = null;
/**
- * List of public links bound to the file
+ * List of public links bound to the file
*/
private ArrayList mPublicLinks;
@@ -133,6 +128,11 @@ public class ShareFileFragment extends Fragment
*/
private OCCapability mCapabilities;
+ /**
+ * Required empty public constructor
+ */
+ public ShareFileFragment() {
+ }
/**
* Public factory method to create new ShareFileFragment instances.
@@ -150,10 +150,26 @@ public static ShareFileFragment newInstance(OCFile fileToShare, Account account)
return fragment;
}
- /**
- * Required empty public constructor
- */
- public ShareFileFragment() {
+ public static void setListViewHeightBasedOnChildren(ListView listView) {
+ ListAdapter listAdapter = listView.getAdapter();
+ if (listAdapter == null) {
+ return;
+ }
+ int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.AT_MOST);
+ int totalHeight = 0;
+ View view = null;
+ for (int i = 0; i < listAdapter.getCount(); i++) {
+ view = listAdapter.getView(i, view, listView);
+ if (i == 0) {
+ view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT));
+ }
+ view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
+ totalHeight += view.getMeasuredHeight();
+ }
+ ViewGroup.LayoutParams params = listView.getLayoutParams();
+ params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
+ listView.setLayoutParams(params);
+ listView.requestLayout();
}
/**
@@ -166,6 +182,7 @@ public void onCreate(Bundle savedInstanceState) {
if (getArguments() != null) {
mFile = getArguments().getParcelable(ARG_FILE);
mAccount = getArguments().getParcelable(ARG_ACCOUNT);
+
}
}
@@ -176,10 +193,8 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log_OC.d(TAG, "onCreateView");
-
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.share_file_layout, container, false);
-
// Setup layout
// Image
ImageView icon = (ImageView) view.findViewById(R.id.shareFileIcon);
@@ -192,6 +207,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
icon.setImageBitmap(thumbnail);
}
}
+
// Name
TextView fileNameHeader = (TextView) view.findViewById(R.id.shareFileName);
fileNameHeader.setText(mFile.getFileName());
@@ -224,7 +240,6 @@ public boolean onLongClick(View view) {
OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mAccount);
final boolean shareWithUsersEnable = (serverVersion != null && serverVersion.isSearchUsersSupported());
-
TextView shareNoUsers = (TextView) view.findViewById(R.id.shareNoUsers);
// Add User/Groups Button
@@ -233,16 +248,24 @@ public boolean onLongClick(View view) {
// Change the sharing text depending on the server version (at least version 8.2 is needed
// for sharing with other users)
- if (!shareWithUsersEnable) {
- shareNoUsers.setText(R.string.share_incompatible_version);
- shareNoUsers.setGravity(View.TEXT_ALIGNMENT_CENTER);
- addUserGroupButton.setVisibility(View.GONE);
- }
+ try {
+
+ if (!shareWithUsersEnable) {
+ shareNoUsers.setText(R.string.share_incompatible_version);
+ shareNoUsers.setGravity(View.TEXT_ALIGNMENT_CENTER);
+ addUserGroupButton.setVisibility(View.GONE);
+ }
+
+ } catch (Exception e) {
+ Toast.makeText(getContext(), "Error in capabilities:" + e, Toast.LENGTH_SHORT).show();
+
+ }
addUserGroupButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- if (shareWithUsersEnable) {
+
+ if (shareWithUsersEnable && mFile.isFolder()) {
// Show Search Fragment
mListener.showSearchUsersAndGroups();
} else {
@@ -268,7 +291,6 @@ public void onClick(View view) {
mListener.showAddPublicShare(getAvailableDefaultPublicName());
}
});
-
// Hide share features sections that are not enabled
hideSectionsDisabledInBuildTime(view);
@@ -366,6 +388,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
// Load data of public share, if exists
refreshPublicSharesListFromDB();
+
}
@Override
@@ -373,6 +396,8 @@ public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (ShareFragmentListener) activity;
+
+
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnShareFragmentInteractionListener");
@@ -385,10 +410,9 @@ public void onDetach() {
mListener = null;
}
-
/**
* Get known server capabilities from DB
- *
+ *
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
* instance ready to use. If not ready, does nothing.
*/
@@ -396,13 +420,28 @@ public void refreshCapabilitiesFromDB() {
if (((FileActivity) mListener).getStorageManager() != null) {
mCapabilities = ((FileActivity) mListener).getStorageManager().
getCapability(mAccount.name);
+
+ if (mCapabilities.getmIndividualFileSharingRestriction().isTrue() && !mFile.isFolder()) {
+
+ // show data
+ ImageButton addUserGroupButton = (ImageButton) getView().findViewById(R.id.addUserButton);
+ TextView shareNoUsers = (TextView) getView().findViewById(R.id.shareNoUsers);
+
+ shareNoUsers.setText("Individual files cannot be shared among users and groups. Please use PUBLIC LINKS below");
+ shareNoUsers.setGravity(View.TEXT_ALIGNMENT_CENTER);
+ addUserGroupButton.setVisibility(View.GONE);
+
+ }
+
+
}
- }
+ }
+
/**
* Get users and groups from the DB to fill in the "share with" list.
- *
+ *
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
* instance ready to use. If not ready, does nothing.
*/
@@ -464,9 +503,9 @@ public void editShare(OCShare share) {
/**
* Get public links from the DB to fill in the "Public links" section in the UI.
- *
+ *
* Takes into account server capabilities before reading database.
- *
+ *
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
* instance ready to use. If not ready, does nothing.
*/
@@ -496,6 +535,9 @@ private boolean isPublicShareDisabled() {
);
}
+
+ /// BEWARE: next methods will failed with NullPointerException if called before onCreateView() finishes
+
/**
* Updates in the UI the section about public share with the information in the current
* public share bound to mFile, if any
@@ -543,9 +585,6 @@ private void updateListOfPublicLinks() {
scrollView.scrollTo(0, 0);
}
-
- /// BEWARE: next methods will failed with NullPointerException if called before onCreateView() finishes
-
private LinearLayout getShareViaLinkSection() {
return (LinearLayout) getView().findViewById(R.id.shareViaLinkSection);
}
@@ -563,29 +602,6 @@ private void hidePublicShare() {
}
- public static void setListViewHeightBasedOnChildren(ListView listView) {
- ListAdapter listAdapter = listView.getAdapter();
- if (listAdapter == null) {
- return;
- }
- int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.AT_MOST);
- int totalHeight = 0;
- View view = null;
- for (int i = 0; i < listAdapter.getCount(); i++) {
- view = listAdapter.getView(i, view, listView);
- if (i == 0) {
- view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT));
- }
- view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
- totalHeight += view.getMeasuredHeight();
- }
- ViewGroup.LayoutParams params = listView.getLayoutParams();
- params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
- listView.setLayoutParams(params);
- listView.requestLayout();
- }
-
-
/**
* Hide share features sections that are not enabled
*
@@ -643,4 +659,6 @@ private boolean enableMultiplePublicSharing() {
return enableMultiplePublicShare;
}
+
+
}