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
352dcd08
Commit
352dcd08
authored
Jul 20, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make webview fragment generic
parent
2e58bb49
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
17 deletions
+70
-17
app/src/main/java/app/insti/Constants.java
app/src/main/java/app/insti/Constants.java
+10
-0
app/src/main/java/app/insti/fragment/BodyFragment.java
app/src/main/java/app/insti/fragment/BodyFragment.java
+2
-1
app/src/main/java/app/insti/fragment/CalendarFragment.java
app/src/main/java/app/insti/fragment/CalendarFragment.java
+6
-0
app/src/main/java/app/insti/fragment/EventFragment.java
app/src/main/java/app/insti/fragment/EventFragment.java
+2
-1
app/src/main/java/app/insti/fragment/FeedFragment.java
app/src/main/java/app/insti/fragment/FeedFragment.java
+2
-0
app/src/main/java/app/insti/fragment/WebViewFragment.java
app/src/main/java/app/insti/fragment/WebViewFragment.java
+48
-15
No files found.
app/src/main/java/app/insti/Constants.java
View file @
352dcd08
...
...
@@ -64,6 +64,16 @@ public class Constants {
public
static
final
String
CARD_TYPE_TITLE
=
"card_type_title"
;
public
static
final
String
CARD_TYPE_BODY_HEAD
=
"card_type_body_head"
;
/* Webview */
public
static
final
String
WV_TYPE
=
"webview_type"
;
public
static
final
String
WV_TYPE_ADD_EVENT
=
"add_event"
;
public
static
final
String
WV_TYPE_UPDATE_EVENT
=
"update_event"
;
public
static
final
String
WV_TYPE_UPDATE_BODY
=
"update_body"
;
public
static
final
String
WV_TYPE_ACHIEVEMENTS
=
"achievements"
;
public
static
final
String
WV_TYPE_URL
=
"url_type"
;
public
static
final
String
WV_ID
=
"id"
;
public
static
final
String
WV_URL
=
"url"
;
/* Map */
public
static
final
double
MAP_Xn
=
19.133691
,
MAP_Yn
=
72.916984
,
MAP_Zn
=
4189
,
MAP_Zyn
=
1655
;
public
static
final
double
[]
MAP_WEIGHTS_X
=
{-
7.769917472065843
,
159.26978694839946
,
244.46989575495544
,
-
6.003894110679995
,
-
0.28864271213341297
,
0.010398324019718075
,
4.215508849724247
,
-
0.6078830146963545
,
-
7.0400449629241395
};
...
...
app/src/main/java/app/insti/fragment/BodyFragment.java
View file @
352dcd08
...
...
@@ -251,7 +251,8 @@ public class BodyFragment extends BackHandledFragment implements TransitionTarge
public
void
onClick
(
View
v
)
{
WebViewFragment
webViewFragment
=
new
WebViewFragment
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"bodyId"
,
body
.
getBodyID
());
bundle
.
putString
(
Constants
.
WV_TYPE
,
Constants
.
WV_TYPE_UPDATE_BODY
);
bundle
.
putString
(
Constants
.
WV_ID
,
body
.
getBodyID
());
webViewFragment
.
setArguments
(
bundle
);
((
MainActivity
)
getActivity
()).
updateFragment
(
webViewFragment
);
}
...
...
app/src/main/java/app/insti/fragment/CalendarFragment.java
View file @
352dcd08
...
...
@@ -43,6 +43,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.TimeZone
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
...
...
@@ -140,6 +141,11 @@ public class CalendarFragment extends BaseFragment {
CalendarDay
day
=
((
MaterialCalendarView
)
view
.
findViewById
(
R
.
id
.
simpleCalendarView
)).
getSelectedDate
();
String
date
=
day
.
getYear
()
+
"-"
+
day
.
getMonth
()
+
"-"
+
day
.
getDay
();
WebViewFragment
webViewFragment
=
(
new
WebViewFragment
()).
withDate
(
date
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
Constants
.
WV_TYPE
,
Constants
.
WV_TYPE_ADD_EVENT
);
webViewFragment
.
setArguments
(
bundle
);
((
MainActivity
)
getActivity
()).
updateFragment
(
webViewFragment
);
}
});
...
...
app/src/main/java/app/insti/fragment/EventFragment.java
View file @
352dcd08
...
...
@@ -357,7 +357,8 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
fab
.
setOnClickListener
(
v
->
{
WebViewFragment
webViewFragment
=
new
WebViewFragment
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"id"
,
event
.
getEventID
());
bundle
.
putString
(
Constants
.
WV_TYPE
,
Constants
.
WV_TYPE_UPDATE_EVENT
);
bundle
.
putString
(
Constants
.
WV_ID
,
event
.
getEventID
());
webViewFragment
.
setArguments
(
bundle
);
((
MainActivity
)
getActivity
()).
updateFragment
(
webViewFragment
);
});
...
...
app/src/main/java/app/insti/fragment/FeedFragment.java
View file @
352dcd08
...
...
@@ -18,6 +18,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import
java.util.List
;
import
app.insti.ActivityBuffer
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
...
...
@@ -133,6 +134,7 @@ public class FeedFragment extends BaseFragment {
public
void
onClick
(
View
v
)
{
WebViewFragment
webViewFragment
=
new
WebViewFragment
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
Constants
.
WV_TYPE
,
Constants
.
WV_TYPE_ADD_EVENT
);
webViewFragment
.
setArguments
(
bundle
);
((
MainActivity
)
getActivity
()).
updateFragment
(
webViewFragment
);
}
...
...
app/src/main/java/app/insti/fragment/WebViewFragment.java
View file @
352dcd08
...
...
@@ -46,11 +46,58 @@ public class WebViewFragment extends BaseFragment {
// Required empty public constructor
}
private
final
String
host
=
"insti.app"
;
public
WebViewFragment
withDate
(
String
date
)
{
query
+=
"&date="
+
date
;
return
this
;
}
private
void
setTitle
(
String
title
)
{
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
if
(
toolbar
!=
null
)
{
toolbar
.
setTitle
(
title
);
}
}
private
String
chooseUrl
(
Bundle
args
)
{
setTitle
(
"InstiApp"
);
// Construct basic URL
String
url
=
"https://"
+
host
;
// Check for type
if
(!
args
.
containsKey
(
Constants
.
WV_TYPE
))
{
return
url
;
}
// Check for arguments
final
String
type
=
args
.
getString
(
Constants
.
WV_TYPE
);
final
String
ID
=
args
.
getString
(
Constants
.
WV_ID
);
switch
(
type
)
{
case
Constants
.
WV_TYPE_ADD_EVENT
:
url
+=
"/add-event/"
;
setTitle
(
"Add Event"
);
break
;
case
Constants
.
WV_TYPE_UPDATE_EVENT
:
url
+=
"/edit-event/"
+
ID
;
setTitle
(
"Update Event"
);
break
;
case
Constants
.
WV_TYPE_UPDATE_BODY
:
url
+=
"/edit-body/"
+
ID
;
setTitle
(
"Update Organization"
);
break
;
case
Constants
.
WV_TYPE_URL
:
return
args
.
getString
(
Constants
.
WV_URL
);
}
return
url
+
"?sandbox=true"
;
}
@Override
public
void
onStart
()
{
super
.
onStart
();
...
...
@@ -68,10 +115,6 @@ public class WebViewFragment extends BaseFragment {
progressDialog
.
setCancelable
(
false
);
progressDialog
.
show
();
String
host
=
"insti.app"
;
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
getArguments
().
containsKey
(
"id"
)
?
"Update Event"
:
"Add Event"
);
if
(
savedInstanceState
==
null
)
{
WebView
webView
=
view
.
findViewById
(
R
.
id
.
add_event_webview
);
webView
.
getSettings
().
setBuiltInZoomControls
(
true
);
...
...
@@ -93,17 +136,7 @@ public class WebViewFragment extends BaseFragment {
CookieSyncManager
.
getInstance
().
sync
();
}
String
url
=
"https://"
+
host
+
"/add-event?sandbox=true"
;
if
(
getArguments
().
containsKey
(
"id"
))
{
url
=
"https://"
+
host
+
"/edit-event/"
+
getArguments
().
getString
(
"id"
)
+
"?sandbox=true"
;
}
else
if
(
getArguments
().
containsKey
(
"bodyId"
))
{
url
=
"https://"
+
host
+
"/edit-body/"
+
getArguments
().
getString
(
"bodyId"
)
+
"?sandbox=true"
;
toolbar
.
setTitle
(
"Update Organization"
);
}
url
+=
query
;
webView
.
loadUrl
(
url
);
webView
.
loadUrl
(
chooseUrl
(
getArguments
())
+
query
);
webView
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
float
m_downX
;
...
...
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