Search in sources :

Example 6 with ConnectivityReceiver

use of com.applozic.mobicomkit.broadcast.ConnectivityReceiver in project Applozic-Android-SDK by AppLozic.

the class ChannelCreateActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.channel_create_activty_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(toolbar);
    String jsonString = FileUtils.loadSettingsJsonFile(getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    connectivityReceiver = new ConnectivityReceiver();
    userPreference = MobiComUserPreference.getInstance(ChannelCreateActivity.this);
    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()));
        }
    }
    mActionBar.setTitle(R.string.channel_create_title);
    mActionBar.setDisplayShowHomeEnabled(true);
    mActionBar.setDisplayHomeAsUpEnabled(true);
    finishActivityReceiver = new FinishActivityReceiver();
    registerReceiver(finishActivityReceiver, new IntentFilter(ACTION_FINISH_CHANNEL_CREATE));
    layout = (LinearLayout) findViewById(R.id.footerAd);
    applozicPermissions = new ApplozicPermissions(this, layout);
    channelName = (EditText) findViewById(R.id.channelName);
    circleImageView = (CircleImageView) findViewById(R.id.channelIcon);
    uploadImageButton = (CircleImageView) findViewById(R.id.applozic_channel_profile_camera);
    uploadImageButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            processImagePicker();
        }
    });
    int drawableResourceId = getResources().getIdentifier(alCustomizationSettings.getAttachCameraIconName(), "drawable", getPackageName());
    uploadImageButton.setImageResource(drawableResourceId);
    fileClientService = new FileClientService(this);
    if (getIntent() != null) {
        groupType = getIntent().getIntExtra(GROUP_TYPE, Channel.GroupType.PUBLIC.getValue().intValue());
    }
    /* groupType = getIntent().getIntExtra(GROUP_TYPE, Channel.GroupType.PRIVATE.getValue().intValue());
        if(groupType.equals(Channel.GroupType.BROADCAST.getValue().intValue())){
            circleImageView.setImageResource(R.drawable.applozic_ic_applozic_broadcast);
            uploadImageButton.setVisibility(View.GONE);
        }*/
    registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Also used : IntentFilter(android.content.IntentFilter) AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) ApplozicPermissions(com.applozic.mobicomkit.uiwidgets.instruction.ApplozicPermissions) ConnectivityReceiver(com.applozic.mobicomkit.broadcast.ConnectivityReceiver) FileClientService(com.applozic.mobicomkit.api.attachment.FileClientService) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) CropImageView(com.theartofdev.edmodo.cropper.CropImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) Toolbar(android.support.v7.widget.Toolbar)

Example 7 with ConnectivityReceiver

use of com.applozic.mobicomkit.broadcast.ConnectivityReceiver 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)

Example 8 with ConnectivityReceiver

use of com.applozic.mobicomkit.broadcast.ConnectivityReceiver in project Applozic-Android-SDK by AppLozic.

the class ChannelNameActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.update_channel_name_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(toolbar);
    mActionBar = getSupportActionBar();
    layout = (LinearLayout) findViewById(R.id.footerAd);
    applozicPermissions = new ApplozicPermissions(this, layout);
    mActionBar.setTitle(getString(R.string.update_channel_title_name));
    selectImageProfileIcon = (CircleImageView) findViewById(R.id.applozic_group_profile_camera);
    applozicGroupProfileIcon = (ImageView) findViewById(R.id.applozic_group_profile);
    String jsonString = FileUtils.loadSettingsJsonFile(getApplicationContext());
    fileClientService = new FileClientService(this);
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    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()));
        }
    }
    int drawableResourceId = getResources().getIdentifier(alCustomizationSettings.getAttachCameraIconName(), "drawable", getPackageName());
    selectImageProfileIcon.setImageResource(drawableResourceId);
    if (getIntent().getExtras() != null) {
        String groupInfoJson = getIntent().getExtras().getString(ChannelInfoActivity.GROUP_UPDTAE_INFO);
        groupInfoUpdate = (GroupInfoUpdate) GsonUtils.getObjectFromJson(groupInfoJson, GroupInfoUpdate.class);
    }
    if (groupInfoUpdate != null && !TextUtils.isEmpty(groupInfoUpdate.getLocalImagePath())) {
        File file = new File(groupInfoUpdate.getLocalImagePath());
        Uri uri = Uri.parse(file.getAbsolutePath());
        if (uri != null) {
            Utils.printLog(this, "ChannelNameActivity::", uri.toString());
            applozicGroupProfileIcon.setImageURI(uri);
        }
    } else {
        applozicGroupProfileIcon.setImageResource(R.drawable.applozic_group_icon);
    }
    channelName = (EditText) findViewById(R.id.newChannelName);
    channelName.setText(groupInfoUpdate.getNewName());
    ok = (Button) findViewById(R.id.channelNameOk);
    cancel = (Button) findViewById(R.id.channelNameCancel);
    selectImageProfileIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            processImagePicker();
        }
    });
    ok.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (channelName.getText().toString().equals(groupInfoUpdate.getNewName()) && imageChangeUri == null || groupInfoUpdate.getNewName() == null) {
                ChannelNameActivity.this.finish();
            }
            if (TextUtils.isEmpty(channelName.getText().toString()) || channelName.getText().toString().trim().length() == 0) {
                Toast.makeText(ChannelNameActivity.this, getString(R.string.channel_name_empty), Toast.LENGTH_SHORT).show();
                ChannelNameActivity.this.finish();
            } else {
                Intent intent = new Intent();
                groupInfoUpdate.setNewName(channelName.getText().toString());
                if (imageChangeUri != null && profilePhotoFile != null) {
                    groupInfoUpdate.setNewlocalPath(profilePhotoFile.getAbsolutePath());
                    groupInfoUpdate.setContentUri(imageChangeUri.toString());
                }
                intent.putExtra(ChannelInfoActivity.GROUP_UPDTAE_INFO, GsonUtils.getJsonFromObject(groupInfoUpdate, GroupInfoUpdate.class));
                setResult(RESULT_OK, intent);
                finish();
            }
        }
    });
    cancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ChannelNameActivity.this.finish();
        }
    });
    connectivityReceiver = new ConnectivityReceiver();
    registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Also used : IntentFilter(android.content.IntentFilter) AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) ApplozicPermissions(com.applozic.mobicomkit.uiwidgets.instruction.ApplozicPermissions) ConnectivityReceiver(com.applozic.mobicomkit.broadcast.ConnectivityReceiver) FileClientService(com.applozic.mobicomkit.api.attachment.FileClientService) Intent(android.content.Intent) Uri(android.net.Uri) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) CropImageView(com.theartofdev.edmodo.cropper.CropImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) File(java.io.File) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

IntentFilter (android.content.IntentFilter)8 ConnectivityReceiver (com.applozic.mobicomkit.broadcast.ConnectivityReceiver)8 Toolbar (android.support.v7.widget.Toolbar)7 AlCustomizationSettings (com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 View (android.view.View)4 ApplozicPermissions (com.applozic.mobicomkit.uiwidgets.instruction.ApplozicPermissions)4 Intent (android.content.Intent)3 ImageView (android.widget.ImageView)3 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)3 AppContactService (com.applozic.mobicomkit.contact.AppContactService)3 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)3 Bitmap (android.graphics.Bitmap)2 MobiComKitBroadcastReceiver (com.applozic.mobicomkit.uiwidgets.conversation.MobiComKitBroadcastReceiver)2 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)2 CropImageView (com.theartofdev.edmodo.cropper.CropImageView)2 File (java.io.File)2 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 AbsListView (android.widget.AbsListView)1