Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 74

sarahk
Code is Art
Profile
Posts: 159
Reg: Jul 16, 2014
Auckland
10,290
07/29/14 04:17 AM (9 years ago)

Making changes to someone else's plugin

I've messing about with the map plugin and there are a few things I'd like to extend/change. Example -(void)centerDeviceLocation This centers the map on the locations given on the map and endeavours to show all of them at once. I'd like to add a pin for the phone's location, center that and force a zoom level that will mean that many pins aren't visible unless the user moves, zooms out etc. I'm reasonably confident I can do that without breaking anything, the code seems clear. * Should I be downloading the standard map plugin, making the changes and reuploading as my own plugin? * Should I create a class that extends the existing plugin? (however that gets done in objective c) * Or should I be changing in Xcode and just remembering to change it again if I ever re-download the code?
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/29/14 04:58 AM (9 years ago)
I would personally download the plugin rename it to modified and upload it to your control panel only. Once updates are made use a program or app to analyze those changes and apply it yourself so that you can keep up with the changes. http://www.kaleidoscopeapp.com is a good app for that.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
07/29/14 05:34 AM (9 years ago)
Both Xcode and TextWrangler have capability to show differences between files. Not sure of they have a merging capability, however. Uploading one's own modification to a plugin is a great idea! It's a tedious chore that you only have to do once per modification. For coding simplicity, I would make the change directly to the plugin. Don't try to extend the class. -- Niraj
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/29/14 07:13 AM (9 years ago)
For file comparison, there's nothing better than DiffMerge from http://www.sourcegear.com. I agree with Niraj; simpler is better in the long run. The following will always make the map center on user location. If this is a permanent fix, use Text Wrangler or NotePad++ to modify the files online, so the next time you download the plugin, the changes are already there. or modify a local copy, and upload it to your plugin directory. If you look at your BT_screen_map.m file, around line 480 you'll see the 'centerMap' method. //if there is ONLY one location, center the location and zoom in to the singleLocationDefaultZoom level if([self.mapLocations count] == 1){ change that to something really easy; BOOL *iWantItLikeThat = TRUE; //if there is ONLY one location, center the location and zoom in to the singleLocationDefaultZoom level if(iWantItLikeThat){ // this ensures it will 'always' go this way... Then, around line 504 you'll see code for the location of the 'single' pin: //location object CLLocationCoordinate2D tmpLocation; tmpLocation.latitude = [[thisMapLocation.jsonVars objectForKey:@"latitude"] doubleValue]; tmpLocation.longitude = [[thisMapLocation.jsonVars objectForKey:@"longitude"] doubleValue]; [self.mapView setCenterCoordinate:tmpLocation animated:TRUE]; 'Replace' that code with the center location code from 'centerOnDeviceLocation', around line 591: //center on location CLLocationCoordinate2D tmpLocation; tmpLocation.latitude = self.mapView.userLocation.coordinate.latitude; tmpLocation.longitude = self.mapView.userLocation.coordinate.longitude; [self.mapView setCenterCoordinate:tmpLocation animated:TRUE]; finally, 'comment out' the 'annotation selection' around line 511 or so... [self.mapView selectAnnotation:[self.mapView.annotations objectAtIndex:0] animated:TRUE]; should turn into // [self.mapView selectAnnotation:[self.mapView.annotations objectAtIndex:0] animated:TRUE]; And that should about do it. It might need 'some' tweaking, if there were unspoken needs. Cheers! -- Smug
 
sarahk
Code is Art
Profile
Posts: 159
Reg: Jul 16, 2014
Auckland
10,290
like
08/29/14 10:02 PM (9 years ago)
I've finally found time for this - wanted to get a few things working before I broke something else :) I've downloaded the source of the map plugin and there are folders for source-android, source-android-2.0, source-android-3.0 and the same for ios do these refer to the BT control panel version? If so can I delete or ignore the earlier version folders?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/30/14 03:15 AM (9 years ago)
This is a 'raw' plugin, that would go in your self hosted server. It contains files for each type of BT config/download possible. That doesn't mean that the plugin supports it; that is usually left to the developer. There are a few directories leftover for backwards compatibility... source-android <-- Pre-BT3 way of calling Android files source-iOS <-- Pre-BT3 way of calling iOS files source-android-2.0/3.0 <-- BT3 way of differentiating source code. BTv2 used activities, BTv3 uses fragments, and the source files for each are a bit different. source-iOS-2.0/3.0 <-- BT3 way of differentiating source code. BTv2 used Xcode 4. BTv3 needs xcode 5. Files held within those directories are in support of the mobile version. All files 'outside' of those directories are in support of the BT control panel, and assist in configuring the plugin for either iOS or Android. Cheers! -- Smug
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.