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
b78325e3
Commit
b78325e3
authored
Feb 01, 2019
by
Varun Patil
Committed by
GitHub
Feb 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #267 from wncc/patch15
Fix up some stuff
parents
cbf41dbc
88aef255
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
151 additions
and
12 deletions
+151
-12
app/build.gradle
app/build.gradle
+1
-1
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+13
-3
app/src/main/java/app/insti/adapter/NotificationsAdapter.java
...src/main/java/app/insti/adapter/NotificationsAdapter.java
+9
-4
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/NewsArticle.java
app/src/main/java/app/insti/api/model/NewsArticle.java
+2
-0
app/src/main/java/app/insti/api/model/PlacementBlogPost.java
app/src/main/java/app/insti/api/model/PlacementBlogPost.java
+2
-0
app/src/main/java/app/insti/api/model/TrainingBlogPost.java
app/src/main/java/app/insti/api/model/TrainingBlogPost.java
+2
-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/RecyclerViewFragment.java
...rc/main/java/app/insti/fragment/RecyclerViewFragment.java
+35
-2
app/src/main/java/app/insti/fragment/SettingsFragment.java
app/src/main/java/app/insti/fragment/SettingsFragment.java
+35
-0
app/src/main/java/app/insti/interfaces/Clickable.java
app/src/main/java/app/insti/interfaces/Clickable.java
+2
-0
app/src/main/res/layout/fragment_settings.xml
app/src/main/res/layout/fragment_settings.xml
+12
-0
app/src/main/res/xml/network_security_config.xml
app/src/main/res/xml/network_security_config.xml
+6
-0
No files found.
app/build.gradle
View file @
b78325e3
...
@@ -28,7 +28,7 @@ ext {
...
@@ -28,7 +28,7 @@ ext {
okhttpVersion
=
'3.11.0'
okhttpVersion
=
'3.11.0'
picassoVersion
=
'2.71828'
picassoVersion
=
'2.71828'
circleImageViewVersion
=
'2.2.0'
circleImageViewVersion
=
'2.2.0'
markwonVersion
=
'
1.0.6
'
markwonVersion
=
'
2.0.1
'
tagViewVersion
=
'1.3'
tagViewVersion
=
'1.3'
circleIndicatorVersion
=
'1.2.2@aar'
circleIndicatorVersion
=
'1.2.2@aar'
firebaseVersion
=
'17.3.4'
firebaseVersion
=
'17.3.4'
...
...
app/src/main/AndroidManifest.xml
View file @
b78325e3
...
@@ -17,7 +17,8 @@
...
@@ -17,7 +17,8 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
android:name=
"app.insti.InstiAppApplication"
>
android:name=
"app.insti.InstiAppApplication"
android:networkSecurityConfig=
"@xml/network_security_config"
>
<meta-data
<meta-data
android:name=
"com.google.android.gms.version"
android:name=
"com.google.android.gms.version"
...
...
app/src/main/java/app/insti/activity/MainActivity.java
View file @
b78325e3
...
@@ -339,7 +339,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -339,7 +339,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
openEventFragment
(
id
);
openEventFragment
(
id
);
return
;
return
;
case
DATA_TYPE_NEWS:
case
DATA_TYPE_NEWS:
updateFragment
(
new
NewsFragment
(
));
updateFragment
(
(
new
NewsFragment
()).
withId
(
id
));
return
;
return
;
}
}
Log
.
e
(
"NOTIFICATIONS"
,
"Server sent invalid notification?"
);
Log
.
e
(
"NOTIFICATIONS"
,
"Server sent invalid notification?"
);
...
@@ -355,9 +355,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -355,9 +355,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
switch
(
type
)
{
switch
(
type
)
{
case
DATA_TYPE_PT:
case
DATA_TYPE_PT:
if
(
extra
.
contains
(
"/trainingblog"
))
{
if
(
extra
.
contains
(
"/trainingblog"
))
{
openTrainingBlog
();
openTrainingBlog
(
id
);
}
else
{
}
else
{
openPlacementBlog
();
openPlacementBlog
(
id
);
}
}
return
;
return
;
}
}
...
@@ -586,8 +586,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -586,8 +586,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
* Open placement blog fragment
* Open placement blog fragment
*/
*/
private
void
openPlacementBlog
()
{
private
void
openPlacementBlog
()
{
openPlacementBlog
(
null
);
}
private
void
openPlacementBlog
(
String
id
)
{
if
(
session
.
isLoggedIn
())
{
if
(
session
.
isLoggedIn
())
{
PlacementBlogFragment
placementBlogFragment
=
new
PlacementBlogFragment
();
PlacementBlogFragment
placementBlogFragment
=
new
PlacementBlogFragment
();
if
(
id
!=
null
)
placementBlogFragment
.
withId
(
id
);
updateFragment
(
placementBlogFragment
);
updateFragment
(
placementBlogFragment
);
}
else
{
}
else
{
Toast
.
makeText
(
this
,
Constants
.
LOGIN_MESSAGE
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
Constants
.
LOGIN_MESSAGE
,
Toast
.
LENGTH_LONG
).
show
();
...
@@ -595,8 +600,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -595,8 +600,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
private
void
openTrainingBlog
()
{
private
void
openTrainingBlog
()
{
openTrainingBlog
(
null
);
}
private
void
openTrainingBlog
(
String
id
)
{
if
(
session
.
isLoggedIn
())
{
if
(
session
.
isLoggedIn
())
{
TrainingBlogFragment
trainingBlogFragment
=
new
TrainingBlogFragment
();
TrainingBlogFragment
trainingBlogFragment
=
new
TrainingBlogFragment
();
if
(
id
!=
null
)
trainingBlogFragment
.
withId
(
id
);
updateFragment
(
trainingBlogFragment
);
updateFragment
(
trainingBlogFragment
);
}
else
{
}
else
{
Toast
.
makeText
(
this
,
Constants
.
LOGIN_MESSAGE
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
Constants
.
LOGIN_MESSAGE
,
Toast
.
LENGTH_LONG
).
show
();
...
...
app/src/main/java/app/insti/adapter/NotificationsAdapter.java
View file @
b78325e3
...
@@ -12,6 +12,7 @@ import app.insti.Utils;
...
@@ -12,6 +12,7 @@ import app.insti.Utils;
import
app.insti.api.EmptyCallback
;
import
app.insti.api.EmptyCallback
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.Event
;
import
app.insti.api.model.Event
;
import
app.insti.api.model.NewsArticle
;
import
app.insti.api.model.Notification
;
import
app.insti.api.model.Notification
;
import
app.insti.api.model.PlacementBlogPost
;
import
app.insti.api.model.PlacementBlogPost
;
import
app.insti.fragment.NewsFragment
;
import
app.insti.fragment.NewsFragment
;
...
@@ -37,22 +38,26 @@ public class NotificationsAdapter extends CardAdapter<Notification> {
...
@@ -37,22 +38,26 @@ public class NotificationsAdapter extends CardAdapter<Notification> {
/* Close the bottom sheet */
/* Close the bottom sheet */
notificationsFragment
.
dismiss
();
notificationsFragment
.
dismiss
();
Gson
gson
=
Utils
.
gson
;
/* Open event */
/* Open event */
if
(
notification
.
isEvent
())
{
if
(
notification
.
isEvent
())
{
Gson
gson
=
new
Gson
();
Event
event
=
gson
.
fromJson
(
gson
.
toJson
(
notification
.
getNotificationActor
()),
Event
.
class
)
;
Event
event
=
gson
.
fromJson
(
gson
.
toJson
(
notification
.
getNotificationActor
()),
Event
.
class
)
;
Utils
.
openEventFragment
(
event
,
fragmentActivity
);
Utils
.
openEventFragment
(
event
,
fragmentActivity
);
}
else
if
(
notification
.
isNews
())
{
}
else
if
(
notification
.
isNews
())
{
NewsFragment
newsFragment
=
new
NewsFragment
();
NewsFragment
newsFragment
=
new
NewsFragment
();
NewsArticle
newsArticle
=
gson
.
fromJson
(
gson
.
toJson
(
notification
.
getNotificationActor
()),
NewsArticle
.
class
)
;
newsFragment
.
withId
(
newsArticle
.
getId
());
Utils
.
updateFragment
(
newsFragment
,
fragmentActivity
);
Utils
.
updateFragment
(
newsFragment
,
fragmentActivity
);
}
else
if
(
notification
.
isBlogPost
())
{
}
else
if
(
notification
.
isBlogPost
())
{
Gson
gson
=
new
Gson
();
PlacementBlogPost
post
=
gson
.
fromJson
(
gson
.
toJson
(
notification
.
getNotificationActor
()),
PlacementBlogPost
.
class
);
PlacementBlogPost
post
=
gson
.
fromJson
(
gson
.
toJson
(
notification
.
getNotificationActor
()),
PlacementBlogPost
.
class
);
Fragment
fragment
;
if
(
post
.
getLink
().
contains
(
"training"
))
{
if
(
post
.
getLink
().
contains
(
"training"
))
{
Utils
.
updateFragment
(
new
TrainingBlogFragment
(),
fragmentActivity
);
fragment
=
(
new
TrainingBlogFragment
()).
withId
(
post
.
getId
()
);
}
else
{
}
else
{
Utils
.
updateFragment
(
new
PlacementBlogFragment
(),
fragmentActivity
);
fragment
=
(
new
PlacementBlogFragment
()).
withId
(
post
.
getId
()
);
}
}
Utils
.
updateFragment
(
fragment
,
fragmentActivity
);
}
}
}
}
...
...
app/src/main/java/app/insti/api/RetrofitInterface.java
View file @
b78325e3
...
@@ -18,6 +18,7 @@ import app.insti.api.request.ComplaintCreateRequest;
...
@@ -18,6 +18,7 @@ import app.insti.api.request.ComplaintCreateRequest;
import
app.insti.api.request.EventCreateRequest
;
import
app.insti.api.request.EventCreateRequest
;
import
app.insti.api.request.ImageUploadRequest
;
import
app.insti.api.request.ImageUploadRequest
;
import
app.insti.api.request.UserFCMPatchRequest
;
import
app.insti.api.request.UserFCMPatchRequest
;
import
app.insti.api.request.UserShowContactPatchRequest
;
import
app.insti.api.response.ComplaintCreateResponse
;
import
app.insti.api.response.ComplaintCreateResponse
;
import
app.insti.api.response.EventCreateResponse
;
import
app.insti.api.response.EventCreateResponse
;
import
app.insti.api.response.ExploreResponse
;
import
app.insti.api.response.ExploreResponse
;
...
@@ -87,6 +88,9 @@ public interface RetrofitInterface {
...
@@ -87,6 +88,9 @@ public interface RetrofitInterface {
@PATCH
(
"user-me"
)
@PATCH
(
"user-me"
)
Call
<
User
>
patchUserMe
(
@Header
(
"Cookie"
)
String
sessionID
,
@Body
UserFCMPatchRequest
userFCMPatchRequest
);
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}"
)
@GET
(
"user-me/ues/{eventID}"
)
Call
<
Void
>
updateUserEventStatus
(
@Header
(
"Cookie"
)
String
sessionID
,
@Path
(
"eventID"
)
String
eventID
,
@Query
(
"status"
)
int
status
);
Call
<
Void
>
updateUserEventStatus
(
@Header
(
"Cookie"
)
String
sessionID
,
@Path
(
"eventID"
)
String
eventID
,
@Query
(
"status"
)
int
status
);
...
...
app/src/main/java/app/insti/api/model/NewsArticle.java
View file @
b78325e3
...
@@ -41,6 +41,8 @@ public class NewsArticle implements Clickable {
...
@@ -41,6 +41,8 @@ public class NewsArticle implements Clickable {
this
.
body
=
body
;
this
.
body
=
body
;
}
}
public
String
getId
()
{
return
articleID
;
}
public
String
getArticleID
()
{
public
String
getArticleID
()
{
return
articleID
;
return
articleID
;
}
}
...
...
app/src/main/java/app/insti/api/model/PlacementBlogPost.java
View file @
b78325e3
...
@@ -37,6 +37,8 @@ public class PlacementBlogPost implements Clickable {
...
@@ -37,6 +37,8 @@ public class PlacementBlogPost implements Clickable {
this
.
published
=
published
;
this
.
published
=
published
;
}
}
public
String
getId
()
{
return
postID
;
}
public
String
getPostID
()
{
public
String
getPostID
()
{
return
postID
;
return
postID
;
}
}
...
...
app/src/main/java/app/insti/api/model/TrainingBlogPost.java
View file @
b78325e3
...
@@ -37,6 +37,8 @@ public class TrainingBlogPost implements Clickable {
...
@@ -37,6 +37,8 @@ public class TrainingBlogPost implements Clickable {
this
.
published
=
published
;
this
.
published
=
published
;
}
}
public
String
getId
()
{
return
postID
;
}
public
String
getPostID
()
{
public
String
getPostID
()
{
return
postID
;
return
postID
;
}
}
...
...
app/src/main/java/app/insti/api/model/User.java
View file @
b78325e3
...
@@ -35,6 +35,9 @@ public class User implements CardInterface {
...
@@ -35,6 +35,9 @@ public class User implements CardInterface {
@SerializedName
(
"contact_no"
)
@SerializedName
(
"contact_no"
)
private
String
userContactNumber
;
private
String
userContactNumber
;
@SerializedName
(
"show_contact_no"
)
private
Boolean
showContactNumber
;
@SerializedName
(
"about"
)
@SerializedName
(
"about"
)
private
String
userAbout
;
private
String
userAbout
;
...
@@ -64,7 +67,7 @@ public class User implements CardInterface {
...
@@ -64,7 +67,7 @@ public class User implements CardInterface {
private
String
currentRole
;
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
.
userID
=
userID
;
this
.
userName
=
userName
;
this
.
userName
=
userName
;
this
.
userProfilePictureUrl
=
userProfilePictureUrl
;
this
.
userProfilePictureUrl
=
userProfilePictureUrl
;
...
@@ -73,6 +76,7 @@ public class User implements CardInterface {
...
@@ -73,6 +76,7 @@ public class User implements CardInterface {
this
.
userEmail
=
userEmail
;
this
.
userEmail
=
userEmail
;
this
.
userRollNumber
=
userRollNumber
;
this
.
userRollNumber
=
userRollNumber
;
this
.
userContactNumber
=
userContactNumber
;
this
.
userContactNumber
=
userContactNumber
;
this
.
showContactNumber
=
showContactNumber
;
this
.
userAbout
=
userAbout
;
this
.
userAbout
=
userAbout
;
this
.
userFollowedBodies
=
userFollowedBodies
;
this
.
userFollowedBodies
=
userFollowedBodies
;
this
.
userFollowedBodiesID
=
userFollowedBodiesID
;
this
.
userFollowedBodiesID
=
userFollowedBodiesID
;
...
@@ -82,6 +86,7 @@ public class User implements CardInterface {
...
@@ -82,6 +86,7 @@ public class User implements CardInterface {
this
.
userWebsiteURL
=
userWebsiteURL
;
this
.
userWebsiteURL
=
userWebsiteURL
;
this
.
userLDAPId
=
userLDAPId
;
this
.
userLDAPId
=
userLDAPId
;
this
.
hostel
=
hostel
;
this
.
hostel
=
hostel
;
this
.
currentRole
=
currentRole
;
}
}
public
static
User
fromString
(
String
json
)
{
public
static
User
fromString
(
String
json
)
{
...
@@ -225,6 +230,14 @@ public class User implements CardInterface {
...
@@ -225,6 +230,14 @@ public class User implements CardInterface {
this
.
hostel
=
hostel
;
this
.
hostel
=
hostel
;
}
}
public
Boolean
getShowContactNumber
()
{
return
showContactNumber
;
}
public
void
setShowContactNumber
(
Boolean
showContactNumber
)
{
this
.
showContactNumber
=
showContactNumber
;
}
public
String
getCurrentRole
()
{
public
String
getCurrentRole
()
{
return
currentRole
;
return
currentRole
;
}
}
...
...
app/src/main/java/app/insti/api/request/UserShowContactPatchRequest.java
0 → 100644
View file @
b78325e3
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/RecyclerViewFragment.java
View file @
b78325e3
package
app.insti.fragment
;
package
app.insti.fragment
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.LinearSmoothScroller
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.SearchView
;
import
android.support.v7.widget.SearchView
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
...
@@ -42,6 +41,12 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
...
@@ -42,6 +41,12 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
private
S
adapter
=
null
;
private
S
adapter
=
null
;
boolean
loading
=
false
;
boolean
loading
=
false
;
private
boolean
allLoaded
=
false
;
private
boolean
allLoaded
=
false
;
private
String
initId
=
null
;
public
RecyclerViewFragment
<
T
,
S
>
withId
(
String
id
)
{
initId
=
id
;
return
this
;
}
/** Update the data clearing existing */
/** Update the data clearing existing */
protected
void
updateData
()
{
protected
void
updateData
()
{
...
@@ -89,6 +94,11 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
...
@@ -89,6 +94,11 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
if
(
adapter
==
null
||
recyclerView
.
getAdapter
()
!=
adapter
)
{
if
(
adapter
==
null
||
recyclerView
.
getAdapter
()
!=
adapter
)
{
initAdapter
(
result
);
initAdapter
(
result
);
/* Scroll to current post */
if
(
initId
!=
null
)
{
scrollToPosition
(
getPosition
(
result
,
initId
));
}
}
else
{
}
else
{
adapter
.
setPosts
(
result
);
adapter
.
setPosts
(
result
);
adapter
.
notifyDataSetChanged
();
adapter
.
notifyDataSetChanged
();
...
@@ -97,6 +107,29 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
...
@@ -97,6 +107,29 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
GONE
);
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
GONE
);
}
}
/** Set position of id in list of clickables */
private
int
getPosition
(
List
<
T
>
result
,
String
id
)
{
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++)
{
if
(
result
.
get
(
i
).
getId
().
equals
(
id
))
{
return
i
;
}
}
return
-
1
;
}
/** Scroll the recyclerview to position */
private
void
scrollToPosition
(
int
i
)
{
if
(
i
<
0
)
return
;
RecyclerView
.
SmoothScroller
smoothScroller
=
new
LinearSmoothScroller
(
getContext
())
{
@Override
protected
int
getVerticalSnapPreference
()
{
return
LinearSmoothScroller
.
SNAP_TO_START
;
}
};
smoothScroller
.
setTargetPosition
(
i
);
recyclerView
.
getLayoutManager
().
startSmoothScroll
(
smoothScroller
);
}
/** Initialize the adapter */
/** Initialize the adapter */
private
void
initAdapter
(
final
List
<
T
>
result
)
{
private
void
initAdapter
(
final
List
<
T
>
result
)
{
try
{
try
{
...
...
app/src/main/java/app/insti/fragment/SettingsFragment.java
View file @
b78325e3
...
@@ -10,7 +10,9 @@ import android.view.LayoutInflater;
...
@@ -10,7 +10,9 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.CompoundButton
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.Switch
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.squareup.picasso.Picasso
;
import
com.squareup.picasso.Picasso
;
...
@@ -23,6 +25,7 @@ import app.insti.activity.LoginActivity;
...
@@ -23,6 +25,7 @@ import app.insti.activity.LoginActivity;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.User
;
import
app.insti.api.model.User
;
import
app.insti.api.request.UserShowContactPatchRequest
;
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
import
retrofit2.Response
;
...
@@ -64,6 +67,7 @@ public class SettingsFragment extends Fragment {
...
@@ -64,6 +67,7 @@ public class SettingsFragment extends Fragment {
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
user
=
response
.
body
();
user
=
response
.
body
();
populateUserCard
();
populateUserCard
();
setupContactSwitch
(
user
);
}
}
}
}
...
@@ -74,6 +78,37 @@ public class SettingsFragment extends Fragment {
...
@@ -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
()
{
private
void
populateUserCard
()
{
if
(
getActivity
()
==
null
||
getView
()
==
null
)
{
if
(
getActivity
()
==
null
||
getView
()
==
null
)
{
return
;
return
;
...
...
app/src/main/java/app/insti/interfaces/Clickable.java
View file @
b78325e3
...
@@ -4,5 +4,7 @@ import android.content.Context;
...
@@ -4,5 +4,7 @@ import android.content.Context;
import
android.view.View.OnClickListener
;
import
android.view.View.OnClickListener
;
public
interface
Clickable
{
public
interface
Clickable
{
String
getId
();
OnClickListener
getOnClickListener
(
Context
context
);
OnClickListener
getOnClickListener
(
Context
context
);
}
}
app/src/main/res/layout/fragment_settings.xml
View file @
b78325e3
...
@@ -43,6 +43,18 @@
...
@@ -43,6 +43,18 @@
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</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
<Button
android:id=
"@+id/settings_update_profile"
android:id=
"@+id/settings_update_profile"
style=
"@style/Widget.AppCompat.Button.Borderless"
style=
"@style/Widget.AppCompat.Button.Borderless"
...
...
app/src/main/res/xml/network_security_config.xml
0 → 100644
View file @
b78325e3
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config
cleartextTrafficPermitted=
"true"
>
<domain
includeSubdomains=
"true"
>
gymkhana.iitb.ac.in
</domain>
</domain-config>
</network-security-config>
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