-
Notifications
You must be signed in to change notification settings - Fork 107
[Student][MBL-11328] View URL submissions #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../androidTest/java/com/instructure/student/ui/pages/renderPages/UrlSubmissionRenderPage.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Copyright (C) 2019 - present Instructure, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.instructure.student.ui.pages.renderPages | ||
|
|
||
| import com.instructure.espresso.OnViewWithId | ||
| import com.instructure.espresso.OnViewWithText | ||
| import com.instructure.espresso.page.BasePage | ||
| import com.instructure.student.R | ||
|
|
||
| class UrlSubmissionRenderPage : BasePage(R.id.urlSubmission) { | ||
|
|
||
| val disclaimer by OnViewWithText(R.string.urlSubmissionDisclaimer) | ||
| val url by OnViewWithId(R.id.urlTextView) | ||
| val previewImage by OnViewWithId(R.id.urlPreviewImageView) | ||
|
|
||
| } |
45 changes: 45 additions & 0 deletions
45
...nt/src/androidTest/java/com/instructure/student/ui/renderTests/UrlSubmissionRenderTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Copyright (C) 2019 - present Instructure, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.instructure.student.ui.renderTests | ||
|
|
||
| import com.instructure.espresso.assertCompletelyDisplayed | ||
| import com.instructure.espresso.assertHasText | ||
| import com.instructure.student.espresso.StudentRenderTest | ||
| import com.instructure.student.mobius.assignmentDetails.submissionDetails.content.UrlSubmissionFragment | ||
| import org.junit.Test | ||
|
|
||
| class UrlSubmissionRenderTest : StudentRenderTest() { | ||
|
|
||
| private val testUrl = "https://www.instructure.com" | ||
|
|
||
| @Test | ||
| fun displaysDisclaimer() { | ||
| loadPageWithData(testUrl, "") | ||
| urlSubmissionRenderPage.disclaimer.assertCompletelyDisplayed() | ||
| } | ||
|
|
||
| @Test | ||
| fun displaysUrl() { | ||
| loadPageWithData(testUrl, "") | ||
| urlSubmissionRenderPage.url.assertHasText(testUrl) | ||
| } | ||
|
|
||
| private fun loadPageWithData(url: String, previewUrl: String) { | ||
| val fragment = UrlSubmissionFragment.newInstance(url, previewUrl) | ||
| activityRule.activity.loadFragment(fragment) | ||
| } | ||
|
|
||
| } |
62 changes: 62 additions & 0 deletions
62
...cture/student/mobius/assignmentDetails/submissionDetails/content/UrlSubmissionFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Copyright (C) 2019 - present Instructure, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, version 3 of the License. | ||
| * | ||
| * 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.instructure.student.mobius.assignmentDetails.submissionDetails.content | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.fragment.app.Fragment | ||
| import com.bumptech.glide.Glide | ||
| import com.instructure.pandautils.utils.NullableStringArg | ||
| import com.instructure.pandautils.utils.StringArg | ||
| import com.instructure.pandautils.utils.ThemePrefs | ||
| import com.instructure.pandautils.utils.onClick | ||
| import com.instructure.student.R | ||
| import com.instructure.student.activity.InternalWebViewActivity | ||
| import kotlinx.android.synthetic.main.fragment_url_submission.* | ||
|
|
||
| class UrlSubmissionFragment : Fragment() { | ||
|
|
||
| private var url by StringArg() | ||
| private var previewUrl by NullableStringArg() | ||
|
|
||
| override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
| return inflater.inflate(R.layout.fragment_url_submission, container, false) | ||
| } | ||
|
|
||
| override fun onStart() { | ||
| super.onStart() | ||
| Glide.with(requireContext()).load(previewUrl).into(urlPreviewImageView) | ||
| urlTextView.text = url | ||
| urlTextView.setTextColor(ThemePrefs.buttonColor) | ||
| val launchUrl = { _: View -> | ||
| val title = getString(R.string.urlSubmission) | ||
| val intent = InternalWebViewActivity.createIntent(requireActivity(), url, title, true) | ||
| requireActivity().startActivity(intent) | ||
| } | ||
| urlTextView.onClick(launchUrl) | ||
| urlPreviewImageView.onClick(launchUrl) | ||
| } | ||
|
|
||
| companion object { | ||
| @JvmStatic | ||
| fun newInstance(url: String, previewUrl: String?) = UrlSubmissionFragment().apply { | ||
| this.url = url | ||
| this.previewUrl = previewUrl | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
apps/student/src/main/res/layout/fragment_url_submission.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- | ||
| ~ Copyright (C) 2019 - present Instructure, Inc. | ||
| ~ | ||
| ~ This program is free software: you can redistribute it and/or modify | ||
| ~ it under the terms of the GNU General Public License as published by | ||
| ~ the Free Software Foundation, version 3 of the License. | ||
| ~ | ||
| ~ 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/>. | ||
| --> | ||
| <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:id="@+id/urlSubmission" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:fillViewport="true" | ||
| android:scrollbars="none"> | ||
|
|
||
| <LinearLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:contentDescription="@string/scrollInstructions" | ||
| android:orientation="vertical" | ||
| android:padding="16dp"> | ||
|
|
||
| <TextView | ||
| style="@style/TextFont.Regular" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:focusable="true" | ||
| android:gravity="center" | ||
| android:importantForAccessibility="yes" | ||
| android:text="@string/urlSubmissionDisclaimer" | ||
| android:textColor="@color/defaultTextDark" | ||
| android:textSize="12sp"/> | ||
|
|
||
| <TextView | ||
| android:id="@+id/urlTextView" | ||
| style="@style/TextFont.Medium" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center" | ||
| android:minHeight="48dp" | ||
| android:paddingStart="16dp" | ||
| android:paddingTop="24dp" | ||
| android:paddingEnd="16dp" | ||
| android:paddingBottom="24dp" | ||
| android:textSize="16sp" | ||
| tools:text="https://www.google.com" | ||
| tools:textColor="@color/canvasDefaultButton"/> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/urlPreviewImageView" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:adjustViewBounds="true" | ||
| android:importantForAccessibility="no" | ||
| tools:background="#EEE" | ||
| tools:scaleType="center" | ||
| tools:src="@tools:sample/backgrounds/scenic"/> | ||
|
|
||
| </LinearLayout> | ||
|
|
||
| </ScrollView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.