Browse Source
this Commit adds a Onboarding Activity, it is currently not usefull or fully working, see #36pull/46/head
12 changed files with 509 additions and 17 deletions
@ -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("•") |
||||
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) {} |
||||
} |
||||
|
||||
|
||||
} |
@ -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) |
||||
} |
||||
|
||||
} |
@ -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> |
@ -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> |
@ -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> |
@ -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> |
Loading…
Reference in new issue