Skip to content

Commit

Permalink
[Student][NewRelic][MBL-13108]: USE_REMOTE_CONFIG -> USE_NEW_RELIC (#267
Browse files Browse the repository at this point in the history
)

* [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
joehoag authored Aug 26, 2019
1 parent 67ae600 commit 16dc91f
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class LoginActivity : BaseLoginInitActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
val startNewRelic =
RemoteConfigUtils.getString(RemoteConfigParam.USE_REMOTE_CONFIG)?.equals("true",ignoreCase = true) ?: false
RemoteConfigUtils.getString(RemoteConfigParam.USE_NEW_RELIC)?.equals("true",ignoreCase = true) ?: false

Log.v("LoginActivity","startNewRelic=$startNewRelic")

Expand Down
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")
}
}
}
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)
})
}
}
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)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.instructure.teacher.events.AssignmentGradedEvent
import com.instructure.teacher.events.SubmissionCommentsUpdated
import com.instructure.teacher.events.SubmissionFilterChangedEvent
import com.instructure.teacher.factory.AssignmentSubmissionListPresenterFactory
import com.instructure.teacher.features.postpolicies.PostPolicyFragment
import com.instructure.teacher.holders.GradeableStudentSubmissionViewHolder
import com.instructure.teacher.presenters.AssignmentSubmissionListPresenter
import com.instructure.teacher.presenters.AssignmentSubmissionListPresenter.SubmissionListFilter
Expand Down Expand Up @@ -286,14 +287,21 @@ class AssignmentSubmissionListFragment : BaseSyncFragment<
EventBus.getDefault().post(SubmissionFilterChangedEvent(canvasContext = canvasContexts))
}.show(requireActivity().supportFragmentManager, PeopleListFilterDialog::class.java.simpleName)
}
R.id.menuPostPolicies -> {
RouteMatcher.route(requireContext(), PostPolicyFragment.makeRoute(mCourse, mAssignment))
}
}
}

