aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/src/main
diff options
context:
space:
mode:
authorMarvin Borner2018-07-24 20:28:47 +0200
committerMarvin Borner2018-07-24 20:28:47 +0200
commit4ada3652d88e7a97680759c44ee7b39953a867a7 (patch)
tree44d003d19e5e9f38d7a5ae9c25fb808c83109729 /app/src/main
parent43fb95de3fb3e825a6cbf0de68bd965556b73a75 (diff)
Added transitions and fixed some design issues
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml14
-rw-r--r--app/src/main/java/com/beam_messenger/beam_messenger/LoginActivity.kt34
-rw-r--r--app/src/main/res/layout/activity_main.xml43
-rw-r--r--app/src/main/res/layout/content_main.xml11
-rw-r--r--app/src/main/res/layout/fragment_main.xml23
-rw-r--r--app/src/main/res/menu/menu_main.xml8
-rw-r--r--app/src/main/res/values-w820dp/dimens.xml6
-rw-r--r--app/src/main/res/values/dimens.xml1
-rw-r--r--app/src/main/res/values/strings.xml7
-rw-r--r--app/src/main/res/values/styles.xml2
10 files changed, 112 insertions, 37 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a990adc..114c168 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -15,17 +15,8 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
- android:name=".LoginActivity"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity
android:name=".MainActivity"
- android:label="@string/title_activity_main"
+ android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -33,6 +24,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity
+ android:name=".LoginActivity"
+ android:label="@string/title_activity_login"></activity>
</application>
</manifest> \ No newline at end of file
diff --git a/app/src/main/java/com/beam_messenger/beam_messenger/LoginActivity.kt b/app/src/main/java/com/beam_messenger/beam_messenger/LoginActivity.kt
index 8c91771..02d1d6f 100644
--- a/app/src/main/java/com/beam_messenger/beam_messenger/LoginActivity.kt
+++ b/app/src/main/java/com/beam_messenger/beam_messenger/LoginActivity.kt
@@ -1,31 +1,34 @@
package com.beam_messenger.beam_messenger
+import android.Manifest.permission.READ_CONTACTS
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.annotation.TargetApi
-import android.content.pm.PackageManager
-import android.support.design.widget.Snackbar
-import android.support.v7.app.AppCompatActivity
+import android.app.ActivityOptions
import android.app.LoaderManager.LoaderCallbacks
import android.content.CursorLoader
+import android.content.Intent
import android.content.Loader
+import android.content.pm.PackageManager
import android.database.Cursor
import android.net.Uri
import android.os.AsyncTask
import android.os.Build
import android.os.Bundle
import android.provider.ContactsContract
+import android.support.design.widget.Snackbar
+import android.support.v7.app.AppCompatActivity
import android.text.TextUtils
+import android.transition.Explode
+import android.view.Gravity
import android.view.View
+import android.view.Window
import android.view.inputmethod.EditorInfo
import android.widget.ArrayAdapter
import android.widget.TextView
-
-import java.util.ArrayList
-import android.Manifest.permission.READ_CONTACTS
-import android.content.Intent
-
+import android.widget.Toast
import kotlinx.android.synthetic.main.activity_login.*
+import java.util.*
/**
* A login screen that offers login via email/password.
@@ -37,6 +40,11 @@ class LoginActivity : AppCompatActivity(), LoaderCallbacks<Cursor> {
private var mAuthTask: UserLoginTask? = null
override fun onCreate(savedInstanceState: Bundle?) {
+ with(window) {
+ requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)
+ exitTransition = Explode()
+ }
+
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
// Set up the login form.
@@ -143,11 +151,11 @@ class LoginActivity : AppCompatActivity(), LoaderCallbacks<Cursor> {
}
private fun isEmailValid(email: String): Boolean {
- return email.contains("@")
+ return email.contains("@") && email.length >= 4
}
private fun isPasswordValid(password: String): Boolean {
- return password.length > 7
+ return password.length >= 8
}
/**
@@ -265,9 +273,13 @@ class LoginActivity : AppCompatActivity(), LoaderCallbacks<Cursor> {
showProgress(false)
if (success!!) {
+ val toast = Toast.makeText(this@LoginActivity, "Successfully logged in.", Toast.LENGTH_LONG)
+ toast.setGravity(Gravity.CENTER, 0, 0)
+ toast.show()
+
val intent = Intent(this@LoginActivity, MainActivity::class.java)
//intent.putExtra("keyIdentifier", value)
- startActivity(intent)
+ startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this@LoginActivity).toBundle())
} else {
password.error = getString(R.string.error_incorrect_password)
password.requestFocus()
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index eed4d89..2bd5037 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -2,31 +2,68 @@
<android.support.design.widget.CoordinatorLayout 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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
+ android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
+ android:layout_weight="1"
android:background="?attr/colorPrimary"
- app:popupTheme="@style/AppTheme.PopupOverlay" />
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:title="@string/app_name">
+ </android.support.v7.widget.Toolbar>
+
+ <android.support.design.widget.TabLayout
+ android:id="@+id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <android.support.design.widget.TabItem
+ android:id="@+id/tabItem"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/tab_text_1" />
+
+ <android.support.design.widget.TabItem
+ android:id="@+id/tabItem2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/tab_text_2" />
+
+ <android.support.design.widget.TabItem
+ android:id="@+id/tabItem3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/tab_text_3" />
+
+ </android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
- <include layout="@layout/content_main" />
+ <android.support.v4.view.ViewPager
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|end"
+ android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml
deleted file mode 100644
index c649451..0000000
--- a/app/src/main/res/layout/content_main.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout 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"
- app:layout_behavior="@string/appbar_scrolling_view_behavior"
- tools:context=".MainActivity"
- tools:showIn="@layout/activity_main">
-
-</android.support.constraint.ConstraintLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml
new file mode 100644
index 0000000..108217e
--- /dev/null
+++ b/app/src/main/res/layout/fragment_main.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout 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:id="@+id/constraintLayout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".MainActivity$PlaceholderFragment">
+
+ <TextView
+ android:id="@+id/section_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/activity_vertical_margin"
+ android:layout_marginEnd="@dimen/activity_horizontal_margin"
+ android:layout_marginStart="@dimen/activity_horizontal_margin"
+ android:layout_marginTop="@dimen/activity_vertical_margin"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/constraintLayout"
+ tools:layout_constraintLeft_creator="1"
+ tools:layout_constraintTop_creator="1" />
+
+</android.support.constraint.ConstraintLayout> \ No newline at end of file
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
new file mode 100644
index 0000000..cefca9d
--- /dev/null
+++ b/app/src/main/res/menu/menu_main.xml
@@ -0,0 +1,8 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context="com.beam_messenger.beam_messenger.MainActivity">
+ <item
+ android:id="@+id/action_settings"
+ android:orderInCategory="100"
+ android:title="@string/action_settings" />
+</menu>
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+ <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 812cb7b..cef3abc 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -3,4 +3,5 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
+ <dimen name="appbar_padding_top">8dp</dimen>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6576e72..e4c7ea7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,5 +1,11 @@
<resources>
<string name="app_name">BEAM-Messenger</string>
+ <string name="tab_text_1">Chats</string>
+ <string name="tab_text_2">Posts</string>
+ <string name="tab_text_3">Contacts</string>
+ <string name="action_settings">Sign in</string>
+ <string name="section_format">This is tab: %1$d</string>
+ <string name="title_activity_login">Sign in</string>
<!-- Strings related to login -->
<string name="prompt_email">Email</string>
@@ -11,5 +17,4 @@
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
<string name="permission_rationale">"Contacts permissions are needed for providing email completions."</string>
- <string name="title_activity_main">Home</string>
</resources>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index d4ea9ae..545b9c6 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,7 +1,7 @@
<resources>
<!-- Base application theme. -->
- <style name="AppTheme" parent="Theme.AppCompat">
+ <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>