Search in sources :

Example 1 with MobiComKitBroadcastReceiver

use of com.applozic.mobicomkit.uiwidgets.conversation.MobiComKitBroadcastReceiver in project Applozic-Android-SDK by AppLozic.

the class ConversationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String jsonString = FileUtils.loadSettingsJsonFile(getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    if (!TextUtils.isEmpty(alCustomizationSettings.getChatBackgroundImageName())) {
        resourceId = getResources().getIdentifier(alCustomizationSettings.getChatBackgroundImageName(), "drawable", getPackageName());
    }
    if (resourceId != 0) {
        getWindow().setBackgroundDrawableResource(resourceId);
    }
    setContentView(R.layout.quickconversion_activity);
    Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(myToolbar);
    baseContactService = new AppContactService(this);
    conversationUIService = new ConversationUIService(this);
    mobiComMessageService = new MobiComMessageService(this, MessageIntentService.class);
    quickConversationFragment = new MobiComQuickConversationFragment();
    connectivityReceiver = new ConnectivityReceiver();
    geoApiKey = Utils.getMetaDataValue(getApplicationContext(), GOOGLE_API_KEY_META_DATA);
    activityToOpenOnClickOfCallButton = Utils.getMetaDataValue(getApplicationContext(), ACTIVITY_TO_OPEN_ONCLICK_OF_CALL_BUTTON_META_DATA);
    layout = (LinearLayout) findViewById(R.id.footerAd);
    applozicPermission = new ApplozicPermissions(this, layout);
    childFragmentLayout = (RelativeLayout) findViewById(R.id.layout_child_activity);
    profilefragment = new ProfileFragment();
    profilefragment.setAlCustomizationSettings(alCustomizationSettings);
    contactsGroupId = MobiComUserPreference.getInstance(this).getContactsGroupId();
    if (Utils.hasMarshmallow()) {
        applozicPermission.checkRuntimePermissionForStorage();
    }
    mActionBar = getSupportActionBar();
    if (!TextUtils.isEmpty(alCustomizationSettings.getThemeColorPrimary()) && !TextUtils.isEmpty(alCustomizationSettings.getThemeColorPrimaryDark())) {
        mActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(alCustomizationSettings.getThemeColorPrimary())));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().setStatusBarColor(Color.parseColor(alCustomizationSettings.getThemeColorPrimaryDark()));
        }
    }
    inviteMessage = Utils.getMetaDataValue(getApplicationContext(), SHARE_TEXT);
    retry = 0;
    if (savedInstanceState != null) {
        capturedImageUri = savedInstanceState.getString(CAPTURED_IMAGE_URI) != null ? Uri.parse(savedInstanceState.getString(CAPTURED_IMAGE_URI)) : null;
        videoFileUri = savedInstanceState.getString(CAPTURED_VIDEO_URI) != null ? Uri.parse(savedInstanceState.getString(CAPTURED_VIDEO_URI)) : null;
        mediaFile = savedInstanceState.getSerializable(LOAD_FILE) != null ? (File) savedInstanceState.getSerializable(LOAD_FILE) : null;
        contact = (Contact) savedInstanceState.getSerializable(CONTACT);
        channel = (Channel) savedInstanceState.getSerializable(CHANNEL);
        currentConversationId = savedInstanceState.getInt(CONVERSATION_ID);
        if (contact != null || channel != null) {
            if (channel != null) {
                conversation = ConversationFragment.newInstance(null, channel, currentConversationId, null);
            } else {
                conversation = ConversationFragment.newInstance(contact, null, currentConversationId, null);
            }
            addFragment(this, conversation, ConversationUIService.CONVERSATION_FRAGMENT);
        }
    } else {
        setSearchListFragment(quickConversationFragment);
        addFragment(this, quickConversationFragment, ConversationUIService.QUICK_CONVERSATION_FRAGMENT);
    }
    mobiComKitBroadcastReceiver = new MobiComKitBroadcastReceiver(this);
    InstructionUtil.showInfo(this, R.string.info_message_sync, BroadcastService.INTENT_ACTIONS.INSTRUCTION.toString());
    mActionBar.setTitle(R.string.conversations);
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);
    googleApiClient = new GoogleApiClient.Builder(getApplicationContext()).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build();
    onNewIntent(getIntent());
    Boolean takeOrder = getIntent().getBooleanExtra(TAKE_ORDER, false);
    if (!takeOrder) {
        Intent lastSeenStatusIntent = new Intent(this, UserIntentService.class);
        lastSeenStatusIntent.putExtra(UserIntentService.USER_LAST_SEEN_AT_STATUS, true);
        UserIntentService.enqueueWork(this, lastSeenStatusIntent);
    }
    if (ApplozicClient.getInstance(this).isAccountClosed() || ApplozicClient.getInstance(this).isNotAllowed()) {
        accountStatusAsyncTask = new SyncAccountStatusAsyncTask(this, layout, snackbar);
        accountStatusAsyncTask.execute();
    }
    registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    if (getIntent() != null) {
        Set<String> userIdLists = new HashSet<String>();
        if (getIntent().getStringArrayListExtra(ConversationUIService.GROUP_NAME_LIST_CONTACTS) != null) {
            MobiComUserPreference.getInstance(this).setIsContactGroupNameList(true);
            userIdLists.addAll(getIntent().getStringArrayListExtra(ConversationUIService.GROUP_NAME_LIST_CONTACTS));
        } else if (getIntent().getStringArrayListExtra(ConversationUIService.GROUP_ID_LIST_CONTACTS) != null) {
            MobiComUserPreference.getInstance(this).setIsContactGroupNameList(false);
            userIdLists.addAll(getIntent().getStringArrayListExtra(ConversationUIService.GROUP_ID_LIST_CONTACTS));
        }
        if (!userIdLists.isEmpty()) {
            MobiComUserPreference.getInstance(this).setContactGroupIdList(userIdLists);
        }
    }
    LocalBroadcastManager.getInstance(this).registerReceiver(mobiComKitBroadcastReceiver, BroadcastService.getIntentFilter());
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) IntentFilter(android.content.IntentFilter) AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) AppContactService(com.applozic.mobicomkit.contact.AppContactService) ConversationUIService(com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService) ApplozicPermissions(com.applozic.mobicomkit.uiwidgets.instruction.ApplozicPermissions) ConnectivityReceiver(com.applozic.mobicomkit.broadcast.ConnectivityReceiver) MobiComKitBroadcastReceiver(com.applozic.mobicomkit.uiwidgets.conversation.MobiComKitBroadcastReceiver) Intent(android.content.Intent) ProfileFragment(com.applozic.mobicomkit.uiwidgets.people.fragment.ProfileFragment) MessageIntentService(com.applozic.mobicomkit.api.conversation.MessageIntentService) MobiComQuickConversationFragment(com.applozic.mobicomkit.uiwidgets.conversation.fragment.MobiComQuickConversationFragment) ColorDrawable(android.graphics.drawable.ColorDrawable) MobiComMessageService(com.applozic.mobicomkit.api.conversation.MobiComMessageService) File(java.io.File) Toolbar(android.support.v7.widget.Toolbar) HashSet(java.util.HashSet)

