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
ecafd9b9
Commit
ecafd9b9
authored
Feb 04, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash on location access
parent
789bde5f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
44 deletions
+42
-44
app/src/main/java/app/insti/Constants.java
app/src/main/java/app/insti/Constants.java
+0
-1
app/src/main/java/app/insti/Utils.java
app/src/main/java/app/insti/Utils.java
+14
-6
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+13
-16
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
+1
-1
app/src/main/java/app/insti/fragment/FileComplaintFragment.java
...c/main/java/app/insti/fragment/FileComplaintFragment.java
+3
-3
app/src/main/java/app/insti/fragment/MapFragment.java
app/src/main/java/app/insti/fragment/MapFragment.java
+4
-4
app/src/main/java/com/mrane/campusmap/ListFragment.java
app/src/main/java/com/mrane/campusmap/ListFragment.java
+0
-1
app/src/main/java/com/mrane/zoomview/CampusMapView.java
app/src/main/java/com/mrane/zoomview/CampusMapView.java
+7
-12
No files found.
app/src/main/java/app/insti/Constants.java
View file @
ecafd9b9
...
@@ -2,7 +2,6 @@ package app.insti;
...
@@ -2,7 +2,6 @@ package app.insti;
public
class
Constants
{
public
class
Constants
{
public
static
final
int
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
=
1
;
public
static
final
int
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
=
1
;
public
static
final
int
MY_PERMISSIONS_REQUEST_ACCESS_LOCATION
=
2
;
public
static
final
int
MY_PERMISSIONS_REQUEST_LOCATION
=
3
;
public
static
final
int
MY_PERMISSIONS_REQUEST_LOCATION
=
3
;
public
static
final
int
RESULT_LOAD_IMAGE
=
11
;
public
static
final
int
RESULT_LOAD_IMAGE
=
11
;
public
static
final
int
REQUEST_CAMERA_INT_ID
=
101
;
public
static
final
int
REQUEST_CAMERA_INT_ID
=
101
;
...
...
app/src/main/java/app/insti/Utils.java
View file @
ecafd9b9
...
@@ -88,8 +88,8 @@ public final class Utils {
...
@@ -88,8 +88,8 @@ public final class Utils {
public
static
final
void
updateFragment
(
Fragment
fragment
,
FragmentActivity
fragmentActivity
)
{
public
static
final
void
updateFragment
(
Fragment
fragment
,
FragmentActivity
fragmentActivity
)
{
FragmentTransaction
ft
=
fragmentActivity
.
getSupportFragmentManager
().
beginTransaction
();
FragmentTransaction
ft
=
fragmentActivity
.
getSupportFragmentManager
().
beginTransaction
();
ft
.
setCustomAnimations
(
R
.
anim
.
slide_in_up
,
R
.
anim
.
fade_out
,
R
.
anim
.
fade_in
,
R
.
anim
.
slide_out_down
);
ft
.
setCustomAnimations
(
R
.
anim
.
slide_in_up
,
R
.
anim
.
fade_out
,
R
.
anim
.
fade_in
,
R
.
anim
.
slide_out_down
);
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
fragment
,
fragment
.
getTag
(
));
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
fragment
,
getTag
(
fragment
));
ft
.
addToBackStack
(
fragment
.
getTag
(
));
ft
.
addToBackStack
(
getTag
(
fragment
));
ft
.
commit
();
ft
.
commit
();
}
}
...
@@ -141,8 +141,8 @@ public final class Utils {
...
@@ -141,8 +141,8 @@ public final class Utils {
}
}
/* Update the fragment */
/* Update the fragment */
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
fragment
,
fragment
.
getTag
(
))
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
fragment
,
getTag
(
fragment
))
.
addToBackStack
(
fragment
.
getTag
(
))
.
addToBackStack
(
getTag
(
fragment
))
.
commit
();
.
commit
();
}
}
...
@@ -247,8 +247,8 @@ public final class Utils {
...
@@ -247,8 +247,8 @@ public final class Utils {
FragmentManager
fm
=
fragmentActivity
.
getSupportFragmentManager
();
FragmentManager
fm
=
fragmentActivity
.
getSupportFragmentManager
();
fm
.
popBackStack
();
fm
.
popBackStack
();
FragmentTransaction
ft
=
fm
.
beginTransaction
();
FragmentTransaction
ft
=
fm
.
beginTransaction
();
ft
.
addToBackStack
(
newFragment
.
getTag
(
));
ft
.
addToBackStack
(
getTag
(
fragment
));
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
newFragment
,
newFragment
.
getTag
(
)).
commit
();
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
newFragment
,
getTag
(
fragment
)).
commit
();
}
}
public
static
void
setSelectedMenuItem
(
Activity
activity
,
int
id
)
{
public
static
void
setSelectedMenuItem
(
Activity
activity
,
int
id
)
{
...
@@ -286,4 +286,12 @@ public final class Utils {
...
@@ -286,4 +286,12 @@ public final class Utils {
CookieManager
.
getInstance
().
removeAllCookies
(
null
);
CookieManager
.
getInstance
().
removeAllCookies
(
null
);
CookieManager
.
getInstance
().
flush
();
CookieManager
.
getInstance
().
flush
();
}
}
public
static
String
getTag
(
Fragment
fragment
)
{
String
TAG
=
fragment
.
getTag
();
try
{
TAG
=
(
String
)
fragment
.
getClass
().
getField
(
"TAG"
).
get
(
fragment
);
}
catch
(
NoSuchFieldException
|
IllegalAccessException
ignored
)
{}
return
TAG
;
}
}
}
app/src/main/java/app/insti/activity/MainActivity.java
View file @
ecafd9b9
...
@@ -85,7 +85,6 @@ import static app.insti.Constants.DATA_TYPE_NEWS;
...
@@ -85,7 +85,6 @@ import static app.insti.Constants.DATA_TYPE_NEWS;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_PT
;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_PT
;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_USER
;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_USER
;
import
static
app
.
insti
.
Constants
.
FCM_BUNDLE_NOTIFICATION_ID
;
import
static
app
.
insti
.
Constants
.
FCM_BUNDLE_NOTIFICATION_ID
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_ACCESS_LOCATION
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_LOCATION
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_LOCATION
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
;
import
static
app
.
insti
.
Constants
.
RESULT_LOAD_IMAGE
;
import
static
app
.
insti
.
Constants
.
RESULT_LOAD_IMAGE
;
...
@@ -616,7 +615,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -616,7 +615,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
* Change the active fragment to the supplied one
* Change the active fragment to the supplied one
*/
*/
public
void
updateFragment
(
Fragment
fragment
)
{
public
void
updateFragment
(
Fragment
fragment
)
{
Log
.
d
(
TAG
,
"updateFragment: "
+
fragment
.
toString
());
Bundle
bundle
=
fragment
.
getArguments
();
Bundle
bundle
=
fragment
.
getArguments
();
if
(
bundle
==
null
)
{
if
(
bundle
==
null
)
{
bundle
=
new
Bundle
();
bundle
=
new
Bundle
();
...
@@ -642,8 +640,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -642,8 +640,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
transaction
.
setCustomAnimations
(
R
.
anim
.
slide_in_up
,
R
.
anim
.
fade_out
,
R
.
anim
.
fade_in
,
R
.
anim
.
slide_out_down
);
transaction
.
setCustomAnimations
(
R
.
anim
.
slide_in_up
,
R
.
anim
.
fade_out
,
R
.
anim
.
fade_in
,
R
.
anim
.
slide_out_down
);
}
}
transaction
.
replace
(
R
.
id
.
framelayout_for_fragment
,
fragment
,
fragment
.
getTag
(
));
transaction
.
replace
(
R
.
id
.
framelayout_for_fragment
,
fragment
,
Utils
.
getTag
(
fragment
));
transaction
.
addToBackStack
(
fragment
.
getTag
(
)).
commit
();
transaction
.
addToBackStack
(
Utils
.
getTag
(
fragment
)).
commit
();
}
}
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
...
@@ -655,21 +653,20 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -655,21 +653,20 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
startActivityForResult
(
i
,
RESULT_LOAD_IMAGE
);
startActivityForResult
(
i
,
RESULT_LOAD_IMAGE
);
}
}
return
;
return
;
case
MY_PERMISSIONS_REQUEST_ACCESS_LOCATION:
if
(
grantResults
.
length
>
0
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
MapFragment
.
getMainActivity
().
setupGPS
();
}
else
{
Toast
toast
=
Toast
.
makeText
(
MainActivity
.
this
,
"Need Permission"
,
Toast
.
LENGTH_SHORT
);
toast
.
show
();
}
break
;
case
MY_PERMISSIONS_REQUEST_LOCATION:
case
MY_PERMISSIONS_REQUEST_LOCATION:
Log
.
i
(
TAG
,
"Permission request captured"
);
if
(
grantResults
.
length
>
0
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
grantResults
.
length
>
0
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
Log
.
i
(
TAG
,
"Permission Granted"
);
// Map
FileComplaintFragment
.
getMainActivity
().
getMapReady
();
MapFragment
mapFragment
=
(
MapFragment
)
getSupportFragmentManager
().
findFragmentByTag
(
MapFragment
.
TAG
);
if
(
mapFragment
!=
null
&&
mapFragment
.
isVisible
())
{
MapFragment
.
getMainActivity
().
setupGPS
();
}
// File complaint
FileComplaintFragment
fileComplaintFragment
=
(
FileComplaintFragment
)
getSupportFragmentManager
().
findFragmentByTag
(
FileComplaintFragment
.
TAG
);
if
(
fileComplaintFragment
!=
null
&&
fileComplaintFragment
.
isVisible
())
{
FileComplaintFragment
.
getMainActivity
().
getMapReady
();
}
}
else
{
}
else
{
Log
.
i
(
TAG
,
"Permission Cancelled"
);
Toast
toast
=
Toast
.
makeText
(
MainActivity
.
this
,
"Need Permission"
,
Toast
.
LENGTH_SHORT
);
Toast
toast
=
Toast
.
makeText
(
MainActivity
.
this
,
"Need Permission"
,
Toast
.
LENGTH_SHORT
);
toast
.
show
();
toast
.
show
();
}
}
...
...
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
View file @
ecafd9b9
...
@@ -51,7 +51,7 @@ public class ComplaintsFragment extends BaseFragment {
...
@@ -51,7 +51,7 @@ public class ComplaintsFragment extends BaseFragment {
FileComplaintFragment
fileComplaintFragment
=
new
FileComplaintFragment
();
FileComplaintFragment
fileComplaintFragment
=
new
FileComplaintFragment
();
fileComplaintFragment
.
setArguments
(
getArguments
());
fileComplaintFragment
.
setArguments
(
getArguments
());
FragmentTransaction
fragmentTransaction
=
getFragmentManager
().
beginTransaction
();
FragmentTransaction
fragmentTransaction
=
getFragmentManager
().
beginTransaction
();
fragmentTransaction
.
replace
(
R
.
id
.
framelayout_for_fragment
,
fileComplaintFragment
,
fileComplaintFragment
.
getTag
(
));
fragmentTransaction
.
replace
(
R
.
id
.
framelayout_for_fragment
,
fileComplaintFragment
,
Utils
.
getTag
(
fileComplaintFragment
));
fragmentTransaction
.
addToBackStack
(
"Complaint Fragment"
).
commit
();
fragmentTransaction
.
addToBackStack
(
"Complaint Fragment"
).
commit
();
}
}
});
});
...
...
app/src/main/java/app/insti/fragment/FileComplaintFragment.java
View file @
ecafd9b9
...
@@ -69,10 +69,10 @@ import java.io.ByteArrayOutputStream;
...
@@ -69,10 +69,10 @@ import java.io.ByteArrayOutputStream;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
app.insti.Constants
;
import
app.insti.ComplaintDescriptionAutoCompleteTextView
;
import
app.insti.ComplaintDescriptionAutoCompleteTextView
;
import
app.insti.R
;
import
app.insti.ComplaintTag
;
import
app.insti.ComplaintTag
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.ImageViewPagerAdapter
;
import
app.insti.adapter.ImageViewPagerAdapter
;
...
@@ -95,7 +95,7 @@ import static app.insti.Constants.RESULT_LOAD_IMAGE;
...
@@ -95,7 +95,7 @@ import static app.insti.Constants.RESULT_LOAD_IMAGE;
public
class
FileComplaintFragment
extends
Fragment
{
public
class
FileComplaintFragment
extends
Fragment
{
p
rivate
static
final
String
TAG
=
FileComplaintFragment
.
class
.
getSimpleName
();
p
ublic
static
final
String
TAG
=
FileComplaintFragment
.
class
.
getSimpleName
();
private
static
FileComplaintFragment
mainactivity
;
private
static
FileComplaintFragment
mainactivity
;
private
Button
buttonSubmit
;
private
Button
buttonSubmit
;
private
ComplaintDescriptionAutoCompleteTextView
descriptionAutoCompleteTextview
;
private
ComplaintDescriptionAutoCompleteTextView
descriptionAutoCompleteTextview
;
...
...
app/src/main/java/app/insti/fragment/MapFragment.java
View file @
ecafd9b9
...
@@ -6,7 +6,6 @@ import android.animation.ValueAnimator;
...
@@ -6,7 +6,6 @@ import android.animation.ValueAnimator;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.IntentSender
;
import
android.content.IntentSender
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.content.res.Configuration
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.graphics.PointF
;
import
android.graphics.PointF
;
import
android.graphics.Typeface
;
import
android.graphics.Typeface
;
...
@@ -27,8 +26,6 @@ import android.support.v4.app.Fragment;
...
@@ -27,8 +26,6 @@ import android.support.v4.app.Fragment;
import
android.support.v4.app.FragmentManager
;
import
android.support.v4.app.FragmentManager
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v7.app.ActionBarDrawerToggle
;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
import
android.text.Editable
;
import
android.text.Editable
;
import
android.text.SpannableStringBuilder
;
import
android.text.SpannableStringBuilder
;
...
@@ -41,7 +38,6 @@ import android.text.util.Linkify;
...
@@ -41,7 +38,6 @@ import android.text.util.Linkify;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.MenuItem
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
...
@@ -103,6 +99,9 @@ import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION;
...
@@ -103,6 +99,9 @@ import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION;
public
class
MapFragment
extends
Fragment
implements
TextWatcher
,
public
class
MapFragment
extends
Fragment
implements
TextWatcher
,
TextView
.
OnEditorActionListener
,
AdapterView
.
OnItemClickListener
,
View
.
OnFocusChangeListener
,
TextView
.
OnEditorActionListener
,
AdapterView
.
OnItemClickListener
,
View
.
OnFocusChangeListener
,
View
.
OnTouchListener
,
ExpandableListView
.
OnChildClickListener
{
View
.
OnTouchListener
,
ExpandableListView
.
OnChildClickListener
{
public
static
final
String
TAG
=
MapFragment
.
class
.
getSimpleName
();
public
static
final
PointF
MAP_CENTER
=
new
PointF
(
2971
f
,
1744
f
);
public
static
final
PointF
MAP_CENTER
=
new
PointF
(
2971
f
,
1744
f
);
public
static
final
long
DURATION_INIT_MAP_ANIM
=
500
;
public
static
final
long
DURATION_INIT_MAP_ANIM
=
500
;
public
static
final
String
FONT_SEMIBOLD
=
"rigascreen_bold.ttf"
;
public
static
final
String
FONT_SEMIBOLD
=
"rigascreen_bold.ttf"
;
...
@@ -232,6 +231,7 @@ public class MapFragment extends Fragment implements TextWatcher,
...
@@ -232,6 +231,7 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override
@Override
public
void
onResponse
(
Call
<
List
<
Venue
>>
call
,
Response
<
List
<
Venue
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
Venue
>>
call
,
Response
<
List
<
Venue
>>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
if
(
getActivity
()
==
null
||
getView
()
==
null
)
return
;
// Setup fade animation for background
// Setup fade animation for background
int
colorFrom
=
Utils
.
getAttrColor
(
getContext
(),
R
.
attr
.
themeColor
);
int
colorFrom
=
Utils
.
getAttrColor
(
getContext
(),
R
.
attr
.
themeColor
);
...
...
app/src/main/java/com/mrane/campusmap/ListFragment.java
View file @
ecafd9b9
...
@@ -18,7 +18,6 @@ public class ListFragment extends Fragment {
...
@@ -18,7 +18,6 @@ public class ListFragment extends Fragment {
MapFragment
mainActivity
;
MapFragment
mainActivity
;
FuzzySearchAdapter
adapter
;
FuzzySearchAdapter
adapter
;
HashMap
<
String
,
Marker
>
data
;
View
rootView
;
View
rootView
;
ListView
list
;
ListView
list
;
...
...
app/src/main/java/com/mrane/zoomview/CampusMapView.java
View file @
ecafd9b9
...
@@ -412,20 +412,17 @@ public class CampusMapView extends SubsamplingScaleImageView {
...
@@ -412,20 +412,17 @@ public class CampusMapView extends SubsamplingScaleImageView {
for
(
Marker
marker
:
markerList
)
{
for
(
Marker
marker
:
markerList
)
{
if
(
isInView
(
marker
.
getPoint
()))
{
if
(
isInView
(
marker
.
getPoint
()))
{
if
(
isShowPinScale
(
marker
)
if
(
isShowPinScale
(
marker
)
&&
&&
!(
isResultMarker
(
marker
)
||
addedMarkerList
!(
isResultMarker
(
marker
)
||
addedMarkerList
.
contains
(
marker
))
&&
.
contains
(
marker
)))
{
shouldShowUp
(
marker
))
{
if
(
shouldShowUp
(
marker
))
drawPionterAndText
(
canvas
,
marker
);
drawPionterAndText
(
canvas
,
marker
);
}
}
}
}
}
}
for
(
Marker
marker
:
addedMarkerList
)
{
for
(
Marker
marker
:
addedMarkerList
)
{
if
(
isInView
(
marker
.
getPoint
()))
{
if
(
isInView
(
marker
.
getPoint
())
&&
!
isResultMarker
(
marker
))
{
if
(!
isResultMarker
(
marker
))
{
drawMarkerBitmap
(
canvas
,
marker
);
drawMarkerBitmap
(
canvas
,
marker
);
drawMarkerText
(
canvas
,
marker
);
drawMarkerText
(
canvas
,
marker
);
}
}
}
}
}
Marker
marker
=
getResultMarker
();
Marker
marker
=
getResultMarker
();
...
@@ -689,8 +686,6 @@ public class CampusMapView extends SubsamplingScaleImageView {
...
@@ -689,8 +686,6 @@ public class CampusMapView extends SubsamplingScaleImageView {
if
(
motionEvent
.
getX
()
<
20
*
density
)
{
if
(
motionEvent
.
getX
()
<
20
*
density
)
{
getParent
().
requestDisallowInterceptTouchEvent
(
false
);
getParent
().
requestDisallowInterceptTouchEvent
(
false
);
return
true
;
return
true
;
}
else
{
// CampusMapView.this.setPanEnabled(true);
}
}
}
else
if
(
action
==
MotionEvent
.
ACTION_UP
)
{
}
else
if
(
action
==
MotionEvent
.
ACTION_UP
)
{
CampusMapView
.
this
.
setPanEnabled
(
true
);
CampusMapView
.
this
.
setPanEnabled
(
true
);
...
...
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