Commit 85e1b813 authored by Sajal Narang's avatar Sajal Narang

Add share button to UserFragment

parent ad8cb8be
...@@ -2,6 +2,7 @@ package app.insti; ...@@ -2,6 +2,7 @@ package app.insti;
import app.insti.data.Body; import app.insti.data.Body;
import app.insti.data.Event; import app.insti.data.Event;
import app.insti.data.User;
/** /**
* Created by varun on 03-Apr-18. * Created by varun on 03-Apr-18.
...@@ -10,11 +11,15 @@ import app.insti.data.Event; ...@@ -10,11 +11,15 @@ import app.insti.data.Event;
public final class ShareURLMaker { public final class ShareURLMaker {
public static final String WEB_HOST = "https://insti.app/"; public static final String WEB_HOST = "https://insti.app/";
public static final String getEventURL(Event event) { public static String getEventURL(Event event) {
return WEB_HOST + "event/" + event.getEventStrID(); return WEB_HOST + "event/" + event.getEventStrID();
} }
public static final String getBodyURL(Body body) { public static String getBodyURL(Body body) {
return WEB_HOST + "org/" + body.getBodyStrID(); return WEB_HOST + "org/" + body.getBodyStrID();
} }
public static String getUserURL(User user) {
return WEB_HOST + "user/" + user.getUserLDAPId();
}
} }
...@@ -22,6 +22,7 @@ import android.view.LayoutInflater; ...@@ -22,6 +22,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
...@@ -32,6 +33,7 @@ import java.util.List; ...@@ -32,6 +33,7 @@ import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.ShareURLMaker;
import app.insti.adapter.RoleAdapter; import app.insti.adapter.RoleAdapter;
import app.insti.adapter.TabAdapter; import app.insti.adapter.TabAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
...@@ -44,6 +46,8 @@ import retrofit2.Call; ...@@ -44,6 +46,8 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import static android.view.View.VISIBLE;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
...@@ -126,9 +130,10 @@ public class UserFragment extends BackHandledFragment { ...@@ -126,9 +130,10 @@ public class UserFragment extends BackHandledFragment {
TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile); TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile);
final TextView userEmailIDTextView = getActivity().findViewById(R.id.user_email_profile); final TextView userEmailIDTextView = getActivity().findViewById(R.id.user_email_profile);
TextView userContactNumberTextView = getActivity().findViewById(R.id.user_contact_no_profile); TextView userContactNumberTextView = getActivity().findViewById(R.id.user_contact_no_profile);
ImageButton userShareImageButton = getActivity().findViewById(R.id.share_user_button);
/* Show tabs */ /* Show tabs */
getActivity().findViewById(R.id.tab_layout).setVisibility(View.VISIBLE); getActivity().findViewById(R.id.tab_layout).setVisibility(VISIBLE);
final List<Role> roleList = user.getUserRoles(); final List<Role> roleList = user.getUserRoles();
List<Role> formerRoleList = user.getUserFormerRoles(); List<Role> formerRoleList = user.getUserFormerRoles();
...@@ -211,6 +216,20 @@ public class UserFragment extends BackHandledFragment { ...@@ -211,6 +216,20 @@ public class UserFragment extends BackHandledFragment {
}); });
} }
userShareImageButton.setOnClickListener(new View.OnClickListener() {
String shareUrl = ShareURLMaker.getUserURL(user);
@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"));
}
});
userShareImageButton.setVisibility(VISIBLE);
getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE); getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
} }
...@@ -325,7 +344,7 @@ public class UserFragment extends BackHandledFragment { ...@@ -325,7 +344,7 @@ public class UserFragment extends BackHandledFragment {
// begins, it will position the zoomed-in view in the place of the // begins, it will position the zoomed-in view in the place of the
// thumbnail. // thumbnail.
thumbView.setAlpha(0f); thumbView.setAlpha(0f);
expandedImageView.setVisibility(View.VISIBLE); expandedImageView.setVisibility(VISIBLE);
// Set the pivot point for SCALE_X and SCALE_Y transformations // Set the pivot point for SCALE_X and SCALE_Y transformations
// to the top-left corner of the zoomed-in view (the default // to the top-left corner of the zoomed-in view (the default
......
...@@ -10,10 +10,9 @@ ...@@ -10,10 +10,9 @@
android:orientation="vertical" android:orientation="vertical"
tools:context="app.insti.fragment.UserFragment"> tools:context="app.insti.fragment.UserFragment">
<LinearLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/user_profile_picture_profile" android:id="@+id/user_profile_picture_profile"
...@@ -26,6 +25,7 @@ ...@@ -26,6 +25,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_toEndOf="@id/user_profile_picture_profile"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
...@@ -60,7 +60,20 @@ ...@@ -60,7 +60,20 @@
</LinearLayout> </LinearLayout>
</LinearLayout> <ImageButton
android:id="@+id/share_user_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Share User"
android:padding="16dp"
android:src="@drawable/ic_menu_share" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/role_recycler_view" android:id="@+id/role_recycler_view"
......
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