Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import com.instructure.student.SingleFragmentTestActivity
import com.instructure.student.ui.pages.renderPages.AssignmentDetailsRenderPage
import com.instructure.student.ui.pages.renderPages.SubmissionDetailsRenderPage
import com.instructure.student.ui.pages.renderPages.UrlSubmissionRenderPage
import com.instructure.student.ui.utils.StudentActivityTestRule
import com.instructure.student.ui.utils.StudentTest
import org.junit.runner.RunWith
Expand All @@ -36,5 +37,6 @@ abstract class StudentRenderTest : StudentTest() {

val assignmentDetailsRenderPage = AssignmentDetailsRenderPage()
val submissionDetailsRenderPage = SubmissionDetailsRenderPage()
val urlSubmissionRenderPage = UrlSubmissionRenderPage()

}
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)

}
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)
}

}
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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.instructure.pandautils.utils.*
import com.instructure.student.R
import com.instructure.student.mobius.assignmentDetails.submissionDetails.SubmissionDetailsContentType
import com.instructure.student.mobius.assignmentDetails.submissionDetails.SubmissionDetailsEvent
import com.instructure.student.mobius.assignmentDetails.submissionDetails.content.UrlSubmissionFragment
import com.instructure.student.mobius.common.ui.MobiusView
import com.sothree.slidinguppanel.SlidingUpPanelLayout
import com.spotify.mobius.functions.Consumer
Expand Down Expand Up @@ -181,10 +182,12 @@ class SubmissionDetailsView(
}

private fun getFragmentForContent(type: SubmissionDetailsContentType): Fragment {
// TODO
return PlaceholderFragment().apply {
typeName = type::class.java.simpleName
typeContents = type.toString()
return when (type) {
is SubmissionDetailsContentType.UrlContent -> UrlSubmissionFragment.newInstance(type.url, type.previewUrl)
else -> PlaceholderFragment().apply {
typeName = type::class.java.simpleName
typeContents = type.toString()
}
}
}

Expand Down
70 changes: 70 additions & 0 deletions apps/student/src/main/res/layout/fragment_url_submission.xml
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>
1 change: 1 addition & 0 deletions libs/pandares/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<string name="submissionDetailsFileTabName">Files (%d)</string>
<string name="rubric">Rubric</string>
<string name="submissionDetailsErrorTitle">Submission Error</string>
<string name="urlSubmissionDisclaimer">This submission was a URL to an external page. We\'ve included a snapshot of what the page looked like when it was submitted.</string>

<!--Profile Fragment Strings -->
<string name="canvasVersionNum">Version:</string>
Expand Down