Skip to content

Instantly share code, notes, and snippets.

View Sunilkumarr's full-sized avatar

Sunil Kumar Sunilkumarr

  • Bengaluru, Karnataka
View GitHub Profile
@Sunilkumarr
Sunilkumarr / 0_reuse_code.js
Created August 30, 2017 08:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Sunilkumarr
Sunilkumarr / DetailedConversationAdapter.java
Last active October 7, 2017 11:04
image click on individual Conversation screen
1)Go to this line in your project file DetailedConversationAdapter.java
https://github.com/AppLozic/Applozic-Android-SDK/blob/master/mobicomkitui/src/main/java/com/applozic/mobicomkit/uiwidgets/conversation/adapter/DetailedConversationAdapter.java#L799
2)
//Paste this code it will give you string userId in your activity intent based on that you can get and display your user profile screen
if (contactImage != null) {
contactImage.setOnClickListener(new View.OnClickListener() {
@Override
@Sunilkumarr
Sunilkumarr / AppDelegate+notification.m
Created October 10, 2017 17:02
Add applozic code for push plugin for handle the APNS notifications
1)Add this import statment
#import <Applozic/ALPushNotificationService.h>
2)In AppDelegate+notification.m file you need to replace this below code to handle the apns notifcation
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"clicked on the shade");
ALPushNotificationService *pushNotificationService = [[ALPushNotificationService alloc] init];
if([pushNotificationService isApplozicNotification:userInfo]){
@Sunilkumarr
Sunilkumarr / Add member option for admin
Created June 7, 2018 13:22
By default you can make option visible and remove if the user is not admin
ChannelUserMapper loggedInUserMapper = ChannelService.getInstance(this).getChannelUserMapperByUserId(groupId, MobiComUserPreference.getInstance(this).getUserId());
if (alCustomizationSettings.isHideGroupAddMembersButton() || loggedInUserMapper != null && ChannelUserMapper.UserRole.MEMBER.getValue().equals(loggedInUserMapper.getRole()) || (!ChannelUtils.isAdminUserId(MobiComUserPreference.getInstance(this).getUserId(), channel) && loggedInUserMapper != null && Integer.valueOf(0).equals(loggedInUserMapper.getRole()))) {
//Here you can remove your menu options and make sure its visible by defualt
// example menu.removeItem(R.id.add_member_to_channel);
}
build group info
1)
GroupInfoUpdate groupInfoUpdate = new GroupInfoUpdate(channelUserMapper.getKey());//groupId here
List<ChannelUsersFeed> channelUsersFeedList = new ArrayList<>();
ChannelUsersFeed channelUsersFeed = new ChannelUsersFeed();
channelUsersFeed.setUserId(channelUserMapper.getUserKey());//userid here whom you want to make admin or mod
channelUsersFeed.setRole(1);
channelUsersFeedList.add(channelUsersFeed);
groupInfoUpdate.setUsers(channelUsersFeedList);
@Sunilkumarr
Sunilkumarr / gist:a5cf2ffb5cc721b9ecc5bcf8b25bdaf4
Created June 21, 2018 12:30
Storage permission for camera
1) Open PermissionsUtils.java
public static boolean isStoragePermissionGranted(Context context) {
int storageRead = context.checkCallingOrSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
int storeWrite = context.checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
return ( storageRead == PackageManager.PERMISSION_GRANTED && storeWrite == PackageManager.PERMISSION_GRANTED );
}
2)Open ConversationActivity.java file and find the method processCameraAction and replace the below complete code
@Sunilkumarr
Sunilkumarr / groupmembers
Created July 1, 2018 11:31
Getting users from group/channel
List<ChannelUserMapper> channelUserMapperList
= ChannelService.getInstance(this).getListOfUsersFromChannelUserMapper(channelKey);// pass the channe.getKey() group id
AppContactService appContactService = new AppContactService(this);
for (ChannelUserMapper channelUserMapper : channelUserMapperList) {
Contact contact = appContactService.getContactById(channelUserMapper.getUserKey());
Log.i("Contact/user ", "object " + contact); //here you will get contact object then you can get the deatils of that user like display name, image etc
}
@Sunilkumarr
Sunilkumarr / addpackage name
Created July 2, 2018 08:44
package name in android manifest
add this
<meta-data android:name="com.package.name"
android:value="${applicationId}" /> <!-- NOTE: Do NOT change this, it should remain same i.e 'com.package.name' -->
@Sunilkumarr
Sunilkumarr / Notification intent service
Created July 3, 2018 08:37
Notification intent service class
<service
android:name="com.applozic.mobicomkit.api.notification.NotificationIntentService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false" />
@Sunilkumarr
Sunilkumarr / Download image auto
Created July 4, 2018 13:33
Download the image
if( !message.hasAttachment()){
return;
}
AttachmentManager attachmentManager = AttachmentManager.getInstance();
if(message.getFileMetas().getContentType().contains("image")
|| message.getFileMetas().getContentType().contains("video")){
AttachmentView attachmentView = new AttachmentView(context);