osmdroid and dynamic permissions in marshmallow - osmdroid

I'm using osmdroid 5.4.1 lib in android 6.0. I'm asking WRITE_EXTERNAL_STORAGE and ACCESS_COARSE / FINE_LOCATION permissions on realtime.
But map not working:
Unable to decode stream: java.io.FileNotFoundException: ... open failed: EACCES (Permission denied)
onRequestPermissionsResult() of the my main Activity calls the following after the user has granted the storage write permission:
public void initTileSources() {
mMapnikTileSource = new XYTileSource(MAPDIR_MAPNIK, 1, MAXZOOMLEVEL, 256, ".png", new String[]{"http://tile.openstreetmap.de/",
"http://tile.openstreetmap.org/"});
mMapView.setTileSource(mMapnikTileSource);
mSeamarksTileSource = new XYTileSource(MAPDIR_SEAMARK, 1, MAXZOOMLEVEL, 256, ".png", new String[]{
"http://t1.openseamap.org/seamark/", "http://tiles.openseamap.org/seamark/"});
TilesOverlay SeamarksOverlay = new TilesOverlay(new MapTileProviderBasic(getActivity(), mSeamarksTileSource), getActivity());
SeamarksOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
mMapView.getOverlays().add(SeamarksOverlay);
// mMapView.invalidate();
}
The mapview only displays the SeamarksOverlay (openseamap) but not the main mMapnikTileSource (openstreetmap). I have to restart the app in order for the mapview to display everything correctly.
I have seen a similar question on stackoverflow but it hasn't been answered.
Can anyone help me? Thanks in advance.

I'll give you the same answer as the other linked issue. You have to ask for the permissions before the mapview is loaded and displayed.
Either that, or the path for the tile storage cache is read only. On some android devices Environment.getExternalStorageDir returns a read only partition. No clue why, but that will definitely cause issues. It can be overridden with the class OpenStreetMapTileProviderConstants

Related

xcode 8 PHPhotoLibrary.requestAuthorization causing crash

My app keeps crashing when running in the simulator everytime I try to request authorization for the photo library. I am using the following code in my appDelegate in didFinishLaunchingWithOptions:
if PHPhotoLibrary.authorizationStatus() != PHAuthorizationStatus.authorized {
PHPhotoLibrary.requestAuthorization({ (status: PHAuthorizationStatus) in
})
}
Using xcode 8 beta with swift 3.0.
In my testing, iOS 10 doesn't like to output useful error messages unless you're running on an actual device. In this particular case, you probably haven't provided the key NSPhotoLibraryUsageDescription in your Info.plist file, and that value must be provided before requesting authorization.
Have to allow access to photos on device. Add below key and string to your info.plist. The autocomplete in the property list view is "Privacy - Photo Library Usage Description". Or just open your info.plist in source code view and add the following:
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photos.</string>

Retrieving profile pictures of Facebook friends using facebook-sdk-unity

We are converting to Facebook's unity SDK and running into an issue downloading the profile images of friends. We are getting this error:
error getting user picture Failed downloading https://graph.facebook.com/#USERIDHER#/picture?type=square?access_token=#OURTOKENISHERE#
The app has permission for friends_photos. Is there another permission required for this?
I'm doing it using the code from the sample Friends Smash Application, while using the default permissions.
Get the list of the friends by using the Graph API and astore it in m_friendData dictionary:
FB.API("/me?fields=id,first_name,friends.limit(20).fields(first_name,id)", Facebook.HttpMethod.GET, GetFbFriendsCallback);
Retrieving the friend avatar:
FB.API(Util.GetPictureURL((string)m_friendData["id"], 96, 96), Facebook.HttpMethod.GET, this.FriendPictureCallback);
The callback which process the answer:
`public void FriendPictureCallback(FBResult result)
{
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}
friendAvatarImage.image = result.Texture;
}
`
Hope this helps.
This is apparently a known issue for the SDK and is being worked on since March 5th, see this reference:
https://developers.facebook.com/x/bugs/364606280347510/

Sitecore file download works only for admin user

