Commit 57243f72 authored by mayu's avatar mayu

removed _site

parent d0bb8cda
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.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.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.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 CMSFragment extends BaseFragment {
public CMSFragment() {
// 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_cms, 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 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.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 ContactsFragment extends BaseFragment {
public ContactsFragment() {
// 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_contacts, container, false);
}
}
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.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 GCRankingsFragment extends BaseFragment {
public GCRankingsFragment() {
// 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_gc_rankings, 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.
*/
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.app.SearchManager;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.SearchView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import java.util.ArrayList;
import in.ac.iitb.gymkhana.iitbapp.PeopleSuggestionAdapter;
import in.ac.iitb.gymkhana.iitbapp.R;
public class PeopleFragment extends BaseFragment {
View view;
SearchView searchView;
PeopleSuggestionAdapter adapter;
ArrayList<String> suggestionList = new ArrayList<String>();
ListView listView;
public PeopleFragment() {
// 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_people, container, false);
setHasOptionsMenu(true);
suggestionList.add("Web and Coding Club");
suggestionList.add("Electronics and Robotics Club");
suggestionList.add("Krittika");
suggestionList.add("Maths and Physics Club");
suggestionList.add("Aeromodelling Club");
suggestionList.add("Literati");
suggestionList.add("Roots");
suggestionList.add("Staccato");
suggestionList.add("Saaz");
suggestionList.add("InSync");
suggestionList.add("Pixels");
suggestionList.add("Rang");
suggestionList.add("FourthWall");
suggestionList.add("WeSpeak and Vaani");
suggestionList.add("SilverScreen");
suggestionList.add("IIT-BBC");
suggestionList.add("Design Club");
suggestionList.add("LifeStyleClub");
suggestionList.add("MoodIndigo");
suggestionList.add("Techfest");
suggestionList.add("SARC");
suggestionList.add("Academic Council");
listView = (ListView) view.findViewById(R.id.list_view);
listView.setVisibility(View.GONE);
adapter = new PeopleSuggestionAdapter(suggestionList);
listView.setAdapter(adapter);
//TODO SuggestionClickListener
return view;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
menu.clear();
inflater.inflate(R.menu.search_view_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
final SearchManager searchManager =
(SearchManager) getContext().getSystemService(Context.SEARCH_SERVICE);
searchView =
(SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
searchView.clearFocus();
listView.setVisibility(View.GONE);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
listView.setVisibility(View.VISIBLE);
adapter.getFilter().filter(newText);
return 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.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 TimetableFragment extends BaseFragment {
public TimetableFragment() {
// 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_timetable, container, false);
}
}
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>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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