Search in sources :

Example 1 with TintImageView

use of im.actor.sdk.view.TintImageView in project actor-platform by actorapp.

the class BaseContactFragment method addFooterOrHeaderAction.

protected void addFooterOrHeaderAction(int color, int icon, int text, boolean isLast, final Runnable action, boolean isHeader) {
    FrameLayout container = new FrameLayout(getActivity());
    container.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    {
        container.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    }
    FrameLayout invitePanel = new FrameLayout(getActivity());
    invitePanel.setBackgroundResource(R.drawable.selector_fill);
    invitePanel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            action.run();
        }
    });
    {
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(64));
        params.leftMargin = Screen.dp(40);
        invitePanel.setLayoutParams(params);
        container.addView(invitePanel);
    }
    TintImageView inviteIcon = new TintImageView(getActivity());
    inviteIcon.setTint(color);
    inviteIcon.setResource(icon);
    {
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(Screen.dp(52), Screen.dp(52));
        layoutParams.leftMargin = Screen.dp(6);
        layoutParams.topMargin = Screen.dp(6);
        layoutParams.bottomMargin = Screen.dp(6);
        layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
        invitePanel.addView(inviteIcon, layoutParams);
    }
    TextView inviteText = new TextView(getActivity());
    inviteText.setText(getString(text).replace("{appName}", ActorSDK.sharedActor().getAppName()));
    inviteText.setTextColor(color);
    inviteText.setPadding(Screen.dp(72), 0, Screen.dp(8), 0);
    inviteText.setTextSize(16);
    inviteText.setSingleLine(true);
    inviteText.setEllipsize(TextUtils.TruncateAt.END);
    inviteText.setTypeface(Fonts.medium());
    {
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.gravity = Gravity.CENTER_VERTICAL;
        layoutParams.topMargin = Screen.dp(16);
        layoutParams.bottomMargin = Screen.dp(16);
        invitePanel.addView(inviteText, layoutParams);
    }
    if (!isLast) {
        View div = new View(getActivity());
        div.setBackgroundColor(ActorSDK.sharedActor().style.getContactDividerColor());
        {
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.div_size));
            layoutParams.gravity = Gravity.BOTTOM;
            layoutParams.leftMargin = Screen.dp(72);
            invitePanel.addView(div, layoutParams);
        }
    }
    if (isHeader) {
        addHeaderView(container);
    } else {
        addFooterView(container);
    }
}
Also used : FrameLayout(android.widget.FrameLayout) TintImageView(im.actor.sdk.view.TintImageView) TextView(android.widget.TextView) SearchView(android.support.v7.widget.SearchView) TintImageView(im.actor.sdk.view.TintImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 2 with TintImageView

use of im.actor.sdk.view.TintImageView in project actor-platform by actorapp.

the class CallFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.callId = getArguments().getLong("call_id");
    this.call = messenger().getCall(callId);
    if (call == null) {
        this.peer = Peer.user(myUid());
    } else {
        this.peer = call.getPeer();
    }
    manager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
    FrameLayout cont = (FrameLayout) inflater.inflate(R.layout.fragment_call, container, false);
    v = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    CallBackgroundAvatarView backgroundAvatarView = (CallBackgroundAvatarView) cont.findViewById(R.id.background);
    // animator = new CallAvatarLayerAnimator(cont.findViewById(R.id.layer),
    // cont.findViewById(R.id.layer1),
    // cont.findViewById(R.id.layer2),
    // cont.findViewById(R.id.layer3),
    // cont.findViewById(R.id.layer4)
    // );
    layer1 = cont.findViewById(R.id.layer1);
    layer2 = cont.findViewById(R.id.layer2);
    layer3 = cont.findViewById(R.id.layer3);
    avatarLayers = new View[] { // cont.findViewById(R.id.layer),
    layer1, layer2, layer3 // cont.findViewById(R.id.layer4)
    };
    for (int i = 0; i < avatarLayers.length; i++) {
        View layer = avatarLayers[i];
        ((GradientDrawable) layer.getBackground()).setColor(Color.WHITE);
        ((GradientDrawable) layer.getBackground()).setAlpha(50);
    }
    endCallContainer = cont.findViewById(R.id.end_call_container);
    answerContainer = cont.findViewById(R.id.answer_container);
    ImageButton answer = (ImageButton) cont.findViewById(R.id.answer);
    answer.setOnClickListener(v1 -> onAnswer());
    ImageButton notAnswer = (ImageButton) cont.findViewById(R.id.notAnswer);
    endCall = (ImageButton) cont.findViewById(R.id.end_call);
    notAnswer.setOnClickListener(v1 -> doEndCall());
    endCall.setOnClickListener(v1 -> doEndCall());
    // 
    // Avatar/Name bind
    // 
    avatarView = (AvatarView) cont.findViewById(R.id.avatar);
    avatarView.init(Screen.dp(130), 50);
    nameTV = (TextView) cont.findViewById(R.id.name);
    nameTV.setTextColor(ActorSDK.sharedActor().style.getProfileTitleColor());
    if (peer.getPeerType() == PeerType.PRIVATE) {
        UserVM user = users().get(peer.getPeerId());
        avatarView.bind(user);
        backgroundAvatarView.bind(user);
        bind(nameTV, user.getName());
    } else if (peer.getPeerType() == PeerType.GROUP) {
        GroupVM g = groups().get(peer.getPeerId());
        avatarView.bind(g);
        backgroundAvatarView.bind(g);
        bind(nameTV, g.getName());
    }
    nameTV.setSelected(true);
    // 
    // Members list
    // 
    membersList = (RecyclerListView) cont.findViewById(R.id.members_list);
    if (call != null) {
        CallMembersAdapter membersAdapter = new CallMembersAdapter(getActivity(), call.getMembers());
        membersList.setAdapter(membersAdapter);
    }
    // 
    // Members list/ avatar switch
    // 
    View.OnClickListener listener = v1 -> switchAvatarMembers();
    avatarView.setOnClickListener(listener);
    // cont.findViewById(R.id.background).setOnClickListener(listener);
    membersList.setOnItemClickListener((parent, view, position, id) -> switchAvatarMembers());
    statusTV = (TextView) cont.findViewById(R.id.status);
    // 
    if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.VIBRATE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.MODIFY_AUDIO_SETTINGS) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WAKE_LOCK) != PackageManager.PERMISSION_GRANTED) {
        Log.d("Permissions", "call - no permission :c");
        CallFragment.this.requestPermissions(new String[] { Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA, Manifest.permission.VIBRATE, Manifest.permission.MODIFY_AUDIO_SETTINGS, Manifest.permission.WAKE_LOCK }, PERMISSIONS_REQUEST_FOR_CALL);
    }
    audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
    audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
    speaker = (TintImageView) cont.findViewById(R.id.speaker);
    speaker.setResource(R.drawable.ic_volume_up_white_24dp);
    speakerTV = (TextView) cont.findViewById(R.id.speaker_tv);
    cont.findViewById(R.id.speaker_btn).setOnClickListener(v1 -> toggleSpeaker(speaker, speakerTV));
    checkSpeaker(speaker, speakerTV);
    muteCall = (TintImageView) cont.findViewById(R.id.mute);
    muteCallTv = (TextView) cont.findViewById(R.id.mute_tv);
    muteCall.setResource(R.drawable.ic_mic_off_white_24dp);
    cont.findViewById(R.id.mute_btn).setOnClickListener(v1 -> messenger().toggleCallMute(callId));
    videoIcon = (TintImageView) cont.findViewById(R.id.video);
    videoIcon.setResource(R.drawable.ic_videocam_white_24dp);
    videoTv = (TextView) cont.findViewById(R.id.video_tv);
    videoTv.setTextColor(getResources().getColor(R.color.picker_grey));
    videoIcon.setTint(getResources().getColor(R.color.picker_grey));
    cont.findViewById(R.id.video_btn).setOnClickListener(v1 -> messenger().toggleVideoEnabled(callId));
    final TintImageView back = (TintImageView) cont.findViewById(R.id.back);
    back.setResource(R.drawable.ic_message_white_24dp);
    cont.findViewById(R.id.back_btn).setOnClickListener(v1 -> getActivity().startActivity(Intents.openDialog(peer, false, getActivity())));
    final TintImageView add = (TintImageView) cont.findViewById(R.id.add);
    add.setResource(R.drawable.ic_person_add_white_24dp);
    TextView addTv = (TextView) cont.findViewById(R.id.add_user_tv);
    addTv.setTextColor(getResources().getColor(R.color.picker_grey));
    add.setTint(getResources().getColor(R.color.picker_grey));
    if (peer.getPeerType() == PeerType.PRIVATE) {
        eglContext = EglBase.create();
        remoteVideoView = (SurfaceViewRenderer) cont.findViewById(R.id.remote_renderer);
        localVideoView = new SurfaceViewRenderer(getActivity()) {

            private boolean aspectFixed = false;

            @Override
            public void renderFrame(VideoRenderer.I420Frame frame) {
                if (!aspectFixed) {
                    aspectFixed = true;
                    int maxWH = Screen.getWidth() / 3 - Screen.dp(20);
                    float scale = Math.min(maxWH / (float) frame.width, maxWH / (float) frame.height);
                    int destW = (int) (scale * frame.width);
                    int destH = (int) (scale * frame.height);
                    boolean turned = frame.rotationDegree % 90 % 2 == 0;
                    localVideoView.post(new Runnable() {

                        @Override
                        public void run() {
                            localVideoView.getLayoutParams().height = turned ? destW : destH;
                            localVideoView.getLayoutParams().width = turned ? destH : destW;
                        }
                    });
                }
                super.renderFrame(frame);
            }
        };
        localVideoView.setVisibility(View.INVISIBLE);
        localVideoView.setZOrderMediaOverlay(true);
        localVideoView.setOnTouchListener((v1, event) -> {
            switch(event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    dX = localVideoView.getX() - event.getRawX();
                    dY = localVideoView.getY() - event.getRawY();
                    break;
                case MotionEvent.ACTION_MOVE:
                    localVideoView.animate().x(event.getRawX() + dX).y(event.getRawY() + dY).setDuration(0).start();
                default:
                    return false;
            }
            return true;
        });
        int margin = Screen.dp(20);
        int localVideoWidth = Screen.getWidth() / 3 - margin;
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(localVideoWidth, Math.round(localVideoWidth / 1.5f), Gravity.TOP | Gravity.LEFT);
        int statusBarHeight = 0;
        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            statusBarHeight = getResources().getDimensionPixelSize(resourceId);
        }
        params.setMargins(margin, margin + statusBarHeight, 0, 0);
        cont.addView(localVideoView, params);
    } else {
        if (call != null) {
            if (call.getIsVideoEnabled().get()) {
                messenger().toggleVideoEnabled(callId);
            }
        }
    }
    return cont;
}
Also used : BaseFragment(im.actor.sdk.controllers.BaseFragment) ImageButton(android.widget.ImageButton) Ringtone(android.media.Ringtone) PoisonPill(im.actor.runtime.actors.messages.PoisonPill) Bundle(android.os.Bundle) SurfaceViewRenderer(org.webrtc.SurfaceViewRenderer) PackageManager(android.content.pm.PackageManager) ActorSDKMessenger.groups(im.actor.sdk.util.ActorSDKMessenger.groups) Date(java.util.Date) ActorSDKMessenger.messenger(im.actor.sdk.util.ActorSDKMessenger.messenger) Uri(android.net.Uri) WindowManager(android.view.WindowManager) FrameLayout(android.widget.FrameLayout) PendingIntent(android.app.PendingIntent) Screen(im.actor.sdk.util.Screen) CallMember(im.actor.core.viewmodel.CallMember) Manifest(android.Manifest) PowerManager(android.os.PowerManager) RecyclerListView(im.actor.sdk.view.adapters.RecyclerListView) View(android.view.View) DateFormat(java.text.DateFormat) Intents(im.actor.sdk.controllers.Intents) NotificationManager(android.app.NotificationManager) TimeZone(java.util.TimeZone) ValueModel(im.actor.runtime.mvvm.ValueModel) ContextCompat(android.support.v4.content.ContextCompat) ViewGroup(android.view.ViewGroup) ActorBinder(im.actor.sdk.controllers.ActorBinder) TextView(android.widget.TextView) Peer(im.actor.core.entity.Peer) Props(im.actor.runtime.actors.Props) Notification(android.app.Notification) CallState(im.actor.core.viewmodel.CallState) ViewHolder(im.actor.sdk.view.adapters.ViewHolder) Context(android.content.Context) ActorSDKMessenger.myUid(im.actor.sdk.util.ActorSDKMessenger.myUid) AndroidVideoTrack(im.actor.runtime.android.webrtc.AndroidVideoTrack) TintImageView(im.actor.sdk.view.TintImageView) SimpleDateFormat(java.text.SimpleDateFormat) Intent(android.content.Intent) GroupVM(im.actor.core.viewmodel.GroupVM) AudioManager(android.media.AudioManager) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) CallVM(im.actor.core.viewmodel.CallVM) MotionEvent(android.view.MotionEvent) GradientDrawable(android.graphics.drawable.GradientDrawable) ActorSystem(im.actor.runtime.actors.ActorSystem) AvatarView(im.actor.sdk.view.avatar.AvatarView) ActorRef(im.actor.runtime.actors.ActorRef) HolderAdapter(im.actor.sdk.view.adapters.HolderAdapter) PeerType(im.actor.core.entity.PeerType) ActorSDK(im.actor.sdk.ActorSDK) TimerActor(im.actor.sdk.controllers.calls.view.TimerActor) VideoRenderer(org.webrtc.VideoRenderer) LayoutInflater(android.view.LayoutInflater) ActorSDKMessenger.users(im.actor.sdk.util.ActorSDKMessenger.users) Color(android.graphics.Color) Gravity(android.view.Gravity) UserVM(im.actor.core.viewmodel.UserVM) R(im.actor.sdk.R) CallBackgroundAvatarView(im.actor.sdk.view.avatar.CallBackgroundAvatarView) RingtoneManager(android.media.RingtoneManager) NotificationCompat(android.support.v4.app.NotificationCompat) EglBase(org.webrtc.EglBase) VideoTrack(org.webrtc.VideoTrack) Log(im.actor.runtime.Log) Vibrator(android.os.Vibrator) Activity(android.app.Activity) GroupVM(im.actor.core.viewmodel.GroupVM) VideoRenderer(org.webrtc.VideoRenderer) TintImageView(im.actor.sdk.view.TintImageView) CallBackgroundAvatarView(im.actor.sdk.view.avatar.CallBackgroundAvatarView) RecyclerListView(im.actor.sdk.view.adapters.RecyclerListView) View(android.view.View) TextView(android.widget.TextView) TintImageView(im.actor.sdk.view.TintImageView) AvatarView(im.actor.sdk.view.avatar.AvatarView) CallBackgroundAvatarView(im.actor.sdk.view.avatar.CallBackgroundAvatarView) GradientDrawable(android.graphics.drawable.GradientDrawable) ImageButton(android.widget.ImageButton) UserVM(im.actor.core.viewmodel.UserVM) SurfaceViewRenderer(org.webrtc.SurfaceViewRenderer) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView)

Example 3 with TintImageView

use of im.actor.sdk.view.TintImageView in project actor-platform by actorapp.

the class BaseActorSettingsFragment method addCategories.

private void addCategories(LinearLayout container, ActorSettingsCategories categories, LayoutInflater inflater) {
    for (ActorSettingsCategory category : categories) {
        LinearLayout categoryContainer = (LinearLayout) inflater.inflate(R.layout.actor_settings_category, null);
        FrameLayout settingsContainer = (FrameLayout) categoryContainer.findViewById(R.id.settings_container);
        TextView categoryName = (TextView) categoryContainer.findViewById(R.id.category_name);
        categoryName.setTextColor(ActorSDK.sharedActor().style.getSettingsCategoryTextColor());
        // Icon
        TintImageView icon = (TintImageView) categoryContainer.findViewById(R.id.icon);
        icon.setTint(ActorSDK.sharedActor().style.getSettingsIconColor());
        if (category.getIconResourceId() != 0) {
            icon.setResource(category.getIconResourceId());
            if (category.getIconColor() != -1) {
                icon.setTint(category.getIconColor());
            }
        } else {
            icon.setVisibility(View.INVISIBLE);
        }
        categoryName.setText(category.getText());
        if (category.getFields() != null) {
            addFields(settingsContainer, category.getFields(), inflater);
        }
        container.addView(categoryContainer, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    }
}
Also used : FrameLayout(android.widget.FrameLayout) TintImageView(im.actor.sdk.view.TintImageView) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 4 with TintImageView

use of im.actor.sdk.view.TintImageView in project actor-platform by actorapp.

the class InputBarFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View res = inflater.inflate(R.layout.fragment_inputbar, container, false);
    res.setBackgroundColor(style.getMainBackgroundColor());
    // 
    // Message Body
    // 
    messageEditText = (BarEditText) res.findViewById(R.id.et_message);
    messageEditText.setTextColor(style.getTextPrimaryColor());
    messageEditText.setHintTextColor(style.getTextHintColor());
    // Hardware keyboard events
    messageEditText.setOnKeyListener((view, keycode, keyEvent) -> {
        if (messenger().isSendByEnterEnabled()) {
            if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keycode == KeyEvent.KEYCODE_ENTER) {
                onSendButtonPressed();
                return true;
            }
        }
        return false;
    });
    // Software keyboard events
    messageEditText.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_SEND) {
            onSendButtonPressed();
            return true;
        }
        if (i == EditorInfo.IME_ACTION_DONE) {
            onSendButtonPressed();
            return true;
        }
        if (messenger().isSendByEnterEnabled()) {
            if (keyEvent != null && i == EditorInfo.IME_NULL && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
                onSendButtonPressed();
                return true;
            }
        }
        return false;
    });
    messageEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            onBeforeTextChanged(charSequence, i, i1, i2);
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            InputBarFragment.this.onTextChanged(charSequence, i, i1, i2);
        }

        @Override
        public void afterTextChanged(Editable editable) {
            onAfterTextChanged(editable);
        }
    });
    messageEditText.addSelectionListener((start, length) -> {
        InputBarFragment.this.onSelectionChanged(start, length);
    });
    messageEditText.setOnFocusChangeListener((v, hasFocus) -> {
        Fragment parent = getParentFragment();
        if (parent instanceof InputBarCallback) {
            ((InputBarCallback) parent).onTextFocusChanged(hasFocus);
        }
    });
    // 
    // Send Button
    // 
    sendButton = (TintImageView) res.findViewById(R.id.ib_send);
    sendButton.setResource(R.drawable.conv_send);
    sendButton.setOnClickListener(v -> {
        onSendButtonPressed();
    });
    // 
    // Attach Button
    // 
    attachButton = (ImageButton) res.findViewById(R.id.ib_attach);
    attachButton.setOnClickListener(v -> {
        onAttachButtonClicked();
    });
    // 
    // Emoji keyboard
    // 
    emojiButton = (ImageView) res.findViewById(R.id.ib_emoji);
    emojiButton.setOnClickListener(v -> emojiKeyboard.toggle());
    emojiKeyboard = getEmojiKeyboard();
    emojiKeyboard.setOnStickerClickListener(sticker -> {
        Fragment parent = getParentFragment();
        if (parent instanceof InputBarCallback) {
            ((InputBarCallback) parent).onStickerSent(sticker);
        }
    });
    emojiKeyboard.setKeyboardStatusListener(new KeyboardStatusListener() {

        @Override
        public void onDismiss() {
            emojiButton.setImageResource(R.drawable.ic_emoji);
        }

        @Override
        public void onShow() {
            emojiButton.setImageResource(R.drawable.ic_keyboard);
        }
    });
    // 
    // Audio
    // 
    audioContainer = res.findViewById(R.id.audioContainer);
    audioTimer = (TextView) res.findViewById(R.id.audioTimer);
    audioSlide = res.findViewById(R.id.audioSlide);
    recordPoint = res.findViewById(R.id.record_point);
    audioButton = (ImageView) res.findViewById(R.id.record_btn);
    audioButton.setVisibility(View.VISIBLE);
    audioButton.setOnTouchListener((v, event) -> {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            if (!isAudioVisible) {
                showAudio();
                slideStart = (int) event.getX();
            }
        } else if (event.getAction() == MotionEvent.ACTION_UP) {
            if (isAudioVisible) {
                hideAudio(false);
            }
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            if (isAudioVisible) {
                int slide = slideStart - (int) event.getX();
                if (slide < 0) {
                    slide = 0;
                }
                if (slide > SLIDE_LIMIT) {
                    hideAudio(true);
                } else {
                    slideAudio(slide);
                }
            }
        }
        return true;
    });
    return res;
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) KeyboardStatusListener(im.actor.sdk.view.emoji.keyboard.KeyboardStatusListener) TintImageView(im.actor.sdk.view.TintImageView) ImageView(android.widget.ImageView) ViewUtils.zoomInView(im.actor.sdk.util.ViewUtils.zoomInView) View(android.view.View) ViewUtils.zoomOutView(im.actor.sdk.util.ViewUtils.zoomOutView) TextView(android.widget.TextView) BaseFragment(im.actor.sdk.controllers.BaseFragment) Fragment(android.support.v4.app.Fragment) MessagesDefaultFragment(im.actor.sdk.controllers.conversation.messages.MessagesDefaultFragment) MessagesFragment(im.actor.sdk.controllers.conversation.messages.MessagesFragment) Nullable(android.support.annotation.Nullable)

Example 5 with TintImageView

use of im.actor.sdk.view.TintImageView in project actor-platform by actorapp.

the class BaseActorSettingsFragment method addFields.

private void addFields(FrameLayout container, ArrayList<ActorSettingsField> fields, LayoutInflater inflater) {
    LinearLayout ll = new LinearLayout(getActivity());
    ll.setOrientation(LinearLayout.VERTICAL);
    container.addView(ll, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    for (ActorSettingsField field : fields) {
        if (field.getView() != null) {
            View view = field.getView();
            ll.addView(view, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        } else {
            LinearLayout fieldLayout = (LinearLayout) inflater.inflate(R.layout.actor_settings_field, null);
            TintImageView icon = (TintImageView) fieldLayout.findViewById(R.id.icon);
            icon.setTint(ActorSDK.sharedActor().style.getSettingsIconColor());
            TextView name = (TextView) fieldLayout.findViewById(R.id.name);
            name.setTextColor(ActorSDK.sharedActor().style.getSettingsTitleColor());
            View rightView = field.getRightView();
            // Icon
            if (field.getIconResourceId() != 0) {
                icon.setResource(field.getIconResourceId());
                if (field.getIconColor() != -1) {
                    icon.setTint(field.getIconColor());
                }
            } else {
                icon.setVisibility(View.INVISIBLE);
            }
            // Name
            if (field.getName() != null) {
                name.setText(field.getName());
            } else {
                name.setVisibility(View.GONE);
            }
            // Right view
            if (rightView != null) {
                fieldLayout.addView(rightView, field.getRightViewWidth(), field.getRightViewHeight());
            }
            // Click
            if (getMenuFieldOnClickListener() != null) {
                fieldLayout.setId(field.getId());
                fieldLayout.setOnClickListener(getMenuFieldOnClickListener());
            }
            // Field
            ll.addView(fieldLayout, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        }
    }
}
Also used : TintImageView(im.actor.sdk.view.TintImageView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TintImageView(im.actor.sdk.view.TintImageView) AvatarView(im.actor.sdk.view.avatar.AvatarView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout)

Aggregations

TextView (android.widget.TextView)7 TintImageView (im.actor.sdk.view.TintImageView)7 View (android.view.View)6 FrameLayout (android.widget.FrameLayout)4 Intent (android.content.Intent)3 RecyclerView (android.support.v7.widget.RecyclerView)3 ViewGroup (android.view.ViewGroup)3 ImageView (android.widget.ImageView)3 LinearLayout (android.widget.LinearLayout)3 AvatarView (im.actor.sdk.view.avatar.AvatarView)3 AlertDialog (android.app.AlertDialog)2 ClipData (android.content.ClipData)2 ClipboardManager (android.content.ClipboardManager)2 Context (android.content.Context)2 Color (android.graphics.Color)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Bundle (android.os.Bundle)2 LayoutInflater (android.view.LayoutInflater)2 MenuItem (android.view.MenuItem)2 ScrollView (android.widget.ScrollView)2