Commit d0bb8cda authored by mayu's avatar mayu

merge conflict resolved

parents 9f1ff9dc a05de136
IITB App
===============
### Powered by the Web and Coding Club, IIT Bombay
All IITB content in one place. IITB App is the result of WnCC's coordinated efforts to build an applications that makes it easier to discover IITB content while being on the go.
The IITB App features the Placement Blog, Upcoming Events and general information on every active club/body in the Institute
### Features:
* Events Directory
* Placement Blog
* Mess Menus
* Internship Blog
* Inter Hostel GC rankings
* Academic Timetable
* Academic Calendar
* Complaint Management System
* Map
A more detailed list of features can be found [here](https://docs.google.com/document/d/1L4wzuw88JrLyBt1DvnjavtAwhJkXgNSIxJG3yBsLwQ0/edit?usp=sharing).
IITB App is a community effort and we appreciate the help of everyone who wants to help improve the App.
Check http://github.com/wncc for more information about all development activities under WnCC.
Development
-----------
Read the [Development Documentation](https://iitbapp1.docs.apiary.io/).
See the [Frontend Design](https://drive.google.com/open?id=1YJRUvsyqR5QtfWYug_PoBJ08p-criCPo).
### Contributors
See [list of contributors](https://github.com/unstablebrainiac/IITB-App/graphs/contributors)
Release
-------
The app is still in early stages of development and is not on the Play Store.
###### The IITB App, WnCC are not endorsed by IIT Bombay, the institute.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "in.ac.iitb.gymkhana.iitbapp"
manifestPlaceholders 'appAuthRedirectScheme': 'https'
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
supportLibVersion = '26.1.0'
playServicesVersion = '12.0.0'
butterKnifeVersion = '8.8.1'
appAuthVersion = '0.2.0'
retrofitVersion = '2.1.0'
okhttpVersion = '3.4.1'
picassoVersion = '2.5.0'
archRoomVersion = '1.1.0-beta1'
circleImageViewVersion = '2.2.0'
markwonVersion = '1.0.4'
}
dependencies {
implementation 'com.android.support:support-v4:26.1.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "net.openid:appauth:${appAuthVersion}"
testImplementation "junit:junit:4.12"
implementation "com.android.support:design:${supportLibVersion}"
implementation "com.android.support:support-v4:${supportLibVersion}"
implementation "com.jakewharton:butterknife:${butterKnifeVersion}"
implementation "com.google.android.gms:play-services-gcm:${playServicesVersion}"
implementation "com.google.android.gms:play-services-maps:${playServicesVersion}"
implementation "com.google.android.gms:play-services-location:${playServicesVersion}"
annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}"
implementation "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
implementation "com.squareup.okhttp3:okhttp:${okhttpVersion}"
implementation "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
implementation "com.squareup.picasso:picasso:${picassoVersion}"
implementation "com.android.support:customtabs:${supportLibVersion}"
implementation "android.arch.persistence.room:runtime:${archRoomVersion}"
annotationProcessor "android.arch.persistence.room:compiler:${archRoomVersion}"
implementation "com.android.support:cardview-v7:${supportLibVersion}"
implementation "de.hdodenhof:circleimageview:${circleImageViewVersion}"
implementation "ru.noties:markwon:${markwonVersion}"
}
apply plugin: 'com.google.gms.google-services'
{
"project_info": {
"project_number": "306601329049",
"firebase_url": "https://iitb-app-5c0aa.firebaseio.com",
"project_id": "iitb-app-5c0aa",
"storage_bucket": "iitb-app-5c0aa.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:306601329049:android:950a72a311331b9c",
"android_client_info": {
"package_name": "in.ac.iitb.gymkhana.iitbapp"
}
},
"oauth_client": [
{
"client_id": "306601329049-6v597vrdv0nbi15ehpehq8hiaek8unqp.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyC1oThCMZN3JMnK6MUTJRjkp47q1K_gnTA"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/sajalnarang/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package in.ac.iitb.gymkhana.iitbapp;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("in.ac.iitb.gymkhana.iitbapp", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.ac.iitb.gymkhana.iitbapp">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- The API key for Google Maps-based APIs. -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="HANDLE_AUTHORIZATION_RESPONSE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
&lt;!&ndash;<category android:name="android.intent.category.LAUNCHER" />&ndash;&gt;
</intent-filter>-->
</activity>
<activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="redirecturi"
android:scheme="https" />
</intent-filter>
</activity>
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.gcm" />
</intent-filter>
</receiver>
<service
android:name="in.ac.iitb.gymkhana.iitbapp.gcm.MyGcmListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="in.ac.iitb.gymkhana.iitbapp.gcm.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name="in.ac.iitb.gymkhana.iitbapp.gcm.RegistrationIntentService"
android:exported="false"></service>
</application>
</manifest>
\ No newline at end of file
package in.ac.iitb.gymkhana.iitbapp;
import android.app.Activity;
import java.util.ArrayList;
import java.util.List;
/**
* A class which maintains a list of transactions to occur when Context becomes available.
*/
public final class ActivityBuffer {
private final List<IRunnable> mRunnables;
/* Member Variables. */
private Activity mActivity;
/**
* Constructor.
*/
public ActivityBuffer() {
// Initialize Member Variables.
this.mActivity = null;
this.mRunnables = new ArrayList<IRunnable>();
}
/**
* Executes the Runnable if there's an available Context. Otherwise, defers execution until it becomes available.
*/
public final void safely(final IRunnable pRunnable) {
// Synchronize along the current instance.
synchronized (this) {
// Do we have a context available?
if (this.isContextAvailable()) {
// Fetch the Activity.
final Activity lActivity = this.getActivity();
// Execute the Runnable along the Activity.
lActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
pRunnable.run(lActivity);
}
});
} else {
// Buffer the Runnable so that it's ready to receive a valid reference.
this.getRunnables().add(pRunnable);
}
}
}
/**
* Called to inform the ActivityBuffer that there's an available Activity reference.
*/
public final void onContextGained(final Activity pActivity) {
// Synchronize along ourself.
synchronized (this) {
// Update the Activity reference.
this.setActivity(pActivity);
// Are there any Runnables awaiting execution?
if (!this.getRunnables().isEmpty()) {
// Iterate the Runnables.
for (final IRunnable lRunnable : this.getRunnables()) {
// Execute the Runnable on the UI Thread.
pActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
// Execute the Runnable.
lRunnable.run(pActivity);
}
});
}
// Empty the Runnables.
this.getRunnables().clear();
}
}
}
/**
* Called to inform the ActivityBuffer that the Context has been lost.
*/
public final void onContextLost() {
// Synchronize along ourself.
synchronized (this) {
// Remove the Context reference.
this.setActivity(null);
}
}
/**
* Defines whether there's a safe Context available for the ActivityBuffer.
*/
public final boolean isContextAvailable() {
// Synchronize upon ourself.
synchronized (this) {
// Return the state of the Activity reference.
return (this.getActivity() != null);
}
}
private final Activity getActivity() {
return this.mActivity;
}
/* Getters and Setters. */
private final void setActivity(final Activity pActivity) {
this.mActivity = pActivity;
}
private final List<IRunnable> getRunnables() {
return this.mRunnables;
}
/**
* A class which defines operations to execute once there's an available Context.
*/
public interface IRunnable {
/**
* Executes when there's an available Context. Ideally, will it operate immediately.
*/
void run(final Activity pActivity);
}
}
\ No newline at end of file
package in.ac.iitb.gymkhana.iitbapp;
public class Constants {
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
public static final int MY_PERMISSIONS_REQUEST_ACCESS_LOCATION = 2;
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 3;
public static final int RESULT_LOAD_IMAGE = 11;
public static final String NOTIFICATIONS_RESPONSE_JSON = "notifications_json";
public static final String EVENT_JSON = "event_json";
public static final String USER_ID = "user_id";
public static final String SENT_TOKEN_TO_SERVER = "sentTokenToServer";
public static final String REGISTRATION_COMPLETE = "registrationComplete";
public static final String PREF_NAME = "LoggedInPref";
public static final String IS_LOGGED_IN = "IsLoggedIn";
public static final String GCM_ID = "GcmId";
public static final String CURRENT_USER = "current_user";
public static final String SESSION_ID = "session_id";
public static final int STATUS_GOING = 2;
public static final int STATUS_INTERESTED = 1;
public static final int STATUS_NOT_GOING = 0;
}
package in.ac.iitb.gymkhana.iitbapp;
import android.view.View;
public interface ItemClickListener {
void onItemClick(View v, int position);
}
package in.ac.iitb.gymkhana.iitbapp;
import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import net.openid.appauth.AuthorizationException;
import net.openid.appauth.AuthorizationRequest;
import net.openid.appauth.AuthorizationResponse;
import net.openid.appauth.AuthorizationService;
import net.openid.appauth.AuthorizationServiceConfiguration;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse;
import in.ac.iitb.gymkhana.iitbapp.gcm.RegistrationIntentService;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LoginActivity extends AppCompatActivity {
private static final String TAG = "LoginActivity";
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private final String clientId = "u1eFlmRWUOY5Sh4yFeqeWD71OXR8M8PYc0xUK33D";
private final Uri redirectUri = Uri.parse("https://redirecturi");
private final Uri mAuthEndpoint = Uri.parse("http://gymkhana.iitb.ac.in/sso/oauth/authorize/");
private final Uri mTokenEndpoint = Uri.parse("http://gymkhana.iitb.ac.in/sso/oauth/token/");
public String authCode = null;
SessionManager session;
Context mContext = this;
private AuthorizationService mAuthService;
private BroadcastReceiver mRegistrationBroadcastReceiver;
private boolean isReceiverRegistered;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
session = new SessionManager(mContext);
setContentView(R.layout.activity_login);
mAuthService = new AuthorizationService(this);
mRegistrationBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean sentToken = sharedPreferences.getBoolean(Constants.SENT_TOKEN_TO_SERVER, false);
if (sentToken) {
String token = intent.getStringExtra("Token");
Log.d(TAG, "Going to login with :" + authCode + "\n" + token);
//************
//TODO Remove following 6 lines after the server is hosted
String gcmRegId = token;
// session.createLoginSession(gcmRegId);
// Intent i = new Intent(mContext, MainActivity.class);
// i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// startActivity(i);
//**************
login(authCode, redirectUri.toString(), gcmRegId);
} else {
}
}
};
registerReceiver();
Button ldapLogin = (Button) findViewById(R.id.ldap_login);
ldapLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "Initiating auth");
AuthorizationServiceConfiguration config = new AuthorizationServiceConfiguration(mAuthEndpoint, mTokenEndpoint);
makeAuthRequest(config);
}
});
Button guestLogin = (Button) findViewById(R.id.guest_login);
guestLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO This is for debug purposes, change once SSO is implemented
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
@Override
protected void onNewIntent(Intent intent) {
checkIntent(intent);
}
private void checkIntent(@Nullable Intent intent) {
if (intent != null) {
Log.d(TAG, "Intent Received");
String action = intent.getAction();
if (action != null) {
switch (action) {
case "HANDLE_AUTHORIZATION_RESPONSE": {
handleAuthorizationResponse(intent);
}
break;
default:
Log.d(TAG, intent.getAction());
}
}
}
}
@Override
protected void onStart() {
super.onStart();
checkIntent(getIntent());
}
@Override
protected void onResume() {
super.onResume();
registerReceiver();
Log.d(TAG, "On Resume");
}
@Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mRegistrationBroadcastReceiver);
isReceiverRegistered = false;
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
mAuthService.dispose();
}
private void handleAuthorizationResponse(@NonNull Intent intent) {
AuthorizationResponse response = AuthorizationResponse.fromIntent(intent);
AuthorizationException error = AuthorizationException.fromIntent(intent);
if (response != null) {
authCode = response.authorizationCode;
Log.d(TAG, "Received AuthorizationResponse: " + "AuthCode: " + authCode);
Toast.makeText(this,
"AuthCode: " + authCode, Toast.LENGTH_SHORT)
.show();
if (checkPlayServices()) {
Intent registerIntent = new Intent(this, RegistrationIntentService.class);
startService(registerIntent);
}
//
} else {
Log.i(TAG, "Authorization failed: " + error.getMessage());
Toast.makeText(this,
"Authorization failed", Toast.LENGTH_LONG)
.show();
}
}
private void makeAuthRequest(@NonNull AuthorizationServiceConfiguration serviceConfig) {
AuthorizationRequest authRequest = new AuthorizationRequest.Builder(
serviceConfig,
clientId,
"code",
redirectUri)
.setScope("basic profile picture sex ldap phone insti_address program secondary_emails")
.build();
Log.d(TAG, "Making auth request");
String action = "HANDLE_AUTHORIZATION_RESPONSE";
Intent postAuthorizationIntent = new Intent(action);
PendingIntent pendingIntent = PendingIntent.getActivity(this, authRequest.hashCode(), postAuthorizationIntent, 0);
mAuthService.performAuthorizationRequest(
authRequest,
pendingIntent,
mAuthService.createCustomTabsIntentBuilder()
.setToolbarColor(getCustomTabColor())
.build());
}
//TODO: Change the color of Chrome custom tabs based on app theme color
@TargetApi(Build.VERSION_CODES.M)
@SuppressWarnings("deprecation")
private int getCustomTabColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return getColor(R.color.colorPrimaryDark);
} else {
return getResources().getColor(R.color.colorPrimaryDark);
}
}
private void login(String authorizationCode, final String redirectURI, String gcmID) {
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.login(authorizationCode, redirectURI, gcmID).enqueue(new Callback<LoginResponse>() {
@Override
public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
if (response.isSuccessful()) {
Log.d(TAG, "Login request successful");
session.createLoginSession(redirectURI, response.body().getUser(), response.body().getSessionID());
Intent i = new Intent(mContext, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
//Save credentials in AccountManager to keep user logged in
//Go to MainActivity
}
//Server error
}
@Override
public void onFailure(Call<LoginResponse> call, Throwable t) {
//Network Error
}
});
}
private void registerReceiver() {
if (!isReceiverRegistered) {
LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
new IntentFilter(Constants.REGISTRATION_COMPLETE));
isReceiverRegistered = true;
}
}
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
}
package in.ac.iitb.gymkhana.iitbapp;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.squareup.picasso.Picasso;
import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse;
import in.ac.iitb.gymkhana.iitbapp.data.User;
import in.ac.iitb.gymkhana.iitbapp.fragment.AboutFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.CMSFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.CalendarFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.ContactsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.GCRankingsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.MessMenuFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.MyEventsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.NotificationsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.PTCellFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.TimetableFragment;
import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION;
import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
import static in.ac.iitb.gymkhana.iitbapp.Constants.RESULT_LOAD_IMAGE;
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
private static final String TAG = "MainActivity";
SessionManager session;
NotificationsResponse notificationsResponse;
private User currentUser;
private boolean showNotifications = false;
FeedFragment feedFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
session = new SessionManager(getApplicationContext());
session.checkLogin();
Toast.makeText(getApplicationContext(), "Log In status: " + session.isLoggedIn(), Toast.LENGTH_LONG).show();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
feedFragment = new FeedFragment();
updateFragment(feedFragment);
// fetchNotifications();
}
@Override
protected void onStart() {
super.onStart();
if (session.isLoggedIn()) {
currentUser = User.fromString(session.pref.getString(Constants.CURRENT_USER, "Error"));
updateNavigationView();
}
}
private void updateNavigationView() {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
View header = navigationView.getHeaderView(0);
header.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle bundle = new Bundle();
bundle.putString(Constants.USER_ID, currentUser.getUserID());
ProfileFragment profileFragment = new ProfileFragment();
profileFragment.setArguments(bundle);
updateFragment(profileFragment);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
});
TextView nameTextView = header.findViewById(R.id.user_name_nav_header);
TextView rollNoTextView = header.findViewById(R.id.user_rollno_nav_header);
ImageView profilePictureImageView = header.findViewById(R.id.user_profile_picture_nav_header);
nameTextView.setText(currentUser.getUserName());
rollNoTextView.setText(currentUser.getUserRollNumber());
Picasso.with(this).load(currentUser.getUserProfilePictureUrl()).into(profilePictureImageView);
}
// private void fetchNotifications() {
// NotificationsRequest notificationsRequest = new NotificationsRequest(0, 20);
// RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
// retrofitInterface.getNotifications(notificationsRequest).enqueue(new Callback<NotificationsResponse>() {
// @Override
// public void onResponse(Call<NotificationsResponse> call, Response<NotificationsResponse> response) {
// if (response.isSuccessful()) {
// notificationsResponse = response.body();
// if (showNotifications) {
// showNotifications();
// showNotifications = false;
// }
// }
// //Server Error
// }
//
// @Override
// public void onFailure(Call<NotificationsResponse> call, Throwable t) {
// //Network Error
// }
// });
// }
public void showNotifications() {
String notificationsResponseJson = new Gson().toJson(notificationsResponse);
Bundle bundle = new Bundle();
bundle.putString(Constants.NOTIFICATIONS_RESPONSE_JSON, notificationsResponseJson);
NotificationsFragment notificationsFragment = new NotificationsFragment();
notificationsFragment.setArguments(bundle);
updateFragment(notificationsFragment);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else if (feedFragment != null && feedFragment.isVisible()) {
finish();
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_notifications) {
showNotifications = true;
// fetchNotifications();
return true;
}
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
switch (id) {
case R.id.nav_feed:
feedFragment = new FeedFragment();
updateFragment(feedFragment);
break;
case R.id.nav_my_events:
MyEventsFragment myeventsFragment = new MyEventsFragment();
updateFragment(myeventsFragment);
break;
case R.id.nav_pt_cell:
PTCellFragment ptcellFragment = new PTCellFragment();
updateFragment(ptcellFragment);
break;
case R.id.nav_mess_menu:
MessMenuFragment messmenuFragment = new MessMenuFragment();
updateFragment(messmenuFragment);
break;
case R.id.nav_gc_rankings:
GCRankingsFragment gcrankingsFragment = new GCRankingsFragment();
updateFragment(gcrankingsFragment);
break;
case R.id.nav_calendar:
CalendarFragment calendarFragment = new CalendarFragment();
updateFragment(calendarFragment);
break;
case R.id.nav_cms:
CMSFragment cmsFragment = new CMSFragment();
updateFragment(cmsFragment);
break;
case R.id.nav_timetable:
TimetableFragment timetableFragment = new TimetableFragment();
updateFragment(timetableFragment);
break;
case R.id.nav_map:
MapFragment mapFragment = new MapFragment();
if (ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
updateFragment(mapFragment);
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSIONS_REQUEST_ACCESS_LOCATION);
}
break;
case R.id.nav_contacts:
ContactsFragment contactsFragment = new ContactsFragment();
updateFragment(contactsFragment);
break;
case R.id.nav_about:
AboutFragment aboutFragment = new AboutFragment();
updateFragment(aboutFragment);
break;
case R.id.nav_people:
PeopleFragment peopleFragment = new PeopleFragment();
updateFragment(peopleFragment);
break;
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
public void updateFragment(Fragment fragment) {
Log.d(TAG, "updateFragment: " + fragment.toString());
Bundle bundle = fragment.getArguments();
if (bundle == null) {
bundle = new Bundle();
}
bundle.putString(Constants.SESSION_ID, session.pref.getString(Constants.SESSION_ID, "Error"));
fragment.setArguments(bundle);
FragmentManager manager = getSupportFragmentManager();
if (fragment instanceof FeedFragment)
manager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, fragment, fragment.getTag());
transaction.addToBackStack(fragment.getTag()).commit();
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE:
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
return;
case MY_PERMISSIONS_REQUEST_ACCESS_LOCATION:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
MapFragment mapFragment = new MapFragment();
updateFragment(mapFragment);
} else {
Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT);
toast.show();
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
for (Fragment fragment : getSupportFragmentManager().getFragments()) {
fragment.onActivityResult(requestCode, resultCode, data);
for (Fragment subfragment : fragment.getChildFragmentManager().getFragments()) {
subfragment.onActivityResult(requestCode, resultCode, data);
}
}
}
}
package in.ac.iitb.gymkhana.iitbapp;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
/**
* Created by mrunz on 6/7/17.
*/
public class PeopleSuggestionAdapter extends BaseAdapter implements Filterable {
List mData;
List mStringFilterList;
ValueFilter valueFilter;
private LayoutInflater inflater;
public PeopleSuggestionAdapter(List cancel_type) {
mData = cancel_type;
mStringFilterList = cancel_type;
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int position) {
return mData.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, final ViewGroup parent) {
if (inflater == null) {
inflater = (LayoutInflater) parent.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
View view = inflater.inflate(R.layout.ppl_search_suggestion_item_view, parent, false);
TextView tv_suggestion = (TextView) view.findViewById(R.id.suggestion_item);
tv_suggestion.setText(mData.get(position).toString());
return view;
}
@Override
public Filter getFilter() {
if (valueFilter == null) {
valueFilter = new ValueFilter();
}
return valueFilter;
}
private class ValueFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
if (constraint != null && constraint.length() > 0) {
List filterList = new ArrayList();
for (int i = 0; i < mStringFilterList.size(); i++) {
if ((mStringFilterList.get(i).toString().toUpperCase()).contains(constraint.toString().toUpperCase())) {
filterList.add(mStringFilterList.get(i));
}
}
results.count = filterList.size();
results.values = filterList;
} else {
results.count = mStringFilterList.size();
results.values = mStringFilterList;
}
return results;
}
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
mData = (List) results.values;
notifyDataSetChanged();
}
}
}
\ No newline at end of file
package in.ac.iitb.gymkhana.iitbapp;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
import in.ac.iitb.gymkhana.iitbapp.data.User;
public class SessionManager {
SharedPreferences pref;
Editor editor;
Context context;
int PRIVATE_MODE = 0;
public SessionManager(Context context) {
this.context = context;
pref = context.getSharedPreferences(Constants.PREF_NAME, PRIVATE_MODE);
editor = pref.edit();
}
public void checkLogin() {
if (!this.isLoggedIn()) {
Intent i = new Intent(context, LoginActivity.class);
// Closing all the Activities
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// Add new Flag to start new Activity
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Staring Login Activity
context.startActivity(i);
}
}
public void createLoginSession(String gcmId, User currentUser, String sessionID) {
Log.d("SessionManager", "GcmId being stored");
editor.putBoolean(Constants.IS_LOGGED_IN, true);
editor.putString(Constants.GCM_ID, gcmId);
editor.putString(Constants.CURRENT_USER, currentUser.toString());
editor.putString(Constants.SESSION_ID, sessionID);
editor.commit();
}
public boolean isLoggedIn() {
return pref.getBoolean(Constants.IS_LOGGED_IN, false);
}
}
package in.ac.iitb.gymkhana.iitbapp;
import in.ac.iitb.gymkhana.iitbapp.data.Event;
/**
* Created by varun on 03-Apr-18.
*/
public final class ShareURLMaker {
public static final String WEB_HOST = "https://insti.app/";
public static final String getEventURL(Event event) {
return WEB_HOST + "event/" + event.getEventStrID();
}
}
package in.ac.iitb.gymkhana.iitbapp.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.data.Event;
import in.ac.iitb.gymkhana.iitbapp.data.Venue;
public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
private List<Event> posts;
private Context context;
private ItemClickListener itemClickListener;
public FeedAdapter(List<Event> posts, ItemClickListener itemClickListener) {
this.posts = posts;
this.itemClickListener = itemClickListener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
context = viewGroup.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View postView = inflater.inflate(R.layout.feed_card, viewGroup, false);
final ViewHolder postViewHolder = new ViewHolder(postView);
postView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemClickListener.onItemClick(v, postViewHolder.getAdapterPosition());
}
});
return postViewHolder;
}
@Override
public void onBindViewHolder(ViewHolder viewHolder, int i) {
Event currentEvent = posts.get(i);
viewHolder.eventTitle.setText(currentEvent.getEventName());
// viewHolder.eventDetails.setText(currentEvent.getEventDescription());
Timestamp timestamp = currentEvent.getEventStartTime();
if (timestamp != null) {
Date Date = new Date(timestamp.getTime());
SimpleDateFormat simpleDateFormatDate = new SimpleDateFormat("dd MMM");
SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm a");
viewHolder.eventDate.setText(simpleDateFormatDate.format(Date));
viewHolder.eventTime.setText(simpleDateFormatTime.format(Date));
}
StringBuilder eventVenueName = new StringBuilder();
for (Venue venue : currentEvent.getEventVenues()) {
eventVenueName.append(", ").append(venue.getVenueName());
}
if (!eventVenueName.toString().equals(""))
viewHolder.eventVenue.setText(eventVenueName.toString().substring(2));
Picasso.with(context).load(currentEvent.getEventImageURL()).resize(320, 0).into(viewHolder.eventPicture);
}
@Override
public int getItemCount() {
return posts.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private ImageView eventPicture;
private TextView eventTitle;
// private TextView eventDetails;
private TextView eventDate;
private TextView eventTime;
private TextView eventVenue;
private ImageView eventEnthu;
public ViewHolder(View itemView) {
super(itemView);
eventPicture = (ImageView) itemView.findViewById(R.id.event_picture);
eventTitle = (TextView) itemView.findViewById(R.id.event_title);
// eventDetails = (TextView) itemView.findViewById(R.id.event_details);
eventDate = (TextView) itemView.findViewById(R.id.event_date);
eventTime = (TextView) itemView.findViewById(R.id.event_time);
eventVenue = (TextView) itemView.findViewById(R.id.event_venue);
}
}
}
package in.ac.iitb.gymkhana.iitbapp.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.api.model.AppNotification;
public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdapter.Viewholder> {
private List<AppNotification> notifications;
private Context context;
private ItemClickListener itemClickListener;
public NotificationsAdapter(List<AppNotification> notifications, ItemClickListener itemClickListener) {
this.notifications = notifications;
this.itemClickListener = itemClickListener;
}
@Override
public Viewholder onCreateViewHolder(ViewGroup viewGroup, int i) {
context = viewGroup.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View notificationView = inflater.inflate(R.layout.notification, viewGroup, false);
final Viewholder notificationsViewHolder = new Viewholder(notificationView);
notificationView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemClickListener.onItemClick(v, notificationsViewHolder.getAdapterPosition());
}
});
return notificationsViewHolder;
}
@Override
public void onBindViewHolder(Viewholder viewholder, int i) {
AppNotification appNotification = notifications.get(i);
viewholder.notificationTitle.setText(appNotification.getNotificationName());
}
@Override
public int getItemCount() {
return notifications.size();
}
public class Viewholder extends RecyclerView.ViewHolder {
private TextView notificationTitle;
public Viewholder(View itemView) {
super(itemView);
notificationTitle = (TextView) itemView.findViewById(R.id.notification_title);
}
}
}
package in.ac.iitb.gymkhana.iitbapp.api;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedResponse;
import in.ac.iitb.gymkhana.iitbapp.data.User;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
public interface RetrofitInterface {
@GET("login")
Call<LoginResponse> login(@Query("code") String AUTH_CODE, @Query("redir") String redirectURI, @Query("fcm_id") String fcmID);
@POST("events")
Call<EventCreateResponse> createEvent(@Header("Cookie") String sessionId, @Body EventCreateRequest eventCreateRequest);
@GET("events")
Call<NewsFeedResponse> getNewsFeed(@Header("Cookie") String sessionId);
@GET("users/{uuid}")
Call<User> getUser(@Header("Cookie") String sessionId, @Path("uuid") String uuid);
@POST("upload")
Call<ImageUploadResponse> uploadImage(@Header("Cookie") String sessionID, @Body ImageUploadRequest imageUploadRequest);
@GET("user-me/ues/{eventID}")
Call<Void> updateUserEventStatus(@Header("Cookie") String sessionID, @Path("eventID") String eventID, @Query("status") int status);
// @POST("getNotifications/")
// Call<NotificationsResponse> getNotifications(@Body NotificationsRequest notificationsRequest);
}
package in.ac.iitb.gymkhana.iitbapp.api;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ServiceGenerator {
private static final String BASE_URL = "https://instiapp.wncc-iitb.org/api/";
private static OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
private static Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create());
private static Retrofit retrofit;
public static <S> S createService(Class<S> serviceClass) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
retrofit = retrofitBuilder.client(clientBuilder.addInterceptor(httpLoggingInterceptor).build()).build();
return retrofit.create(serviceClass);
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
public class AppNotification {
@SerializedName("notification_type")
private int notificationType;
@SerializedName("notification_id")
private String notificationId;
@SerializedName("notification_related_id")
private String notificationRelatedId;
@SerializedName("notification_name")
private String notificationName;
@SerializedName("notification_description")
private String notificationDescription;
@SerializedName("notification_image")
private String notificationImage;
public AppNotification(int notificationType, String notificationId, String notificationRelatedId, String notificationName, String notificationDescription, String notificationImage) {
this.notificationType = notificationType;
this.notificationId = notificationId;
this.notificationRelatedId = notificationRelatedId;
this.notificationName = notificationName;
this.notificationDescription = notificationDescription;
this.notificationImage = notificationImage;
}
public int getNotificationType() {
return notificationType;
}
public void setNotificationType(int notificationType) {
this.notificationType = notificationType;
}
public String getNotificationId() {
return notificationId;
}
public void setNotificationId(String notificationId) {
this.notificationId = notificationId;
}
public String getNotificationRelatedId() {
return notificationRelatedId;
}
public void setNotificationRelatedId(String notificationRelatedId) {
this.notificationRelatedId = notificationRelatedId;
}
public String getNotificationName() {
return notificationName;
}
public void setNotificationName(String notificationName) {
this.notificationName = notificationName;
}
public String getNotificationDescription() {
return notificationDescription;
}
public void setNotificationDescription(String notificationDescription) {
this.notificationDescription = notificationDescription;
}
public String getNotificationImage() {
return notificationImage;
}
public void setNotificationImage(String notificationImage) {
this.notificationImage = notificationImage;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class EventCreateRequest {
@SerializedName("name")
private String eventName;
@SerializedName("description")
private String eventDescription;
@SerializedName("image_url")
private String eventImageURL;
@SerializedName("start_time")
private String eventStartTime;
@SerializedName("end_time")
private String eventEndTime;
@SerializedName("all_day")
private boolean allDayEvent;
@SerializedName("venue_names")
private List<String> eventVenueNames;
@SerializedName("bodies_id")
private List<String> eventBodiesID;
public EventCreateRequest(String eventName, String eventDescription, String eventImageURL, String eventStartTime, String eventEndTime, boolean allDayEvent, List<String> eventVenueNames, List<String> eventBodiesID) {
this.eventName = eventName;
this.eventDescription = eventDescription;
this.eventImageURL = eventImageURL;
this.eventStartTime = eventStartTime;
this.eventEndTime = eventEndTime;
this.allDayEvent = allDayEvent;
this.eventVenueNames = eventVenueNames;
this.eventBodiesID = eventBodiesID;
}
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public String getEventDescription() {
return eventDescription;
}
public void setEventDescription(String eventDescription) {
this.eventDescription = eventDescription;
}
public String getEventImageURL() {
return eventImageURL;
}
public void setEventImageURL(String eventImageURL) {
this.eventImageURL = eventImageURL;
}
public String getEventStartTime() {
return eventStartTime;
}
public void setEventStartTime(String eventStartTime) {
this.eventStartTime = eventStartTime;
}
public String getEventEndTime() {
return eventEndTime;
}
public void setEventEndTime(String eventEndTime) {
this.eventEndTime = eventEndTime;
}
public boolean isAllDayEvent() {
return allDayEvent;
}
public void setAllDayEvent(boolean allDayEvent) {
this.allDayEvent = allDayEvent;
}
public List<String> getEventVenueNames() {
return eventVenueNames;
}
public void setEventVenueNames(List<String> eventVenueNames) {
this.eventVenueNames = eventVenueNames;
}
public List<String> getEventBodiesID() {
return eventBodiesID;
}
public void setEventBodiesID(List<String> eventBodiesID) {
this.eventBodiesID = eventBodiesID;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
/**
* Created by mrunz on 15/7/17.
*/
public class EventCreateResponse {
private String result;
private String eventId;
public EventCreateResponse(String result, String eventId) {
this.result = result;
this.eventId = eventId;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
public class ImageUploadRequest {
@SerializedName("picture")
private String base64Image;
public ImageUploadRequest(String base64Image) {
this.base64Image = base64Image;
}
public String getBase64Image() {
return base64Image;
}
public void setBase64Image(String base64Image) {
this.base64Image = base64Image;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
public class ImageUploadResponse {
@SerializedName("id")
private String pictureID;
@SerializedName("picture")
private String pictureURL;
public ImageUploadResponse(String pictureID, String pictureURL) {
this.pictureID = pictureID;
this.pictureURL = pictureURL;
}
public String getPictureID() {
return pictureID;
}
public void setPictureID(String pictureID) {
this.pictureID = pictureID;
}
public String getPictureURL() {
return pictureURL;
}
public void setPictureURL(String pictureURL) {
this.pictureURL = pictureURL;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
import in.ac.iitb.gymkhana.iitbapp.data.User;
public class LoginResponse {
@SerializedName("sessionid")
private String sessionID;
@SerializedName("user")
private int userID;
@SerializedName("profile_id")
private String profileID;
@SerializedName("profile")
private User user;
public LoginResponse(String sessionID, int userID, String profileID, User user) {
this.sessionID = sessionID;
this.userID = userID;
this.profileID = profileID;
this.user = user;
}
public String getSessionID() {
return sessionID;
}
public void setSessionID(String sessionID) {
this.sessionID = sessionID;
}
public int getUserID() {
return userID;
}
public void setUserID(int userID) {
this.userID = userID;
}
public String getProfileID() {
return profileID;
}
public void setProfileID(String profileID) {
this.profileID = profileID;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.data.Event;
public class NewsFeedResponse {
@SerializedName("data")
private List<Event> events;
@SerializedName("count")
private int count;
public NewsFeedResponse(List<Event> events, int count) {
this.events = events;
this.count = count;
}
public List<Event> getEvents() {
return events;
}
public void setEvents(List<Event> events) {
this.events = events;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
public class NotificationsRequest {
private int from;
private int to;
public NotificationsRequest(int from, int to) {
this.from = from;
this.to = to;
}
public int getFrom() {
return from;
}
public void setFrom(int from) {
this.from = from;
}
public int getTo() {
return to;
}
public void setTo(int to) {
this.to = to;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import java.util.List;
public class NotificationsResponse {
private String result;
private List<AppNotification> notifications;
public NotificationsResponse(String result, List<AppNotification> notifications) {
this.result = result;
this.notifications = notifications;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public List<AppNotification> getNotifications() {
return notifications;
}
public void setNotifications(List<AppNotification> notifications) {
this.notifications = notifications;
}
}
package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;
import android.content.Context;
/**
* Created by mrunz on 14/3/18.
*/
@Database(entities = {Event.class, Body.class, Venue.class}, version = 1)
@TypeConverters({Converters.class})
public abstract class AppDatabase extends RoomDatabase {
private static AppDatabase INSTANCE;
public static AppDatabase getAppDatabase(Context context) {
if (INSTANCE == null) {
INSTANCE =
Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, "database")
// allow queries on the main thread.
// Don't do this on a real app! See PersistenceBasicSample for an example.
.allowMainThreadQueries()
.build();
}
return INSTANCE;
}
public static void destroyInstance() {
INSTANCE = null;
}
public abstract DbDao dbDao();
}
package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import com.google.gson.annotations.SerializedName;
import java.util.List;
@Entity(tableName = "bodies")
class Body {
@PrimaryKey(autoGenerate = true)
int db_id;
@ColumnInfo(name = "id")
@SerializedName("id")
String bodyID;
@ColumnInfo(name = "name")
@SerializedName("name")
String bodyName;
@ColumnInfo(name = "description")
@SerializedName("description")
String bodyDescription;
@ColumnInfo(name = "image_url")
@SerializedName("image_url")
String bodyImageURL;
@ColumnInfo(name = "children")
@SerializedName("children")
List<Body> bodyChildren;
@ColumnInfo(name = "parents")
@SerializedName("parents")
List<Body> bodyParents;
@ColumnInfo(name = "events")
@SerializedName("events")
List<Event> bodyEvents;
@ColumnInfo(name = "followers_count")
@SerializedName("followers_count")
int bodyFollowersCount;
public Body(String bodyID, String bodyName, String bodyDescription, String bodyImageURL, List<Body> bodyChildren, List<Body> bodyParents, List<Event> bodyEvents, int bodyFollowersCount) {
this.bodyID = bodyID;
this.bodyName = bodyName;
this.bodyDescription = bodyDescription;
this.bodyImageURL = bodyImageURL;
this.bodyChildren = bodyChildren;
this.bodyParents = bodyParents;
this.bodyEvents = bodyEvents;
this.bodyFollowersCount = bodyFollowersCount;
}
public String getBodyID() {
return bodyID;
}
public void setBodyID(String bodyID) {
this.bodyID = bodyID;
}
public String getBodyName() {
return bodyName;
}
public void setBodyName(String bodyName) {
this.bodyName = bodyName;
}
public String getBodyDescription() {
return bodyDescription;
}
public void setBodyDescription(String bodyDescription) {
this.bodyDescription = bodyDescription;
}
public String getBodyImageURL() {
return bodyImageURL;
}
public void setBodyImageURL(String bodyImageURL) {
this.bodyImageURL = bodyImageURL;
}
public List<Body> getBodyChildren() {
return bodyChildren;
}
public void setBodyChildren(List<Body> bodyChildren) {
this.bodyChildren = bodyChildren;
}
public List<Body> getBodyParents() {
return bodyParents;
}
public void setBodyParents(List<Body> bodyParents) {
this.bodyParents = bodyParents;
}
public List<Event> getBodyEvents() {
return bodyEvents;
}
public void setBodyEvents(List<Event> bodyEvents) {
this.bodyEvents = bodyEvents;
}
public int getBodyFollowersCount() {
return bodyFollowersCount;
}
public void setBodyFollowersCount(int bodyFollowersCount) {
this.bodyFollowersCount = bodyFollowersCount;
}
}
\ No newline at end of file
package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.TypeConverter;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.util.List;
/**
* Created by mrunz on 14/3/18.
*/
public class Converters {
@TypeConverter
public static List<Event> eventsfromString(String value) {
Type listType = new TypeToken<List<Event>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromEvents(List<Event> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
@TypeConverter
public static List<User> usersfromString(String value) {
Type listType = new TypeToken<List<User>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromUsers(List<User> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
@TypeConverter
public static List<Venue> venuesfromString(String value) {
Type listType = new TypeToken<List<Venue>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromVenues(List<Venue> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
@TypeConverter
public static List<Body> bodiesfromString(String value) {
Type listType = new TypeToken<List<Body>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromBodies(List<Body> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
@TypeConverter
public static Timestamp timestampfromString(String value) {
try {
return new Gson().fromJson(value, Timestamp.class);
} catch (JsonSyntaxException e) {
Log.d("Converters", "timestampfromString: " + value);
e.printStackTrace();
return null;
}
}
@TypeConverter
public static String stringfromTimestamp(Timestamp timestamp) {
Gson gson = new Gson();
String json = gson.toJson(timestamp);
return json;
}
}
\ No newline at end of file
package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import java.util.List;
/**
* Created by mrunz on 13/3/18.
*/
@Dao
public interface DbDao {
@Query("SELECT * FROM events")
List<Event> getAllEvents();
@Query("SELECT * FROM bodies")
List<Body> getAllBodies();
@Query("SELECT * FROM venues")
List<Venue> getAllVenues();
@Query("SELECT COUNT(*) from events")
int countEvents();
@Query("SELECT COUNT(*) from venues")
int countVenues();
@Query("SELECT COUNT(*) from bodies")
int countBodies();
@Insert
void insertEvents(List<Event> events);
@Insert
void insertBodies(List<Body> bodies);
@Insert
void insertVenues(List<Venue> venues);
@Delete
void deleteEvent(Event event);
@Delete
void deleteVenue(Venue venue);
@Delete
void deleteBody(Body body);
@Query("DELETE from events")
void deleteEvents();
@Query("DELETE from venues")
void deleteVenues();
@Query("DELETE from bodies")
void deleteBodies();
}
package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp;
import java.util.List;
@Entity(tableName = "events")
public class Event {
@PrimaryKey(autoGenerate = true)
int db_id;
@ColumnInfo(name = "id")
@SerializedName("id")
String eventID;
@ColumnInfo(name = "str_id")
@SerializedName("str_id")
String eventStrID;
@ColumnInfo(name = "name")
@SerializedName("name")
String eventName;
@ColumnInfo(name = "description")
@SerializedName("description")
String eventDescription;
@ColumnInfo(name = "image_url")
@SerializedName("image_url")
String eventImageURL;
@ColumnInfo(name = "start_time")
@SerializedName("start_time")
Timestamp eventStartTime;
@ColumnInfo(name = "end_time")
@SerializedName("end_time")
Timestamp eventEndTime;
@ColumnInfo(name = "all_day")
@SerializedName("all_day")
boolean allDayEvent;
@ColumnInfo(name = "venues")
@SerializedName("venues")
List<Venue> eventVenues;
@ColumnInfo(name = "bodies")
@SerializedName("bodies")
List<Body> eventBodies;
@ColumnInfo(name = "interested_count")
@SerializedName("interested_count")
int eventInterestedCount;
@ColumnInfo(name = "going_count")
@SerializedName("going_count")
int eventGoingCount;
@ColumnInfo(name = "interested")
@SerializedName("interested")
List<User> eventInterested;
@ColumnInfo(name = "going")
@SerializedName("going")
List<User> eventGoing;
public Event(String eventID, String eventName, String eventDescription, String eventImageURL, Timestamp eventStartTime, Timestamp eventEndTime, boolean allDayEvent, List<Venue> eventVenues, List<Body> eventBodies, int eventInterestedCount, int eventGoingCount, List<User> eventInterested, List<User> eventGoing) {
this.eventID = eventID;
this.eventName = eventName;
this.eventDescription = eventDescription;
this.eventImageURL = eventImageURL;
this.eventStartTime = eventStartTime;
this.eventEndTime = eventEndTime;
this.allDayEvent = allDayEvent;
this.eventVenues = eventVenues;
this.eventBodies = eventBodies;
this.eventInterestedCount = eventInterestedCount;
this.eventGoingCount = eventGoingCount;
this.eventInterested = eventInterested;
this.eventGoing = eventGoing;
}
public String getEventID() {
return eventID;
}
public void setEventID(String eventID) {
this.eventID = eventID;
}
public String getEventStrID() {
return eventStrID;
}
public void setEventStrID(String eventStrID) {
this.eventStrID = eventStrID;
}
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public String getEventDescription() {
return eventDescription;
}
public void setEventDescription(String eventDescription) {
this.eventDescription = eventDescription;
}
public String getEventImageURL() {
return eventImageURL;
}
public void setEventImageURL(String eventImageURL) {
this.eventImageURL = eventImageURL;
}
public Timestamp getEventStartTime() {
return eventStartTime;
}
public void setEventStartTime(Timestamp eventStartTime) {
this.eventStartTime = eventStartTime;
}
public Timestamp getEventEndTime() {
return eventEndTime;
}
public void setEventEndTime(Timestamp eventEndTime) {
this.eventEndTime = eventEndTime;
}
public boolean isAllDayEvent() {
return allDayEvent;
}
public void setAllDayEvent(boolean allDayEvent) {
this.allDayEvent = allDayEvent;
}
public List<Venue> getEventVenues() {
return eventVenues;
}
public void setEventVenues(List<Venue> eventVenues) {
this.eventVenues = eventVenues;
}
public List<Body> getEventBodies() {
return eventBodies;
}
public void setEventBodies(List<Body> eventBodies) {
this.eventBodies = eventBodies;
}
public int getEventInterestedCount() {
return eventInterestedCount;
}
public void setEventInterestedCount(int eventInterestedCount) {
this.eventInterestedCount = eventInterestedCount;
}
public int getEventGoingCount() {
return eventGoingCount;
}
public void setEventGoingCount(int eventGoingCount) {
this.eventGoingCount = eventGoingCount;
}
public List<User> getEventInterested() {
return eventInterested;
}
public void setEventInterested(List<User> eventInterested) {
this.eventInterested = eventInterested;
}
public List<User> getEventGoing() {
return eventGoing;
}
public void setEventGoing(List<User> eventGoing) {
this.eventGoing = eventGoing;
}
}
package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.util.List;
@Entity(tableName = "users")
public class User {
@PrimaryKey(autoGenerate = true)
int db_id;
@ColumnInfo(name = "id")
@SerializedName("id")
String userID;
@ColumnInfo(name = "name")
@SerializedName("name")
String userName;
@ColumnInfo(name = "profile_pic")
@SerializedName("profile_pic")
String userProfilePictureUrl;
@ColumnInfo(name = "events_interested")
@SerializedName("events_interested")
List<Event> userInterestedEvents;
@ColumnInfo(name = "events_going")
@SerializedName("events_going")
List<Event> userGoingEvents;
@ColumnInfo(name = "email")
@SerializedName("email")
String userEmail;
@ColumnInfo(name = "year")
@SerializedName("year")
int userYear;
@ColumnInfo(name = "roll_no")
@SerializedName("roll_no")
String userRollNumber;
@ColumnInfo(name = "contact_no")
@SerializedName("contact_no")
String userContactNumber;
@ColumnInfo(name = "about")
@SerializedName("about")
String userAbout;
@ColumnInfo(name = "followed_bodies")
@SerializedName("followed_bodies")
List<Body> userFollowedBodies;
@ColumnInfo(name = "followed_bodies_id")
@SerializedName("followed_bodies_id")
List<String> userFollowedBodiesID;
public User(String userID, String userName, String userProfilePictureUrl, List<Event> userInterestedEvents, List<Event> userGoingEvents, String userEmail, int userYear, String userRollNumber, String userContactNumber, String userAbout, List<Body> userFollowedBodies, List<String> userFollowedBodiesID) {
this.userID = userID;
this.userName = userName;
this.userProfilePictureUrl = userProfilePictureUrl;
this.userInterestedEvents = userInterestedEvents;
this.userGoingEvents = userGoingEvents;
this.userEmail = userEmail;
this.userYear = userYear;
this.userRollNumber = userRollNumber;
this.userContactNumber = userContactNumber;
this.userAbout = userAbout;
this.userFollowedBodies = userFollowedBodies;
this.userFollowedBodiesID = userFollowedBodiesID;
}
public static User fromString(String json) {
return new Gson().fromJson(json, User.class);
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserProfilePictureUrl() {
return userProfilePictureUrl;
}
public void setUserProfilePictureUrl(String userProfilePictureUrl) {
this.userProfilePictureUrl = userProfilePictureUrl;
}
public List<Event> getUserInterestedEvents() {
return userInterestedEvents;
}
public void setUserInterestedEvents(List<Event> userInterestedEvents) {
this.userInterestedEvents = userInterestedEvents;
}
public List<Event> getUserGoingEvents() {
return userGoingEvents;
}
public void setUserGoingEvents(List<Event> userGoingEvents) {
this.userGoingEvents = userGoingEvents;
}
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
public int getUserYear() {
return userYear;
}
public void setUserYear(int userYear) {
this.userYear = userYear;
}
public String getUserRollNumber() {
return userRollNumber;
}
public void setUserRollNumber(String userRollNumber) {
this.userRollNumber = userRollNumber;
}
public String getUserContactNumber() {
return userContactNumber;
}
public void setUserContactNumber(String userContactNumber) {
this.userContactNumber = userContactNumber;
}
public String getUserAbout() {
return userAbout;
}
public void setUserAbout(String userAbout) {
this.userAbout = userAbout;
}
public List<Body> getUserFollowedBodies() {
return userFollowedBodies;
}
public void setUserFollowedBodies(List<Body> userFollowedBodies) {
this.userFollowedBodies = userFollowedBodies;
}
public List<String> getUserFollowedBodiesID() {
return userFollowedBodiesID;
}
public void setUserFollowedBodiesID(List<String> userFollowedBodiesID) {
this.userFollowedBodiesID = userFollowedBodiesID;
}
@Override
public String toString() {
return new Gson().toJson(this);
}
}
package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import com.google.gson.annotations.SerializedName;
@Entity(tableName = "venues")
public class Venue {
@PrimaryKey(autoGenerate = true)
int db_id;
@ColumnInfo(name = "id")
@SerializedName("id")
String venueID;
@ColumnInfo(name = "name")
@SerializedName("name")
String venueName;
@ColumnInfo(name = "lat")
@SerializedName("lat")
double venueLatitude;
@ColumnInfo(name = "lng")
@SerializedName("lng")
double venueLongitude;
public Venue(String venueID, String venueName, double venueLatitude, double venueLongitude) {
this.venueID = venueID;
this.venueName = venueName;
this.venueLatitude = venueLatitude;
this.venueLongitude = venueLongitude;
}
public String getVenueID() {
return venueID;
}
public void setVenueID(String venueID) {
this.venueID = venueID;
}
public String getVenueName() {
return venueName;
}
public void setVenueName(String venueName) {
this.venueName = venueName;
}
public double getVenueLatitude() {
return venueLatitude;
}
public void setVenueLatitude(double venueLatitude) {
this.venueLatitude = venueLatitude;
}
public double getVenueLongitude() {
return venueLongitude;
}
public void setVenueLongitude(double venueLongitude) {
this.venueLongitude = venueLongitude;
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
* A simple {@link Fragment} subclass.
*/
public class AboutFragment extends BaseFragment {
public AboutFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_about, container, false);
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.Manifest;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.app.TimePickerDialog;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import java.io.ByteArrayOutputStream;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Calendar;
import butterknife.BindView;
import butterknife.ButterKnife;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadResponse;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static android.app.Activity.RESULT_OK;
import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
import static in.ac.iitb.gymkhana.iitbapp.Constants.RESULT_LOAD_IMAGE;
public class AddEventFragment extends BaseFragment {
@BindView(R.id.button_createEvent)
Button createEvent;
@BindView(R.id.tv_start)
TextView start;
@BindView(R.id.et_eventName)
EditText eventName;
@BindView(R.id.tv_end)
TextView end;
@BindView(R.id.et_venue)
EditText venue;
@BindView(R.id.et_eventDetails)
EditText details;
@BindView(R.id.iv_eventImage)
ImageView eventImage;
@BindView(R.id.ib_eventImage)
ImageButton imageButton;
Timestamp timestamp_start;
Timestamp timestamp_end;
@BindView(R.id.advanced_menu)
RelativeLayout advancedMenu;
@BindView(R.id.cb_public)
CheckBox cb_public;
@BindView(R.id.cb_permission)
CheckBox cb_permission;
@BindView(R.id.map_location)
EditText et_mapLocation;
@BindView(R.id.open)
ImageView open;
@BindView(R.id.close)
ImageView close;
ImageView eventPictureImageView;
int publicStatus;
View view;
String base64Image;
ProgressDialog progressDialog;
String TAG = "AddEventFragment";
public AddEventFragment() {
// Required empty public constructor
}
public static String convertImageToString(Bitmap imageBitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
if (imageBitmap != null) {
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 60, stream);
byte[] byteArray = stream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
} else {
return null;
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
container.removeAllViews();
view = inflater.inflate(R.layout.fragment_add_event, container, false);
ButterKnife.bind(this, view);
eventPictureImageView = view.findViewById(R.id.ib_eventImage);
progressDialog = new ProgressDialog(getContext());
cb_permission.setVisibility(View.GONE);
cb_public.setVisibility(View.GONE);
et_mapLocation.setVisibility(View.GONE);
close.setVisibility(View.GONE);
open.setVisibility(View.VISIBLE);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calendar = Calendar.getInstance();
int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
final int mMin = calendar.get(Calendar.MINUTE);
long millis = calendar.getTimeInMillis();
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
start.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
}
}, mHour, mMin, true);
timePickerDialog.show();
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
timestamp_start = new Timestamp(millis);
}
});
end.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calendar = Calendar.getInstance();
int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
final int mMin = calendar.get(Calendar.MINUTE);
long millis = calendar.getTimeInMillis();
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
end.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
}
}, mHour, mMin, true);
timePickerDialog.show();
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
timestamp_end = new Timestamp(millis);
}
});
if (cb_permission.isChecked()) {
publicStatus = 1;
} else publicStatus = 0;
advancedMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (cb_public.getVisibility() == View.VISIBLE) {
open.setVisibility(View.VISIBLE);
close.setVisibility(View.GONE);
cb_permission.setVisibility(View.GONE);
cb_public.setVisibility(View.GONE);
et_mapLocation.setVisibility(View.GONE);
} else {
close.setVisibility(View.VISIBLE);
open.setVisibility(View.GONE);
cb_permission.setVisibility(View.VISIBLE);
cb_public.setVisibility(View.VISIBLE);
et_mapLocation.setVisibility(View.VISIBLE);
}
}
});
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
}
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
});
createEvent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.show();
sendImage();
}
});
return view;
}
private void sendImage() {
progressDialog.setMessage("Uploading Image");
ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.uploadImage("sessionid=" + getArguments().getString(Constants.SESSION_ID), imageUploadRequest).enqueue(new Callback<ImageUploadResponse>() {
@Override
public void onResponse(Call<ImageUploadResponse> call, Response<ImageUploadResponse> response) {
if (response.isSuccessful()) {
ImageUploadResponse imageUploadResponse = response.body();
String imageURL = imageUploadResponse.getPictureURL();
addEvent(imageURL);
}
}
@Override
public void onFailure(Call<ImageUploadResponse> call, Throwable t) {
progressDialog.dismiss();
}
});
}
public void addEvent(String eventImageURL) {
progressDialog.setMessage("Creating Event");
EventCreateRequest eventCreateRequest = new EventCreateRequest(eventName.getText().toString(), details.getText().toString(), eventImageURL, timestamp_start.toString(), timestamp_end.toString(), false, Arrays.asList(new String[]{venue.getText().toString()}), Arrays.asList(new String[]{"bde82d5e-f379-4b8a-ae38-a9f03e4f1c4a"}));
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.createEvent("sessionid=" + getArguments().getString(Constants.SESSION_ID), eventCreateRequest).enqueue(new Callback<EventCreateResponse>() {
@Override
public void onResponse(Call<EventCreateResponse> call, Response<EventCreateResponse> response) {
Toast.makeText(getContext(), "Event Created", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
@Override
public void onFailure(Call<EventCreateResponse> call, Throwable t) {
Toast.makeText(getContext(), "Event Creation Failed", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getActivity().getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
eventPictureImageView.setImageBitmap(getScaledBitmap(picturePath, imageButton.getWidth(), imageButton.getHeight()));
eventPictureImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
base64Image = convertImageToString(getScaledBitmap(picturePath, 800, 800));
Log.d(TAG, "onActivityResult: " + base64Image);
}
}
private Bitmap getScaledBitmap(String picturePath, int width, int height) {
BitmapFactory.Options sizeOptions = new BitmapFactory.Options();
sizeOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(picturePath, sizeOptions);
int inSampleSize = calculateInSampleSize(sizeOptions, width, height);
sizeOptions.inJustDecodeBounds = false;
sizeOptions.inSampleSize = inSampleSize;
return BitmapFactory.decodeFile(picturePath, sizeOptions);
}
private int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
// Calculate ratios of height and width to requested height and
// width
final int heightRatio = Math.round((float) height / (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
// Choose the smallest ratio as inSampleSize value, this will
// guarantee
// a final image with both dimensions larger than or equal to the
// requested height and width.
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.app.Activity;
import android.content.Context;
import android.support.v4.app.Fragment;
import in.ac.iitb.gymkhana.iitbapp.ActivityBuffer;
/**
* A simple {@link Fragment} subclass.
*/
public class BaseFragment extends Fragment {
/* Member Variables. */
private ActivityBuffer mActivityBuffer;
public BaseFragment() {
// Implement the Parent.
super();
// Allocate the ActivityBuffer.
this.mActivityBuffer = new ActivityBuffer();
}
@Override
public final void onAttach(final Context pContext) {
// Handle as usual.
super.onAttach(pContext);
// Is the Context an Activity?
if (pContext instanceof Activity) {
// Cast Accordingly.
final Activity lActivity = (Activity) pContext;
// Inform the ActivityBuffer.
this.getActivityBuffer().onContextGained(lActivity);
}
}
@Deprecated
@Override
public final void onAttach(final Activity pActivity) {
// Handle as usual.
super.onAttach(pActivity);
// Inform the ActivityBuffer.
this.getActivityBuffer().onContextGained(pActivity);
}
@Override
public final void onDetach() {
// Handle as usual.
super.onDetach();
// Inform the ActivityBuffer.
this.getActivityBuffer().onContextLost();
}
/* Getters. */
public final ActivityBuffer getActivityBuffer() {
return this.mActivityBuffer;
}
}
\ No newline at end of file
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CalendarView;
import android.widget.Toast;
import in.ac.iitb.gymkhana.iitbapp.MainActivity;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
* A simple {@link Fragment} subclass.
*/
public class CalendarFragment extends BaseFragment {
FloatingActionButton fab;
private View view;
private Toast toast;
public CalendarFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_calendar, container, false);
fab = (FloatingActionButton) view.findViewById(R.id.fab);
final CalendarView simpleCalendarView = (CalendarView) view.findViewById(R.id.simpleCalendarView); // get the reference of CalendarView
simpleCalendarView.setFirstDayOfWeek(1); // set Sunday as the first day of the week
simpleCalendarView.setWeekNumberColor(getResources().getColor(R.color.colorCalendarWeek));//setWeekNumberColor
simpleCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
if (toast != null) {
toast.cancel();
}
toast = Toast.makeText(getContext(), "Date: (" + dayOfMonth + "/" + (month + 1) + "/" + year + ")", Toast.LENGTH_LONG);
toast.show();
}
});
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AddEventFragment addEventFragment = new AddEventFragment();
((MainActivity) getActivity()).updateFragment(addEventFragment);
}
});
return view;
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.squareup.picasso.Picasso;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.ShareURLMaker;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.data.Event;
import in.ac.iitb.gymkhana.iitbapp.data.Venue;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import ru.noties.markwon.Markwon;
/**
* A simple {@link Fragment} subclass.
*/
public class EventFragment extends BaseFragment implements View.OnClickListener {
Event event;
Button goingButton;
Button interestedButton;
Button notGoingButton;
ImageButton shareEventButton;
String TAG = "EventFragment";
public EventFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_event, container, false);
}
@Override
public void onStart() {
super.onStart();
Bundle bundle = getArguments();
String eventJson = bundle.getString(Constants.EVENT_JSON);
Log.d(TAG, "onStart: " + eventJson);
event = new Gson().fromJson(eventJson, Event.class);
inflateViews(event);
}
private void inflateViews(final Event event) {
ImageView eventPicture = (ImageView) getActivity().findViewById(R.id.event_picture_2);
TextView eventTitle = (TextView) getActivity().findViewById(R.id.event_page_title);
TextView eventDate = (TextView) getActivity().findViewById(R.id.event_page_date);
TextView eventTime = (TextView) getActivity().findViewById(R.id.event_page_time);
TextView eventVenue = (TextView) getActivity().findViewById(R.id.event_page_venue);
TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_page_description);
goingButton = getActivity().findViewById(R.id.going_button);
interestedButton = getActivity().findViewById(R.id.interested_button);
notGoingButton = getActivity().findViewById(R.id.not_going_button);
shareEventButton = getActivity().findViewById(R.id.share_event_button);
Picasso.with(getContext()).load(event.getEventImageURL()).into(eventPicture);
eventTitle.setText(event.getEventName());
Markwon.setMarkdown(eventDescription, event.getEventDescription());
Timestamp timestamp = event.getEventStartTime();
Date Date = new Date(timestamp.getTime());
SimpleDateFormat simpleDateFormatDate = new SimpleDateFormat("dd MMM");
SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm a");
eventDate.setText(simpleDateFormatDate.format(Date));
eventTime.setText(simpleDateFormatTime.format(Date));
StringBuilder eventVenueName = new StringBuilder();
for (Venue venue : event.getEventVenues()) {
eventVenueName.append(", ").append(venue.getVenueName());
}
if (!eventVenueName.toString().equals(""))
eventVenue.setText(eventVenueName.toString().substring(2));
goingButton.setOnClickListener(this);
interestedButton.setOnClickListener(this);
notGoingButton.setOnClickListener(this);
shareEventButton.setOnClickListener(new View.OnClickListener() {
String shareUrl = ShareURLMaker.getEventURL(event);
@Override
public void onClick(View view) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
i.putExtra(Intent.EXTRA_TEXT, shareUrl);
startActivity(Intent.createChooser(i, "Share URL"));
}
});
}
@Override
public void onClick(View view) {
goingButton.setBackgroundColor(getResources().getColor(R.color.colorWhite));
interestedButton.setBackgroundColor(getResources().getColor(R.color.colorWhite));
notGoingButton.setBackgroundColor(getResources().getColor(R.color.colorWhite));
view.setBackgroundColor(getResources().getColor(R.color.colorAccent));
int status = 0;
switch (view.getId()) {
case R.id.going_button:
status = Constants.STATUS_GOING;
break;
case R.id.interested_button:
status = Constants.STATUS_INTERESTED;
break;
case R.id.not_going_button:
status = Constants.STATUS_NOT_GOING;
break;
}
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.updateUserEventStatus("sessionid=" + getArguments().getString(Constants.SESSION_ID), event.getEventID(), status).enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.isSuccessful()) {
//TODO: Set flag for details updated so as to not try again when connected
}
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
//TODO: Store the status offline and update when connected
Toast.makeText(getContext(), "Network Error", Toast.LENGTH_LONG).show();
}
});
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.app.Activity;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.gson.Gson;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.ActivityBuffer;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.adapter.FeedAdapter;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedResponse;
import in.ac.iitb.gymkhana.iitbapp.data.AppDatabase;
import in.ac.iitb.gymkhana.iitbapp.data.Event;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* A simple {@link Fragment} subclass.
*/
public class FeedFragment extends BaseFragment {
private RecyclerView feedRecyclerView;
private SwipeRefreshLayout feedSwipeRefreshLayout;
private AppDatabase appDatabase;
private FloatingActionButton fab;
public FeedFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_feed, container, false);
fab = (FloatingActionButton) view.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AddEventFragment addEventFragment = new AddEventFragment();
addEventFragment.setArguments(getArguments());
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
ft.replace(R.id.relative_layout, addEventFragment);
ft.addToBackStack("addEvent");
ft.commit();
}
});
return view;
}
@Override
public void onStart() {
super.onStart();
appDatabase = AppDatabase.getAppDatabase(getContext());
final List<Event> events = appDatabase.dbDao().getAllEvents();
displayEvents(events);
updateFeed();
feedSwipeRefreshLayout = getActivity().findViewById(R.id.feed_swipe_refresh_layout);
feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateFeed();
}
});
}
private void updateFeed() {
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getNewsFeed("sessionid=" + getArguments().getString(Constants.SESSION_ID)).enqueue(new Callback<NewsFeedResponse>() {
@Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) {
NewsFeedResponse newsFeedResponse = response.body();
List<Event> events = newsFeedResponse.getEvents();
displayEvents(events);
appDatabase.dbDao().deleteEvents();
appDatabase.dbDao().insertEvents(events);
}
//Server Error
feedSwipeRefreshLayout.setRefreshing(false);
}
@Override
public void onFailure(Call<NewsFeedResponse> call, Throwable t) {
//Network Error
feedSwipeRefreshLayout.setRefreshing(false);
}
});
}
private void displayEvents(final List<Event> events) {
final FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
String eventJson = new Gson().toJson(events.get(position));
Bundle bundle = getArguments();
if (bundle == null)
bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
transaction.addToBackStack(eventFragment.getTag()).commit();
}
});
getActivityBuffer().safely(new ActivityBuffer.IRunnable() {
@Override
public void run(Activity pActivity) {
try {
feedRecyclerView = getActivity().findViewById(R.id.feed_recycler_view);
feedRecyclerView.setAdapter(feedAdapter);
feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
} catch (NullPointerException e) {
e.printStackTrace();
}
}
});
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.Manifest;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.location.Location;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStates;
import com.google.android.gms.location.LocationSettingsStatusCodes;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.R;
import static android.content.Context.LOCATION_SERVICE;
public class MapFragment extends BaseFragment implements OnMapReadyCallback, LocationListener,
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
SupportMapFragment gMapFragment;
GoogleMap googleMap;
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
Marker mCurrLocationMarker;
LocationRequest mLocationRequest;
private FloatingActionButton locationButton;
private Location currentLocation;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_map, container, false);
gMapFragment = (SupportMapFragment) this.getChildFragmentManager().findFragmentById(R.id.viewMap);
gMapFragment.getMapAsync(this);
return view;
}
@Override
public void onStart() {
super.onStart();
locationButton = (FloatingActionButton) getActivity().findViewById(R.id.location_button);
locationButton.setImageResource(R.drawable.ic_my_location_black_24dp);
locationButton.getDrawable().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorPrimaryDark), PorterDuff.Mode.SRC_IN);
locationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.v("MapFragment", "Location button pressed");
try {
LocationManager lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
boolean gps_enabled = false;
boolean network_enabled = false;
if (ActivityCompat.checkSelfPermission(getActivity(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, Constants.MY_PERMISSIONS_REQUEST_LOCATION);
return;
}
try {
gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch (Exception ex) {
}
try {
network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
} catch (Exception ex) {
}
if (!gps_enabled && !network_enabled) {
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(30 * 1000);
locationRequest.setFastestInterval(5 * 1000);
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
.addLocationRequest(locationRequest);
//**************************
builder.setAlwaysShow(true); //this is the key ingredient
//**************************
PendingResult<LocationSettingsResult> result =
LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
final LocationSettingsStates state = result.getLocationSettingsStates();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied. The client can initialize location
// requests here.
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied. But could be fixed by showing the user
// a dialog.
try {
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult().
status.startResolutionForResult(
getActivity(), 1000);
} catch (IntentSender.SendIntentException e) {
// Ignore the error.
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
// Location settings are not satisfied. However, we have no way to fix the
// settings so we won't show the dialog.
break;
}
}
});
}
currentLocation = getLastKnownLocation();
if (currentLocation != null) {
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()), 17);
googleMap.animateCamera(cameraUpdate);
locationButton.getDrawable().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
}
} catch (Exception e) {
checkLocationPermission();
Toast.makeText(getContext(), "Please turn on Location from the Settings", Toast.LENGTH_SHORT).show();
}
}
});
}
private Location getLastKnownLocation() {
//Create a location manager object instance
LocationManager mLocationManager = (LocationManager) getContext().getSystemService(LOCATION_SERVICE);
//Get all the different providers which can give current location info
List<String> providers = mLocationManager.getProviders(true);
//Initialising the location to be null
Location bestLocation = null;
//Creating a for loop to go through all the location providers and get the location
for (String provider : providers) {
//if permission is not granted, then get the permission
if (ContextCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION},
Constants.MY_PERMISSIONS_REQUEST_LOCATION);
}
//Get the last known location from the data provider
Location l = mLocationManager.getLastKnownLocation(provider);
//If the last know location provided by the data provider is null then ignore the provider and move to the next one.
if (l == null) {
continue;
}
if (bestLocation == null || l.getAccuracy() < bestLocation.getAccuracy()) {
bestLocation = l;
}
}
return bestLocation;
}
@Override
public void onMapReady(GoogleMap gMap) {
googleMap = gMap;
if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
checkLocationPermission();
} else {
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
}
locationButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FFFFFF")));
//Initialize Google Play Services
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
//Location Permission already granted
buildGoogleApiClient();
googleMap.setMyLocationEnabled(true);
} else {
//Request Location Permission
checkLocationPermission();
}
} else {
buildGoogleApiClient();
googleMap.setMyLocationEnabled(true);
}
googleMap.getUiSettings().setZoomGesturesEnabled(true);
LatLngBounds iitbBounds = new LatLngBounds(new LatLng(19.1249000, 72.9046000), new LatLng(19.143522, 72.920000));
googleMap.setLatLngBoundsForCameraTarget(iitbBounds);
googleMap.setMaxZoomPreference(30);
googleMap.setMinZoomPreference(14.5f);
// Position the map's camera near Mumbai
LatLng iitb = new LatLng(19.1334, 72.9133);
googleMap.addMarker(new MarkerOptions().position(iitb)
.title("Marker in IITB"));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(iitb));
}
private void checkLocationPermission() {
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
new AlertDialog.Builder(getActivity())
.setTitle("Location Permission Needed")
.setMessage("This app needs the Location permission, please accept to use location functionality")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//Prompt the user once explanation has been shown
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
Constants.MY_PERMISSIONS_REQUEST_LOCATION);
}
})
.create()
.show();
} else {
// No explanation needed, we can request the permission.
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
Constants.MY_PERMISSIONS_REQUEST_LOCATION);
}
}
}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
}
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
//move map camera
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(17));
//stop location updates
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case Constants.MY_PERMISSIONS_REQUEST_LOCATION: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (mGoogleApiClient == null) {
buildGoogleApiClient();
}
googleMap.setMyLocationEnabled(true);
}
}
return;
}
}
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
@Override
public void onConnected(Bundle bundle) {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if (ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
* A simple {@link Fragment} subclass.
*/
public class MessMenuFragment extends BaseFragment {
public MessMenuFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_mess_menu, container, false);
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
* A simple {@link Fragment} subclass.
*/
public class MyEventsFragment extends BaseFragment {
FloatingActionButton fab;
public MyEventsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_my_events, container, false);
fab = (FloatingActionButton) view.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AddEventFragment addEventFragment = new AddEventFragment();
addEventFragment.setArguments(getArguments());
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
ft.replace(R.id.relative_layout, addEventFragment);
ft.addToBackStack("addEvent");
ft.commit();
}
});
return view;
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.gson.Gson;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.adapter.NotificationsAdapter;
import in.ac.iitb.gymkhana.iitbapp.api.model.AppNotification;
import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse;
/**
* A simple {@link Fragment} subclass.
*/
public class NotificationsFragment extends BaseFragment {
RecyclerView notificationsRecyclerView;
public NotificationsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_notifications, container, false);
}
@Override
public void onStart() {
super.onStart();
Bundle bundle = getArguments();
String notificationsResponseJson = bundle.getString(Constants.NOTIFICATIONS_RESPONSE_JSON);
NotificationsResponse notificationsResponse = new Gson().fromJson(notificationsResponseJson, NotificationsResponse.class);
showNotifications(notificationsResponse);
}
private void showNotifications(NotificationsResponse notificationsResponse) {
List<AppNotification> notifications = notificationsResponse.getNotifications();
NotificationsAdapter notificationsAdapter = new NotificationsAdapter(notifications, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
//TODO: What to do?
}
});
notificationsRecyclerView = (RecyclerView) getActivity().findViewById(R.id.notifications_recycler_view);
notificationsRecyclerView.setAdapter(notificationsAdapter);
notificationsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
* A simple {@link Fragment} subclass.
*/
public class PTCellFragment extends BaseFragment {
public PTCellFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_pt_cell, container, false);
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.data.User;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* A simple {@link Fragment} subclass.
*/
public class ProfileFragment extends BaseFragment {
User user;
public ProfileFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_profile, container, false);
}
@Override
public void onStart() {
super.onStart();
Bundle bundle = getArguments();
String userID = bundle.getString(Constants.USER_ID);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getUser("sessionid=" + getArguments().getString(Constants.SESSION_ID), userID).enqueue(new Callback<User>() {
@Override
public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) {
user = response.body();
populateViews();
}
}
@Override
public void onFailure(Call<User> call, Throwable t) {
}
});
}
private void populateViews() {
ImageView userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile);
TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile);
TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile);
TextView userEmailIDTextView = getActivity().findViewById(R.id.user_email_profile);
TextView userContactNumberTextView = getActivity().findViewById(R.id.user_contact_no_profile);
Picasso.with(getContext()).load(user.getUserProfilePictureUrl()).into(userProfilePictureImageView);
userNameTextView.setText(user.getUserName());
userRollNumberTextView.setText(user.getUserRollNumber());
userEmailIDTextView.setText(user.getUserEmail());
userContactNumberTextView.setText(user.getUserContactNumber());
}
}
package in.ac.iitb.gymkhana.iitbapp.gcm;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.google.android.gms.gcm.GcmListenerService;
import in.ac.iitb.gymkhana.iitbapp.MainActivity;
import in.ac.iitb.gymkhana.iitbapp.R;
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
@Override
public void onMessageReceived(String s, Bundle bundle) {
String message = bundle.getString("message");
Log.d(TAG, "From: " + s);
Log.d(TAG, "Message: " + message);
sendNotification(message);
}
public void sendNotification(String message) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
//TODO Change the notification icon
.setSmallIcon(R.drawable.ic_notifications_black_24dp)
.setContentTitle("GCM Message")
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
}
package in.ac.iitb.gymkhana.iitbapp.gcm;
import android.content.Intent;
import com.google.android.gms.iid.InstanceIDListenerService;
public class MyInstanceIDListenerService extends InstanceIDListenerService {
@Override
public void onTokenRefresh() {
// Fetch updated Instance ID token and notify our app's server of any changes (if applicable).
Intent intent = new Intent(this, RegistrationIntentService.class);
startService(intent);
}
}
package in.ac.iitb.gymkhana.iitbapp.gcm;
import android.annotation.TargetApi;
import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID;
import in.ac.iitb.gymkhana.iitbapp.Constants;
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public class RegistrationIntentService extends IntentService {
private static final String TAG = "RegIntentService";
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
public RegistrationIntentService() {
super(TAG);
}
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
@Override
protected void onHandleIntent(@Nullable Intent intent) {
String token = null;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
try {
InstanceID instanceID = InstanceID.getInstance(this);
token = instanceID.getToken("306601329049",
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
Log.i(TAG, "GCM Registration Token: " + token);
Toast.makeText(this, "GCM Registration Token: " + token, Toast.LENGTH_SHORT).show();
sharedPreferences.edit().putBoolean(Constants.SENT_TOKEN_TO_SERVER, true).apply();
} catch (Exception e) {
Log.d(TAG, "Failed to complete token refresh", e);
sharedPreferences.edit().putBoolean(Constants.SENT_TOKEN_TO_SERVER, false).apply();
}
//Notify UI that registration is complete
Intent registrationComplete = new Intent(Constants.REGISTRATION_COMPLETE);
registrationComplete.putExtra("Token", token);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
<path
android:fillColor="#FF000000"
android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z" />
</vector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="50dip" />
<stroke android:width="0dip" android:color="#667162" />
<gradient android:angle="-90" android:endColor="@color/colorAccent" android:startColor="@color/colorAccent" />
</shape>
</item>
</selector>
\ No newline at end of file
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="135"
android:centerColor="#009688"
android:endColor="#00695C"
android:startColor="#4DB6AC"
android:type="linear" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/guest_login"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center"
android:text="Guest Login" />
<Button
android:id="@+id/ldap_login"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center"
android:text="LDAP login" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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/framelayout_for_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="in.ac.iitb.gymkhana.iitbapp.MainActivity"
tools:showIn="@layout/app_bar_main" />
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/event_picture"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="@+id/event_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Event Title"
android:textColor="@android:color/black"
android:textSize="18sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/event_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="26 May" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textSize="20dp" />
<TextView
android:id="@+id/event_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6:00 PM" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textSize="20dp" />
<TextView
android:id="@+id/event_venue"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:text="LH 101" />
</LinearLayout>
</LinearLayout>
<!--<ImageView-->
<!--android:id="@+id/event_enthu"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_marginRight="20dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:src="@drawable/ic_action_add"-->
<!--android:layout_gravity="center_vertical"/>-->
</LinearLayout>
<!--<View-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="2dp"-->
<!--android:background="#adfff6"-->
<!--android:layout_marginLeft="16dp"-->
<!--android:layout_marginRight="16dp">-->
<!--</View>-->
</LinearLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.AboutFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.AddEventFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="@+id/iv_eventImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE" />
<ImageButton
android:id="@+id/ib_eventImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:src="@drawable/ic_input_add" />
</RelativeLayout>
<EditText
android:id="@+id/et_eventName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#81d2cb"
android:hint="Event Name"
android:padding="16dp"
android:paddingBottom="16dp"
android:textColorHint="#FFFFFF"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="16dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_start"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/editTextBackground"
android:gravity="bottom"
android:hint="From "
android:paddingRight="6dp"
android:paddingTop="8dp"
android:textSize="20sp" />
<View
android:layout_width="3dp"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@color/common_google_signin_btn_text_dark_disabled" />
<TextView
android:id="@+id/tv_end"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/editTextBackground"
android:gravity="bottom"
android:hint="To "
android:paddingRight="6dp"
android:paddingTop="8dp"
android:textSize="20sp" />
</LinearLayout>
<EditText
android:id="@+id/et_venue"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="16dp"
android:layout_marginTop="10dp"
android:hint="Venue"
android:paddingRight="6dp"
android:textSize="20sp" />
<EditText
android:id="@+id/et_eventDetails"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:gravity="top"
android:hint="Details"
android:paddingRight="6dp"
android:textSize="20sp" />
<RelativeLayout
android:id="@+id/advanced_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:paddingLeft="18dp"
android:paddingRight="16dp"
android:text="Advanced Options"
android:textSize="20sp" />
<ImageView
android:id="@+id/close"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:src="@mipmap/advanced_menu_close" />
<ImageView
android:id="@+id/open"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:src="@mipmap/advanced_menu_open" />
</RelativeLayout>
<CheckBox
android:id="@+id/cb_public"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="12dp"
android:text="Outsiders Allowed " />
<EditText
android:id="@+id/map_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="22dp"
android:layout_marginRight="12dp"
android:hint="Map Location" />
<CheckBox
android:id="@+id/cb_permission"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="12dp"
android:text="Request User Info" />
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/button_createEvent"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="8dp"
android:background="@drawable/round_text_box"
android:gravity="center"
android:text="Create" />
</LinearLayout>
\ No newline at end of file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/calendar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E0E0E0"
android:theme="@style/CalendarTheme">
<!-- TODO: Update blank fragment layout -->
<View
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#00BCD4" />
<CalendarView
android:id="@+id/simpleCalendarView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusedMonthDateColor="#000000"
android:unfocusedMonthDateColor="#FFFFFF" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/simpleCalendarView"
android:layout_marginBottom="19.5dp"
android:layout_marginTop="19.5dp"
android:background="@android:color/darker_gray" />
<TextView
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_below="@id/simpleCalendarView"
android:layout_centerHorizontal="true"
android:background="@drawable/round_text_box"
android:gravity="center"
android:text="# Events Today" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@android:drawable/ic_input_add" />
</RelativeLayout>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.EventFragment">
<ImageView
android:id="@+id/event_picture_2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="12dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/event_page_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="10"
android:text="Event Title"
android:textColor="#fff"
android:textSize="28sp" />
<ImageButton
android:id="@+id/share_event_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Share Event"
android:src="@drawable/ic_menu_share"
android:tint="@color/colorWhite" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/event_page_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Date Specified"
android:textColor="#fff"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textColor="#fff"
android:textSize="20sp" />
<TextView
android:id="@+id/event_page_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Time Specified"
android:textColor="#fff"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textColor="#fff"
android:textSize="20sp" />
<TextView
android:id="@+id/event_page_venue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:text="No Venue Specified"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/going_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:text="Going"
android:textColor="@color/colorGray" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginBottom="6dp"
android:layout_marginTop="10dp"
android:background="#aaa">
</View>
<Button
android:id="@+id/interested_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:text="Interested"
android:textColor="@color/colorGray" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginBottom="6dp"
android:layout_marginTop="10dp"
android:background="#aaa">
</View>
<Button
android:id="@+id/not_going_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:text="Not Going"
android:textColor="@color/colorGray" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="#aaa">
</View>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/event_page_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:textColor="#777"
android:textSize="16sp" />
</ScrollView>
</LinearLayout>
</LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/feed_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/feed_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="8dp" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@android:drawable/ic_input_add" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment">
<fragment
android:id="@+id/viewMap"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraZoom="18" />
<!--TODO: Change colours-->
<android.support.design.widget.FloatingActionButton
android:id="@+id/location_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="48dp"
android:layout_marginEnd="@dimen/fab_margin"
android:src="@drawable/ic_my_location_black_24dp" />
</FrameLayout>
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.MessMenuFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@android:drawable/ic_input_add" />
</RelativeLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.NotificationsFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/notifications_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/user_profile_picture_profile"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_margin="32dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:orientation="vertical">
<TextView
android:id="@+id/user_name_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/user_rollno_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textSize="16sp" />
<TextView
android:id="@+id/user_email_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textSize="16sp" />
<TextView
android:id="@+id/user_contact_no_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.PTCellFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
<?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:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/user_profile_picture_nav_header"
android:layout_width="64dp"
android:layout_height="64dp"
android:paddingTop="@dimen/nav_header_vertical_spacing"
app:srcCompat="@mipmap/ic_launcher_round" />
<TextView
android:id="@+id/user_name_nav_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="Android Studio"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/user_rollno_nav_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android.studio@android.com" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/notification_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/suggestion_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="suggestion"
android:padding="8dp"
android:textSize="20sp" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<!--TODO Update icons-->
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_feed"
android:icon="@drawable/ic_dashboard_black_48dp"
android:title="Feed" />
<item
android:id="@+id/nav_my_events"
android:icon="@drawable/ic_event"
android:title="My Events" />
<item
android:id="@+id/nav_pt_cell"
android:icon="@drawable/ic_work_black_48dp"
android:title="PT Cell" />
<item
android:id="@+id/nav_mess_menu"
android:icon="@drawable/ic_restaurant_black_48dp"
android:title="Mess Menu" />
<item
android:id="@+id/nav_gc_rankings"
android:icon="@drawable/ic_equalizer_black_48dp"
android:title="GC Rankings" />
<item
android:id="@+id/nav_calendar"
android:icon="@drawable/ic_date_range_black_48dp"
android:title="Calendar" />
<item
android:id="@+id/nav_timetable"
android:icon="@drawable/ic_web_black_48dp"
android:title="Timetable" />
<item
android:id="@+id/nav_cms"
android:icon="@drawable/ic_announcement_black_48dp"
android:title="CMS" />e
<item
android:id="@+id/nav_map"
android:icon="@drawable/ic_map_black_48dp"
android:title="Map" />
<item
android:id="@+id/nav_people"
android:icon="@drawable/ic_supervisor_account_black_48dp"
android:title="People" />
</group>
<item android:title="Communicate">
<menu>
<item
android:id="@+id/nav_contacts"
android:icon="@drawable/ic_phone"
android:title="Contacts" />
<item
android:id="@+id/nav_about"
android:icon="@drawable/ic_info_black_48dp"
android:title="About" />
</menu>
</item>
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_notifications"
android:icon="@drawable/ic_notifications_black_24dp"
android:orderInCategory="1"
android:title="Notifications"
app:showAsAction="always" />
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_search"
android:icon="@android:drawable/ic_menu_search"
android:title="Search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always|collapseActionView" />
</menu>
\ No newline at end of file
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
<style name="CalendarTheme" parent="@style/AppTheme.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#ecf833</item>
<item name="android:colorBackground">?attr/colorButtonNormal</item>
<item name="android:textColorPrimaryInverse">@android:color/darker_gray</item>
<item name="android:windowBackground">?android:attr/colorButtonNormal</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#81D2CB</color>
<color name="colorPrimaryDark">#44C0CA</color>
<color name="colorAccent">#ECF833</color>
<color name="colorCalendarWeek">#000000</color>
<color name="colorGray">#757575</color>
<color name="colorWhite">#FFFFFF</color>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
\ No newline at end of file
<resources>
<item name="ic_menu_camera" type="drawable">@android:drawable/ic_menu_camera</item>
<item name="ic_menu_gallery" type="drawable">@android:drawable/ic_menu_gallery</item>
<item name="ic_menu_slideshow" type="drawable">@android:drawable/ic_menu_slideshow</item>
<item name="ic_menu_manage" type="drawable">@android:drawable/ic_menu_manage</item>
<item name="ic_menu_share" type="drawable">@android:drawable/ic_menu_share</item>
<item name="ic_menu_send" type="drawable">@android:drawable/ic_menu_send</item>
<item name="ic_input_add" type="drawable">@android:drawable/ic_input_add</item>
</resources>
<resources>
<string name="app_name">IITB App</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="action_settings">Settings</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="Cancel">Cancel</string>
<string name="gps_network_not_enabled">Location is not enabled. Please turn on your location from the settings.</string>
<string name="open_location_settings">Open Location Settings</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="CalendarTheme" parent="@style/AppTheme.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#ecf833</item>
<item name="android:colorBackground">@android:color/darker_gray</item>
<item name="android:textColorPrimaryInverse">@android:color/darker_gray</item>
<item name="android:windowBackground">@android:color/darker_gray</item>
</style>
</resources>
package in.ac.iitb.gymkhana.iitbapp;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# TODO Replace Key and put in local:properties
#GOOGLE_MAPS_API_KEY=AIzaSyB72DhM4E1NW0F-_SLnYtYYvz0rT9kne-U
GOOGLE_MAPS_API_KEY=AIzaSyC31o6h06Z36V8M0lXgkGj4Y1cmNRVV9s0
#Wed Mar 28 12:02:24 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
a {
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.logodiv {
width: 45%;
margin: 0 auto;
margin-top: 25%;
text-align: center;
}
.logo {
width: 100%;
}
.app-name {
margin-top: 10px;
font-weight: 200;
font-size: 1.5em;
}
.lowerdiv {
position: fixed;
bottom: 8%;
left: 0;
width: 100%;
}
.logindiv {
margin: 0 auto;
width: 100%;
text-align: center;
}
a {color: black;}
a:link {color: black;} /* unvisited link */
a:visited {color: black;} /* visited link */
a:hover {color: black;} /* mouse over link */
a:active {color: black;} /* selected link */
.login {
font-size: 1.05em;
padding: 10px 28%;
border-radius: 4px;
background-color: rgb(255, 215, 64);
text-decoration: none;
}
.guest {
text-decoration: none;
font-weight: 200;
line-height: 1.7em;
font-size: 1.05em;
}
</style>
</head>
<body>
<div class="logodiv">
<img src="lotus.png" class="logo">
<div class="app-name">InstiApp</div>
</div>
<div class="lowerdiv">
<div class="logindiv">
<a class="login"
href="https://gymkhana.iitb.ac.in/sso/account/login/?next=/sso/oauth/authorize/%3Fclient_id%3DvR1pU7wXWyve1rUkg0fMS6StL1Kr6paoSmRIiLXJ%26response_type%3Dcode%26scope%3Dbasic%2520profile%2520picture%2520sex%2520ldap%2520phone%2520insti_address%2520program%2520secondary_emails%26redirect_uri=https://redirecturi">
LOG IN VIA SSO
</a>
<br><br>
or
<br>
<a class="guest" href="https://guesturi">
Continue as a Guest
</a>
</div>
</div>
</body>
</html>
\ No newline at end of file
...@@ -7,6 +7,7 @@ public class Constants { ...@@ -7,6 +7,7 @@ public class Constants {
public static final int RESULT_LOAD_IMAGE = 11; public static final int RESULT_LOAD_IMAGE = 11;
public static final String NOTIFICATIONS_RESPONSE_JSON = "notifications_json"; public static final String NOTIFICATIONS_RESPONSE_JSON = "notifications_json";
public static final String EVENT_JSON = "event_json"; public static final String EVENT_JSON = "event_json";
public static final String EVENT_LIST_JSON = "event_list_json";
public static final String USER_ID = "user_id"; public static final String USER_ID = "user_id";
public static final String USER_HOSTEL = "user_hostel"; public static final String USER_HOSTEL = "user_hostel";
public static final String SENT_TOKEN_TO_SERVER = "sentTokenToServer"; public static final String SENT_TOKEN_TO_SERVER = "sentTokenToServer";
...@@ -19,5 +20,6 @@ public class Constants { ...@@ -19,5 +20,6 @@ public class Constants {
public static final int STATUS_GOING = 2; public static final int STATUS_GOING = 2;
public static final int STATUS_INTERESTED = 1; public static final int STATUS_INTERESTED = 1;
public static final int STATUS_NOT_GOING = 0; public static final int STATUS_NOT_GOING = 0;
public static final String BODY_JSON= "body_json"; public static final String BODY_JSON = "body_json";
public static final String BODY_LIST_JSON = "body_list_json";
} }
package in.ac.iitb.gymkhana.iitbapp; package in.ac.iitb.gymkhana.iitbapp;
import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.net.http.SslError;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.View; import android.webkit.SslErrorHandler;
import android.widget.Button; import android.webkit.WebView;
import android.widget.Toast; import android.webkit.WebViewClient;
import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.common.GoogleApiAvailability;
import net.openid.appauth.AuthorizationException;
import net.openid.appauth.AuthorizationRequest;
import net.openid.appauth.AuthorizationResponse;
import net.openid.appauth.AuthorizationService;
import net.openid.appauth.AuthorizationServiceConfiguration;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface; import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator; import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse; import in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse;
import in.ac.iitb.gymkhana.iitbapp.gcm.RegistrationIntentService;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -43,16 +27,11 @@ import retrofit2.Response; ...@@ -43,16 +27,11 @@ import retrofit2.Response;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
private static final String TAG = "LoginActivity"; private static final String TAG = "LoginActivity";
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private static final String CLIENT_ID = "vR1pU7wXWyve1rUkg0fMS6StL1Kr6paoSmRIiLXJ"; private final String redirectUri = "https://redirecturi";
private final Uri redirectUri = Uri.parse("https://redirecturi"); private final String guestUri = "https://guesturi";
private final Uri mAuthEndpoint = Uri.parse("http://gymkhana.iitb.ac.in/sso/oauth/authorize/");
private final Uri mTokenEndpoint = Uri.parse("http://gymkhana.iitb.ac.in/sso/oauth/token/");
public String authCode = null; public String authCode = null;
SessionManager session; SessionManager session;
Context mContext = this; Context mContext = this;
private AuthorizationService mAuthService;
private BroadcastReceiver mRegistrationBroadcastReceiver;
private boolean isReceiverRegistered;
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
@Override @Override
...@@ -60,169 +39,18 @@ public class LoginActivity extends AppCompatActivity { ...@@ -60,169 +39,18 @@ public class LoginActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
session = new SessionManager(mContext); session = new SessionManager(mContext);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
mAuthService = new AuthorizationService(this); progressDialog = new ProgressDialog(LoginActivity.this);
mRegistrationBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean sentToken = sharedPreferences.getBoolean(Constants.SENT_TOKEN_TO_SERVER, false);
if (sentToken) {
String token = intent.getStringExtra("Token");
Log.d(TAG, "Going to login with :" + authCode + "\n" + token);
//************
//TODO Remove following 6 lines after the server is hosted
String gcmRegId = token;
// session.createLoginSession(gcmRegId);
// Intent i = new Intent(mContext, MainActivity.class);
// i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// startActivity(i);
//**************
login(authCode, redirectUri.toString(), gcmRegId);
} else {
}
}
};
registerReceiver();
Button ldapLogin = (Button) findViewById(R.id.ldap_login);
ldapLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "Initiating auth");
AuthorizationServiceConfiguration config = new AuthorizationServiceConfiguration(mAuthEndpoint, mTokenEndpoint);
makeAuthRequest(config);
}
});
Button guestLogin = (Button) findViewById(R.id.guest_login);
guestLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO This is for debug purposes, change once SSO is implemented
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
@Override
protected void onNewIntent(Intent intent) {
checkIntent(intent);
}
private void checkIntent(@Nullable Intent intent) {
if (intent != null) {
Log.d(TAG, "Intent Received");
String action = intent.getAction();
if (action != null) {
switch (action) {
case "HANDLE_AUTHORIZATION_RESPONSE": {
handleAuthorizationResponse(intent);
}
break;
default:
Log.d(TAG, intent.getAction());
}
}
}
} }
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
checkIntent(getIntent());
}
@Override
protected void onResume() {
super.onResume();
registerReceiver();
Log.d(TAG, "On Resume");
}
@Override WebView webview = (WebView) findViewById(R.id.login_webview);
protected void onPause() { webview.getSettings().setJavaScriptEnabled(true);
LocalBroadcastManager.getInstance(this).unregisterReceiver(mRegistrationBroadcastReceiver); webview.getSettings().setDomStorageEnabled(true);
isReceiverRegistered = false; webview.setWebViewClient(new WvClient());
super.onPause(); webview.loadUrl("file:///android_asset/login.html");
}
@Override
protected void onDestroy() {
super.onDestroy();
mAuthService.dispose();
}
private void handleAuthorizationResponse(@NonNull Intent intent) {
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Logging In");
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.show();
AuthorizationResponse response = AuthorizationResponse.fromIntent(intent);
AuthorizationException error = AuthorizationException.fromIntent(intent);
if (response != null) {
authCode = response.authorizationCode;
Log.d(TAG, "Received AuthorizationResponse: " + "AuthCode: " + authCode);
if (checkPlayServices()) {
Intent registerIntent = new Intent(this, RegistrationIntentService.class);
startService(registerIntent);
}
//
} else {
Log.i(TAG, "Authorization failed: " + error.getMessage());
Toast.makeText(this,
"Authorization failed", Toast.LENGTH_LONG)
.show();
}
}
private void makeAuthRequest(@NonNull AuthorizationServiceConfiguration serviceConfig) {
AuthorizationRequest authRequest = new AuthorizationRequest.Builder(
serviceConfig,
CLIENT_ID,
"code",
redirectUri)
.setScope("basic profile picture sex ldap phone insti_address program secondary_emails")
.build();
Log.d(TAG, "Making auth request");
String action = "HANDLE_AUTHORIZATION_RESPONSE";
Intent postAuthorizationIntent = new Intent(action);
PendingIntent pendingIntent = PendingIntent.getActivity(this, authRequest.hashCode(), postAuthorizationIntent, 0);
mAuthService.performAuthorizationRequest(
authRequest,
pendingIntent,
mAuthService.createCustomTabsIntentBuilder()
.setToolbarColor(getCustomTabColor())
.build());
}
//TODO: Change the color of Chrome custom tabs based on app theme color
@TargetApi(Build.VERSION_CODES.M)
@SuppressWarnings("deprecation")
private int getCustomTabColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return getColor(R.color.colorPrimaryDark);
} else {
return getResources().getColor(R.color.colorPrimaryDark);
}
} }
private void login(String authorizationCode, final String redirectURI, String gcmID) { private void login(String authorizationCode, final String redirectURI, String gcmID) {
...@@ -251,15 +79,6 @@ public class LoginActivity extends AppCompatActivity { ...@@ -251,15 +79,6 @@ public class LoginActivity extends AppCompatActivity {
}); });
} }
private void registerReceiver() {
if (!isReceiverRegistered) {
LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
new IntentFilter(Constants.REGISTRATION_COMPLETE));
isReceiverRegistered = true;
}
}
private boolean checkPlayServices() { private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
...@@ -276,5 +95,56 @@ public class LoginActivity extends AppCompatActivity { ...@@ -276,5 +95,56 @@ public class LoginActivity extends AppCompatActivity {
return true; return true;
} }
private class WvClient extends WebViewClient {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError er) {
handler.proceed();
}
@Override
public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
/* Capture redirect */
if (url.startsWith(redirectUri)) {
/* Show progress dialog */
progressDialog.setMessage("Logging In");
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
if (!progressDialog.isShowing()) {
progressDialog.show();
}
/* Get auth code from query */
String query = Uri.parse(url).getQuery();
authCode = query.substring(query.lastIndexOf("=") + 1);
login(authCode, redirectUri, authCode);
return true;
}
/* Guest Login */
if (url.startsWith(guestUri)) {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
return true;
}
if (!progressDialog.isShowing()) {
progressDialog.setMessage("Loading");
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.show();
}
/* Load URL */
view.loadUrl(url);
return false;
}
@Override
public void onPageFinished(WebView view, String url) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
}
} }
...@@ -30,21 +30,17 @@ import com.squareup.picasso.Picasso; ...@@ -30,21 +30,17 @@ import com.squareup.picasso.Picasso;
import in.ac.iitb.gymkhana.iitbapp.api.UnsafeOkHttpClient; import in.ac.iitb.gymkhana.iitbapp.api.UnsafeOkHttpClient;
import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse; import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse;
import in.ac.iitb.gymkhana.iitbapp.data.User; import in.ac.iitb.gymkhana.iitbapp.data.User;
import in.ac.iitb.gymkhana.iitbapp.fragment.AboutFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.CMSFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.CalendarFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.CalendarFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.ContactsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.GCRankingsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.MessMenuFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.MessMenuFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.MyEventsFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.MyEventsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.NewsFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.NewsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.NotificationsFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.NotificationsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.PlacementBlogFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.PlacementBlogFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.TimetableFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.QLinksFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.SettingsFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.TrainingBlogFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.TrainingBlogFragment;
import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION; import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION;
...@@ -58,13 +54,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -58,13 +54,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private static final String TAG = "MainActivity"; private static final String TAG = "MainActivity";
SessionManager session; SessionManager session;
NotificationsResponse notificationsResponse; NotificationsResponse notificationsResponse;
FeedFragment feedFragment;
private User currentUser; private User currentUser;
private boolean showNotifications = false; private boolean showNotifications = false;
FeedFragment feedFragment;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
try {
initPicasso();
} catch (IllegalStateException ignored) {
}
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
session = new SessionManager(getApplicationContext()); session = new SessionManager(getApplicationContext());
session.checkLogin(); session.checkLogin();
...@@ -121,15 +121,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -121,15 +121,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
nameTextView.setText(currentUser.getUserName()); nameTextView.setText(currentUser.getUserName());
rollNoTextView.setText(currentUser.getUserRollNumber()); rollNoTextView.setText(currentUser.getUserRollNumber());
Picasso.Builder picassoBuilder = new Picasso.Builder(this); Picasso.with(this).load(currentUser.getUserProfilePictureUrl()).into(profilePictureImageView);
picassoBuilder.downloader(
new OkHttp3Downloader((
UnsafeOkHttpClient.getUnsafeOkHttpClient()
)
));
Picasso picasso = picassoBuilder.build();
picasso.load(currentUser.getUserProfilePictureUrl()).into(profilePictureImageView);
} }
// private void fetchNotifications() { // private void fetchNotifications() {
...@@ -231,21 +223,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -231,21 +223,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
MessMenuFragment messMenuFragment = new MessMenuFragment(); MessMenuFragment messMenuFragment = new MessMenuFragment();
updateFragment(messMenuFragment); updateFragment(messMenuFragment);
break; break;
case R.id.nav_gc_rankings:
GCRankingsFragment gcrankingsFragment = new GCRankingsFragment();
updateFragment(gcrankingsFragment);
break;
case R.id.nav_calendar: case R.id.nav_calendar:
CalendarFragment calendarFragment = new CalendarFragment(); CalendarFragment calendarFragment = new CalendarFragment();
updateFragment(calendarFragment); updateFragment(calendarFragment);
break; break;
case R.id.nav_cms: case R.id.nav_qlinks:
CMSFragment cmsFragment = new CMSFragment(); QLinksFragment qLinksFragment = new QLinksFragment();
updateFragment(cmsFragment); updateFragment(qLinksFragment);
break;
case R.id.nav_timetable:
TimetableFragment timetableFragment = new TimetableFragment();
updateFragment(timetableFragment);
break; break;
case R.id.nav_map: case R.id.nav_map:
MapFragment mapFragment = new MapFragment(); MapFragment mapFragment = new MapFragment();
...@@ -258,18 +242,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -258,18 +242,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
break; break;
case R.id.nav_contacts: case R.id.nav_settings:
ContactsFragment contactsFragment = new ContactsFragment(); SettingsFragment settingsFragment = new SettingsFragment();
updateFragment(contactsFragment); updateFragment(settingsFragment);
break;
case R.id.nav_about:
AboutFragment aboutFragment = new AboutFragment();
updateFragment(aboutFragment);
break;
case R.id.nav_people:
PeopleFragment peopleFragment = new PeopleFragment();
updateFragment(peopleFragment);
break; break;
} }
...@@ -327,6 +302,18 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -327,6 +302,18 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return "sessionid=" + session.getSessionID(); return "sessionid=" + session.getSessionID();
} }
public void initPicasso() {
Picasso.Builder builder = new Picasso.Builder(getApplicationContext());
builder.downloader(new OkHttp3Downloader((
UnsafeOkHttpClient.getUnsafeOkHttpClient(getApplicationContext())
)));
Picasso built = builder.build();
// TODO Set these to false before launch
built.setIndicatorsEnabled(true);
built.setLoggingEnabled(true);
Picasso.setSingletonInstance(built);
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
......
...@@ -17,12 +17,13 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -17,12 +17,13 @@ import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.data.Body; import in.ac.iitb.gymkhana.iitbapp.data.Body;
public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder>{ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
private List<Body> bodyList; private List<Body> bodyList;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
private Context context; private Context context;
public BodyAdapter(List<Body> bodyList, ItemClickListener itemClickListener){
public BodyAdapter(List<Body> bodyList, ItemClickListener itemClickListener) {
this.bodyList = bodyList; this.bodyList = bodyList;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
} }
...@@ -31,13 +32,13 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder>{ ...@@ -31,13 +32,13 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder>{
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
context = parent.getContext(); context = parent.getContext();
View v = LayoutInflater.from(context) View v = LayoutInflater.from(context)
.inflate(R.layout.body_card_view,parent,false); .inflate(R.layout.body_card_view, parent, false);
final ViewHolder postViewHolder = new ViewHolder(v); final ViewHolder postViewHolder = new ViewHolder(v);
v.setOnClickListener(new View.OnClickListener() { v.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
itemClickListener.onItemClick(view,postViewHolder.getAdapterPosition()); itemClickListener.onItemClick(view, postViewHolder.getAdapterPosition());
} }
}); });
...@@ -72,6 +73,5 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder>{ ...@@ -72,6 +73,5 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder>{
} }
} }
} }
...@@ -68,7 +68,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -68,7 +68,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
if (!eventVenueName.toString().equals("")) if (!eventVenueName.toString().equals(""))
viewHolder.eventVenue.setText(eventVenueName.toString().substring(2)); viewHolder.eventVenue.setText(eventVenueName.toString().substring(2));
Picasso.with(context).load(currentEvent.getEventImageURL()).resize(320, 0).into(viewHolder.eventPicture); Picasso.with(context).load(currentEvent.getEventImageURL()).into(viewHolder.eventPicture);
} }
@Override @Override
......
...@@ -47,24 +47,6 @@ public class MessMenuAdapter extends RecyclerView.Adapter<MessMenuAdapter.ViewHo ...@@ -47,24 +47,6 @@ public class MessMenuAdapter extends RecyclerView.Adapter<MessMenuAdapter.ViewHo
return messMenus.size(); return messMenus.size();
} }
public class ViewHolder extends RecyclerView.ViewHolder {
private TextView day;
private TextView breakfast;
private TextView lunch;
private TextView snacks;
private TextView dinner;
public ViewHolder(View itemView) {
super(itemView);
day = itemView.findViewById(R.id.day_text_view);
breakfast = itemView.findViewById(R.id.breakfast_text_view);
lunch = itemView.findViewById(R.id.lunch_text_view);
snacks = itemView.findViewById(R.id.snacks_text_view);
dinner = itemView.findViewById(R.id.dinner_text_view);
}
}
private String generateDayString(int day) { private String generateDayString(int day) {
switch (day) { switch (day) {
case 1: case 1:
...@@ -85,4 +67,22 @@ public class MessMenuAdapter extends RecyclerView.Adapter<MessMenuAdapter.ViewHo ...@@ -85,4 +67,22 @@ public class MessMenuAdapter extends RecyclerView.Adapter<MessMenuAdapter.ViewHo
throw new RuntimeException("DayIndexOutOfBounds: " + day); throw new RuntimeException("DayIndexOutOfBounds: " + day);
} }
} }
public class ViewHolder extends RecyclerView.ViewHolder {
private TextView day;
private TextView breakfast;
private TextView lunch;
private TextView snacks;
private TextView dinner;
public ViewHolder(View itemView) {
super(itemView);
day = itemView.findViewById(R.id.day_text_view);
breakfast = itemView.findViewById(R.id.breakfast_text_view);
lunch = itemView.findViewById(R.id.lunch_text_view);
snacks = itemView.findViewById(R.id.snacks_text_view);
dinner = itemView.findViewById(R.id.dinner_text_view);
}
}
} }
...@@ -9,7 +9,6 @@ import android.view.ViewGroup; ...@@ -9,7 +9,6 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
......
...@@ -8,7 +8,6 @@ import android.view.ViewGroup; ...@@ -8,7 +8,6 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
......
package in.ac.iitb.gymkhana.iitbapp.adapter; package in.ac.iitb.gymkhana.iitbapp.adapter;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -18,27 +19,29 @@ import in.ac.iitb.gymkhana.iitbapp.data.Body; ...@@ -18,27 +19,29 @@ import in.ac.iitb.gymkhana.iitbapp.data.Body;
import in.ac.iitb.gymkhana.iitbapp.data.Role; import in.ac.iitb.gymkhana.iitbapp.data.Role;
public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder>{ public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder> {
private List<Role> roleList; private List<Role> roleList;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
private Context context; private Context context;
public RoleAdapter(List<Role> roleList, ItemClickListener itemClickListener){
public RoleAdapter(List<Role> roleList, ItemClickListener itemClickListener) {
this.roleList = roleList; this.roleList = roleList;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
} }
@NonNull
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
context = parent.getContext(); context = parent.getContext();
View v = LayoutInflater.from(context) View v = LayoutInflater.from(context)
.inflate(R.layout.role_card,parent,false); .inflate(R.layout.role_card, parent, false);
final ViewHolder postViewHolder = new ViewHolder(v); final ViewHolder postViewHolder = new ViewHolder(v);
v.setOnClickListener(new View.OnClickListener() { v.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
itemClickListener.onItemClick(view,postViewHolder.getAdapterPosition()); itemClickListener.onItemClick(view, postViewHolder.getAdapterPosition());
} }
}); });
...@@ -74,6 +77,5 @@ public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder>{ ...@@ -74,6 +77,5 @@ public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder>{
} }
} }
} }
package in.ac.iitb.gymkhana.iitbapp.adapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import java.util.ArrayList;
import java.util.List;
public class TabAdapter extends FragmentStatePagerAdapter {
private final List<Fragment> list_fragment = new ArrayList<>();
private final List<String> list_title = new ArrayList<>();
public TabAdapter(FragmentManager fm) {
super(fm);
}
public void addFragment(Fragment fragment, String title) {
list_fragment.add(fragment);
list_title.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return list_title.get(position);
}
@Override
public Fragment getItem(int position) {
return list_fragment.get(position);
}
@Override
public int getCount() {
return list_fragment.size();
}
}
\ No newline at end of file
...@@ -8,7 +8,6 @@ import android.view.ViewGroup; ...@@ -8,7 +8,6 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
......
package in.ac.iitb.gymkhana.iitbapp.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.data.User;
public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
private List<User> userList;
private ItemClickListener itemClickListener;
private Context context;
public UserAdapter(List<User> userList, ItemClickListener itemClickListener) {
this.userList = userList;
this.itemClickListener = itemClickListener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
context = parent.getContext();
View v = LayoutInflater.from(context)
.inflate(R.layout.role_card, parent, false);
final ViewHolder postViewHolder = new ViewHolder(v);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
itemClickListener.onItemClick(view, postViewHolder.getAdapterPosition());
}
});
return postViewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
User user = userList.get(position);
holder.userName.setText(user.getUserName());
holder.role.setText(user.getCurrentRole());
Picasso.with(context).load(user.getUserProfilePictureUrl()).resize(120, 0).into(holder.image);
}
@Override
public int getItemCount() {
return userList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView userName;
public TextView role;
public ImageView image;
public ViewHolder(View itemView) {
super(itemView);
userName = (TextView) itemView.findViewById(R.id.role_card_body);
role = (TextView) itemView.findViewById(R.id.role_card_role);
image = (ImageView) itemView.findViewById(R.id.role_card_avatar);
}
}
}
package in.ac.iitb.gymkhana.iitbapp.api; package in.ac.iitb.gymkhana.iitbapp.api;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List; import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateRequest; import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateRequest;
......
package in.ac.iitb.gymkhana.iitbapp.api; package in.ac.iitb.gymkhana.iitbapp.api;
import android.content.Context;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
...@@ -9,13 +11,14 @@ import javax.net.ssl.SSLSocketFactory; ...@@ -9,13 +11,14 @@ import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import okhttp3.Cache;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
public class UnsafeOkHttpClient { public class UnsafeOkHttpClient {
public static OkHttpClient getUnsafeOkHttpClient() { public static OkHttpClient getUnsafeOkHttpClient(Context context) {
try { try {
// Create a trust manager that does not validate certificate chains // Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[] { final TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() { new X509TrustManager() {
@Override @Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
...@@ -40,7 +43,9 @@ public class UnsafeOkHttpClient { ...@@ -40,7 +43,9 @@ public class UnsafeOkHttpClient {
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
OkHttpClient.Builder builder = new OkHttpClient.Builder(); OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager)trustAllCerts[0]); Cache cache = new Cache(context.getCacheDir(), 200000000);
builder.cache(cache);
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]);
builder.hostnameVerifier(new HostnameVerifier() { builder.hostnameVerifier(new HostnameVerifier() {
@Override @Override
public boolean verify(String hostname, SSLSession session) { public boolean verify(String hostname, SSLSession session) {
......
...@@ -52,8 +52,11 @@ public class Body { ...@@ -52,8 +52,11 @@ public class Body {
@ColumnInfo(name = "user_follows") @ColumnInfo(name = "user_follows")
@SerializedName("user_follows") @SerializedName("user_follows")
boolean bodyUserFollows; boolean bodyUserFollows;
@ColumnInfo(name = "roles")
@SerializedName("roles")
List<Role> bodyRoles;
public Body(String bodyID, String bodyStrID, String bodyName, String bodyShortDescription, String bodyDescription, String bodyImageURL, List<Body> bodyChildren, List<Body> bodyParents, List<Event> bodyEvents, int bodyFollowersCount, String bodyWebsiteURL, String bodyBlogURL, Boolean bodyUserFollows) { public Body(String bodyID, String bodyStrID, String bodyName, String bodyShortDescription, String bodyDescription, String bodyImageURL, List<Body> bodyChildren, List<Body> bodyParents, List<Event> bodyEvents, int bodyFollowersCount, String bodyWebsiteURL, String bodyBlogURL, boolean bodyUserFollows, List<Role> bodyRoles) {
this.bodyID = bodyID; this.bodyID = bodyID;
this.bodyStrID = bodyStrID; this.bodyStrID = bodyStrID;
this.bodyName = bodyName; this.bodyName = bodyName;
...@@ -67,6 +70,7 @@ public class Body { ...@@ -67,6 +70,7 @@ public class Body {
this.bodyWebsiteURL = bodyWebsiteURL; this.bodyWebsiteURL = bodyWebsiteURL;
this.bodyBlogURL = bodyBlogURL; this.bodyBlogURL = bodyBlogURL;
this.bodyUserFollows = bodyUserFollows; this.bodyUserFollows = bodyUserFollows;
this.bodyRoles = bodyRoles;
} }
public String getBodyID() { public String getBodyID() {
...@@ -172,4 +176,12 @@ public class Body { ...@@ -172,4 +176,12 @@ public class Body {
public void setBodyUserFollows(boolean bodyUserFollows) { public void setBodyUserFollows(boolean bodyUserFollows) {
this.bodyUserFollows = bodyUserFollows; this.bodyUserFollows = bodyUserFollows;
} }
public List<Role> getBodyRoles() {
return bodyRoles;
}
public void setBodyRoles(List<Role> bodyRoles) {
this.bodyRoles = bodyRoles;
}
} }
\ No newline at end of file
...@@ -6,7 +6,6 @@ import android.arch.persistence.room.PrimaryKey; ...@@ -6,7 +6,6 @@ import android.arch.persistence.room.PrimaryKey;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.List; import java.util.List;
@Entity(tableName = "roles") @Entity(tableName = "roles")
...@@ -17,44 +16,44 @@ public class Role { ...@@ -17,44 +16,44 @@ public class Role {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
int db_id; int db_id;
@ColumnInfo(name="id") @ColumnInfo(name = "id")
@SerializedName("id") @SerializedName("id")
String roleID; String roleID;
@ColumnInfo(name="name") @ColumnInfo(name = "name")
@SerializedName("name") @SerializedName("name")
String roleName; String roleName;
@ColumnInfo(name="inheritable") @ColumnInfo(name = "inheritable")
@SerializedName("inheritable") @SerializedName("inheritable")
boolean roleInheritable; boolean roleInheritable;
@ColumnInfo(name="body") @ColumnInfo(name = "body")
@SerializedName("body") @SerializedName("body")
String roleBody; String roleBody;
@ColumnInfo(name="body_detail") @ColumnInfo(name = "body_detail")
@SerializedName("body_detail") @SerializedName("body_detail")
Body roleBodyDetails; Body roleBodyDetails;
@ColumnInfo(name="bodies") @ColumnInfo(name = "bodies")
@SerializedName("bodies") @SerializedName("bodies")
List<Body> roleBodies; List<Body> roleBodies;
@ColumnInfo(name="permissions") @ColumnInfo(name = "permissions")
@SerializedName("permissions") @SerializedName("permissions")
List<String> rolePermissions; List<String> rolePermissions;
@ColumnInfo(name="users") @ColumnInfo(name = "users")
@SerializedName("users") @SerializedName("users")
List<String> roleUsers; List<String> roleUsers;
@ColumnInfo(name="users_details") @ColumnInfo(name = "users_detail")
@SerializedName("users_details") @SerializedName("users_detail")
List<User> roleUsersDetails; List<User> roleUsersDetail;
public Role(String roleID, String roleName, boolean roleInheritable, String roleBody, Body roleBodyDetails, List<Body> roleBodies, List<String> rolePermissions, List<String> roleUsers, List<User> roleUsersDetails) { public Role(String roleID, String roleName, boolean roleInheritable, String roleBody, Body roleBodyDetails, List<Body> roleBodies, List<String> rolePermissions, List<String> roleUsers, List<User> roleUsersDetail) {
this.roleID = roleID; this.roleID = roleID;
this.roleName = roleName; this.roleName = roleName;
this.roleInheritable = roleInheritable; this.roleInheritable = roleInheritable;
...@@ -63,7 +62,7 @@ public class Role { ...@@ -63,7 +62,7 @@ public class Role {
this.roleBodies = roleBodies; this.roleBodies = roleBodies;
this.rolePermissions = rolePermissions; this.rolePermissions = rolePermissions;
this.roleUsers = roleUsers; this.roleUsers = roleUsers;
this.roleUsersDetails = roleUsersDetails; this.roleUsersDetail = roleUsersDetail;
} }
public String getRoleID() { public String getRoleID() {
...@@ -130,11 +129,11 @@ public class Role { ...@@ -130,11 +129,11 @@ public class Role {
this.roleUsers = roleUsers; this.roleUsers = roleUsers;
} }
public List<User> getRoleUsersDetails() { public List<User> getRoleUsersDetail() {
return roleUsersDetails; return roleUsersDetail;
} }
public void setRoleUsersDetails(List<User> roleUsersDetails) { public void setRoleUsersDetail(List<User> roleUsersDetail) {
this.roleUsersDetails = roleUsersDetails; this.roleUsersDetail = roleUsersDetail;
} }
} }
...@@ -2,8 +2,8 @@ package in.ac.iitb.gymkhana.iitbapp.data; ...@@ -2,8 +2,8 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo; import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity; import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey; import android.arch.persistence.room.PrimaryKey;
import android.util.Log;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
...@@ -50,10 +50,10 @@ public class User { ...@@ -50,10 +50,10 @@ public class User {
List<String> userFollowedBodiesID; List<String> userFollowedBodiesID;
@ColumnInfo(name = "roles") @ColumnInfo(name = "roles")
@SerializedName("roles") @SerializedName("roles")
List<Role>userRoles; List<Role> userRoles;
@ColumnInfo(name="institute_roles") @ColumnInfo(name = "institute_roles")
@SerializedName("institute_roles") @SerializedName("institute_roles")
List<Role>userInstituteRoles; List<Role> userInstituteRoles;
@ColumnInfo(name = "website_url") @ColumnInfo(name = "website_url")
@SerializedName("website_url") @SerializedName("website_url")
String userWebsiteURL; String userWebsiteURL;
...@@ -64,6 +64,12 @@ public class User { ...@@ -64,6 +64,12 @@ public class User {
@SerializedName("hostel") @SerializedName("hostel")
String hostel; String hostel;
/**
* Not in database
*/
@Ignore
String currentRole;
public User(int db_id, String userID, String userName, String userProfilePictureUrl, List<Event> userInterestedEvents, List<Event> userGoingEvents, String userEmail, String userRollNumber, String userContactNumber, String userAbout, List<Body> userFollowedBodies, List<String> userFollowedBodiesID, List<Role> userRoles, List<Role> userInstituteRoles, String userWebsiteURL, String userLDAPId, String hostel) { public User(int db_id, String userID, String userName, String userProfilePictureUrl, List<Event> userInterestedEvents, List<Event> userGoingEvents, String userEmail, String userRollNumber, String userContactNumber, String userAbout, List<Body> userFollowedBodies, List<String> userFollowedBodiesID, List<Role> userRoles, List<Role> userInstituteRoles, String userWebsiteURL, String userLDAPId, String hostel) {
this.db_id = db_id; this.db_id = db_id;
this.userID = userID; this.userID = userID;
...@@ -216,6 +222,14 @@ public class User { ...@@ -216,6 +222,14 @@ public class User {
this.hostel = hostel; this.hostel = hostel;
} }
public String getCurrentRole() {
return currentRole;
}
public void setCurrentRole(String currentRole) {
this.currentRole = currentRole;
}
@Override @Override
public String toString() { public String toString() {
return new Gson().toJson(this); return new Gson().toJson(this);
......
...@@ -6,16 +6,13 @@ import android.app.ProgressDialog; ...@@ -6,16 +6,13 @@ import android.app.ProgressDialog;
import android.app.TimePickerDialog; import android.app.TimePickerDialog;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.widget.ImageViewCompat;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -30,10 +27,13 @@ import android.widget.TextView; ...@@ -30,10 +27,13 @@ import android.widget.TextView;
import android.widget.TimePicker; import android.widget.TimePicker;
import android.widget.Toast; import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
...@@ -98,17 +98,6 @@ public class AddEventFragment extends BaseFragment { ...@@ -98,17 +98,6 @@ public class AddEventFragment extends BaseFragment {
// Required empty public constructor // Required empty public constructor
} }
public static String convertImageToString(Bitmap imageBitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
if (imageBitmap != null) {
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 60, stream);
byte[] byteArray = stream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
} else {
return null;
}
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
...@@ -133,14 +122,13 @@ public class AddEventFragment extends BaseFragment { ...@@ -133,14 +122,13 @@ public class AddEventFragment extends BaseFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Calendar calendar = Calendar.getInstance(); final Calendar calendar = Calendar.getInstance();
int mYear = calendar.get(Calendar.YEAR); int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH); int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH); int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int mHour = calendar.get(Calendar.HOUR_OF_DAY); final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
final int mMin = calendar.get(Calendar.MINUTE); final int mMin = calendar.get(Calendar.MINUTE);
long millis = calendar.getTimeInMillis();
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() { DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
...@@ -150,57 +138,25 @@ public class AddEventFragment extends BaseFragment { ...@@ -150,57 +138,25 @@ public class AddEventFragment extends BaseFragment {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() { TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override @Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) { public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
timestamp_start = makeTimestamp(year, month, dayOfMonth, hourOfDay, minute);
if (timestamp_start.after(new Timestamp(Calendar.getInstance().getTimeInMillis()))) {
if (timestamp_end == null || timestamp_end.after(timestamp_start)) {
start.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute); start.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
enableEndDatePicker(year, month, dayOfMonth, hourOfDay, minute);
} }
}, mHour, mMin, true); } else {
timePickerDialog.show(); Toast.makeText(getContext(), "Start Time cannot be in the past", Toast.LENGTH_SHORT).show();
} }
}, mYear, mMonth, mDay);
datePickerDialog.show();
timestamp_start = new Timestamp(millis);
}
});
end.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calendar = Calendar.getInstance();
int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
final int mMin = calendar.get(Calendar.MINUTE);
long millis = calendar.getTimeInMillis();
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
end.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
} }
}, mHour, mMin, true); }, mHour, mMin, true);
timePickerDialog.show(); timePickerDialog.show();
} }
}, mYear, mMonth, mDay); }, mYear, mMonth, mDay);
datePickerDialog.show(); datePickerDialog.show();
timestamp_end = new Timestamp(millis);
} }
}); });
if (cb_permission.isChecked()) { if (cb_permission.isChecked()) {
publicStatus = 1; publicStatus = 1;
} else publicStatus = 0; } else publicStatus = 0;
...@@ -248,6 +204,45 @@ public class AddEventFragment extends BaseFragment { ...@@ -248,6 +204,45 @@ public class AddEventFragment extends BaseFragment {
return view; return view;
} }
private void enableEndDatePicker(final int startYear, final int startMonth, final int startDayOfMonth, final int startHourOfDay, final int startMinute) {
end.setEnabled(true);
end.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
timestamp_end = makeTimestamp(year, month, dayOfMonth, hourOfDay, minute);
if (timestamp_end.after(timestamp_start))
end.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
else {
Toast.makeText(getContext(), "End Time cannot be before Start Time", Toast.LENGTH_SHORT).show();
}
}
}, startHourOfDay, startMinute, true);
timePickerDialog.show();
}
}, startYear, startMonth, startDayOfMonth);
datePickerDialog.show();
}
});
}
public static Timestamp makeTimestamp(int year, int month, int day, int hour, int minute) {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DATE, day);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
return new Timestamp(cal.getTimeInMillis());
}
private void sendImage() { private void sendImage() {
progressDialog.setMessage("Uploading Image"); progressDialog.setMessage("Uploading Image");
ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image); ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image);
...@@ -293,53 +288,8 @@ public class AddEventFragment extends BaseFragment { ...@@ -293,53 +288,8 @@ public class AddEventFragment extends BaseFragment {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData(); Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA}; ImageViewCompat.setImageTintList(eventPictureImageView, null);
Cursor cursor = getActivity().getContentResolver().query(selectedImage, filePathColumn, null, null, null); Picasso.with(getContext()).load(selectedImage).into(eventPictureImageView);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
eventPictureImageView.setImageBitmap(getScaledBitmap(picturePath, imageButton.getWidth(), imageButton.getHeight()));
eventPictureImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
base64Image = convertImageToString(getScaledBitmap(picturePath, 800, 800));
Log.d(TAG, "onActivityResult: " + base64Image);
}
} }
private Bitmap getScaledBitmap(String picturePath, int width, int height) {
BitmapFactory.Options sizeOptions = new BitmapFactory.Options();
sizeOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(picturePath, sizeOptions);
int inSampleSize = calculateInSampleSize(sizeOptions, width, height);
sizeOptions.inJustDecodeBounds = false;
sizeOptions.inSampleSize = inSampleSize;
return BitmapFactory.decodeFile(picturePath, sizeOptions);
}
private int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
// Calculate ratios of height and width to requested height and
// width
final int heightRatio = Math.round((float) height / (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
// Choose the smallest ratio as inSampleSize value, this will
// guarantee
// a final image with both dimensions larger than or equal to the
// requested height and width.
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
} }
} }
...@@ -7,9 +7,9 @@ import android.os.AsyncTask; ...@@ -7,9 +7,9 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -22,6 +22,7 @@ import android.widget.Toast; ...@@ -22,6 +22,7 @@ import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.Constants; import in.ac.iitb.gymkhana.iitbapp.Constants;
...@@ -29,12 +30,16 @@ import in.ac.iitb.gymkhana.iitbapp.ItemClickListener; ...@@ -29,12 +30,16 @@ import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.MainActivity; import in.ac.iitb.gymkhana.iitbapp.MainActivity;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.ShareURLMaker; import in.ac.iitb.gymkhana.iitbapp.ShareURLMaker;
import in.ac.iitb.gymkhana.iitbapp.adapter.BodyAdapter;
import in.ac.iitb.gymkhana.iitbapp.adapter.FeedAdapter; import in.ac.iitb.gymkhana.iitbapp.adapter.FeedAdapter;
import in.ac.iitb.gymkhana.iitbapp.adapter.UserAdapter;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface; import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator; import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.data.AppDatabase; import in.ac.iitb.gymkhana.iitbapp.data.AppDatabase;
import in.ac.iitb.gymkhana.iitbapp.data.Body; import in.ac.iitb.gymkhana.iitbapp.data.Body;
import in.ac.iitb.gymkhana.iitbapp.data.Event; import in.ac.iitb.gymkhana.iitbapp.data.Event;
import in.ac.iitb.gymkhana.iitbapp.data.Role;
import in.ac.iitb.gymkhana.iitbapp.data.User;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -50,9 +55,8 @@ public class BodyFragment extends Fragment { ...@@ -50,9 +55,8 @@ public class BodyFragment extends Fragment {
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private AppDatabase appDatabase;
String TAG = "BodyFragment"; String TAG = "BodyFragment";
private AppDatabase appDatabase;
// TODO: Rename and change types of parameters // TODO: Rename and change types of parameters
private Body min_body; private Body min_body;
private SwipeRefreshLayout bodySwipeRefreshLayout; private SwipeRefreshLayout bodySwipeRefreshLayout;
...@@ -92,9 +96,9 @@ public class BodyFragment extends Fragment { ...@@ -92,9 +96,9 @@ public class BodyFragment extends Fragment {
/* Initialize */ /* Initialize */
appDatabase = AppDatabase.getAppDatabase(getContext()); appDatabase = AppDatabase.getAppDatabase(getContext());
displayBody(min_body);
new getDbBody().execute(min_body.getBodyID()); new getDbBody().execute(min_body.getBodyID());
bodySwipeRefreshLayout=getActivity().findViewById(R.id.body_swipe_refresh_layout); bodySwipeRefreshLayout = getActivity().findViewById(R.id.body_swipe_refresh_layout);
bodySwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { bodySwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override @Override
public void onRefresh() { public void onRefresh() {
...@@ -105,7 +109,7 @@ public class BodyFragment extends Fragment { ...@@ -105,7 +109,7 @@ public class BodyFragment extends Fragment {
private void updateBody() { private void updateBody() {
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getBody(((MainActivity)getActivity()).getSessionIDHeader(), min_body.getBodyID()).enqueue(new Callback<Body>() { retrofitInterface.getBody(((MainActivity) getActivity()).getSessionIDHeader(), min_body.getBodyID()).enqueue(new Callback<Body>() {
@Override @Override
public void onResponse(Call<Body> call, Response<Body> response) { public void onResponse(Call<Body> call, Response<Body> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -136,9 +140,15 @@ public class BodyFragment extends Fragment { ...@@ -136,9 +140,15 @@ public class BodyFragment extends Fragment {
/* Set body information */ /* Set body information */
bodyName.setText(body.getBodyName()); bodyName.setText(body.getBodyName());
Markwon.setMarkdown(bodyDescription, body.getBodyDescription());
Picasso.with(getContext()).load(body.getBodyImageURL()).into(eventPicture); Picasso.with(getContext()).load(body.getBodyImageURL()).into(eventPicture);
/* Return if it's a min body */
if (body.getBodyDescription() == null) {
return;
}
Markwon.setMarkdown(bodyDescription, body.getBodyDescription());
/* Check if user is already following /* Check if user is already following
* Initialize follow button */ * Initialize follow button */
followButton.setBackgroundColor(getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite)); followButton.setBackgroundColor(getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite));
...@@ -147,7 +157,7 @@ public class BodyFragment extends Fragment { ...@@ -147,7 +157,7 @@ public class BodyFragment extends Fragment {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.updateBodyFollowing(((MainActivity) getActivity()).getSessionIDHeader(), body.getBodyID(), body.getBodyUserFollows() ? 0:1).enqueue(new Callback<Void>() { retrofitInterface.updateBodyFollowing(((MainActivity) getActivity()).getSessionIDHeader(), body.getBodyID(), body.getBodyUserFollows() ? 0 : 1).enqueue(new Callback<Void>() {
@Override @Override
public void onResponse(Call<Void> call, Response<Void> response) { public void onResponse(Call<Void> call, Response<Void> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -166,11 +176,11 @@ public class BodyFragment extends Fragment { ...@@ -166,11 +176,11 @@ public class BodyFragment extends Fragment {
}); });
/* Initialize web button */ /* Initialize web button */
if (body.getBodyWebsiteURL() != null && !body.getBodyWebsiteURL().isEmpty()) if (body.getBodyWebsiteURL() != null && !body.getBodyWebsiteURL().isEmpty()) {
{
webBodyButton.setVisibility(View.VISIBLE); webBodyButton.setVisibility(View.VISIBLE);
webBodyButton.setOnClickListener(new View.OnClickListener() { webBodyButton.setOnClickListener(new View.OnClickListener() {
String bodywebURL = body.getBodyWebsiteURL(); String bodywebURL = body.getBodyWebsiteURL();
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(bodywebURL)); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(bodywebURL));
...@@ -182,6 +192,7 @@ public class BodyFragment extends Fragment { ...@@ -182,6 +192,7 @@ public class BodyFragment extends Fragment {
/* Initialize share button */ /* Initialize share button */
shareBodyButton.setOnClickListener(new View.OnClickListener() { shareBodyButton.setOnClickListener(new View.OnClickListener() {
String shareUrl = ShareURLMaker.getBodyURL(body); String shareUrl = ShareURLMaker.getBodyURL(body);
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Intent i = new Intent(Intent.ACTION_SEND); Intent i = new Intent(Intent.ACTION_SEND);
...@@ -212,6 +223,82 @@ public class BodyFragment extends Fragment { ...@@ -212,6 +223,82 @@ public class BodyFragment extends Fragment {
}); });
eventRecyclerView.setAdapter(eventAdapter); eventRecyclerView.setAdapter(eventAdapter);
eventRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); eventRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
/* Get users from roles */
final List<Role> roles = body.getBodyRoles();
final List<User> users = new ArrayList();
for (Role role : roles) {
if (role.getRoleUsersDetail() != null) {
for (User user : role.getRoleUsersDetail()) {
user.setCurrentRole(role.getRoleName());
users.add(user);
}
}
}
/* Initialize People */
RecyclerView userRecyclerView = (RecyclerView) getActivity().findViewById(R.id.people_card_recycler_view);
UserAdapter userAdapter = new UserAdapter(users, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
User user = users.get(position);
Bundle bundle = new Bundle();
bundle.putString(Constants.USER_ID, user.getUserID());
ProfileFragment profileFragment = new ProfileFragment();
profileFragment.setArguments(bundle);
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
ft.replace(R.id.framelayout_for_fragment, profileFragment, profileFragment.getTag());
ft.addToBackStack(profileFragment.getTag());
ft.commit();
}
});
userRecyclerView.setAdapter(userAdapter);
userRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
/* Initialize Parent bodies */
RecyclerView parentsRecyclerView = (RecyclerView) getActivity().findViewById(R.id.parentorg_card_recycler_view);
BodyAdapter parentAdapter = new BodyAdapter(body.getBodyParents(), new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
openBody(body.getBodyParents().get(position));
}
});
parentsRecyclerView.setAdapter(parentAdapter);
parentsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
/* Initialize child bodies */
RecyclerView childrenRecyclerView = (RecyclerView) getActivity().findViewById(R.id.org_card_recycler_view);
BodyAdapter childrenAdapter = new BodyAdapter(body.getBodyChildren(), new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
openBody(body.getBodyChildren().get(position));
}
});
childrenRecyclerView.setAdapter(childrenAdapter);
childrenRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
/**
* Open body fragment for a body
*/
private void openBody(Body body) {
Bundle bundle = new Bundle();
bundle.putString(Constants.BODY_JSON, new Gson().toJson(body));
BodyFragment bodyFragment = new BodyFragment();
bodyFragment.setArguments(bundle);
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
ft.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
ft.addToBackStack(bodyFragment.getTag());
ft.commit();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_body, container, false);
} }
private class updateDbBody extends AsyncTask<Body, Void, Integer> { private class updateDbBody extends AsyncTask<Body, Void, Integer> {
...@@ -246,11 +333,4 @@ public class BodyFragment extends Fragment { ...@@ -246,11 +333,4 @@ public class BodyFragment extends Fragment {
} }
} }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_body, container, false);
}
} }
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.adapter.BodyAdapter;
import in.ac.iitb.gymkhana.iitbapp.data.Body;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* to handle interaction events.
* Use the {@link BodyRecyclerViewFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class BodyRecyclerViewFragment extends Fragment {
private static final String TAG = "BodyRecyclerViewFragment";
private RecyclerView recyclerView;
private BodyAdapter bodyAdapter;
private List<Body> bodyList;
public BodyRecyclerViewFragment() {
// Required empty public constructor
}
// TODO: Rename and change types and number of parameters
public static BodyRecyclerViewFragment newInstance(List<Body> bodyList) {
BodyRecyclerViewFragment fragment = new BodyRecyclerViewFragment();
Bundle args = new Bundle();
args.putString(Constants.BODY_LIST_JSON, new Gson().toJson(bodyList));
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
bodyList = new Gson().fromJson(getArguments().getString(Constants.BODY_LIST_JSON
), new TypeToken<List<Body>>() {
}.getType());
}
}
@Override
public void onStart() {
super.onStart();
recyclerView = (RecyclerView) getActivity().findViewById(R.id.body_recycler_view);
bodyAdapter = new BodyAdapter(bodyList, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
Body body = bodyList.get(position);
BodyFragment bodyFragment = new BodyFragment();
Bundle arguments = getArguments();
arguments.putString(Constants.BODY_JSON, new Gson().toJson(body));
bodyFragment.setArguments(getArguments());
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
ft.addToBackStack(bodyFragment.getTag());
ft.commit();
}
});
recyclerView.setAdapter(bodyAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_body_recycler_view, container, false);
}
}
\ No newline at end of file
...@@ -109,7 +109,7 @@ public class CalendarFragment extends BaseFragment { ...@@ -109,7 +109,7 @@ public class CalendarFragment extends BaseFragment {
final String oneMonthOn = isoFormatter.format(oneMonthOnDate).toString(); final String oneMonthOn = isoFormatter.format(oneMonthOnDate).toString();
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getEventsBetweenDates(((MainActivity)getActivity()).getSessionIDHeader(), oneMonthBack, oneMonthOn).enqueue(new Callback<NewsFeedResponse>() { retrofitInterface.getEventsBetweenDates(((MainActivity) getActivity()).getSessionIDHeader(), oneMonthBack, oneMonthOn).enqueue(new Callback<NewsFeedResponse>() {
@Override @Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) { public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -136,7 +136,7 @@ public class CalendarFragment extends BaseFragment { ...@@ -136,7 +136,7 @@ public class CalendarFragment extends BaseFragment {
private void showEventsForDate(Date date) { private void showEventsForDate(Date date) {
final List<Event> filteredEvents = new ArrayList<Event>(); final List<Event> filteredEvents = new ArrayList<Event>();
for( Event event : events) { for (Event event : events) {
Date nextDay = new Date(date.getTime() + (1000 * 60 * 60 * 24)); Date nextDay = new Date(date.getTime() + (1000 * 60 * 60 * 24));
Timestamp start = event.getEventStartTime(); Timestamp start = event.getEventStartTime();
if (start.after(date) && start.before(nextDay)) { if (start.after(date) && start.before(nextDay)) {
...@@ -154,6 +154,7 @@ public class CalendarFragment extends BaseFragment { ...@@ -154,6 +154,7 @@ public class CalendarFragment extends BaseFragment {
EventFragment eventFragment = new EventFragment(); EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle); eventFragment.setArguments(bundle);
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
ft.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag()); ft.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
ft.addToBackStack(eventFragment.getTag()); ft.addToBackStack(eventFragment.getTag());
ft.commit(); ft.commit();
......
...@@ -55,8 +55,8 @@ public class EventFragment extends BaseFragment { ...@@ -55,8 +55,8 @@ public class EventFragment extends BaseFragment {
ImageButton webEventButton; ImageButton webEventButton;
ImageButton shareEventButton; ImageButton shareEventButton;
RecyclerView bodyRecyclerView; RecyclerView bodyRecyclerView;
private AppDatabase appDatabase;
String TAG = "EventFragment"; String TAG = "EventFragment";
private AppDatabase appDatabase;
public EventFragment() { public EventFragment() {
// Required empty public constructor // Required empty public constructor
......
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.adapter.FeedAdapter;
import in.ac.iitb.gymkhana.iitbapp.data.Event;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* to handle interaction events.
* Use the {@link EventRecyclerViewFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class EventRecyclerViewFragment extends Fragment {
private static final String TAG = "EventRecyclerViewFragment";
private RecyclerView recyclerView;
private FeedAdapter feedAdapter;
private List<Event> eventList;
public EventRecyclerViewFragment() {
// Required empty public constructor
}
// TODO: Rename and change types and number of parameters
public static EventRecyclerViewFragment newInstance(List<Event> eventList) {
EventRecyclerViewFragment fragment = new EventRecyclerViewFragment();
Bundle args = new Bundle();
args.putString(Constants.EVENT_LIST_JSON, new Gson().toJson(eventList));
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
eventList = new Gson().fromJson(getArguments().getString(Constants.EVENT_LIST_JSON), new TypeToken<List<Event>>() {
}.getType());
}
}
@Override
public void onStart() {
super.onStart();
recyclerView = (RecyclerView) getActivity().findViewById(R.id.event_recycler_view);
feedAdapter = new FeedAdapter(eventList, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
Event event = eventList.get(position);
EventFragment eventFragment = new EventFragment();
Bundle arguments = getArguments();
arguments.putString(Constants.EVENT_JSON, new Gson().toJson(event));
eventFragment.setArguments(getArguments());
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
ft.addToBackStack(eventFragment.getTag());
ft.commit();
}
});
recyclerView.setAdapter(feedAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_event_recycler_view, container, false);
}
}
\ No newline at end of file
...@@ -14,7 +14,6 @@ import android.support.v7.widget.RecyclerView; ...@@ -14,7 +14,6 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -58,6 +57,14 @@ public class FeedFragment extends BaseFragment { ...@@ -58,6 +57,14 @@ public class FeedFragment extends BaseFragment {
fab = (FloatingActionButton) view.findViewById(R.id.fab); fab = (FloatingActionButton) view.findViewById(R.id.fab);
feedSwipeRefreshLayout = view.findViewById(R.id.feed_swipe_refresh_layout);
feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateFeed();
}
});
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
...@@ -81,14 +88,6 @@ public class FeedFragment extends BaseFragment { ...@@ -81,14 +88,6 @@ public class FeedFragment extends BaseFragment {
new showEventsFromDB().execute(); new showEventsFromDB().execute();
updateFeed(); updateFeed();
feedSwipeRefreshLayout = getActivity().findViewById(R.id.feed_swipe_refresh_layout);
feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateFeed();
}
});
} }
private void updateFeed() { private void updateFeed() {
...@@ -115,25 +114,6 @@ public class FeedFragment extends BaseFragment { ...@@ -115,25 +114,6 @@ public class FeedFragment extends BaseFragment {
}); });
} }
private class updateDatabase extends AsyncTask<List<Event>, Void, Integer> {
@Override
protected Integer doInBackground(List<Event>... events) {
appDatabase.dbDao().deleteEvents();
appDatabase.dbDao().insertEvents(events[0]);
return 1;
}
}
private class showEventsFromDB extends AsyncTask<String, Void, List<Event>> {
@Override
protected List<Event> doInBackground(String... events) {
return appDatabase.dbDao().getAllEvents();
}
protected void onPostExecute(List<Event> result) {
displayEvents(result);
}
}
private void displayEvents(final List<Event> events) { private void displayEvents(final List<Event> events) {
final FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() { final FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {
@Override @Override
...@@ -165,4 +145,24 @@ public class FeedFragment extends BaseFragment { ...@@ -165,4 +145,24 @@ public class FeedFragment extends BaseFragment {
} }
}); });
} }
private class updateDatabase extends AsyncTask<List<Event>, Void, Integer> {
@Override
protected Integer doInBackground(List<Event>... events) {
appDatabase.dbDao().deleteEvents();
appDatabase.dbDao().insertEvents(events[0]);
return 1;
}
}
private class showEventsFromDB extends AsyncTask<String, Void, List<Event>> {
@Override
protected List<Event> doInBackground(String... events) {
return appDatabase.dbDao().getAllEvents();
}
protected void onPostExecute(List<Event> result) {
displayEvents(result);
}
}
} }
...@@ -2,8 +2,10 @@ package in.ac.iitb.gymkhana.iitbapp.fragment; ...@@ -2,8 +2,10 @@ package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -12,7 +14,6 @@ import android.view.ViewGroup; ...@@ -12,7 +14,6 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.jakewharton.picasso.OkHttp3Downloader;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import java.util.List; import java.util.List;
...@@ -21,10 +22,11 @@ import in.ac.iitb.gymkhana.iitbapp.Constants; ...@@ -21,10 +22,11 @@ import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener; import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.adapter.RoleAdapter; import in.ac.iitb.gymkhana.iitbapp.adapter.RoleAdapter;
import in.ac.iitb.gymkhana.iitbapp.adapter.TabAdapter;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface; import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator; import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.api.UnsafeOkHttpClient;
import in.ac.iitb.gymkhana.iitbapp.data.Body; import in.ac.iitb.gymkhana.iitbapp.data.Body;
import in.ac.iitb.gymkhana.iitbapp.data.Event;
import in.ac.iitb.gymkhana.iitbapp.data.Role; import in.ac.iitb.gymkhana.iitbapp.data.Role;
import in.ac.iitb.gymkhana.iitbapp.data.User; import in.ac.iitb.gymkhana.iitbapp.data.User;
import retrofit2.Call; import retrofit2.Call;
...@@ -97,18 +99,31 @@ public class ProfileFragment extends BaseFragment { ...@@ -97,18 +99,31 @@ public class ProfileFragment extends BaseFragment {
userRoleRecyclerView.setAdapter(roleAdapter); userRoleRecyclerView.setAdapter(roleAdapter);
userRoleRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); userRoleRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
Picasso.Builder picassoBuilder = new Picasso.Builder(getContext()); Picasso.with(getContext()).load(user.getUserProfilePictureUrl()).into(userProfilePictureImageView);
picassoBuilder.downloader(
new OkHttp3Downloader(( final List<Body> bodyList = user.getUserFollowedBodies();
UnsafeOkHttpClient.getUnsafeOkHttpClient() final List<Event> eventList = user.getUserGoingEvents();
) final List<Event> eventInterestedList = user.getUserInterestedEvents();
)); eventList.removeAll(eventInterestedList);
Picasso picasso = picassoBuilder.build(); eventList.addAll(eventInterestedList);
BodyRecyclerViewFragment frag1 = BodyRecyclerViewFragment.newInstance(bodyList);
picasso.load(user.getUserProfilePictureUrl()).into(userProfilePictureImageView); EventRecyclerViewFragment frag2 = EventRecyclerViewFragment.newInstance(eventList);
TabAdapter tabAdapter = new TabAdapter(getChildFragmentManager());
tabAdapter.addFragment(frag1, "Following");
tabAdapter.addFragment(frag2, "Events");
// Set up the ViewPager with the sections adapter.
ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.viewPager);
viewPager.setAdapter(tabAdapter);
viewPager.setOffscreenPageLimit(2);
TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tab_layout);
tabLayout.setupWithViewPager(viewPager);
userNameTextView.setText(user.getUserName()); userNameTextView.setText(user.getUserName());
userRollNumberTextView.setText(user.getUserRollNumber()); userRollNumberTextView.setText(user.getUserRollNumber());
userEmailIDTextView.setText(user.getUserEmail()); userEmailIDTextView.setText(user.getUserEmail());
userContactNumberTextView.setText(user.getUserContactNumber()); userContactNumberTextView.setText(user.getUserContactNumber());
} }
} }
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
* A simple {@link Fragment} subclass.
*/
public class QLinksFragment extends BaseFragment {
public QLinksFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_qlinks, container, false);
}
}
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
* A simple {@link Fragment} subclass.
* Use the {@link SettingsFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SettingsFragment extends Fragment {
public SettingsFragment() {
// Required empty public constructor
}
public static SettingsFragment newInstance(String param1, String param2) {
SettingsFragment fragment = new SettingsFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_settings, container, false);
}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set> <set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:propertyName="x" android:propertyName="x"
android:valueType="floatType"
android:valueFrom="1280" android:valueFrom="1280"
android:valueTo="0" android:valueTo="0"
android:duration="400"/> android:valueType="floatType" />
</set> </set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set> <set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:propertyName="x" android:propertyName="x"
android:valueType="floatType"
android:valueFrom="-1280" android:valueFrom="-1280"
android:valueTo="0" android:valueTo="0"
android:duration="400"/> android:valueType="floatType" />
</set> </set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set> <set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:propertyName="x" android:propertyName="x"
android:valueType="floatType"
android:valueFrom="0" android:valueFrom="0"
android:valueTo="-1280" android:valueTo="-1280"
android:duration="400"/> android:valueType="floatType" />
</set> </set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set> <set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:propertyName="x" android:propertyName="x"
android:valueType="floatType"
android:valueFrom="0" android:valueFrom="0"
android:valueTo="1280" android:valueTo="1280"
android:duration="400"/> android:valueType="floatType" />
</set> </set>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal"> android:viewportWidth="24.0">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z"/> android:pathData="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal"> android:viewportWidth="24.0">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M6.18,17.82m-2.18,0a2.18,2.18 0,1 1,4.36 0a2.18,2.18 0,1 1,-4.36 0"/> android:pathData="M6.18,17.82m-2.18,0a2.18,2.18 0,1 1,4.36 0a2.18,2.18 0,1 1,-4.36 0" />
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M4,4.44v2.83c7.03,0 12.73,5.7 12.73,12.73h2.83c0,-8.59 -6.97,-15.56 -15.56,-15.56zM4,10.1v2.83c3.9,0 7.07,3.17 7.07,7.07h2.83c0,-5.47 -4.43,-9.9 -9.9,-9.9z"/> android:pathData="M4,4.44v2.83c7.03,0 12.73,5.7 12.73,12.73h2.83c0,-8.59 -6.97,-15.56 -15.56,-15.56zM4,10.1v2.83c3.9,0 7.07,3.17 7.07,7.07h2.83c0,-5.47 -4.43,-9.9 -9.9,-9.9z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:viewportHeight="24.0"
android:viewportHeight="24.0"> android:viewportWidth="24.0">
<path <path
android:fillColor="#FF000000" android:fillColor="#FF000000"
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56 1.84,0.63 3.37,1.91 4.33,3.56zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82c0.43,-1.43 1.08,-2.76 1.91,-3.96zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2 0,0.68 0.06,1.34 0.14,2L4.26,14zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56 -1.84,-0.63 -3.37,-1.9 -4.33,-3.56zM8.03,8L5.08,8c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8zM12,19.96c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96h3.82c-0.43,1.43 -1.08,2.76 -1.91,3.96zM14.34,14L9.66,14c-0.09,-0.66 -0.16,-1.32 -0.16,-2 0,-0.68 0.07,-1.35 0.16,-2h4.68c0.09,0.65 0.16,1.32 0.16,2 0,0.68 -0.07,1.34 -0.16,2zM14.59,19.56c0.6,-1.11 1.06,-2.31 1.38,-3.56h2.95c-0.96,1.65 -2.49,2.93 -4.33,3.56zM16.36,14c0.08,-0.66 0.14,-1.32 0.14,-2 0,-0.68 -0.06,-1.34 -0.14,-2h3.38c0.16,0.64 0.26,1.31 0.26,2s-0.1,1.36 -0.26,2h-3.38z"/> android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56 1.84,0.63 3.37,1.91 4.33,3.56zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82c0.43,-1.43 1.08,-2.76 1.91,-3.96zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2 0,0.68 0.06,1.34 0.14,2L4.26,14zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56 -1.84,-0.63 -3.37,-1.9 -4.33,-3.56zM8.03,8L5.08,8c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8zM12,19.96c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96h3.82c-0.43,1.43 -1.08,2.76 -1.91,3.96zM14.34,14L9.66,14c-0.09,-0.66 -0.16,-1.32 -0.16,-2 0,-0.68 0.07,-1.35 0.16,-2h4.68c0.09,0.65 0.16,1.32 0.16,2 0,0.68 -0.07,1.34 -0.16,2zM14.59,19.56c0.6,-1.11 1.06,-2.31 1.38,-3.56h2.95c-0.96,1.65 -2.49,2.93 -4.33,3.56zM16.36,14c0.08,-0.66 0.14,-1.32 0.14,-2 0,-0.68 -0.06,-1.34 -0.14,-2h3.38c0.16,0.64 0.26,1.31 0.26,2s-0.1,1.36 -0.26,2h-3.38z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
</vector>
...@@ -4,20 +4,17 @@ ...@@ -4,20 +4,17 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<WebView
<Button android:id="@+id/login_webview"
android:id="@+id/guest_login" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_height="48dp" android:layout_alignParentLeft="true"
android:layout_gravity="center" android:layout_alignParentStart="true"
android:text="Guest Login" /> android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
<Button android:layout_alignParentTop="false"
android:id="@+id/ldap_login" android:layout_alignWithParentIfMissing="false">
android:layout_width="wrap_content" </WebView>
android:layout_height="48dp"
android:layout_gravity="center"
android:text="LDAP login" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="1dp"
card_view:cardElevation="4dp"> card_view:cardElevation="1dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
android:id="@+id/post_title" android:id="@+id/post_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:textColor="#000000" android:textColor="#000000"
android:textSize="20sp" android:textSize="22sp" />
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/post_published" android:id="@+id/post_published"
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:textColor="#000000" /> android:textColor="#000000"
android:textColorLink="@color/colorPrimary" />
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
\ No newline at end of file
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="1dp"
card_view:cardElevation="4dp"> card_view:cardElevation="1dp">
<LinearLayout <LinearLayout
android:id="@+id/body_card_layout" android:id="@+id/body_card_layout"
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="1dp"
card_view:cardElevation="4dp"> card_view:cardElevation="1dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
<TextView <TextView
android:id="@+id/tv_end" android:id="@+id/tv_end"
android:enabled="false"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
android:text="Org Title" android:text="Org Title"
android:textColor="#fff" android:textColor="#fff"
android:textSize="21sp" android:textSize="21sp"
android:textStyle="bold"/> android:textStyle="bold" />
<ImageButton <ImageButton
android:id="@+id/web_body_button" android:id="@+id/web_body_button"
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
android:contentDescription="Org Website" android:contentDescription="Org Website"
android:src="@drawable/ic_language_black_24dp" android:src="@drawable/ic_language_black_24dp"
android:tint="@color/colorWhite" android:tint="@color/colorWhite"
android:visibility="invisible"/> android:visibility="invisible" />
<ImageButton <ImageButton
android:id="@+id/share_body_button" android:id="@+id/share_body_button"
...@@ -119,13 +119,21 @@ ...@@ -119,13 +119,21 @@
android:id="@+id/body_description" android:id="@+id/body_description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginBottom="16dp"
android:textColor="#777" android:textColor="#777"
android:textSize="16sp" /> android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:fontFamily="sans-serif-light"
android:text="Events"
android:textSize="20sp" />
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/event_card_recycler_view" android:id="@+id/event_card_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -133,6 +141,51 @@ ...@@ -133,6 +141,51 @@
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:nestedScrollingEnabled="false" /> android:nestedScrollingEnabled="false" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:fontFamily="sans-serif-light"
android:text="Organizations"
android:textSize="20sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/org_card_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:nestedScrollingEnabled="false" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:fontFamily="sans-serif-light"
android:text="People"
android:textSize="20sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/people_card_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:nestedScrollingEnabled="false" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:fontFamily="sans-serif-light"
android:text="Part of"
android:textSize="20sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/parentorg_card_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:nestedScrollingEnabled="false" />
</LinearLayout> </LinearLayout>
</android.support.v4.widget.NestedScrollView> </android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".fragment.BodyRecyclerViewFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/body_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
\ No newline at end of file
<RelativeLayout android:layout_width="match_parent" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent" android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"> android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent" <android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
...@@ -10,8 +11,8 @@ ...@@ -10,8 +11,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="#fafafa" android:background="#fafafa"
android:theme="@style/CalendarTheme" android:orientation="vertical"
android:orientation="vertical"> android:theme="@style/CalendarTheme">
<RelativeLayout <RelativeLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -47,7 +48,7 @@ ...@@ -47,7 +48,7 @@
android:background="@drawable/round_text_box" android:background="@drawable/round_text_box"
android:gravity="center" android:gravity="center"
android:text="# Events Today" android:text="# Events Today"
android:textColor="@color/primaryTextColor"/> android:textColor="@color/secondaryTextColor" />
</RelativeLayout> </RelativeLayout>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
...@@ -70,6 +71,6 @@ ...@@ -70,6 +71,6 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_margin="16dp" android:layout_margin="16dp"
android:src="@android:drawable/ic_input_add" android:src="@android:drawable/ic_input_add"
android:tint="@android:color/white" /> android:tint="@android:color/black" />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -53,39 +53,39 @@ ...@@ -53,39 +53,39 @@
android:text="Event Title" android:text="Event Title"
android:textColor="#fff" android:textColor="#fff"
android:textSize="21sp" android:textSize="21sp"
android:textStyle="bold"/> android:textStyle="bold" />
<ImageButton <ImageButton
android:id="@+id/web_event_button" android:id="@+id/web_event_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Event Website" android:contentDescription="Event Website"
android:layout_marginStart="8dp"
app:srcCompat="@drawable/ic_language_black_24dp"
android:tint="@color/colorWhite" android:tint="@color/colorWhite"
android:visibility="invisible"/> android:visibility="invisible"
app:srcCompat="@drawable/ic_language_black_24dp" />
<ImageButton <ImageButton
android:id="@+id/navigate_button" android:id="@+id/navigate_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Navigate" android:contentDescription="Navigate"
android:layout_marginStart="8dp" android:tint="@color/colorWhite"
app:srcCompat="@drawable/baseline_navigation_24" app:srcCompat="@drawable/baseline_navigation_24" />
android:tint="@color/colorWhite" />
<ImageButton <ImageButton
android:id="@+id/share_event_button" android:id="@+id/share_event_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Share Event" android:contentDescription="Share Event"
android:layout_marginStart="8dp"
android:src="@drawable/ic_menu_share" android:src="@drawable/ic_menu_share"
android:tint="@color/colorWhite" /> android:tint="@color/colorWhite" />
</LinearLayout> </LinearLayout>
...@@ -189,10 +189,10 @@ ...@@ -189,10 +189,10 @@
android:id="@+id/event_page_description" android:id="@+id/event_page_description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginBottom="16dp"
android:textColor="#777" android:textColor="#777"
android:textSize="16sp" /> android:textSize="16sp" />
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/event_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
\ No newline at end of file
...@@ -25,5 +25,5 @@ ...@@ -25,5 +25,5 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_margin="16dp" android:layout_margin="16dp"
android:src="@android:drawable/ic_input_add" android:src="@android:drawable/ic_input_add"
android:tint="@android:color/white" /> android:tint="@android:color/black" />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
android:id="@+id/hostel_spinner" android:id="@+id/hostel_spinner"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp" /> android:background="@color/colorPrimary"
android:paddingBottom="12dp"
android:paddingLeft="16dp"
android:theme="@style/AppTheme" />
<android.support.v4.widget.SwipeRefreshLayout <android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/mess_menu_swipe_refresh_layout" android:id="@+id/mess_menu_swipe_refresh_layout"
...@@ -20,8 +23,7 @@ ...@@ -20,8 +23,7 @@
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/mess_menu_recycler_view" android:id="@+id/mess_menu_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" />
android:paddingTop="8dp" />
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout> </LinearLayout>
...@@ -26,5 +26,6 @@ ...@@ -26,5 +26,6 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_margin="16dp" android:layout_margin="16dp"
android:src="@android:drawable/ic_input_add" android:src="@android:drawable/ic_input_add"
android:tint="@android:color/white" /> <<<<<<< HEAD
android:tint="@android:color/black" />
</RelativeLayout> </RelativeLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.QLinksFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.SettingsFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
\ No newline at end of file
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="start" android:gravity="start"
android:padding="4dp" android:padding="4dp"
android:textColor="#000000" android:textColor="@color/primaryTextColor"
android:textSize="20sp" /> android:textSize="20sp" />
\ No newline at end of file
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="1dp"
card_view:cardElevation="4dp"> card_view:cardElevation="1dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="1dp"
card_view:cardElevation="4dp"> card_view:cardElevation="1dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -31,16 +31,25 @@ ...@@ -31,16 +31,25 @@
<TextView <TextView
android:id="@+id/article_body" android:id="@+id/article_body"
android:layout_marginEnd="8dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:textColor="#000000" android:textColor="#000000"
android:textStyle="bold" /> android:textSize="17sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text=" | "
android:textSize="17sp" />
<TextView <TextView
android:id="@+id/article_published" android:id="@+id/article_published"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:textSize="17sp" />
</LinearLayout> </LinearLayout>
<TextView <TextView
...@@ -48,6 +57,7 @@ ...@@ -48,6 +57,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:textColor="#000000" /> android:textColor="#000000"
android:textColorLink="@color/colorPrimary" />
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
\ No newline at end of file
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="1dp"
card_view:cardElevation="4dp"> card_view:cardElevation="1dp">
<LinearLayout <LinearLayout
android:id="@+id/role_card_layout" android:id="@+id/role_card_layout"
......
...@@ -9,15 +9,20 @@ ...@@ -9,15 +9,20 @@
android:id="@+id/nav_feed" android:id="@+id/nav_feed"
android:icon="@drawable/ic_dashboard_black_48dp" android:icon="@drawable/ic_dashboard_black_48dp"
android:title="Feed" /> android:title="Feed" />
<item
android:id="@+id/nav_news"
android:icon="@drawable/baseline_rss_feed_black_48"
android:title="News" />
<item <item
android:id="@+id/nav_my_events" android:id="@+id/nav_my_events"
android:icon="@drawable/ic_event" android:icon="@drawable/ic_event"
android:title="My Events" /> android:title="My Events" />
<item <item
android:id="@+id/nav_news" android:id="@+id/nav_mess_menu"
android:icon="@drawable/baseline_rss_feed_black_48" android:icon="@drawable/ic_restaurant_black_48dp"
android:title="News" /> android:title="Mess Menu" />
<item <item
android:id="@+id/nav_placement_blog" android:id="@+id/nav_placement_blog"
...@@ -29,47 +34,25 @@ ...@@ -29,47 +34,25 @@
android:icon="@drawable/ic_work_black_48dp" android:icon="@drawable/ic_work_black_48dp"
android:title="Training Blog" /> android:title="Training Blog" />
<item
android:id="@+id/nav_mess_menu"
android:icon="@drawable/ic_restaurant_black_48dp"
android:title="Mess Menu" />
<item
android:id="@+id/nav_gc_rankings"
android:icon="@drawable/ic_equalizer_black_48dp"
android:title="GC Rankings" />
<item <item
android:id="@+id/nav_calendar" android:id="@+id/nav_calendar"
android:icon="@drawable/ic_date_range_black_48dp" android:icon="@drawable/ic_date_range_black_48dp"
android:title="Calendar" /> android:title="Calendar" />
<item
android:id="@+id/nav_timetable"
android:icon="@drawable/ic_web_black_48dp"
android:title="Timetable" />
<item
android:id="@+id/nav_cms"
android:icon="@drawable/ic_announcement_black_48dp"
android:title="CMS" />
<item <item
android:id="@+id/nav_map" android:id="@+id/nav_map"
android:icon="@drawable/ic_map_black_48dp" android:icon="@drawable/ic_map_black_48dp"
android:title="Map" /> android:title="Map" />
<item
android:id="@+id/nav_people"
android:icon="@drawable/ic_supervisor_account_black_48dp"
android:title="People" />
</group>
<item android:title="Communicate">
<menu>
<item <item
android:id="@+id/nav_contacts" android:id="@+id/nav_qlinks"
android:icon="@drawable/ic_phone" android:icon="@drawable/ic_link_black_24dp"
android:title="Contacts" /> android:title="Quick Links" />
<item <item
android:id="@+id/nav_about" android:id="@+id/nav_settings"
android:icon="@drawable/ic_info_black_48dp" android:icon="@drawable/ic_settings_black_24dp"
android:title="About" /> android:title="Settings" />
</menu> </group>
</item>
</menu> </menu>
...@@ -7,12 +7,9 @@ ...@@ -7,12 +7,9 @@
</style> </style>
<style name="CalendarTheme" parent="@style/AppTheme.NoActionBar"> <style name="CalendarTheme" parent="@style/AppTheme.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorSecondary</item>
<item name="colorAccent">#ecf833</item> <item name="android:textColorPrimaryInverse">@color/secondaryTextColor</item>
<item name="android:colorBackground">?attr/colorButtonNormal</item>
<item name="android:textColorPrimaryInverse">@android:color/darker_gray</item>
<item name="android:windowBackground">?android:attr/colorButtonNormal</item> <item name="android:windowBackground">?android:attr/colorButtonNormal</item>
</style> </style>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<color name="colorPrimary">#536dfe</color> <color name="colorPrimary">#536dfe</color>
<color name="primaryLightColor">#8f9bff</color> <color name="primaryLightColor">#8f9bff</color>
<color name="colorPrimaryDark">#0043ca</color> <color name="colorPrimaryDark">#0043ca</color>
<color name="colorAccent">#0043ca</color> <color name="colorAccent">#ffd740</color>
<color name="colorSecondary">#ffd740</color> <color name="colorSecondary">#ffd740</color>
......
...@@ -17,15 +17,4 @@ ...@@ -17,15 +17,4 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="CalendarTheme" parent="@style/AppTheme.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorBackground">@android:color/darker_gray</item>
<item name="android:textColorPrimaryInverse">@android:color/darker_gray</item>
<item name="android:windowBackground">@android:color/darker_gray</item>
</style>
</resources> </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 to comment