Browse Source

Onboarding [Part 1]

this Commit adds a Onboarding Activity, it is currently not usefull or fully working, see #36
pull/46/head
Jannik 2 years ago
parent
commit
01677c04ef
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 8
      app/src/main/AndroidManifest.xml
  2. 3
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
  3. 99
      app/src/main/java/org/mosad/seil0/projectlaogai/OnboardingActivity.kt
  4. 4
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  5. 59
      app/src/main/java/org/mosad/seil0/projectlaogai/onboarding/ViewPagerAdapter.kt
  6. 53
      app/src/main/res/layouts/activities/layout/activity_onboarding.xml
  7. 72
      app/src/main/res/layouts/fragments/layout/fragment_on_course.xml
  8. 92
      app/src/main/res/layouts/fragments/layout/fragment_on_login.xml
  9. 70
      app/src/main/res/layouts/fragments/layout/fragment_on_welcome.xml
  10. 38
      app/src/main/res/layouts/fragments/layout/fragment_settings.xml
  11. 14
      app/src/main/res/values-de-rDE/strings.xml
  12. 14
      app/src/main/res/values/strings.xml

8
app/src/main/AndroidManifest.xml

@ -28,6 +28,14 @@
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name=".OnboardingActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.Light"
android:screenOrientation="portrait"
android:launchMode="singleTop">
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"

3
app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

@ -97,6 +97,9 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// open the activeFragment, default is the HomeFragment
fragmentTransaction.replace(R.id.fragment_container, activeFragment)
fragmentTransaction.commit()
//println("starting Onboarding")
//startActivity(Intent(this, OnboardingActivity::class.java))
}
override fun onNewIntent(intent: Intent) {

99
app/src/main/java/org/mosad/seil0/projectlaogai/OnboardingActivity.kt

@ -0,0 +1,99 @@
package org.mosad.seil0.projectlaogai
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.text.Html
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.viewpager.widget.ViewPager
import kotlinx.android.synthetic.main.activity_onboarding.*
import org.mosad.seil0.projectlaogai.fragments.SettingsFragment
import org.mosad.seil0.projectlaogai.onboarding.ViewPagerAdapter
class OnboardingActivity : AppCompatActivity() {
companion object {
val layouts = intArrayOf(R.layout.fragment_on_welcome, R.layout.fragment_on_course) //, R.layout.fragment_on_login)
}
private lateinit var viewPager: ViewPager
private lateinit var viewPagerAdapter: ViewPagerAdapter
private lateinit var linLayoutDots: LinearLayout
private lateinit var dots: Array<TextView>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_onboarding)
viewPager = findViewById(R.id.viewPager)
linLayoutDots = findViewById(R.id.linLayout_Dots)
addBottomDots(0)
viewPagerAdapter = ViewPagerAdapter(this)
viewPager.adapter = viewPagerAdapter
viewPager.addOnPageChangeListener(viewPagerPageChangeListener)
btn_Skip.visibility = View.GONE // without the the skip button is visible
}
fun btnNextClick(v: View) {
if (viewPager.currentItem < layouts.size - 1) {
viewPager.currentItem++
} else {
launchHomeScreen()
}
}
fun btnSkipClick(v: View) {
launchHomeScreen()
}
fun btnSelectCourseClick(v: View) {
SettingsFragment().selectCourse(this) // TODO
}
private fun addBottomDots(currentPage: Int) {
dots = Array(layouts.size) { TextView(this) }
linLayoutDots.removeAllViews()
dots.forEach {
it.text = Html.fromHtml("&#8226;")
it.textSize = 35f
it.setTextColor(Color.parseColor("#cccccc"))
linLayoutDots.addView(it)
}
if (dots.isNotEmpty())
dots[currentPage].setTextColor(Color.parseColor("#000000"))
}
private fun launchHomeScreen() {
startActivity(Intent(this, MainActivity::class.java))
//finish()
}
private var viewPagerPageChangeListener: ViewPager.OnPageChangeListener = object : ViewPager.OnPageChangeListener {
override fun onPageSelected(position: Int) {
addBottomDots(position)
// changing the next button text
if (position == layouts.size - 1) {
btn_Next.text = getString(R.string.start)
btn_Next.visibility = View.VISIBLE
btn_Skip.visibility = View.GONE
} else {
btn_Next.visibility = View.GONE
btn_Skip.visibility = View.GONE
}
}
override fun onPageScrolled(arg0: Int, arg1: Float, arg2: Int) {}
override fun onPageScrollStateChanged(arg0: Int) {}
}
}

4
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt

@ -171,7 +171,9 @@ class SettingsFragment : Fragment() {
resources.getString(R.string.themeDark),
resources.getString(R.string.themeBlack)
)
MaterialDialog(context!!).show {
MaterialDialog(context!!)
.title(R.string.theme)
.show {
listItemsSingleChoice(items = themes) { _, index, _ ->
Aesthetic.config {
when (index) {

59
app/src/main/java/org/mosad/seil0/projectlaogai/onboarding/ViewPagerAdapter.kt

@ -0,0 +1,59 @@
/**
* ProjectLaogai
*
* Copyright 2019-2020 <seil0@mosad.xyz>
*
* 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; either version 3 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package org.mosad.seil0.projectlaogai.onboarding
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter
import org.mosad.seil0.projectlaogai.OnboardingActivity.Companion.layouts
/**
* TODO
*/
class ViewPagerAdapter(cont: Context) : PagerAdapter() {
private val context = cont
override fun isViewFromObject(view: View, `object`: Any): Boolean {
return view === `object`
}
override fun getCount(): Int {
return layouts.size
}
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val view = LayoutInflater.from(context).inflate(layouts[position], container, false)
container.addView(view)
return view
}
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
val view = `object` as View
container.removeView(view)
}
}

53
app/src/main/res/layouts/activities/layout/activity_onboarding.xml

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</androidx.viewpager.widget.ViewPager>
<LinearLayout
android:id="@+id/linLayout_Dots"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:gravity="center"
android:orientation="horizontal"></LinearLayout>
<View
android:id="@+id/view"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_above="@id/linLayout_Dots"
android:alpha="0.5"
android:background="@android:color/white" />
<Button
android:id="@+id/btn_Next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="@null"
android:onClick="btnNextClick"
android:text="@string/next"
android:visibility="gone" />
<Button
android:id="@+id/btn_Skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:background="@null"
android:onClick="btnSkipClick"
android:text="@string/skip"
tools:visibility="gone" />
</RelativeLayout>

72
app/src/main/res/layouts/fragments/layout/fragment_on_course.xml

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imgCourse"
android:layout_width="256dp"
android:layout_height="256dp"
android:contentDescription="@string/timetable"
android:scaleType="fitCenter"
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_baseline_calendar_today_24dp" />
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="60dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/txtView_Course"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/course_heading"
android:textAlignment="center"
android:textSize="26sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_CourseDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:text="@string/course_desc_on"
android:textAlignment="center"
android:textSize="18sp" />
<Button
android:id="@+id/btnSelectCourse"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:onClick="btnSelectCourseClick"
android:text="@string/select_course"
android:textColor="#FFFFFFFF"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

92
app/src/main/res/layouts/fragments/layout/fragment_on_login.xml

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imgGrades"
android:layout_width="256dp"
android:layout_height="256dp"
android:layout_marginBottom="8dp"
android:contentDescription="@string/app_name"
android:scaleType="fitCenter"
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_school_black_24dp" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="60dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/txtView_Grades"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/grades_heading"
android:textAlignment="center"
android:textSize="26sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_GradesDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:text="@string/grades_desc_on"
android:textAlignment="center"
android:textSize="18sp" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:ems="10"
android:hint="@string/email"
android:importantForAutofill="no"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:ems="10"
android:hint="@string/password"
android:importantForAutofill="no"
android:inputType="textPassword" />
<Button
android:id="@+id/btnLogin"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="@string/login"
android:textColor="#FFFFFFFF"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

70
app/src/main/res/layouts/fragments/layout/fragment_on_welcome.xml

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logo"
android:layout_width="256dp"
android:layout_height="256dp"
android:contentDescription="@string/app_name"
android:scaleType="fitCenter"
app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/ic_launcher_foreground" />
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="60dp"
android:orientation="vertical"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/txtAppName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAlignment="center"
android:textSize="26sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtWelcome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:text="@string/welcome"
android:textAlignment="center"
android:textSize="18sp" />
<Button
android:id="@+id/btnGetStarted"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:onClick="btnNextClick"
android:text="@string/get_started"
android:textColor="#FFFFFFFF"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

38
app/src/main/res/layouts/fragments/layout/fragment_settings.xml

@ -177,43 +177,49 @@
android:layout_height="1dp"
android:background="?dividerColor"
/>
<LinearLayout
android:orientation="horizontal"
android:id="@+id/linLayout_PrimaryColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|end"
android:layout_margin="7dp"
android:clickable="true"
android:id="@+id/linLayout_PrimaryColor"
android:focusable="true" android:layout_margin="7dp">
android:focusable="true"
android:gravity="center_vertical|end"
android:orientation="horizontal">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="@string/primary_color"
android:id="@+id/txtView_PrimaryColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtView_PrimaryColor"
android:text="@string/primary_color"
android:textSize="16sp"
android:textStyle="bold"
/>
android:textStyle="bold" />
<TextView
android:text="@string/primary_color_desc"
android:id="@+id/txtView_PrimaryColorDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtView_PrimaryColorDesc"/>
android:text="@string/primary_color_desc" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:gravity="end">
android:gravity="end"
android:orientation="vertical">
<View
android:id="@+id/view_PrimaryColor"
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/view_PrimaryColor"
android:background="?colorPrimary"/>
android:background="?colorPrimary" />
</LinearLayout>
</LinearLayout>
<View

14
app/src/main/res/values-de-rDE/strings.xml

@ -10,6 +10,20 @@
<string name="moodle">Moodle</string>
<string name="settings">Einstellungen</string>
<!-- Onboarding -->
<string name="skip">überspringen</string>
<string name="next">weiter</string>
<string name="start">fertig</string>
<string name="welcome">Willkommen bei Project Laogai.\nBevor wir loslegen können, richte bitte die App ein.</string>
<string name="get_started">los geht\'s</string>
<string name="course_heading">Studiengang</string>
<string name="course_desc_on">Wähle deinen aktuellen Studiengang.\nZusätzliche Vorlesungen können später hinzugefügt werden.</string>
<string name="grades_heading">Noten</string>
<string name="grades_desc_on">Project Laogai kann uaf die Notenverwaltung zugreifen. Deine Login-Daten werden verschlüsselt auf deinem Gerät gespeichert.</string>
<string name="email">E-Mail</string>
<string name="password">Passwort</string>
<string name="login">login</string>
<!-- fragment_home -->
<string name="meal">Essen</string>
<string name="today_date">Heute, %1$s</string>

14
app/src/main/res/values/strings.xml

@ -12,6 +12,20 @@
<string name="moodle">Moodle</string>
<string name="settings">Settings</string>
<!-- Onboarding -->
<string name="skip">skip</string>
<string name="next">next</string>
<string name="start">start</string>
<string name="welcome">Welcome to Project Laogai.\nBefore we can start, setup the App.</string>
<string name="get_started">get started</string>
<string name="course_heading">Course</string>
<string name="course_desc_on">Select your current course.\nAdditional lessons can be added later.</string>
<string name="grades_heading">Grades</string>
<string name="grades_desc_on">Project Laogai can connect to the HIS Online-Portal. Your Login-Data will be stored encrypted on your device.</string>
<string name="email">E-Mail</string>
<string name="password">Password</string>
<string name="login">login</string>
<!-- fragment_home -->
<string name="meal">Meal</string>
<string name="today_date">Today, %1$s</string>

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close