Skip to content

Commit

Permalink
Share new ui updated with divider, index icons, colors, empty state.
Browse files Browse the repository at this point in the history
Received sharing disabled state handled.
Test cases updated
  • Loading branch information
surinder-tsys committed Dec 17, 2024
1 parent de81ddc commit 1ead2c7
Show file tree
Hide file tree
Showing 30 changed files with 718 additions and 564 deletions.
107 changes: 53 additions & 54 deletions app/src/androidTest/java/com/nmc/android/ui/FileSharingIT.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.rules.ActivityScenarioRule
Expand All @@ -21,7 +22,6 @@ import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.resources.shares.OCShare
import com.owncloud.android.lib.resources.shares.ShareType
import com.owncloud.android.ui.fragment.FileDetailFragment
import com.owncloud.android.ui.fragment.FileDetailSharingFragment
import com.owncloud.android.ui.fragment.util.SharingMenuHelper
import org.hamcrest.Matchers.not
import org.junit.After
Expand Down Expand Up @@ -70,15 +70,6 @@ class FileSharingIT : AbstractIT() {
shortSleep()
}

private fun getFragment(): FileDetailSharingFragment? {
var fragment: FileDetailSharingFragment? = null
activityScenarioRule.scenario.onActivity {
fragment =
it.supportFragmentManager.findFragmentByTag("SHARING_DETAILS_FRAGMENT") as FileDetailSharingFragment
}
return fragment
}

@Test
fun validateUiOfFileDetailFragment() {
show(file)
Expand All @@ -91,25 +82,41 @@ class FileSharingIT : AbstractIT() {
onView(withId(R.id.last_modification_timestamp)).check(matches(isCompletelyDisplayed()))
}

@Test
fun validateUiForEmptyShares() {
show(file)
private fun validateCommonUI() {
onView(withId(R.id.sharing_heading_title)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.sharing_heading_title)).check(matches(withText("Send link by mail")))

onView(withId(R.id.shared_with_you_container)).check(matches(not(isCompletelyDisplayed())))
onView(withId(R.id.tv_sharing_details_message)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_sharing_details_message)).check(matches(withText("You can create links or send shares by mail. If you invite MagentaCLOUD users, you have more opportunities for collaboration.")))
onView(withId(R.id.searchView)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.searchView)).check(matches(isEnabled()))
onView(withId(R.id.pick_contact_email_btn)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.label_personal_share)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.label_personal_share)).check(matches(withText("Personal share by mail")))
onView(withId(R.id.pick_contact_email_btn)).check(matches(isEnabled()))

onView(withId(R.id.or_section_layout)).check(matches(isCompletelyDisplayed()))

onView(withId(R.id.link_share_section_heading)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.link_share_section_heading)).check(matches(withText("Copy link")))

onView(withId(R.id.share_create_new_link)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.share_create_new_link)).check(matches(withText("Create Link")))
onView(withId(R.id.share_create_new_link)).check(matches(withText("Create new link")))

onView(withId(R.id.shared_with_divider)).check(matches(isCompletelyDisplayed()))

onView(withId(R.id.tv_your_shares)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_your_shares)).check(matches(withText("Shared with")))
}

@Test
fun validateUiForEmptyShares() {
show(file)

validateCommonUI()

onView(withId(R.id.linkSharesList)).check(matches(not(isDisplayed())))

onView(withId(R.id.tv_your_shares)).check(matches(not(isDisplayed())))
onView(withId(R.id.sharesList)).check(matches(not(isDisplayed())))

onView(withId(R.id.tv_empty_shares)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_empty_shares)).check(matches(withText("No shares created yet.")))
onView(withId(R.id.tv_empty_shares)).check(matches(withText("You have not yet shared your file/folder. Share to give others access.")))
}

@Test
Expand Down Expand Up @@ -152,19 +159,9 @@ class FileSharingIT : AbstractIT() {
}
show(file)

onView(withId(R.id.shared_with_you_container)).check(matches(not(isCompletelyDisplayed())))
onView(withId(R.id.tv_sharing_details_message)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_sharing_details_message)).check(matches(withText("You can create links or send shares by mail. If you invite MagentaCLOUD users, you have more opportunities for collaboration.")))
onView(withId(R.id.searchView)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.pick_contact_email_btn)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.label_personal_share)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.label_personal_share)).check(matches(withText("Personal share by mail")))
validateCommonUI()

onView(withId(R.id.share_create_new_link)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.share_create_new_link)).check(matches(withText("Create Link")))

