Commit 9754760c by Kunj Gupta

UOFLMA-126: Added logout option.

parent c4da3c22
package com.vsoft.uoflservicenow.ui;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.GridView;
......@@ -11,10 +13,12 @@ import com.google.android.gms.analytics.Tracker;
import com.vsoft.uoflservicenow.CatalogueApplication;
import com.vsoft.uoflservicenow.R;
import com.vsoft.uoflservicenow.adapters.HomeScreenAdapter;
import com.vsoft.uoflservicenow.utils.PrefManager;
import com.vsoft.uoflservicenow.utils.Util;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnItemClick;
/**
......@@ -56,4 +60,26 @@ public class HomeScreen extends AppCompatActivity {
startActivity(new Intent(HomeScreen.this, MyRequestActivity.class));
}
}
@OnClick(R.id.home_screen_logout_image_view)
void logoutOnClicked() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.home_screen_logout_confirmation_msg_string)
.setCancelable(false)
.setPositiveButton(R.string.ok_string, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
PrefManager.saveUserDetailsInPreferences(HomeScreen.this, "", "", "", "", "");
Intent loginIntent = new Intent(HomeScreen.this, LoginScreen.class);
loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(loginIntent);
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
......@@ -11,12 +11,17 @@
android:layout_height="wrap_content"
android:background="@android:color/white"
android:minHeight="?attr/actionBarSize"
app:titleTextColor="@color/tool_bar_title_color">
app:titleTextColor="@color/tool_bar_title_color"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true">
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin">
<ImageView
android:id="@+id/nav_back"
......@@ -24,7 +29,7 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@mipmap/ic_home_icon" />
android:src="@drawable/home_icon" />
<TextView
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
......@@ -35,6 +40,14 @@
android:text="@string/app_name"
android:textColor="@color/tool_bar_title_color" />
<ImageView
android:id="@+id/home_screen_logout_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/logout_icon" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
......
......@@ -8,6 +8,7 @@
<string name="none_string">-None-</string>
<string name="yes_string">Yes</string>
<string name="no_string">No</string>
<string name="ok_string">Ok</string>
<string name="search_for_reference_string">Reference</string>
<string name="home_screen_string">Home Screen</string>
<string name="login_screen_string">Login Screen</string>
......@@ -98,7 +99,6 @@
<string name="catalogue_user_full_name">full_name</string>
<string name="catalogue_user_id">user_id</string>
<!--Preference keys for pre fill value-->
<string name="preference_full_name">full_name</string>
<string name="preference_user_id">user_id</string>
<!--Home Screen-->
<string name="home_screen_logout_confirmation_msg_string">Are you sure you want to logout?</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment