Search in sources :

Example 1 with ConversationUIService

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

the class MobiComConversationFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String jsonString = FileUtils.loadSettingsJsonFile(getActivity().getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    applozicDocumentView = new ApplozicDocumentView(getContext());
    restrictedWords = FileUtils.loadRestrictedWordsFile(getContext());
    conversationUIService = new ConversationUIService(getActivity());
    syncCallService = SyncCallService.getInstance(getActivity());
    appContactService = new AppContactService(getActivity());
    messageDatabaseService = new MessageDatabaseService(getActivity());
    fileClientService = new FileClientService(getActivity());
    setHasOptionsMenu(true);
    imageThumbnailLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return fileClientService.loadThumbnailImage(getContext(), (Message) data, getImageLayoutParam(false).width, getImageLayoutParam(false).height);
        }
    };
    imageCache = ImageCache.getInstance((getActivity()).getSupportFragmentManager(), 0.1f);
    imageThumbnailLoader.setImageFadeIn(false);
    imageThumbnailLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f);
    messageImageLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return fileClientService.loadMessageImage(getContext(), (String) data);
        }
    };
    messageImageLoader.setImageFadeIn(false);
    messageImageLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f);
    applozicAudioRecordManager = new ApplozicAudioRecordManager(getActivity());
    mDetector = new GestureDetectorCompat(getContext(), this);
}
Also used : AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) ConversationUIService(com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService) AppContactService(com.applozic.mobicomkit.contact.AppContactService) Message(com.applozic.mobicomkit.api.conversation.Message) FileClientService(com.applozic.mobicomkit.api.attachment.FileClientService) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) Bitmap(android.graphics.Bitmap) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader) ApplozicDocumentView(com.applozic.mobicomkit.uiwidgets.attachmentview.ApplozicDocumentView) MessageDatabaseService(com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService) ApplozicAudioRecordManager(com.applozic.mobicomkit.uiwidgets.attachmentview.ApplozicAudioRecordManager)

Example 2 with ConversationUIService

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

the class MultimediaOptionFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    capturedImageUri = null;
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setItems(menuOptionsResourceId, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            switch(which) {
                case 0:
                    ((ConversationActivity) getActivity()).processLocation();
                    break;
                case 1:
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    // Ensure that there's a camera activity to handle the intent
                    if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
                        // Create the File where the photo should go
                        File photoFile;
                        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
                        String imageFileName = "JPEG_" + timeStamp + "_" + ".jpeg";
                        photoFile = FileClientService.getFilePath(imageFileName, getActivity(), "image/jpeg");
                        // Continue only if the File was successfully created
                        if (photoFile != null) {
                            capturedImageUri = Uri.fromFile(photoFile);
                            ConversationActivity.setCapturedImageUri(capturedImageUri);
                            intent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
                            getActivity().startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO);
                        }
                    }
                    break;
                case 2:
                    Intent intentPick = new Intent(getActivity(), MobiComAttachmentSelectorActivity.class);
                    getActivity().startActivityForResult(intentPick, REQUEST_MULTI_ATTCAHMENT);
                    break;
                case 3:
                    ((ConversationActivity) getActivity()).showAudioRecordingDialog();
                    break;
                case 4:
                    // create new Intentwith with Standard Intent action that can be
                    // sent to have the camera application capture an video and return it.
                    intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
                    String imageFileName = "VID_" + timeStamp + "_" + ".mp4";
                    File fileUri = FileClientService.getFilePath(imageFileName, getActivity(), "video/mp4");
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(fileUri));
                    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
                    ((ConversationActivity) (getActivity())).setVideoFileUri(Uri.fromFile(fileUri));
                    getActivity().startActivityForResult(intent, REQUEST_CODE_CAPTURE_VIDEO_ACTIVITY);
                    break;
                case 5:
                    // Sharing contact.
                    intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
                    intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
                    getActivity().startActivityForResult(intent, REQUEST_CODE_CONTACT_SHARE);
                    break;
                case 6:
                    new ConversationUIService(getActivity()).sendPriceMessage();
                    break;
                default:
            }
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) MobiComAttachmentSelectorActivity(com.applozic.mobicomkit.uiwidgets.conversation.activity.MobiComAttachmentSelectorActivity) ConversationUIService(com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) Date(java.util.Date) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with ConversationUIService

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

the class AudioMessageFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.mobicom_audio_message_layout, container, false);
    this.getDialog().setTitle("Voice Message");
    this.getDialog().setCancelable(Boolean.TRUE);
    this.getDialog().setCanceledOnTouchOutside(Boolean.FALSE);
    record = (ImageButton) v.findViewById(R.id.audio_mic_imageview);
    send = (Button) v.findViewById(R.id.audio_send);
    cancel = (Button) v.findViewById(R.id.audio_cancel);
    txtcount = (TextView) v.findViewById(R.id.txtcount);
    audioRecordingText = (TextView) v.findViewById(R.id.audio_recording_text);
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String audioFileName = "AUD_" + timeStamp + "_" + ".m4a";
    outputFile = FileClientService.getFilePath(audioFileName, getActivity().getApplicationContext(), "audio/m4a").getAbsolutePath();
    prepareMediaRecorder();
    record.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                if (isRecordring) {
                    AudioMessageFragment.this.stopRecording();
                    cancel.setVisibility(View.VISIBLE);
                    send.setVisibility(View.VISIBLE);
                } else {
                    cancel.setVisibility(View.GONE);
                    send.setVisibility(View.GONE);
                    if (audioRecorder == null) {
                        prepareMediaRecorder();
                    }
                    audioRecordingText.setText(getResources().getString(R.string.stop));
                    audioRecorder.prepare();
                    audioRecorder.start();
                    isRecordring = true;
                    record.setImageResource(R.drawable.applozic_audio_mic_inverted);
                    t.cancel();
                    t.start();
                    cnt = 0;
                }
            } catch (IllegalStateException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    cancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isRecordring) {
                AudioMessageFragment.this.stopRecording();
            }
            File file = new File(outputFile);
            if (file != null) {
                Utils.printLog(getContext(), "AudioFRG:", "File deleted...");
                file.delete();
            }
            AudioMessageFragment.this.dismiss();
        }
    });
    send.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) throws IllegalArgumentException, SecurityException, IllegalStateException {
            // IF recording is running stoped it ...
            if (isRecordring) {
                stopRecording();
            }
            // FILE CHECK ....
            if (!(new File(outputFile).exists())) {
                Toast.makeText(getContext(), R.string.audio_recording_send_text, Toast.LENGTH_SHORT).show();
                return;
            }
            ConversationUIService conversationUIService = new ConversationUIService(getActivity());
            conversationUIService.sendAudioMessage(outputFile);
            AudioMessageFragment.this.dismiss();
        }
    });
    // Set Timer
    t = new CountDownTimer(Long.MAX_VALUE, 1000) {

        @Override
        public void onTick(long millisUntilFinished) {
            cnt++;
            long millis = cnt;
            int seconds = (int) (millis / 60);
            int minutes = seconds / 60;
            seconds = seconds % 60;
            txtcount.setText(String.format("%d:%02d:%02d", minutes, seconds, millis));
        }

        @Override
        public void onFinish() {
        }
    };
    return v;
}
Also used : ConversationUIService(com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService) CountDownTimer(android.os.CountDownTimer) IOException(java.io.IOException) TextView(android.widget.TextView) View(android.view.View) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Example 4 with ConversationUIService

use of com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService 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 5 with ConversationUIService

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

the class MobiComQuickConversationFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String jsonString = FileUtils.loadSettingsJsonFile(getActivity().getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    syncCallService = SyncCallService.getInstance(getActivity());
    conversationUIService = new ConversationUIService(getActivity());
    baseContactService = new AppContactService(getActivity());
    messageDatabaseService = new MessageDatabaseService(getActivity());
    Thread thread = new Thread(new Runnable() {

        @Override
        public void run() {
            MobiComUserPreference.getInstance(getActivity()).setDeviceTimeOffset(DateUtils.getTimeDiffFromUtc());
        }
    });
    thread.setPriority(Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    setHasOptionsMenu(true);
    BroadcastService.lastIndexForChats = 0;
}
Also used : AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) ConversationUIService(com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService) AppContactService(com.applozic.mobicomkit.contact.AppContactService) MessageDatabaseService(com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)

Aggregations

ConversationUIService (com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService)5 AppContactService (com.applozic.mobicomkit.contact.AppContactService)3 AlCustomizationSettings (com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings)3 File (java.io.File)3 Intent (android.content.Intent)2 MessageDatabaseService (com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 IntentFilter (android.content.IntentFilter)1 Bitmap (android.graphics.Bitmap)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 CountDownTimer (android.os.CountDownTimer)1 GestureDetectorCompat (android.support.v4.view.GestureDetectorCompat)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 TextView (android.widget.TextView)1 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)1 Message (com.applozic.mobicomkit.api.conversation.Message)1