Skip to content

Commit

Permalink
style fix and logout
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanchhatpar committed Mar 8, 2018
1 parent 030cff3 commit 694e6a7
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class LoginActivity : AppCompatActivity(), LoaderCallbacks<Cursor> {
}

private fun syncWekaAndLaunchApp(intent: Intent, accessToken: String) {
sync_message.visibility = View.VISIBLE
apiController.downloadFile("${WekaPredictor.model_name}.zip", accessToken, Response.Listener<ByteArray> { response ->
try {
if (response != null) {
Expand All @@ -254,6 +255,7 @@ class LoginActivity : AppCompatActivity(), LoaderCallbacks<Cursor> {
Toast.makeText(this, "WEKA Download complete.", Toast.LENGTH_LONG).show()
val b = unpackZip("${filesDir.absolutePath}/", name)
Toast.makeText(this, "WEKA unzip: $b.", Toast.LENGTH_LONG).show()
sync_message.visibility = View.GONE
this@LoginActivity.startActivity(intent)
this@LoginActivity.finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.beproject.group1.vta.activities
import android.Manifest.permission.ACCESS_COARSE_LOCATION
import android.Manifest.permission.ACCESS_FINE_LOCATION
import android.content.Context
import android.content.Intent
import android.content.IntentSender
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.content.res.Resources
import android.graphics.Color
Expand All @@ -27,6 +29,7 @@ import android.os.SystemClock
import android.support.v4.content.ContextCompat
import android.view.animation.LinearInterpolator
import com.beproject.group1.vta.R
import com.beproject.group1.vta.VTAApplication
import com.beproject.group1.vta.helpers.ETA
import com.beproject.group1.vta.helpers.Geofence
import com.beproject.group1.vta.helpers.TFPredictor
Expand Down Expand Up @@ -178,6 +181,17 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, SensorEventListene

})

logout.setOnClickListener({_ ->
val sp = getSharedPreferences(VTAApplication.PREF_FILE, Context.MODE_PRIVATE)
val spe = sp.edit()
spe.remove("email")
spe.remove("password")
spe.apply()
val intent = Intent(this@MapsActivity, LoginActivity::class.java)
startActivity(intent)
finish()
})

/* val country:String = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
resources.configuration.locales[0].country
} else {
Expand Down Expand Up @@ -386,7 +400,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, SensorEventListene

val c = Calendar.getInstance()
val tfPredictor = TFPredictor(this)
val wekaPredictor = WekaPredictor(this)
// val wekaPredictor = WekaPredictor(this)
Log.d("Total routes", ""+results.routes.size)
for(i in 0 until route.size)
{
Expand Down Expand Up @@ -532,6 +546,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, SensorEventListene
}
if(Geofence.containsCoordinates(source.latitude, source.longitude)
&& Geofence.containsCoordinates(destination.latitude, destination.longitude)) {
Log.d("not ignore", "true")
getDirectionsDetails(source.latitude.toString() + "," + source.longitude.toString(), destination.latitude.toString() + "," + destination.longitude.toString(), TravelMode.DRIVING, callback)
} else {
Snackbar.make(mapFragment.view!!,R.string.out_of_service_region, Snackbar.LENGTH_SHORT)
Expand Down Expand Up @@ -601,7 +616,9 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, SensorEventListene
}
}
route.clear()
timeBar!!.dismiss()
if(timeBar != null) {
timeBar!!.dismiss()
}
locateMe()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import android.content.Intent
import android.content.SharedPreferences
import android.os.Handler
import android.util.Log
import android.view.View
import android.widget.Toast
import com.android.volley.Response
import com.beproject.group1.vta.VTAApplication
import com.beproject.group1.vta.helpers.APIController
import com.beproject.group1.vta.helpers.TFPredictor.Companion.model_name
import com.beproject.group1.vta.helpers.VolleyService
import com.beproject.group1.vta.helpers.WekaPredictor
import kotlinx.android.synthetic.main.activity_splash_screen.*
import org.json.JSONObject
import java.io.*
import java.text.SimpleDateFormat
Expand Down Expand Up @@ -124,6 +126,7 @@ class SplashScreen : AppCompatActivity() {
}

private fun syncWekaAndLaunchApp(intent: Intent, accessToken: String) {
splash_message.visibility = View.VISIBLE
apiController.downloadFile("${WekaPredictor.model_name}.zip", accessToken, Response.Listener<ByteArray> {response ->
try {
if (response != null) {
Expand All @@ -135,6 +138,7 @@ class SplashScreen : AppCompatActivity() {
Toast.makeText(this, "WEKA Download complete.", Toast.LENGTH_LONG).show()
val b = unpackZip("${filesDir.absolutePath}/", name)
Toast.makeText(this, "WEKA unzip: $b.", Toast.LENGTH_LONG).show()
splash_message.visibility = View.GONE
this@SplashScreen.startActivity(intent)
this@SplashScreen.finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ protected Response<byte[]> parseNetworkResponse(NetworkResponse response) {
//Pass the response data here
return Response.success( response.data, HttpHeaderParser.parseCacheHeaders(response));
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 20 additions & 2 deletions vta-android/app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,28 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@color/colorPrimary"
tools:context="com.beproject.group1.vta.activities.LoginActivity">

<!-- Login progress -->
<ProgressBar
android:visibility="gone"
android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
/>
<TextView
android:visibility="gone"
android:id="@+id/sync_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sync_alert"
android:textAlignment="center"
android:textStyle="italic"
android:textColor="@android:color/white"
android:textSize="18sp"/>

<ScrollView
android:id="@+id/login_form"
Expand All @@ -32,9 +44,11 @@

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:textColorHint="@color/colorAccent"
android:layout_height="wrap_content">

<AutoCompleteTextView
android:textColor="@android:color/white"
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -47,10 +61,12 @@

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:textColorHint="@color/colorAccent"
android:layout_height="wrap_content">

<EditText
android:id="@+id/password"
android:textColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
Expand All @@ -65,8 +81,10 @@

<Button
android:id="@+id/email_sign_in_button"
style="?android:textAppearanceSmall"
style="?android:textAppearanceLarge"
android:background="@color/colorAccent"
android:layout_width="match_parent"
android:textColor="@android:color/white"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/action_sign_in"
Expand Down
10 changes: 10 additions & 0 deletions vta-android/app/src/main/res/layout/activity_maps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@
app:backgroundTint="@android:color/white"
app:pressedTranslationZ="12dp"
/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_margin="16dp"
android:id="@+id/logout"
app:srcCompat="@drawable/ic_logout"
app:backgroundTint="@android:color/white"
app:pressedTranslationZ="12dp"
/>
</android.support.design.widget.CoordinatorLayout>
11 changes: 10 additions & 1 deletion vta-android/app/src/main/res/layout/activity_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@color/colorPrimary"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.beproject.group1.vta.activities.SignUpActivity">

Expand All @@ -32,13 +33,15 @@

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:textColorHint="@color/colorAccent"
android:layout_height="wrap_content">

<AutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_email"
android:textColor="@android:color/white"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
Expand All @@ -47,12 +50,14 @@

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:textColorHint="@color/colorAccent"
android:layout_height="wrap_content">

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:hint="@string/prompt_password"
android:imeActionId="6"
android:inputType="textPassword"
Expand All @@ -63,9 +68,11 @@

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:textColorHint="@color/colorAccent"
android:layout_height="wrap_content">

<EditText
android:textColor="@android:color/white"
android:id="@+id/confirm_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -81,9 +88,11 @@

<Button
android:id="@+id/email_sign_up_button"
style="?android:textAppearanceSmall"
style="?android:textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:background="@color/colorAccent"
android:layout_marginTop="16dp"
android:text="@string/action_sign_up"
android:textStyle="bold" />
Expand Down
12 changes: 12 additions & 0 deletions vta-android/app/src/main/res/layout/activity_splash_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,16 @@
android:indeterminate="true"
android:layout_centerHorizontal="true"
/>
<TextView
android:visibility="gone"
android:id="@+id/splash_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sync_alert"
android:textAlignment="center"
android:layout_below="@id/splash_process"
android:textStyle="italic"
android:textColor="@android:color/white"
android:textSize="18sp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
10 changes: 5 additions & 5 deletions vta-android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorPrimary">#000</color>
<color name="colorPrimaryDark">#000</color>
<color name="colorAccent">#0091EA</color>
<color name="green">#84ca50</color>
<color name="orange">#f07d02</color>
<color name="red">#e60000</color>
<color name="darkRed">#9e1313</color>
<color name="geoFenceColor">#1e6a1b9a</color>
<color name="geoFenceBorder">#6a1b9a</color>
<color name="geoFenceColor">#367492a8</color>
<color name="geoFenceBorder">#7492a8</color>
<color name="routeInactive">#b4363636</color>
</resources>
1 change: 1 addition & 0 deletions vta-android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<string name="from_location">Source</string>
<string name="out_of_service_region">We do not serve this region yet</string>
<string name="offline_alert">Currently offline</string>
<string name="sync_alert">Synchronizing...\nThis may take time</string>
</resources>
15 changes: 15 additions & 0 deletions vta-android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:actionBarStyle">@style/AppTheme.ActionBarStyle</item>
<item name="actionBarStyle">@style/AppTheme.ActionBarStyle</item>
<item name="android:actionMenuTextColor">@color/colorAccent</item>
<item name="actionMenuTextColor">@color/colorAccent</item>
</style>

<style name="AppTheme.ActionBarStyle" parent="Widget.AppCompat.ActionBar.Solid">
<item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
<item name="android:homeAsUpIndicator">@drawable/ic_back</item>
<item name="homeAsUpIndicator">@drawable/ic_back</item>
<item name="titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
</style>

<style name="AppTheme.ActionBar.TitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar" parent="AppTheme">
Expand Down

0 comments on commit 694e6a7

Please sign in to comment.