Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
c2e0bd37
Commit
c2e0bd37
authored
Feb 01, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add show contact number to settings
parent
0c4a31cf
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
1 deletion
+77
-1
app/src/main/java/app/insti/api/RetrofitInterface.java
app/src/main/java/app/insti/api/RetrofitInterface.java
+4
-0
app/src/main/java/app/insti/api/model/User.java
app/src/main/java/app/insti/api/model/User.java
+14
-1
app/src/main/java/app/insti/api/request/UserShowContactPatchRequest.java
...va/app/insti/api/request/UserShowContactPatchRequest.java
+12
-0
app/src/main/java/app/insti/fragment/SettingsFragment.java
app/src/main/java/app/insti/fragment/SettingsFragment.java
+35
-0
app/src/main/res/layout/fragment_settings.xml
app/src/main/res/layout/fragment_settings.xml
+12
-0
No files found.
app/src/main/java/app/insti/api/RetrofitInterface.java
View file @
c2e0bd37
...
...
@@ -18,6 +18,7 @@ import app.insti.api.request.ComplaintCreateRequest;
import
app.insti.api.request.EventCreateRequest
;
import
app.insti.api.request.ImageUploadRequest
;
import
app.insti.api.request.UserFCMPatchRequest
;
import
app.insti.api.request.UserShowContactPatchRequest
;
import
app.insti.api.response.ComplaintCreateResponse
;
import
app.insti.api.response.EventCreateResponse
;
import
app.insti.api.response.ExploreResponse
;
...
...
@@ -87,6 +88,9 @@ public interface RetrofitInterface {
@PATCH
(
"user-me"
)
Call
<
User
>
patchUserMe
(
@Header
(
"Cookie"
)
String
sessionID
,
@Body
UserFCMPatchRequest
userFCMPatchRequest
);
@PATCH
(
"user-me"
)
Call
<
User
>
patchUserMe
(
@Header
(
"Cookie"
)
String
sessionID
,
@Body
UserShowContactPatchRequest
userShowContactPatchRequest
);
@GET
(
"user-me/ues/{eventID}"
)
Call
<
Void
>
updateUserEventStatus
(
@Header
(
"Cookie"
)
String
sessionID
,
@Path
(
"eventID"
)
String
eventID
,
@Query
(
"status"
)
int
status
);
...
...
app/src/main/java/app/insti/api/model/User.java
View file @
c2e0bd37
...
...
@@ -35,6 +35,9 @@ public class User implements CardInterface {
@SerializedName
(
"contact_no"
)
private
String
userContactNumber
;
@SerializedName
(
"show_contact_no"
)
private
Boolean
showContactNumber
;
@SerializedName
(
"about"
)
private
String
userAbout
;
...
...
@@ -64,7 +67,7 @@ public class User implements CardInterface {
private
String
currentRole
;
public
User
(
@NonNull
String
userID
,
String
userName
,
String
userProfilePictureUrl
,
List
<
Event
>
userInterestedEvents
,
List
<
Event
>
userGoingEvents
,
String
userEmail
,
String
userRollNumber
,
String
userContactNumber
,
String
userAbout
,
List
<
Body
>
userFollowedBodies
,
List
<
String
>
userFollowedBodiesID
,
List
<
Role
>
userRoles
,
List
<
Role
>
userInstituteRoles
,
List
<
Role
>
userFormerRoles
,
String
userWebsiteURL
,
String
userLDAPId
,
String
hostel
)
{
public
User
(
@NonNull
String
userID
,
String
userName
,
String
userProfilePictureUrl
,
List
<
Event
>
userInterestedEvents
,
List
<
Event
>
userGoingEvents
,
String
userEmail
,
String
userRollNumber
,
String
userContactNumber
,
Boolean
showContactNumber
,
String
userAbout
,
List
<
Body
>
userFollowedBodies
,
List
<
String
>
userFollowedBodiesID
,
List
<
Role
>
userRoles
,
List
<
Role
>
userInstituteRoles
,
List
<
Role
>
userFormerRoles
,
String
userWebsiteURL
,
String
userLDAPId
,
String
hostel
,
String
currentRole
)
{
this
.
userID
=
userID
;
this
.
userName
=
userName
;
this
.
userProfilePictureUrl
=
userProfilePictureUrl
;
...
...
@@ -73,6 +76,7 @@ public class User implements CardInterface {
this
.
userEmail
=
userEmail
;
this
.
userRollNumber
=
userRollNumber
;
this
.
userContactNumber
=
userContactNumber
;
this
.
showContactNumber
=
showContactNumber
;
this
.
userAbout
=
userAbout
;
this
.
userFollowedBodies
=
userFollowedBodies
;
this
.
userFollowedBodiesID
=
userFollowedBodiesID
;
...
...
@@ -82,6 +86,7 @@ public class User implements CardInterface {
this
.
userWebsiteURL
=
userWebsiteURL
;
this
.
userLDAPId
=
userLDAPId
;
this
.
hostel
=
hostel
;
this
.
currentRole
=
currentRole
;
}
public
static
User
fromString
(
String
json
)
{
...
...
@@ -225,6 +230,14 @@ public class User implements CardInterface {
this
.
hostel
=
hostel
;
}
public
Boolean
getShowContactNumber
()
{
return
showContactNumber
;
}
public
void
setShowContactNumber
(
Boolean
showContactNumber
)
{
this
.
showContactNumber
=
showContactNumber
;
}
public
String
getCurrentRole
()
{
return
currentRole
;
}
...
...
app/src/main/java/app/insti/api/request/UserShowContactPatchRequest.java
0 → 100644
View file @
c2e0bd37
package
app.insti.api.request
;
import
com.google.gson.annotations.SerializedName
;
public
class
UserShowContactPatchRequest
{
@SerializedName
(
"show_contact_no"
)
private
Boolean
showContactNumber
;
public
UserShowContactPatchRequest
(
Boolean
showContactNumber
)
{
this
.
showContactNumber
=
showContactNumber
;
}
}
app/src/main/java/app/insti/fragment/SettingsFragment.java
View file @
c2e0bd37
...
...
@@ -10,7 +10,9 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.CompoundButton
;
import
android.widget.ImageView
;
import
android.widget.Switch
;
import
android.widget.TextView
;
import
com.squareup.picasso.Picasso
;
...
...
@@ -23,6 +25,7 @@ import app.insti.activity.LoginActivity;
import
app.insti.activity.MainActivity
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.User
;
import
app.insti.api.request.UserShowContactPatchRequest
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
...
...
@@ -64,6 +67,7 @@ public class SettingsFragment extends Fragment {
if
(
response
.
isSuccessful
())
{
user
=
response
.
body
();
populateUserCard
();
setupContactSwitch
(
user
);
}
}
...
...
@@ -74,6 +78,37 @@ public class SettingsFragment extends Fragment {
});
}
private
void
setupContactSwitch
(
User
user
)
{
final
Switch
showContactSwitch
=
getView
().
findViewById
(
R
.
id
.
show_contact_switch
);
showContactSwitch
.
setVisibility
(
View
.
VISIBLE
);
showContactSwitch
.
setChecked
(
user
.
getShowContactNumber
());
showContactSwitch
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
buttonView
,
final
boolean
isChecked
)
{
showContactSwitch
.
setEnabled
(
false
);
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
patchUserMe
(
Utils
.
getSessionIDHeader
(),
new
UserShowContactPatchRequest
(
isChecked
)).
enqueue
(
new
Callback
<
User
>()
{
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
if
(
response
.
isSuccessful
())
{
showContactSwitch
.
setEnabled
(
true
);
}
else
{
showContactSwitch
.
setChecked
(!
isChecked
);
showContactSwitch
.
setEnabled
(
true
);
}
}
@Override
public
void
onFailure
(
Call
<
User
>
call
,
Throwable
t
)
{
showContactSwitch
.
setChecked
(!
isChecked
);
showContactSwitch
.
setEnabled
(
true
);
}
});
}
});
}
private
void
populateUserCard
()
{
if
(
getActivity
()
==
null
||
getView
()
==
null
)
{
return
;
...
...
app/src/main/res/layout/fragment_settings.xml
View file @
c2e0bd37
...
...
@@ -43,6 +43,18 @@
</LinearLayout>
</android.support.v7.widget.CardView>
<Switch
android:id=
"@+id/show_contact_switch"
style=
"@style/Widget.AppCompat.Button.Borderless"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Show contact no"
android:textSize=
"20sp"
android:gravity=
"center_vertical"
android:textAllCaps=
"false"
android:padding=
"16dp"
android:visibility=
"gone"
/>
<Button
android:id=
"@+id/settings_update_profile"
style=
"@style/Widget.AppCompat.Button.Borderless"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment