-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Student][NewRelic][MBL-13108]: USE_REMOTE_CONFIG -> USE_NEW_RELIC (#267
) * [RC6.6.1] Change cancel text to red (#263) * [Teacher][MBL-13105] Post Policy skeleton (#257) Added the feature flag, necessary strings, and the view pager layout for the base screen. Now just the two individual screens need their loops/views done. * MBL-13108: USE_REMOTE_CONFIG -> USE_NEW_RELIC
- Loading branch information
Showing
15 changed files
with
341 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
88 changes: 88 additions & 0 deletions
88
...teacher/src/main/java/com/instructure/teacher/features/postpolicies/PostPolicyFragment.kt
This file contains 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,88 @@ | ||
/* | ||
* 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.teacher.features.postpolicies | ||
|
||
import android.graphics.Color | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.content.ContextCompat | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.fragment.app.FragmentPagerAdapter | ||
import com.instructure.canvasapi2.models.Assignment | ||
import com.instructure.canvasapi2.models.Course | ||
import com.instructure.interactions.router.Route | ||
import com.instructure.pandautils.utils.* | ||
import com.instructure.teacher.R | ||
import com.instructure.teacher.features.postpolicies.ui.HideGradeFragment | ||
import com.instructure.teacher.features.postpolicies.ui.PostGradeFragment | ||
import com.instructure.teacher.utils.setupBackButtonAsBackPressedOnly | ||
import kotlinx.android.synthetic.main.fragment_post_policy_settings.* | ||
import kotlinx.android.synthetic.main.fragment_post_policy_settings.view.* | ||
|
||
class PostPolicyFragment : Fragment() { | ||
|
||
private var assignment: Assignment by ParcelableArg(Assignment(), Const.ASSIGNMENT) | ||
private var course: Course by ParcelableArg(Course(), Const.CANVAS_CONTEXT) | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
val view = inflater.inflate(R.layout.fragment_post_policy_settings, container, false) | ||
|
||
val titles = listOf(getString(R.string.postGradesTab), getString(R.string.hideGradesTab)) | ||
view.postPolicyPager.adapter = PostPolicyPagerAdapter(course, assignment, childFragmentManager, titles) | ||
view.postPolicyTabLayout.setupWithViewPager(view.postPolicyPager, true) | ||
|
||
return view | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
applyTheme() | ||
} | ||
|
||
private fun applyTheme() { | ||
postPolicyToolbar.setupBackButtonAsBackPressedOnly(this) | ||
|
||
ViewStyler.themeToolbar(requireActivity(), postPolicyToolbar, Color.WHITE, Color.BLACK) | ||
|
||
val courseColor = ColorKeeper.getOrGenerateColor(course) | ||
postPolicyTabLayout.setSelectedTabIndicatorColor(courseColor) | ||
postPolicyTabLayout.setTabTextColors(ContextCompat.getColor(requireContext(), R.color.gray), courseColor) | ||
} | ||
|
||
companion object { | ||
fun makeRoute(course: Course, assignment: Assignment) = | ||
Route(PostPolicyFragment::class.java, course, Bundle().apply { putParcelable(Const.ASSIGNMENT, assignment) }) | ||
|
||
fun newInstance(args: Bundle) = PostPolicyFragment().withArgs(args) | ||
} | ||
} | ||
|
||
private class PostPolicyPagerAdapter(val course: Course, val assignment: Assignment, fragmentManager: FragmentManager, val titles: List<String>) : FragmentPagerAdapter(fragmentManager) { | ||
override fun getCount() = 2 | ||
override fun getPageTitle(position: Int) = titles[position] | ||
|
||
override fun getItem(position: Int): Fragment { | ||
return when (position) { | ||
0 -> PostGradeFragment.newInstance(course, assignment) | ||
1 -> HideGradeFragment.newInstance(course, assignment) | ||
else -> throw IndexOutOfBoundsException("No post policy adapter item at position $position") | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...acher/src/main/java/com/instructure/teacher/features/postpolicies/ui/HideGradeFragment.kt
This file contains 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,46 @@ | ||
/* | ||
* 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.teacher.features.postpolicies.ui | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.fragment.app.Fragment | ||
import com.instructure.canvasapi2.models.Assignment | ||
import com.instructure.canvasapi2.models.Course | ||
import com.instructure.pandautils.utils.Const | ||
import com.instructure.pandautils.utils.ParcelableArg | ||
import com.instructure.pandautils.utils.makeBundle | ||
import com.instructure.pandautils.utils.withArgs | ||
import com.instructure.teacher.R | ||
|
||
class HideGradeFragment : Fragment() { | ||
private var assignment: Assignment by ParcelableArg(Assignment(), Const.ASSIGNMENT) | ||
private var course: Course by ParcelableArg(Course(), Const.CANVAS_CONTEXT) | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return TextView(requireContext()).apply { setText(R.string.hideGradesTab) } | ||
} | ||
|
||
companion object { | ||
fun newInstance(course: Course, assignment: Assignment) = HideGradeFragment().withArgs(course.makeBundle { | ||
putParcelable(Const.ASSIGNMENT, assignment) | ||
}) | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...acher/src/main/java/com/instructure/teacher/features/postpolicies/ui/PostGradeFragment.kt
This file contains 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,46 @@ | ||
/* | ||
* 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.teacher.features.postpolicies.ui | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.fragment.app.Fragment | ||
import com.instructure.canvasapi2.models.Assignment | ||
import com.instructure.canvasapi2.models.Course | ||
import com.instructure.pandautils.utils.Const | ||
import com.instructure.pandautils.utils.ParcelableArg | ||
import com.instructure.pandautils.utils.makeBundle | ||
import com.instructure.pandautils.utils.withArgs | ||
import com.instructure.teacher.R | ||
|
||
class PostGradeFragment : Fragment() { | ||
private var assignment: Assignment by ParcelableArg(Assignment(), Const.ASSIGNMENT) | ||
private var course: Course by ParcelableArg(Course(), Const.CANVAS_CONTEXT) | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return TextView(requireContext()).apply { setText(R.string.postGradesTab) } | ||
} | ||
|
||
companion object { | ||
fun newInstance(course: Course, assignment: Assignment) = PostGradeFragment().withArgs(course.makeBundle { | ||
putParcelable(Const.ASSIGNMENT, assignment) | ||
}) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
65 changes: 65 additions & 0 deletions
65
apps/teacher/src/main/res/layout/fragment_post_policy_settings.xml
This file contains 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,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ 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. | ||
~ | ||
--> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/postPolicyPage" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/postPolicyToolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?android:attr/actionBarSize" | ||
app:popupTheme="@style/ToolBarPopupStyle" | ||
app:theme="@style/ToolBarStyle" | ||
app:title="@string/postPolicyTitle" | ||
app:navigationIcon="@drawable/vd_back_arrow" | ||
android:elevation="6dp" /> | ||
|
||
<com.google.android.material.tabs.TabLayout | ||
android:id="@+id/postPolicyTabLayout" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:elevation="6dp" | ||
android:background="@color/white" | ||
app:tabIndicatorColor="#00bcd5" | ||
app:tabIndicatorHeight="2dp" | ||
app:tabPaddingEnd="4dp" | ||
app:tabPaddingStart="4dp" | ||
app:tabSelectedTextColor="#00bcd5" | ||
app:tabTextColor="@color/gray"> | ||
|
||
<com.google.android.material.tabs.TabItem | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/postGradesTab" /> | ||
|
||
<com.google.android.material.tabs.TabItem | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/hideGradesTab" /> | ||
|
||
</com.google.android.material.tabs.TabLayout> | ||
|
||
<androidx.viewpager.widget.ViewPager | ||
android:id="@+id/postPolicyPager" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
</LinearLayout> |
This file contains 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
This file contains 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
Oops, something went wrong.