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));
}
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));
}
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));
}
Aggregations