Commit abb6aa1e authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge pull request #162 from pulsejet/patch-3

Patch 3
parents 8f18cea2 87dc3ee1
......@@ -10,7 +10,7 @@
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
......@@ -20,15 +20,12 @@
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" />
<!-- FCM styling -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_lotusgray" />
android:resource="@drawable/ic_lotus_blue" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" />
<activity
android:name=".MainActivity"
......@@ -97,18 +94,6 @@
</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>
<service
android:name=".notifications.NotificationIntentService"
......@@ -125,16 +110,6 @@
</intent-filter>
</receiver>
<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=".InstiAppFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
......
......@@ -28,11 +28,15 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import com.squareup.picasso.Picasso;
import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator;
import app.insti.api.UnsafeOkHttpClient;
import app.insti.data.Body;
import app.insti.data.Event;
import app.insti.data.User;
import app.insti.fragment.BackHandledFragment;
import app.insti.fragment.BodyFragment;
......@@ -51,6 +55,9 @@ import app.insti.fragment.QuickLinksFragment;
import app.insti.fragment.SettingsFragment;
import app.insti.fragment.TrainingBlogFragment;
import app.insti.notifications.NotificationEventReceiver;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
......@@ -189,9 +196,37 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if (session.isLoggedIn()) {
currentUser = User.fromString(session.pref.getString(Constants.CURRENT_USER, ""));
updateNavigationView();
updateFCMId();
}
}
/** Update FCM Id and update profile */
private void updateFCMId() {
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
@Override
public void onSuccess(InstanceIdResult instanceIdResult) {
String fcmId = instanceIdResult.getToken();
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getUserMe(getSessionIDHeader(), fcmId).enqueue(new Callback<User>() {
@Override
public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) {
session.createLoginSession(response.body().getUserName(), response.body(), session.getSessionID());
currentUser = response.body();
} else {
session.logout();
currentUser = null;
Toast.makeText(MainActivity.this, "You session has expired!", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Call<User> call, Throwable t) { }
});
}
});
}
private void initNavigationView() {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
......
......@@ -51,7 +51,7 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
Body body = bodyList.get(position);
holder.name.setText(body.getBodyName());
holder.description.setText(body.getBodyShortDescription());
Picasso.get().load(body.getBodyImageURL()).into(holder.image);
Picasso.get().load(body.getBodyImageURL()).resize(0,200).into(holder.image);
}
......
......@@ -61,6 +61,12 @@ public interface RetrofitInterface {
@POST("upload")
Call<ImageUploadResponse> uploadImage(@Header("Cookie") String sessionID, @Body ImageUploadRequest imageUploadRequest);
@GET("user-me")
Call<User> getUserMe(@Header("Cookie") String sessionID);
@GET("user-me")
Call<User> getUserMe(@Header("Cookie") String sessionID, @Query("fcm_id") String fcmId);
@GET("user-me/ues/{eventID}")
Call<Void> updateUserEventStatus(@Header("Cookie") String sessionID, @Path("eventID") String eventID, @Query("status") int status);
......
......@@ -72,7 +72,7 @@ public class AboutFragment extends BaseFragment {
/* Show team pics */
for (final Map.Entry<Integer, String> entry : team.entrySet()) {
CircleImageView circleImageView = getActivity().findViewById(entry.getKey());
Picasso.get().load("https://insti.app/team-pics/" + entry.getValue()).into(circleImageView);
Picasso.get().load("https://insti.app/team-pics/" + entry.getValue()).resize(0,300).into(circleImageView);
}
/* Map TextView ids to links */
......
......@@ -200,6 +200,8 @@ public class MapFragment extends Fragment implements TextWatcher,
/* Initialize */
appDatabase = AppDatabase.getAppDatabase(getContext());
editText = (EditText)getView().findViewById(R.id.search);
setFonts();
getAPILocations();
new showLocationsFromDB().execute();
......@@ -442,15 +444,25 @@ public class MapFragment extends Fragment implements TextWatcher,
}
private void setFonts() {
if (getView() == null || getActivity() == null) return;
Typeface regular = Typeface.createFromAsset(getActivity().getAssets(), FONT_REGULAR);
placeNameTextView.setTypeface(regular, Typeface.BOLD);
placeSubHeadTextView.setTypeface(regular);
editText.setTypeface(regular);
if (placeNameTextView != null) {
placeNameTextView.setTypeface(regular, Typeface.BOLD);
}
if (placeSubHeadTextView != null) {
placeSubHeadTextView.setTypeface(regular);
}
if (editText != null) {
editText.setTypeface(regular);
}
TextView settingsTitle = (TextView) getActivity()
.findViewById(R.id.settings_title);
settingsTitle.setTypeface(regular);
if (settingsTitle != null) {
settingsTitle.setTypeface(regular);
}
}
private Runnable setAnchor() {
......
......@@ -142,7 +142,7 @@ public class ProfileFragment extends BackHandledFragment {
Picasso.get()
.load(user.getUserProfilePictureUrl())
.resize(800, 0)
.resize(500, 0)
.placeholder(R.drawable.user_placeholder)
.into(userProfilePictureImageView);
......
<vector android:height="24dp" android:viewportHeight="792"
android:viewportWidth="792" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="0.4" android:fillColor="#448aff"
android:pathData="m396.004,170.224l0,0a303.09,303.09 90,0 1,-0.007 428.627l0,0 0,0A303.09,303.09 90,0 1,396.004 170.224Z" android:strokeAlpha="0.4"/>
<path android:fillAlpha="0.4" android:fillColor="#448aff"
android:pathData="m699.09,295.76l-0,0a303.09,303.09 0,0 1,-303.09 303.09l-0,0 -0,0A303.09,303.09 0,0 1,699.09 295.76Z" android:strokeAlpha="0.4"/>
<path android:fillAlpha="0.4" android:fillColor="#448aff"
android:pathData="m92.91,295.76v0A303.09,303.09 0,0 1,396 598.85v0,0A303.09,303.09 0,0 1,92.91 295.76Z" android:strokeAlpha="0.4"/>
<path android:fillAlpha="0.4" android:fillColor="#448aff"
android:pathData="m231.969,202.853l0,0a303.09,303.09 67.5,0 1,164.035 395.997l0,0 0,0A303.09,303.09 67.5,0 1,231.969 202.853Z" android:strokeAlpha="0.4"/>
<path android:fillAlpha="0.4" android:fillColor="#448aff"
android:pathData="m791.997,434.851a302.83,302.83 0,0 1,-396 164,302.83 302.83,0 0,1 396,-164z" android:strokeAlpha="0.4"/>
<path android:fillAlpha="0.4" android:fillColor="#448aff"
android:pathData="m560.025,202.845l0,0a303.09,303.09 112.5,0 1,-164.022 396.002l0,0 0,0A303.09,303.09 112.5,0 1,560.025 202.845Z" android:strokeAlpha="0.4"/>
<path android:fillAlpha="0.4" android:fillColor="#448aff"
android:pathData="M396,598.82C321.742,629.652 241.162,630.1 166.879,599.33 92.595,568.561 30.706,509.1 0,434.79 154.64,370.577 332.04,444.046 396,598.79Z" android:strokeAlpha="0.4"/>
</vector>
......@@ -24,7 +24,7 @@
android:layout_alignParentTop="true"
android:background="@null"
android:dropDownHeight="0dp"
android:fontFamily="sans-serif-light"
android:fontFamily="sans-serif"
android:hint="Search"
android:imeOptions="actionSearch"
android:inputType="textNoSuggestions"
......
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