I have a Sitecore 6.4 setup where an editor can click a button to generate a Word doc. I was adding the file to the media library and that was working fine. The editor would click the button in the content editor, the file was generated, media item was generated, then the content editor would show the new item in the media library and the editor could click the "download" button on the ribbon or the item to download it. However, my media library was getting unnecessarily filled up so I am trying to bypass the media library.
Instead of making the file in an arbitrary location as before, I am putting it in the temp directory like this:
wordOutputPath = Sitecore.IO.FileUtil.GetWorkFilename(Sitecore.Configuration.Settings.TempFolderPath, printItem.Name, ".docx");
File.Copy(wordTemplatePath, wordOutputPath);
WordprocessingDocument doc = WordprocessingDocument.Open(wordOutputPath, true);
After I "fill in" the file with content, I do this:
Sitecore.Context.ClientPage.ClientResponse.Download(wordFilePath);
Now if I am logged in as a Sitecore admin I get the browser's download dialog and can download the file. However, if I am logged in as a non-admin user, I get a little clicking and whirring, so to speak, and the file is generated, but the save file dialog never comes up in the browser. I can go in through the file system and see & open the Word doc, and it looks fine.
I found something in the Sitecore release notes for 6.6:
Released Sitecore CMS and DMS 6.6.0 rev. 130111 (6.6.0 Update-3)
[...]
Miscellaneous
Only Administrators were allowed to download files. (316774, 348557)
This was a problem in several areas of the system, for example the Package Generator and the Export Language Wizard in the CMS. It also affected the Export Users Wizard in the ECM module.
So I tried using SecurityDisabler (no longer have the code handy) and UserSwitcher like this:
using (new Sitecore.Security.Accounts.UserSwitcher(Sitecore.Security.Accounts.User.FromName("sitecore\admin", false)))
{
Sitecore.Context.ClientPage.ClientResponse.Download(wordFilePath);
}
The IUSR and IIS_IUSRS accounts both have read, list & read/execute permissions on the temp folder and the individual files show read & read/execute permissions for those two accounts as well.
What can I do to allow non-admin users to download these files? Does the bug that was fixed in 6.6 have anything to do with it?
Thank you.
Calling Sitecore.Context.ClientPage.ClientResponse.Download() method will result in a Download command sent back to the Sitecore Client in the Web browser, which in turn will make a call back to the server to execute it. This will be why using a security switcher (or a security disabler for that matter) before calling the Sitecore.Context.ClientPage.ClientResponse.Download() method has no effect, as the admin only restriction is being applied to the download else where.
If you search through sitecore\shell directory in your webroot, you will find that there is a file called download.aspx. This should be the actual page the download request is sent to. This web form page inherits the Sitecore.Shell.DownloadPage class, so if you take a look at that class's implementation, you will find that the OnLoad method is implemented as such:
protected override void OnLoad(EventArgs e)
{
Assert.ArgumentNotNull(e, "e");
base.OnLoad(e);
string fileHandle = StringUtil.GetString(new string[] { base.Request.QueryString["file"] });
bool flag = false;
string filename = FileHandle.GetFilename(fileHandle);
if (!string.IsNullOrEmpty(filename))
{
fileHandle = filename;
flag = true;
}
if (!string.IsNullOrEmpty(fileHandle))
{
if (MediaManager.IsMediaUrl(fileHandle))
{
this.DownloadMediaFile(fileHandle);
}
else if (fileHandle.IndexOf("id=", StringComparison.OrdinalIgnoreCase) >= 0)
{
this.DownloadMediaById(fileHandle);
}
else if (flag || Context.IsAdministrator)
{
this.DownloadFile(fileHandle);
}
}
}
As you can see, the last if block has an IsAdministrator check which would be where your non-admin users are getting blocked.
Although I haven't 100% verified that this is where the problem lies, the download restriction issue can be resolved, by creating a new class that inherits Sitecore.Shell.DownloadPage and overrides the OnLoad implementation with some extra security checks as required. I recommend that you don't remove the IsAdministrator check altogether as it is there for a good reason. Update the Inherits attribute in the download.aspx to make it use it instead.

Blackberry facebook SDK login browser error

I recently switched from using the BlackBerry Facebook SDK jar to using the project's source code (checked out from the tag that the jar was built from).
Ever since this switch, I've experienced BrowserField problems:
On a device, the loading graphics persists until I back out.
On a simulator I see:
Error requesting content for
https://www.facebook.com/dialog/oauth?scope=user_about_me,user_activities,user_birthday,user_education_history,user_events,user_groups,user_hometown,user_interests,user_likes,user_location,user_notes,user_online_presence,user_photo_video_tags,user_photos,user_relationships,user_relationship_details,user_religion_politics,user_status,user_videos,user_website,user_work_history,email,read_friendlists,read_insights,read_mailbox,read_requests,read_stream,xmpp_login,ads_management,user_checkins,friends_about_me,friends_activities,friends_birthday,friends_education_history,friends_events,friends_groups,friends_hometown,friends_interests,friends_likes,friends_location,friends_notes,friends_online_presence,friends_photo_video_tags,friends_photos,friends_relationships,friends_relationship_details,friends_religion_politics,friends_status,friends_videos,friends_website,friends_work_history,manage_friendlists,friends_checkins,publish_stream,create_event,rsvp_event,offline_access,publish_checkins,manage_pages&redirect_uri=http://www.facebook.com/connect/login_success.html&display=wap&client_id=[APPLICATION_ID]&response_type=token
Error message null.
where APPLICATION_ID is my correct application ID.
The above URL opens fine in my PC browser, and I have debugged for a while through the Facebook sdk's source and found nothing.
It is possible that the application id might have changed recently without me knowing, and my next step is to revert back to using the .jar just for testing purposes.
Has anyone seen similar behavior with the BlackBerry SDK before?
I'm not sure if this is what happened in your case, but I've seen that error when the ProtocolController is set before the BrowserField is initialized. Like so:
private BrowserField bf;
...
BrowserFieldConfig bfc = new BrowserFieldConfig();
// bf not initialized yet but no compiler error
bfc.setProperty(BrowserFieldConfig.CONTROLLER, new ProtocolController(bf){
public void handleNavigationRequest(BrowserFieldRequest request) throws Exception {
super.handleNavigationRequest(request);
}
public InputConnection handleResourceRequest(BrowserFieldRequest request) throws Exception {
return super.handleResourceRequest(request);
}
});
bf = new BrowserField(bfc);
add(bf);
bf.requestContent("http://www.google.com");
...
Simply setting the ProtocolController after the BrowserField is initialized but before content is requested solves it.

Upload file to SharePoint WSS 3.0 with WebRequest PUT

Hey, I've got this nice little piece of code, much like all the other versions of this method of upload using WSS WebServices. I've got one major problem though - once I have uploaded a file into my doc list, and updated the list item to write a comment/description, the file is stuck there. What I mean is that this method will not overwrite the file once I've uploaded it. Nobody else out there seems to have posted this issue yet, so .. anyone?
I have another version of the method which uses a byte[] instead of a Stream .. same issue though.
Note: I have switched off the 'require documents to be checked out before they can be edited' option for the library. No luck tho .. The doc library does have versioning turned on though, with a major version being created for each update.
private void UploadStream(string fullPath, Stream uploadStream)
{
WebRequest request = WebRequest.Create(fullPath);
request.Credentials = CredentialCache.DefaultCredentials; // User must have 'Contributor' access to the document library
request.Method = "PUT";
request.Headers.Add("Overwrite", "t");
byte[] buffer = new byte[4096];
using (Stream stream = request.GetRequestStream())
{
for (int i = uploadStream.Read(buffer, 0, buffer.Length); i > 0; i = uploadStream.Read(buffer, 0, buffer.Length))
{
stream.Write(buffer, 0, i);
}
}
WebResponse response = request.GetResponse(); // Upload the file
response.Close();
}
Original credits to: http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html
EDIT -- major finding .. when I call it from my nUnit test project it works fine. It seems it only fails when I call it from my WCF application (nUnit running under logged on user account, WCF app has app pool running under that same user -- my account, which also has valid permissions in SharePoint).
Nuts. "Now where to start?!", I muses to myself.
SOLVED -- I found a little bug - the file was being created in the right place, but the update path was wrong.. I ended up finding a folder full of files with many, many new versions.. doh!
Why not use the out-of-the-box SharePoint webservice, Lists.asmx? You'll find it in
http://SITEURL/___vti_bin/Lists.asmx
Edit, I checked out the link and it seems you are calling the out of the box web service. This has got be versioning related then. Can you check out the different versions that exist in the doc lib of the specific file? see if it perhaps gets added as a minor version through the service?
Have you tried using a capital T? SharePoint's webdav header processing is not very likely to be case-sensitive, but the protocol does specify a capital T. Oh, and what is the response? A 412 error code or something altogether different?