private fun updateStatuses() {
val isMuted = presenter.mAssignment.muted
assignmentSubmissionListToolbar.menu.findItem(R.id.menuMuteGrades)?.let {
it.isVisible = !FeatureFlags.postPolicies
it.title = getString(if (isMuted) R.string.unmuteGrades else R.string.muteGrades)
}
assignmentSubmissionListToolbar.menu.findItem(R.id.menuPostPolicies)?.let {
it.isVisible = FeatureFlags.postPolicies
}

val statuses = mutableListOf<String>()
if (presenter.mAssignment.anonymousGrading) statuses += getString(R.string.anonymousGradingLabel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ import com.instructure.interactions.router.RouteContext
import com.instructure.interactions.router.RouterParams
import com.instructure.pandautils.activities.BaseViewMediaActivity
import com.instructure.pandautils.loaders.OpenMediaAsyncTaskLoader
import com.instructure.pandautils.utils.Const
import com.instructure.pandautils.utils.LoaderUtils
import com.instructure.pandautils.utils.RouteUtils
import com.instructure.pandautils.utils.nonNullArgs
import com.instructure.pandautils.utils.*
import com.instructure.teacher.PSPDFKit.AnnotationComments.AnnotationCommentListFragment
import com.instructure.teacher.R
import com.instructure.teacher.activities.*
import com.instructure.teacher.adapters.StudentContextFragment
import com.instructure.teacher.features.postpolicies.PostPolicyFragment
import com.instructure.teacher.fragments.*
import com.instructure.teacher.fragments.FileListFragment
import instructure.rceditor.RCEFragment
Expand Down Expand Up @@ -332,6 +330,7 @@ object RouteMatcher : BaseRouteMatcher() {
AssignmentDetailsFragment::class.java.isAssignableFrom(cls) -> fragment = getAssignmentDetailsFragment(canvasContext, route)
DueDatesFragment::class.java.isAssignableFrom(cls) -> fragment = DueDatesFragment.getInstance((canvasContext as Course?)!!, route.arguments)
AssignmentSubmissionListFragment::class.java.isAssignableFrom(cls) -> fragment = AssignmentSubmissionListFragment.newInstance((canvasContext as Course?)!!, route.arguments)
PostPolicyFragment::class.java.isAssignableFrom(cls) -> fragment = PostPolicyFragment.newInstance(route.argsWithContext)
EditAssignmentDetailsFragment::class.java.isAssignableFrom(cls) -> fragment = EditAssignmentDetailsFragment.newInstance((canvasContext as Course?)!!, route.arguments)
AssigneeListFragment::class.java.isAssignableFrom(cls) -> fragment = AssigneeListFragment.newInstance(route.arguments)
EditFavoritesFragment::class.java.isAssignableFrom(cls) -> fragment = EditFavoritesFragment.newInstance(route.arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import com.instructure.canvasapi2.models.Course
import com.instructure.interactions.router.Route
import com.instructure.interactions.router.RouterParams
import com.instructure.pandautils.utils.Const
import com.instructure.pandautils.utils.argsWithContext
import com.instructure.teacher.PSPDFKit.AnnotationComments.AnnotationCommentListFragment
import com.instructure.teacher.adapters.StudentContextFragment
import com.instructure.teacher.features.files.search.FileSearchFragment
import com.instructure.teacher.features.modules.list.ui.ModuleListFragment
import com.instructure.teacher.features.postpolicies.PostPolicyFragment
import com.instructure.teacher.fragments.*
import instructure.rceditor.RCEFragment

Expand Down Expand Up @@ -76,6 +78,8 @@ object RouteResolver {
fragment = DueDatesFragment.getInstance((canvasContext as Course?)!!, route.arguments)
} else if (AssignmentSubmissionListFragment::class.java.isAssignableFrom(cls)) {
fragment = AssignmentSubmissionListFragment.newInstance((canvasContext as Course?)!!, route.arguments)
} else if (PostPolicyFragment::class.java.isAssignableFrom(cls)) {
fragment = PostPolicyFragment.newInstance(route.argsWithContext)
} else if (EditAssignmentDetailsFragment::class.java.isAssignableFrom(cls)) {
fragment = EditAssignmentDetailsFragment.newInstance((canvasContext as Course?)!!, route.arguments)
} else if (AssigneeListFragment::class.java.isAssignableFrom(cls)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/
package com.instructure.teacher.utils

import com.instructure.canvasapi2.utils.FeatureFlagPref
import com.instructure.canvasapi2.utils.PrefManager

object FeatureFlags : PrefManager("feature_flags") {

var postPolicies by FeatureFlagPref("Post Policies")
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
android:layout_margin="16dp"
app:fabSize="normal"
app:elevation="4dp"
app:srcCompat="@drawable/vd_mail"
app:srcCompat="@drawable/ic_mail_filled"
android:tint="@color/white"
android:contentDescription="@string/sendMessage"/>

</RelativeLayout>
65 changes: 65 additions & 0 deletions apps/teacher/src/main/res/layout/fragment_post_policy_settings.xml
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>
6 changes: 6 additions & 0 deletions apps/teacher/src/main/res/menu/menu_filter_submissions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menuPostPolicies"
android:title="@string/postPolicyTitle"
android:icon="@drawable/ic_eye_filled"
app:showAsAction="ifRoom"
/>
<item
android:id="@+id/submissionFilter"
android:icon="@drawable/vd_filter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum class RemoteConfigParam(val rc_name: String, val safeValueAsString: String)
TEST_FLOAT("test_float", "0f"),
TEST_STRING("test_string", "hey there"),
TEST_LONG("test_long", "42"),
USE_REMOTE_CONFIG("all_remote_config", "false")
USE_NEW_RELIC("all_new_relic_enabled", "false")
}

/**
Expand Down
Loading

0 comments on commit 16dc91f

Please sign in to comment.