From 1b4f4ac45bb32cf02a92c5e3f2a5a7ee08701bc0 Mon Sep 17 00:00:00 2001 From: kjehad94 Date: Tue, 5 Sep 2017 11:20:01 +0200 Subject: [PATCH 1/3] Restrict sharing individual files --- .../ui/fragment/ShareFileFragment.java | 132 +++++++++++------- 1 file changed, 78 insertions(+), 54 deletions(-) diff --git a/src/com/owncloud/android/ui/fragment/ShareFileFragment.java b/src/com/owncloud/android/ui/fragment/ShareFileFragment.java index 245c83c57d0..68cbde80439 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 . */ @@ -28,6 +28,7 @@ import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -46,6 +47,8 @@ import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.OCShare; +import com.owncloud.android.lib.resources.status.CapabilityBooleanType; +import com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation; import com.owncloud.android.lib.resources.status.OCCapability; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.ui.activity.FileActivity; @@ -76,23 +79,19 @@ 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 */ @@ -133,6 +132,13 @@ public class ShareFileFragment extends Fragment */ private OCCapability mCapabilities; + /** + * Required empty public constructor + */ + + private boolean flag = false; + public ShareFileFragment() { + } /** * Public factory method to create new ShareFileFragment instances. @@ -150,10 +156,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(); } /** @@ -162,10 +184,12 @@ public ShareFileFragment() { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + refreshCapabilitiesFromDB(); Log_OC.d(TAG, "onCreate"); if (getArguments() != null) { mFile = getArguments().getParcelable(ARG_FILE); mAccount = getArguments().getParcelable(ARG_ACCOUNT); + } } @@ -176,10 +200,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); @@ -223,8 +245,7 @@ public boolean onLongClick(View view) { }); OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mAccount); - final boolean shareWithUsersEnable = (serverVersion != null && serverVersion.isSearchUsersSupported()); - + final boolean shareWithUsersEnable = true;// (serverVersion != null && serverVersion.isSearchUsersSupported()); TextView shareNoUsers = (TextView) view.findViewById(R.id.shareNoUsers); // Add User/Groups Button @@ -233,16 +254,29 @@ 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); + } else if ( flag && !mFile.isFolder()) { + Toast.makeText(getContext(), "ggg", Toast.LENGTH_SHORT).show(); + shareNoUsers.setText("Individual files cannot be shared among users and groups.."); + shareNoUsers.setGravity(View.TEXT_ALIGNMENT_CENTER); + addUserGroupButton.setVisibility(View.GONE); + + } + } catch (Exception e) { + Toast.makeText(getContext(), "Error in capapilites:" + e, Toast.LENGTH_SHORT).show(); + Log_OC.d("ddd ss",mListener.toString()); + } addUserGroupButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if (shareWithUsersEnable) { + + if (shareWithUsersEnable && mFile.isFolder()) { // Show Search Fragment mListener.showSearchUsersAndGroups(); } else { @@ -360,12 +394,14 @@ public void onActivityCreated(Bundle savedInstanceState) { // Load known capabilities of the server from DB refreshCapabilitiesFromDB(); + Log_OC.d("OnActivityCreated", flag+""); // Load data into the list of private shares refreshUsersOrGroupsListFromDB(); // Load data of public share, if exists refreshPublicSharesListFromDB(); + } @Override @@ -373,6 +409,7 @@ public void onAttach(Activity activity) { super.onAttach(activity); try { mListener = (ShareFragmentListener) activity; + } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnShareFragmentInteractionListener"); @@ -385,7 +422,6 @@ public void onDetach() { mListener = null; } - /** * Get known server capabilities from DB * @@ -393,13 +429,19 @@ public void onDetach() { * instance ready to use. If not ready, does nothing. */ public void refreshCapabilitiesFromDB() { - if (((FileActivity) mListener).getStorageManager() != null) { + if (((FileActivity) mListener).getStorageManager() != null) { mCapabilities = ((FileActivity) mListener).getStorageManager(). getCapability(mAccount.name); - } - } + flag = restrictShare(); + + } + else + Log_OC.d("ddd","Not init"); + + } + /** * Get users and groups from the DB to fill in the "share with" list. * @@ -496,6 +538,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 +588,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 +605,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 +662,9 @@ private boolean enableMultiplePublicSharing() { return enableMultiplePublicShare; } + + + private boolean restrictShare(){ + return mCapabilities.getmIndividualFileSharingRestriction().isTrue(); + } } From 8793aac7443178e967820ace0136d0ab90723dd7 Mon Sep 17 00:00:00 2001 From: kjehad94 Date: Tue, 12 Sep 2017 11:04:02 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=D9=90adding=20capabilities=20and=20snippet?= =?UTF-8?q?=20of=20code=20to=20restrict=20the=20sharing=20for=20the=20indi?= =?UTF-8?q?vidual=20files=20if=20it=20is=20added=20by=20the=20JSON=20file.?= =?UTF-8?q?=20The=20remained=20class=20is=20withen=20own=5Fcloud=5Flibrary?= =?UTF-8?q?=20which=20is=20GetRemoteCapabilitiesOperation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/layout/phone_book.xml | 13 ++++ .../datamodel/FileDataStorageManager.java | 4 ++ src/com/owncloud/android/db/ProviderMeta.java | 3 +- .../providers/FileContentProvider.java | 13 +++- .../android/ui/activity/PhoneBook.java | 23 +++++++ .../ui/fragment/ShareFileFragment.java | 60 +++++++++---------- 6 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 res/layout/phone_book.xml create mode 100644 src/com/owncloud/android/ui/activity/PhoneBook.java 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 082ffa51a9c..285efbc47a0 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..d162a8adff6 --- /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("http://m.web.cern.ch/m/#phonebook"); + + + } +} diff --git a/src/com/owncloud/android/ui/fragment/ShareFileFragment.java b/src/com/owncloud/android/ui/fragment/ShareFileFragment.java index 68cbde80439..f2b70882c4f 100644 --- a/src/com/owncloud/android/ui/fragment/ShareFileFragment.java +++ b/src/com/owncloud/android/ui/fragment/ShareFileFragment.java @@ -28,7 +28,6 @@ import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -40,15 +39,12 @@ 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; import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.OCShare; -import com.owncloud.android.lib.resources.status.CapabilityBooleanType; -import com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation; import com.owncloud.android.lib.resources.status.OCCapability; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.ui.activity.FileActivity; @@ -66,13 +62,13 @@ /** * 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. */ @@ -118,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; @@ -135,8 +131,6 @@ public class ShareFileFragment extends Fragment /** * Required empty public constructor */ - - private boolean flag = false; public ShareFileFragment() { } @@ -184,7 +178,6 @@ public static void setListViewHeightBasedOnChildren(ListView listView) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - refreshCapabilitiesFromDB(); Log_OC.d(TAG, "onCreate"); if (getArguments() != null) { mFile = getArguments().getParcelable(ARG_FILE); @@ -214,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()); @@ -245,7 +239,7 @@ public boolean onLongClick(View view) { }); OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mAccount); - final boolean shareWithUsersEnable = true;// (serverVersion != null && serverVersion.isSearchUsersSupported()); + final boolean shareWithUsersEnable = (serverVersion != null && serverVersion.isSearchUsersSupported()); TextView shareNoUsers = (TextView) view.findViewById(R.id.shareNoUsers); // Add User/Groups Button @@ -260,16 +254,11 @@ public boolean onLongClick(View view) { shareNoUsers.setText(R.string.share_incompatible_version); shareNoUsers.setGravity(View.TEXT_ALIGNMENT_CENTER); addUserGroupButton.setVisibility(View.GONE); - } else if ( flag && !mFile.isFolder()) { - Toast.makeText(getContext(), "ggg", Toast.LENGTH_SHORT).show(); - shareNoUsers.setText("Individual files cannot be shared among users and groups.."); - shareNoUsers.setGravity(View.TEXT_ALIGNMENT_CENTER); - addUserGroupButton.setVisibility(View.GONE); } + } catch (Exception e) { - Toast.makeText(getContext(), "Error in capapilites:" + e, Toast.LENGTH_SHORT).show(); - Log_OC.d("ddd ss",mListener.toString()); + Toast.makeText(getContext(), "Error in capabilities:" + e, Toast.LENGTH_SHORT).show(); } addUserGroupButton.setOnClickListener(new View.OnClickListener() { @@ -302,7 +291,6 @@ public void onClick(View view) { mListener.showAddPublicShare(getAvailableDefaultPublicName()); } }); - // Hide share features sections that are not enabled hideSectionsDisabledInBuildTime(view); @@ -394,7 +382,6 @@ public void onActivityCreated(Bundle savedInstanceState) { // Load known capabilities of the server from DB refreshCapabilitiesFromDB(); - Log_OC.d("OnActivityCreated", flag+""); // Load data into the list of private shares refreshUsersOrGroupsListFromDB(); @@ -410,6 +397,7 @@ public void onAttach(Activity activity) { try { mListener = (ShareFragmentListener) activity; + } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnShareFragmentInteractionListener"); @@ -424,27 +412,36 @@ public void onDetach() { /** * 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. */ public void refreshCapabilitiesFromDB() { - if (((FileActivity) mListener).getStorageManager() != null) { + if (((FileActivity) mListener).getStorageManager() != null) { mCapabilities = ((FileActivity) mListener).getStorageManager(). getCapability(mAccount.name); - flag = restrictShare(); + + 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); + + } + } - } - else - Log_OC.d("ddd","Not init"); } /** * 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. */ @@ -506,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. */ @@ -664,7 +661,4 @@ private boolean enableMultiplePublicSharing() { } - private boolean restrictShare(){ - return mCapabilities.getmIndividualFileSharingRestriction().isTrue(); - } } From 93e0a0c584003358cb03b87c2b3c65307a9bcc65 Mon Sep 17 00:00:00 2001 From: kjehad94 Date: Tue, 12 Sep 2017 11:04:54 +0200 Subject: [PATCH 3/3] PhoneBook feature for CERNBox --- src/com/owncloud/android/ui/activity/PhoneBook.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/owncloud/android/ui/activity/PhoneBook.java b/src/com/owncloud/android/ui/activity/PhoneBook.java index d162a8adff6..9259b2fec02 100644 --- a/src/com/owncloud/android/ui/activity/PhoneBook.java +++ b/src/com/owncloud/android/ui/activity/PhoneBook.java @@ -16,7 +16,7 @@ protected void onCreate(Bundle savedInstanceState) { WebView webView = (WebView) findViewById(R.id.Phonebook); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setDomStorageEnabled(true); - webView.loadUrl("http://m.web.cern.ch/m/#phonebook"); + webView.loadUrl("https://phonebook.cern.ch/phonebook/"); }