onView(withId(R.id.tv_your_shares)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_your_shares)).check(matches(withText("Your Shares")))
onView(withId(R.id.linkSharesList)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.sharesList)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_empty_shares)).check(matches(not(isDisplayed())))
}
Expand All @@ -179,17 +176,22 @@ class FileSharingIT : AbstractIT() {
}
show(file)

onView(withId(R.id.shared_with_you_container)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_sharing_details_message)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_sharing_details_message)).check(matches(withText("Resharing is not allowed.")))
onView(withId(R.id.shared_with_you_username)).check(matches(withText("Shared with you by John Doe")))
onView(withId(R.id.shared_with_you_note)).check(matches(withText("Shared for testing purpose.")))
onView(withId(R.id.shared_with_you_avatar)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_resharing_info)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_resharing_info)).check(matches(withText("This file / folder was shared with you by John Doe")))

onView(withId(R.id.tv_resharing_status)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_resharing_status)).check(matches(withText("Resharing is not allowed.")))

onView(withId(R.id.searchView)).check(matches(not(isDisplayed())))
onView(withId(R.id.pick_contact_email_btn)).check(matches(not(isDisplayed())))
onView(withId(R.id.label_personal_share)).check(matches(not(isDisplayed())))
onView(withId(R.id.searchView)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.searchView)).check(matches(not(isEnabled())))
onView(withId(R.id.pick_contact_email_btn)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.pick_contact_email_btn)).check(matches(not(isEnabled())))

onView(withId(R.id.or_section_layout)).check(matches(not(isDisplayed())))
onView(withId(R.id.link_share_section_heading)).check(matches(not(isDisplayed())))
onView(withId(R.id.linkSharesList)).check(matches(not(isDisplayed())))
onView(withId(R.id.share_create_new_link)).check(matches(not(isDisplayed())))
onView(withId(R.id.shared_with_divider)).check(matches(not(isDisplayed())))
onView(withId(R.id.tv_your_shares)).check(matches(not(isDisplayed())))
onView(withId(R.id.sharesList)).check(matches(not(isDisplayed())))
onView(withId(R.id.tv_empty_shares)).check(matches(not(isDisplayed())))
Expand All @@ -203,21 +205,18 @@ class FileSharingIT : AbstractIT() {
}
show(file)

onView(withId(R.id.shared_with_you_container)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_sharing_details_message)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_sharing_details_message)).check(matches(withText("Resharing is allowed. You can create links or send shares by mail. If you invite MagentaCLOUD users, you have more opportunities for collaboration.")))
onView(withId(R.id.shared_with_you_username)).check(matches(withText("Shared with you by John Doe")))
onView(withId(R.id.shared_with_you_avatar)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.shared_with_you_note_container)).check(matches(not(isDisplayed())))
validateCommonUI()

onView(withId(R.id.searchView)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.pick_contact_email_btn)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.label_personal_share)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.share_create_new_link)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_your_shares)).check(matches(not(isDisplayed())))
onView(withId(R.id.tv_resharing_info)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_resharing_info)).check(matches(withText("This file / folder was shared with you by John Doe")))

onView(withId(R.id.tv_resharing_status)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_resharing_status)).check(matches(withText("Resharing is allowed.")))

onView(withId(R.id.linkSharesList)).check(matches(not(isDisplayed())))
onView(withId(R.id.sharesList)).check(matches(not(isDisplayed())))
onView(withId(R.id.tv_empty_shares)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.tv_empty_shares)).check(matches(withText("No shares created yet.")))
onView(withId(R.id.tv_empty_shares)).check(matches(withText("You have not yet shared your file/folder. Share to give others access.")))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package com.nmc.android.utils

import android.content.Context
import android.widget.ImageView
import androidx.appcompat.widget.AppCompatAutoCompleteTextView
import androidx.appcompat.widget.SearchView
import com.owncloud.android.R

