From 8f8ec69fb7557aa3e9031e4d18ea829ecc67e413 Mon Sep 17 00:00:00 2001 From: Hunter Han Date: Sun, 28 Apr 2019 23:44:05 -0500 Subject: [PATCH] New Demo is almost out --- app/src/main/AndroidManifest.xml | 2 + .../AssignmentsViewController.kt | 73 +++++++++++++++++++ .../ProgressReportViewController.kt | 2 - app/src/main/res/layout/assignments_view.xml | 24 ++++-- app/src/main/res/values/strings.xml | 1 + 5 files changed, 92 insertions(+), 10 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8c77923..9fc3bc4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,6 +26,8 @@ + diff --git a/app/src/main/java/com/lingfeishengtian/skymobile/ViewControllers/GradesRelated/AssignmentsViewController.kt b/app/src/main/java/com/lingfeishengtian/skymobile/ViewControllers/GradesRelated/AssignmentsViewController.kt index 8c4b2b5..185bd76 100644 --- a/app/src/main/java/com/lingfeishengtian/skymobile/ViewControllers/GradesRelated/AssignmentsViewController.kt +++ b/app/src/main/java/com/lingfeishengtian/skymobile/ViewControllers/GradesRelated/AssignmentsViewController.kt @@ -1,16 +1,89 @@ package com.lingfeishengtian.skymobile.ViewControllers.GradesRelated +import android.graphics.Color +import android.graphics.Point import android.os.Bundle import android.support.v7.app.AppCompatActivity +import android.view.Gravity +import android.widget.RelativeLayout +import android.widget.TableRow +import android.widget.TextView +import com.lingfeishengtian.skymobile.ImportantUtilities.UtilsClass.CurrentAssignmentBlocks import com.lingfeishengtian.skymobile.R +import kotlinx.android.synthetic.main.assignments_view.* class AssignmentsViewController : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.assignments_view) + + TableRefreshOrInit() + } + + private fun TableRefreshOrInit(){ + AssignmentsTableView.removeAllViews() + AssignmentsTableView.setPadding(15,10,15,10) + AssignmentsTableView.setColumnStretchable(1, true) + + for (Assignment in CurrentAssignmentBlocks!!.AssignmentSections) { + var Grade = "" + if (Assignment.grade != null){ + Grade = Assignment.grade!! + } + val display = getWindowManager().getDefaultDisplay() + val size = Point() + display.getSize(size) + val Row = makeNewRowFromNameAndGrade(Assignment.name, Grade) + Row.minimumHeight = size.y / 14 + AssignmentsTableView.addView(Row) + Row.gravity = Gravity.CENTER_VERTICAL + + for (MainSections in Assignment.MinorSections){ + val GapRow = TableRow(this) + GapRow.minimumHeight = 10 + + AssignmentsTableView.addView(makeNewRowFromNameAndGrade(MainSections.name, MainSections.grade)) + } + + for (AssignmentSection in Assignment.AssignmentList){ + val GapRow = TableRow(this) + GapRow.minimumHeight = 10 + + AssignmentsTableView.addView(makeNewRowFromNameAndGrade(AssignmentSection.name, AssignmentSection.grade.toString())) + } + } } + private fun makeNewRowFromNameAndGrade(name: String, grade: String): TableRow{ + var NeueRow = TableRow(this) + NeueRow.setBackgroundResource(R.drawable.rounded_row) + NeueRow.minimumHeight = root_view.height/2 + + val AssignmentName = TextView(this) + val Grade = TextView(this) + + val display = getWindowManager().getDefaultDisplay() + val size = Point() + display.getSize(size) + + val ArrOfViewsInTableRow = mutableListOf(AssignmentName, Grade) + for (View in ArrOfViewsInTableRow){ + View.setTextColor(Color.BLACK) + View.minimumHeight = size.y / 20 + View.textSize = 20F + View.includeFontPadding = false + View.setPadding(10,0,15,0) + NeueRow.addView(View) + } + + AssignmentName.text = (name) + Grade.text = grade + AssignmentName.gravity = Gravity.CENTER_VERTICAL + Grade.gravity = Gravity.CENTER_VERTICAL or Gravity.END + + return (NeueRow) + } } \ No newline at end of file diff --git a/app/src/main/java/com/lingfeishengtian/skymobile/ViewControllers/GradesRelated/ProgressReportViewController.kt b/app/src/main/java/com/lingfeishengtian/skymobile/ViewControllers/GradesRelated/ProgressReportViewController.kt index b06edd8..40469ab 100644 --- a/app/src/main/java/com/lingfeishengtian/skymobile/ViewControllers/GradesRelated/ProgressReportViewController.kt +++ b/app/src/main/java/com/lingfeishengtian/skymobile/ViewControllers/GradesRelated/ProgressReportViewController.kt @@ -133,10 +133,8 @@ class ProgressReportViewController: AppCompatActivity() { /** * "Click it until you fucking make it" algorithm. */ - Log.d("Course Details", "Clicked") if(GradeValueAsInt != null){ ClickProgressReportToShowGrades(Course, selectable_terms.selectedItem.toString()) - Log.d("Course Details", "CLICK") //TODO: Loading icon... ClickedCourse = Course startRepeatingTask() diff --git a/app/src/main/res/layout/assignments_view.xml b/app/src/main/res/layout/assignments_view.xml index f1700f9..fd4bf68 100644 --- a/app/src/main/res/layout/assignments_view.xml +++ b/app/src/main/res/layout/assignments_view.xml @@ -2,13 +2,21 @@ - + - + android:layout_height="match_parent"> + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a33f726..c487c6d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,4 +14,5 @@ Student ID Login Assignment Title + Progress Report