Example 2 with MobiComKitBroadcastReceiver

use of com.applozic.mobicomkit.uiwidgets.conversation.MobiComKitBroadcastReceiver in project Applozic-Android-SDK by AppLozic.

the class ChannelInfoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.channel_info_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    String jsonString = FileUtils.loadSettingsJsonFile(getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    refreshBroadcast = new RefreshBroadcast();
    baseContactService = new AppContactService(getApplicationContext());
    channelImage = (ImageView) findViewById(R.id.channelImage);
    userPreference = MobiComUserPreference.getInstance(this);
    createdBy = (TextView) findViewById(R.id.created_by);
    groupParticipantsTexView = (TextView) findViewById(R.id.groupParticipantsTexView);
    exitChannelButton = (Button) findViewById(R.id.exit_channel);
    deleteChannelButton = (Button) findViewById(R.id.delete_channel_button);
    channelDeleteRelativeLayout = (RelativeLayout) findViewById(R.id.channel_delete_relativeLayout);
    channelExitRelativeLayout = (RelativeLayout) findViewById(R.id.channel_exit_relativeLayout);
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    collapsingToolbarLayout.setContentScrimColor(Color.parseColor(alCustomizationSettings.getCollapsingToolbarLayoutColor()));
    groupParticipantsTexView.setTextColor(Color.parseColor(alCustomizationSettings.getGroupParticipantsTextColor()));
    deleteChannelButton.setBackgroundColor(Color.parseColor((alCustomizationSettings.getGroupDeleteButtonBackgroundColor())));
    exitChannelButton.setBackgroundColor(Color.parseColor(alCustomizationSettings.getGroupExitButtonBackgroundColor()));
    mActionBar = getSupportActionBar();
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);
    mActionBar.setDisplayShowHomeEnabled(true);
    mainListView = (ListView) findViewById(R.id.mainList);
    mainListView.setLongClickable(true);
    mainListView.setSmoothScrollbarEnabled(true);
    if (Utils.hasLollipop()) {
        mainListView.setNestedScrollingEnabled(true);
    }
    connectivityReceiver = new ConnectivityReceiver();
    mobiComKitBroadcastReceiver = new MobiComKitBroadcastReceiver(this);
    registerForContextMenu(mainListView);
    if (alCustomizationSettings.isHideGroupExitButton()) {
        channelExitRelativeLayout.setVisibility(View.GONE);
    }
    if (getIntent().getExtras() != null) {
        channelKey = getIntent().getIntExtra(CHANNEL_KEY, 0);
        channel = ChannelService.getInstance(this).getChannelByChannelKey(channelKey);
        isUserPresent = ChannelService.getInstance(this).processIsUserPresentInChannel(channelKey);
        if (channel != null) {
            String title = ChannelUtils.getChannelTitleName(channel, userPreference.getUserId());
            if (!TextUtils.isEmpty(channel.getAdminKey())) {
                contact = baseContactService.getContactById(channel.getAdminKey());
                mActionBar.setTitle(title);
                if (userPreference.getUserId().equals(contact.getUserId())) {
                    createdBy.setText(getString(R.string.channel_created_by) + " " + getString(R.string.you_string));
                } else {
                    createdBy.setText(getString(R.string.channel_created_by) + " " + contact.getDisplayName());
                }
            }
            if (!isUserPresent) {
                channelExitRelativeLayout.setVisibility(View.GONE);
                channelDeleteRelativeLayout.setVisibility(View.VISIBLE);
            }
        }
    }
    if (channel != null && channel.getType() != null) {
        if (Channel.GroupType.BROADCAST.getValue().equals(channel.getType())) {
            deleteChannelButton.setText(R.string.broadcast_delete_button);
            exitChannelButton.setText(R.string.broadcast_exit_button);
        } else {
            deleteChannelButton.setText(R.string.channel_delete_group_button);
            exitChannelButton.setText(R.string.channel_exit_button);
        }
    }
    contactImageLoader = new ImageLoader(getApplicationContext(), getListPreferredItemHeight()) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return baseContactService.downloadContactImage(getApplicationContext(), (Contact) data);
        }
    };
    contactImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light);
    contactImageLoader.addImageCache(this.getSupportFragmentManager(), 0.1f);
    contactImageLoader.setImageFadeIn(false);
    channelImageLoader = new ImageLoader(getApplicationContext(), getListPreferredItemHeight()) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return baseContactService.downloadGroupImage(getApplicationContext(), (Channel) data);
        }
    };
    channelImageLoader.setLoadingImage(R.drawable.applozic_group_icon);
    channelImageLoader.addImageCache(this.getSupportFragmentManager(), 0.1f);
    channelImageLoader.setImageFadeIn(false);
    if (channelImage != null && !channel.isBroadcastMessage()) {
        channelImageLoader.loadImage(channel, channelImage);
    } else {
        channelImage.setImageResource(R.drawable.applozic_ic_applozic_broadcast);
    }
    channelUserMapperList = ChannelService.getInstance(this).getListOfUsersFromChannelUserMapper(channel.getKey());
    contactsAdapter = new ContactsAdapter(this);
    mainListView.setAdapter(contactsAdapter);
    mainListView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            // Pause image loader to ensure smoother scrolling when flinging
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                contactImageLoader.setPauseWork(true);
            } else {
                contactImageLoader.setPauseWork(false);
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int i, int i1, int i2) {
        }
    });
    exitChannelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            leaveChannel(channel);
        }
    });
    deleteChannelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            deleteChannel(channel);
        }
    });
    registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Also used : IntentFilter(android.content.IntentFilter) AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) AppContactService(com.applozic.mobicomkit.contact.AppContactService) ConnectivityReceiver(com.applozic.mobicomkit.broadcast.ConnectivityReceiver) Channel(com.applozic.mobicommons.people.channel.Channel) AbsListView(android.widget.AbsListView) MobiComKitBroadcastReceiver(com.applozic.mobicomkit.uiwidgets.conversation.MobiComKitBroadcastReceiver) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) Contact(com.applozic.mobicommons.people.contact.Contact) Bitmap(android.graphics.Bitmap) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

IntentFilter (android.content.IntentFilter)2 Toolbar (android.support.v7.widget.Toolbar)2 ConnectivityReceiver (com.applozic.mobicomkit.broadcast.ConnectivityReceiver)2 AppContactService (com.applozic.mobicomkit.contact.AppContactService)2 AlCustomizationSettings (com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings)2 MobiComKitBroadcastReceiver (com.applozic.mobicomkit.uiwidgets.conversation.MobiComKitBroadcastReceiver)2 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 MessageIntentService (com.applozic.mobicomkit.api.conversation.MessageIntentService)1 MobiComMessageService (com.applozic.mobicomkit.api.conversation.MobiComMessageService)1 ConversationUIService (com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService)1 MobiComQuickConversationFragment (com.applozic.mobicomkit.uiwidgets.conversation.fragment.MobiComQuickConversationFragment)1 ApplozicPermissions (com.applozic.mobicomkit.uiwidgets.instruction.ApplozicPermissions)1