use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class FragmentiGapMap method initToolbar.
private void initToolbar(View view) {
mHelperToolbar = new Toolbar(getContext());
mHelperToolbar.setTitle(getString(R.string.igap_nearby));
mHelperToolbar.setBackIcon(new BackDrawable(false));
mHelperToolbar.addItem(toolbarDotsTag, R.string.icon_other_vertical_dots, Color.WHITE);
mHelperToolbar.setListener(i -> {
switch(i) {
case -1:
// after return to FragmentMapUsers from FragmentContactsProfile don't execute this block
if (getActivity() != null && getActivity().getSupportFragmentManager().getFragments().get(getActivity().getSupportFragmentManager().getFragments().size() - 1) != null && getActivity().getSupportFragmentManager().getFragments().get(getActivity().getSupportFragmentManager().getFragments().size() - 1).getClass().getName().equals(FragmentContactsProfile.class.getName())) {
return;
}
if (rippleMoreMap.getVisibility() == View.GONE || fabGps.getVisibility() == View.GONE) {
rippleMoreMap.setVisibility(View.VISIBLE);
fabGps.show();
fabStateSwitcher.setVisibility(View.VISIBLE);
}
if (!isBackPress) {
// getActivity().getSupportFragmentManager().popBackStack();
G.fragmentActivity.onBackPressed();
}
closeKeyboard(view);
isBackPress = false;
page = pageiGapMap;
break;
case toolbarDotsTag:
if (getActivity() != null) {
List<Integer> items = new ArrayList<>();
items.add(R.string.list_user_map);
items.add(R.string.nearby);
if (getActivity().getSharedPreferences(SHP_SETTING.FILE_NAME, MODE_PRIVATE).getBoolean(SHP_SETTING.REGISTER_STATUS, false)) {
items.add(R.string.map_registration);
} else {
items.add(R.string.map_registration_enable);
}
dialog = new TopSheetDialog(getActivity()).setListDataWithResourceId(items, -1, new BottomSheetItemClickCallback() {
@Override
public void onClick(int position) {
if (items.get(position) == R.string.list_user_map) {
fabGps.hide();
fabStateSwitcher.setVisibility(View.GONE);
rippleMoreMap.setVisibility(View.GONE);
page = pageUserList;
try {
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentMapUsers.newInstance()).setResourceContainer(R.id.mapContainer_main).setReplace(false).load();
}
} catch (Exception e) {
e.getStackTrace();
}
} else if (items.get(position) == R.string.nearby) {
if (location != null && !isSendRequestGeoCoordinate) {
new RequestGeoGetNearbyCoordinate().getNearbyCoordinate(location.getLatitude(), location.getLongitude());
showProgress(true);
isSendRequestGeoCoordinate = true;
}
} else if (items.get(position) == R.string.map_registration) {
new MaterialDialog.Builder(getActivity()).title(R.string.Visible_Status_title_dialog_invisible).content(R.string.Visible_Status_text_dialog_invisible).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
new RequestGeoRegister().register(false);
}
}).negativeText(R.string.no).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
}
}).show();
} else if (items.get(position) == R.string.map_registration_enable) {
if (!isGpsOn) {
try {
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
} else {
new MaterialDialog.Builder(getContext()).title(R.string.Visible_Status_title_dialog).content(R.string.Visible_Status_text_dialog).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (getRequestManager().isUserLogin()) {
new RequestGeoRegister().register(true);
} else {
toggleGps.setChecked(false);
showSnackBar(getString(R.string.please_check_your_connenction));
}
}
}).negativeText(R.string.no).onNegative((dialog, which) -> toggleGps.setChecked(false)).show();
}
}
}
});
dialog.show();
}
break;
}
});
ViewGroup layoutToolbar = view.findViewById(R.id.fm_layout_toolbar);
layoutToolbar.addView(mHelperToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
}
use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class FragmentSetting method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
settingToolbar = new Toolbar(getContext());
settingToolbar.setBackIcon(new BackDrawable(false));
settingToolbar.setTitle(getString(R.string.settings));
settingToolbar.addItem(toolbarDotsTag, R.string.icon_other_vertical_dots, Color.WHITE);
settingToolbar.setListener(i -> {
switch(i) {
case -1:
if (getActivity() != null) {
getActivity().onBackPressed();
}
break;
case toolbarDotsTag:
showMenu();
break;
}
});
binding.toolbar.addView(settingToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
viewModel.setCurrentLanguage();
viewModel.showDialogDeleteAccount.observe(getViewLifecycleOwner(), aBoolean -> {
if (aBoolean != null && aBoolean) {
showDeleteAccountDialog();
}
});
viewModel.goToManageSpacePage.observe(getViewLifecycleOwner(), aBoolean -> {
if (getActivity() != null && aBoolean != null && aBoolean) {
startActivity(new Intent(getActivity(), ActivityManageSpace.class));
}
});
viewModel.goToLanguagePage.observe(getViewLifecycleOwner(), go -> {
if (getActivity() != null && go != null && go) {
new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentLanguage()).setReplace(true).load();
}
});
viewModel.goToNotificationAndSoundPage.observe(getViewLifecycleOwner(), go -> {
if (getActivity() != null && go != null && go) {
new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentNotificationAndSound()).setReplace(false).load();
}
});
viewModel.goToPrivacyAndSecurityPage.observe(getViewLifecycleOwner(), go -> {
if (getActivity() != null && go != null && go) {
new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentPrivacyAndSecurity()).setReplace(false).load();
}
});
viewModel.goToChatSettingsPage.observe(getViewLifecycleOwner(), go -> {
if (getActivity() != null && go != null && go) {
new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentChatSettings()).load();
}
});
viewModel.showDialogLogout.observe(getViewLifecycleOwner(), aBoolean -> {
if (aBoolean != null && aBoolean) {
showDialogLogout();
}
});
viewModel.showError.observe(getViewLifecycleOwner(), aBoolean -> {
if (aBoolean != null && aBoolean) {
HelperError.showSnackMessage(getString(R.string.error), false);
}
});
viewModel.goBack.observe(getViewLifecycleOwner(), aBoolean -> {
if (getActivity() != null && aBoolean != null && aBoolean) {
getActivity().onBackPressed();
}
});
viewModel.getUpdateForOtherAccount().observe(getViewLifecycleOwner(), isNeedUpdate -> {
if (getActivity() instanceof ActivityMain && isNeedUpdate != null && isNeedUpdate) {
// ToDO: handel remove notification for logout account
((ActivityMain) getActivity()).updateUiForChangeAccount();
}
});
viewModel.getGoToRegisterPage().observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() != null && isGo != null && isGo) {
try {
NotificationManager nMgr = (NotificationManager) getActivity().getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
nMgr.cancelAll();
} catch (Exception e) {
e.getStackTrace();
}
if (MusicPlayer.mp != null && MusicPlayer.mp.isPlaying()) {
MusicPlayer.stopSound();
MusicPlayer.closeLayoutMediaPlayer();
}
WebSocketClient.getInstance().connect(true);
startActivity(new Intent(getActivity(), ActivityRegistration.class));
getActivity().finish();
}
});
AppUtils.setProgresColler(binding.loading);
}
use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class FragmentShearedMedia method initComponent.
private void initComponent(View view) {
FrameLayout toolbarLayout = view.findViewById(R.id.frg_shared_media_ll_toolbar_layout);
FragmentMediaContainer mediaContainer = new FragmentMediaContainer(getContext(), this);
mediaContainer.setListener(i -> {
switch(i) {
case FragmentMediaContainer.CALL_TAG:
getActivity().startActivity(new Intent(getContext(), CallActivity.class));
break;
case FragmentMediaContainer.MEDIA_TAG:
if (!MusicPlayer.isVoice) {
Intent intent = new Intent(context, ActivityMain.class);
intent.putExtra(ActivityMain.openMediaPlayer, true);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getActivity().startActivity(intent);
}
break;
case FragmentMediaContainer.PLAY_TAG:
break;
}
});
sharedMediaToolbar = new Toolbar(getContext());
sharedMediaToolbar.setBackIcon(new BackDrawable(false));
sharedMediaToolbar.createToolbarItems();
sharedMediaToolbar.setTitle(getString(R.string.shared_media));
sharedMediaToolbar.setListener(i -> {
switch(i) {
case -1:
if (isSelectedMode) {
adapter.resetSelected();
sharedMediaToolbar.hideActionToolbar();
return;
}
popBackStackFragment();
break;
case deleteTag:
DbManager.getInstance().doRealmTask(realm -> {
String count = SelectedList.size() + "";
final RealmRoom realmRoom = RealmRoom.getRealmRoom(realm, roomId);
if (roomType == ProtoGlobal.Room.Type.CHAT && bothDeleteMessageId != null && bothDeleteMessageId.size() > 0) {
// TODO: 1/10/21 OPTIMAZE CODE
// show both Delete check box
String delete;
if (HelperCalander.isPersianUnicode) {
delete = HelperCalander.convertToUnicodeFarsiNumber(requireContext().getResources().getString(R.string.st_desc_delete) + count);
} else {
delete = HelperCalander.convertToUnicodeFarsiNumber(requireContext().getResources().getString(R.string.st_desc_delete) + "the");
}
new MaterialDialog.Builder(getContext()).limitIconToDefaultSize().content(delete).title(R.string.message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive((dialog, which) -> {
if (!dialog.isPromptCheckBoxChecked()) {
bothDeleteMessageId = null;
}
if (realmRoom != null) {
ArrayList<Long> selectedListForDel = new ArrayList<>();
ArrayList<Long> selectedDocumentListForDel = new ArrayList<>();
for (StructShearedMedia item : SelectedList) {
selectedListForDel.add(item.messageId);
selectedDocumentListForDel.add(item.documentId);
}
getMessageController().deleteSelectedMessage(roomType.getNumber(), roomId, selectedListForDel, selectedDocumentListForDel, bothDeleteMessageId);
}
resetItems();
}).checkBoxPromptRes(R.string.delete_item_dialog, false, null).show();
} else {
new MaterialDialog.Builder(requireContext()).title(R.string.message).content(getContext().getResources().getString(R.string.st_desc_delete) + count).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
bothDeleteMessageId = null;
if (realmRoom != null) {
ArrayList<Long> messageIds = new ArrayList<>();
ArrayList<Long> documentIds = new ArrayList<>();
for (StructShearedMedia item : SelectedList) {
messageIds.add(item.messageId);
documentIds.add(item.documentId);
}
getMessageController().deleteSelectedMessage(roomType.getNumber(), roomId, messageIds, documentIds, bothDeleteMessageId);
}
resetItems();
}
}).show();
}
});
break;
case forwardTag:
ArrayList<MessageObject> messageInfos = new ArrayList<>(SelectedList.size());
for (StructShearedMedia media : SelectedList) {
messageInfos.add(MessageObject.create(media.item));
}
FragmentChat.mForwardMessages = messageInfos;
adapter.resetSelected();
if (getActivity() instanceof ActivityMain) {
((ActivityMain) getActivity()).setForwardMessage(true);
((ActivityMain) getActivity()).removeAllFragmentFromMain();
/*new HelperFragment(getActivity().getSupportFragmentManager()).popBackStack(3);*/
}
break;
case seeInChatTag:
if (SelectedList.size() == 1) {
long messageId = SelectedList.get(0).messageId;
long documentId = SelectedList.get(0).documentId;
RealmRoomMessage.setGap(messageId, documentId);
goToPositionFromShardMedia.goToPosition(messageId, documentId);
goToPosition = true;
popBackStackFragment();
adapter.resetSelected();
popBackStackFragment();
}
break;
}
});
createActionMode();
toolbarLayout.addView(mediaContainer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 39, Gravity.BOTTOM, 0, 60, 0, 0));
toolbarLayout.addView(sharedMediaToolbar);
progressBar = view.findViewById(R.id.asm_progress_bar_waiting);
AppUtils.setProgresColler(progressBar);
mediaTypesLayout = view.findViewById(R.id.asm_ll_media_types_buttons);
complete = new OnComplete() {
@Override
public void complete(boolean result, String messageOne, String MessageTwo) {
int whatAction = 0;
String number = "0";
if (messageOne != null) {
if (messageOne.length() > 0)
whatAction = Integer.parseInt(messageOne);
}
if (MessageTwo != null)
if (MessageTwo.length() > 0)
number = MessageTwo;
callBack(result, whatAction, number);
}
};
recyclerView = view.findViewById(R.id.asm_recycler_view_sheared_media);
recyclerView.setItemViewCacheSize(400);
recyclerView.setItemAnimator(null);
onScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(final RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (isThereAnyMoreItemToLoad) {
if (!isSendRequestForLoading) {
int lastVisiblePosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
if (lastVisiblePosition + 30 >= offset) {
new RequestClientSearchRoomHistory().clientSearchRoomHistory(roomId, nextMessageId, nextDocumentId, mFilter);
isSendRequestForLoading = true;
progressBar.setVisibility(View.VISIBLE);
}
}
}
}
};
recyclerView.addOnScrollListener(onScrollListener);
checkSelectedDefaultTab();
makeSharedTypesViews();
checkSharedButtonsBackgrounds();
}
use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class FragmentNotificationAndSound method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
binding.setFragmentNotificationAndSoundViewModel(viewModel);
notificationAndSoundToolbar = new Toolbar(getContext());
notificationAndSoundToolbar.setBackIcon(new BackDrawable(false));
notificationAndSoundToolbar.setTitle(getString(R.string.notificaion_and_sound));
notificationAndSoundToolbar.setListener(i -> {
switch(i) {
case -1:
popBackStackFragment();
break;
}
});
binding.toolbar.addView(notificationAndSoundToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
setupResetNotification();
showLedDialog();
showVibrationDialog();
showPopupNotification();
showMessageSound();
showGroupSound();
}
use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class FragmentUserScore method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
userScoreToolbar = new Toolbar(getContext());
userScoreToolbar.setTitle(getString(R.string.score));
userScoreToolbar.setBackIcon(new BackDrawable(false));
userScoreToolbar.addItem(historyTag, R.string.icon_time, Color.WHITE);
userScoreToolbar.setListener(i -> {
switch(i) {
case -1:
if (getActivity() != null) {
getActivity().onBackPressed();
}
break;
case historyTag:
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentIVandActivities.newInstance()).setReplace(false).load();
}
break;
}
});
binding.toolbar.addView(userScoreToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
binding.rvScoreList.setLayoutManager(new LinearLayoutManager(getContext()));
binding.rvScoreList.setAdapter(new IvandScoreAdapter());
viewModel.getUserRankPointer().observe(getViewLifecycleOwner(), integer -> {
if (integer != null) {
ConstraintSet set = new ConstraintSet();
set.clone(binding.root);
set.constrainCircle(binding.rankPointer.getId(), binding.rankView.getId(), binding.rankView.getWidth() / 2, integer);
set.applyTo(binding.root);
TransitionManager.beginDelayedTransition(binding.root);
}
});
viewModel.getIvandScore().observe(getViewLifecycleOwner(), iVandScores -> {
if (binding.rvScoreList.getAdapter() instanceof IvandScoreAdapter && iVandScores != null) {
((IvandScoreAdapter) binding.rvScoreList.getAdapter()).setItems(iVandScores);
}
});
viewModel.getGoToScannerPage().observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() != null && isGo != null && isGo) {
IntentIntegrator integrator = new IntentIntegrator(getActivity());
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE);
integrator.setRequestCode(REQUEST_CODE_QR_IVAND_CODE);
integrator.setBeepEnabled(false);
integrator.setPrompt("");
integrator.initiateScan();
}
});
viewModel.getErrorMessage().observe(getViewLifecycleOwner(), errorMessageResource -> {
if (errorMessageResource != null) {
HelperError.showSnackMessage(getString(errorMessageResource), false);
}
});
viewModel.getHowToGetPoints().observe(getViewLifecycleOwner(), go -> {
getActivity().getSupportFragmentManager().beginTransaction().addToBackStack(null).add(R.id.baseRootUserScore, FragmentWebView.newInstance(TO_HOW_TO_GET_POINTS_URL)).commit();
});
}
Aggregations