object SearchViewThemeUtils {
fun themeSearchView(context: Context, searchView: SearchView) {
val fontColor = context.resources.getColor(R.color.fontAppbar, null)
val editText: SearchView.SearchAutoComplete = searchView.findViewById(R.id.search_src_text)
val editText: AppCompatAutoCompleteTextView = searchView.findViewById(R.id.search_src_text)
editText.textSize = 16F
editText.setTextColor(fontColor)
editText.highlightColor = context.resources.getColor(R.color.et_highlight_color, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
BaseColumns._ID,
SearchManager.SUGGEST_COLUMN_TEXT_1,
SearchManager.SUGGEST_COLUMN_TEXT_2,
SearchManager.SUGGEST_COLUMN_ICON_1,
// SearchManager.SUGGEST_COLUMN_ICON_1,
SearchManager.SUGGEST_COLUMN_INTENT_DATA
};

Expand Down Expand Up @@ -350,14 +350,14 @@ private Cursor searchForUsersOrGroups(Uri uri) {
.add(count++) // BaseColumns._ID
.add(subline) // SearchManager.SUGGEST_COLUMN_TEXT_1
.add(displayName) // SearchManager.SUGGEST_COLUMN_TEXT_2
.add(icon) // SearchManager.SUGGEST_COLUMN_ICON_1
//.add(icon) // SearchManager.SUGGEST_COLUMN_ICON_1
.add(dataUri);
} else {
response.newRow()
.add(count++) // BaseColumns._ID
.add(displayName) // SearchManager.SUGGEST_COLUMN_TEXT_1
.add(subline) // SearchManager.SUGGEST_COLUMN_TEXT_2
.add(icon) // SearchManager.SUGGEST_COLUMN_ICON_1
//.add(icon) // SearchManager.SUGGEST_COLUMN_ICON_1
.add(dataUri);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
private TextView mInfoBoxMessage;
protected AppCompatSpinner mToolbarSpinner;
private boolean isHomeSearchToolbarShow = false;
private ImageView mToolbarBackIcon;

@Inject public ThemeColorUtils themeColorUtils;
@Inject public ThemeUtils themeUtils;
Expand All @@ -82,7 +81,6 @@ private void setupToolbar(boolean isHomeSearchToolbarShow, boolean showSortListB
mHomeSearchToolbar = findViewById(R.id.home_toolbar);
mMenuButton = findViewById(R.id.menu_button);
mSearchText = findViewById(R.id.search_text);
mToolbarBackIcon = findViewById(R.id.toolbar_back_icon);
mSwitchAccountButton = findViewById(R.id.switch_account_button);

if (showSortListButtonGroup) {
Expand All @@ -104,8 +102,6 @@ private void setupToolbar(boolean isHomeSearchToolbarShow, boolean showSortListB
viewThemeUtils.material.colorToolbarOverflowIcon(mToolbar);
viewThemeUtils.platform.themeStatusBar(this);
viewThemeUtils.material.colorMaterialTextButton(mSwitchAccountButton);

mToolbarBackIcon.setOnClickListener(v -> onBackPressed());
}

public void setupToolbarShowOnlyMenuButtonAndTitle(String title, View.OnClickListener toggleDrawer) {
Expand Down Expand Up @@ -261,20 +257,10 @@ public boolean sortListGroupVisibility(){
public void setPreviewImageBitmap(Bitmap bitmap) {
if (mPreviewImage != null) {
mPreviewImage.setImageBitmap(bitmap);
resetPreviewImageConfiguration();
setPreviewImageVisibility(true);
}
}

/**
* reset preview image configuration if required the scale type and padding are changing in sharing screen so to
* reset it call this method
*/
private void resetPreviewImageConfiguration() {
mPreviewImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
mPreviewImage.setPadding(0, 0, 0, 0);
}

/**
* Change the drawable for the toolbar's preview image.
*
Expand All @@ -283,35 +269,10 @@ private void resetPreviewImageConfiguration() {
public void setPreviewImageDrawable(Drawable drawable) {
if (mPreviewImage != null) {
mPreviewImage.setImageDrawable(drawable);
resetPreviewImageConfiguration();
setPreviewImageVisibility(true);
}
}

/**
* method to show/hide the toolbar custom back icon currently this is only showing for sharing details screen for
* thumbnail images
*
* @param show
*/
public void showToolbarBackImage(boolean show) {
if (mToolbarBackIcon == null) {
return;
}
ActionBar actionBar = getSupportActionBar();
if (show) {
mToolbarBackIcon.setVisibility(View.VISIBLE);
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
}
} else {
mToolbarBackIcon.setVisibility(View.GONE);
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
}

/**
* get the toolbar's preview image view.
*/
Expand All @@ -323,15 +284,6 @@ public FrameLayout getPreviewImageContainer() {
return mPreviewImageContainer;
}

/**
* method will expand the toolbar using app bar if its hidden due to scrolling
*/
public void expandToolbar() {
if (mAppBar != null) {
mAppBar.setExpanded(true, true);
}
}

public void updateToolbarSubtitle(@NonNull String subtitle) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
Expand Down
Loading

0 comments on commit 1ead2c7

Please sign in to comment.