Search in sources :

Example 1 with EphemeralExpiration

use of com.waz.api.EphemeralExpiration in project wire-android by wireapp.

the class MainActivity method onUserLoggedInAndVerified.

private void onUserLoggedInAndVerified(Self self) {
    getStoreFactory().getProfileStore().setUser(self);
    getControllerFactory().getAccentColorController().setColor(AccentColorChangeRequester.LOGIN, self.getAccent().getColor());
    getControllerFactory().getUsernameController().setUser(self);
    final Intent intent = getIntent();
    if (IntentUtils.isLaunchFromNotificationIntent(intent)) {
        final IConversation conversation = getStoreFactory().getConversationStore().getConversation(IntentUtils.getLaunchConversationId(intent));
        final boolean startCallNotificationIntent = IntentUtils.isStartCallNotificationIntent(intent);
        Timber.i("Start from notification with call=%b", startCallNotificationIntent);
        IntentUtils.clearLaunchIntentExtra(intent);
        if (conversation != null) {
            // Only want to swipe over when app has loaded
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    getStoreFactory().getConversationStore().setCurrentConversation(conversation, ConversationChangeRequester.NOTIFICATION);
                    if (startCallNotificationIntent) {
                        startCall(false);
                    }
                }
            }, LAUNCH_CONVERSATION_CHANGE_DELAY);
        }
    } else if (IntentUtils.isLaunchFromSharingIntent(intent)) {
        List<String> targetConversations = IntentUtils.getLaunchConversationIds(intent);
        String sharedText = IntentUtils.getLaunchConversationSharedText(intent);
        List<Uri> sharedFileUris = IntentUtils.getLaunchConversationSharedFiles(intent);
        EphemeralExpiration expiration = IntentUtils.getEphemeralExpiration(intent);
        SharingController sharingController = injectJava(SharingController.class);
        if (targetConversations != null) {
            if (targetConversations.size() == 1 && targetConversations.get(0) != null) {
                String conversationId = targetConversations.get(0);
                final IConversation conversation = getStoreFactory().getConversationStore().getConversation(conversationId);
                if (!TextUtils.isEmpty(sharedText)) {
                    getControllerFactory().getSharingController().setSharedContentType(SharedContentType.TEXT);
                } else {
                    getControllerFactory().getSharingController().setSharedContentType(SharedContentType.FILE);
                }
                getControllerFactory().getSharingController().setSharedText(sharedText);
                getControllerFactory().getSharingController().setSharedUris(sharedFileUris);
                getControllerFactory().getSharingController().setSharingConversationId(conversationId);
                if (conversation != null) {
                    conversation.setEphemeralExpiration(expiration);
                }
                // Only want to swipe over when app has loaded
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        getStoreFactory().getConversationStore().setCurrentConversation(conversation, ConversationChangeRequester.SHARING);
                    }
                }, LAUNCH_CONVERSATION_CHANGE_DELAY);
            } else {
                sharingController.sendContent(sharedText, sharedFileUris, targetConversations, expiration, this);
            }
        }
        IntentUtils.clearLaunchIntentExtra(intent);
    }
    setIntent(intent);
    openMainPage();
}
Also used : Handler(android.os.Handler) ExceptionHandler(net.hockeyapp.android.ExceptionHandler) EphemeralExpiration(com.waz.api.EphemeralExpiration) Intent(android.content.Intent) IConversation(com.waz.api.IConversation) List(java.util.List) ArrayList(java.util.ArrayList) ConversationsList(com.waz.api.ConversationsList) SharingController(com.waz.zclient.controllers.SharingController)

Example 2 with EphemeralExpiration

use of com.waz.api.EphemeralExpiration in project wire-android by wireapp.

the class EphemeralLayout method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    ContextThemeWrapper cw = new ContextThemeWrapper(getContext(), com.waz.zclient.ui.R.style.NumberPickerText);
    numberPicker = new NumberPicker(cw);
    numberPicker.setMinValue(0);
    final EphemeralExpiration[] ephemeralExpirationsValues = getAvailableEphemeralExpirations();
    numberPicker.setMaxValue(ephemeralExpirationsValues.length - 1);
    String[] values = new String[ephemeralExpirationsValues.length];
    for (int i = 0; i < values.length; i++) {
        values[i] = getDisplayName(ephemeralExpirationsValues[i]);
    }
    numberPicker.setDisplayedValues(values);
    numberPicker.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (callback != null) {
                callback.onEphemeralExpirationSelected(ephemeralExpirationsValues[numberPicker.getValue()], true);
            }
        }
    });
    numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {

        @Override
        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            if (callback != null) {
                callback.onEphemeralExpirationSelected(ephemeralExpirationsValues[numberPicker.getValue()], false);
            }
        }
    });
    try {
        //NoSuchFieldException
        Field f = numberPicker.getClass().getDeclaredField("mSelectionDivider");
        f.setAccessible(true);
        f.set(numberPicker, getResources().getDrawable(com.waz.zclient.ui.R.drawable.number_picker_divider));
    } catch (Throwable t) {
        Timber.e(t, "Something went wrong");
    }
    addView(numberPicker);
}
Also used : NumberPicker(android.widget.NumberPicker) EphemeralExpiration(com.waz.api.EphemeralExpiration) View(android.view.View) Field(java.lang.reflect.Field) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper)

Example 3 with EphemeralExpiration

use of com.waz.api.EphemeralExpiration in project wire-android by wireapp.

the class CursorLayout method updateEphemeralButtonBackground.

private void updateEphemeralButtonBackground() {
    if (conversation != null && conversation.isEphemeral()) {
        EphemeralExpiration expiration = conversation.getEphemeralExpiration();
        final String value;
        switch(expiration) {
            case ONE_DAY:
                value = getResources().getString(R.string.cursor__ephemeral_message__timer_days, String.valueOf(expiration.milliseconds / 1000 / 60 / 60 / 24));
                break;
            case ONE_MINUTE:
            case FIVE_MINUTES:
                value = getResources().getString(R.string.cursor__ephemeral_message__timer_min, String.valueOf(expiration.milliseconds / 1000 / 60));
                break;
            case FIVE_SECONDS:
            case FIFTEEN_SECONDS:
            case THIRTY_SECONDS:
            case NONE:
            default:
                value = getResources().getString(R.string.cursor__ephemeral_message__timer_seconds, String.valueOf(expiration.milliseconds / 1000));
        }
        int bgColor = ColorUtils.injectAlpha(ResourceUtils.getResourceFloat(getResources(), R.dimen.ephemeral__accent__timer_alpha), accentColor);
        ephemeralButton.setBackground(ColorUtils.getTintedDrawable(getContext(), R.drawable.background__cursor__ephemeral_timer, bgColor));
        ephemeralButton.setText(value);
        ephemeralButton.setTypeface(TypefaceUtils.getTypeface(getContext().getString(R.string.wire__typeface__regular)));
        ephemeralButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, getContext().getResources().getDimensionPixelSize(R.dimen.wire__text_size__small));
    } else {
        ephemeralButton.setBackground(null);
        ephemeralButton.setTypeface(TypefaceUtils.getTypeface(TypefaceUtils.getGlyphsTypefaceName()));
        ephemeralButton.setText(R.string.glyph__hourglass);
        ephemeralButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, getContext().getResources().getDimensionPixelSize(R.dimen.wire__text_size__regular));
    }
}
Also used : EphemeralExpiration(com.waz.api.EphemeralExpiration)

Example 4 with EphemeralExpiration

use of com.waz.api.EphemeralExpiration in project wire-android by wireapp.

the class ConversationFragment method onExtendedCursorClosed.

@Override
public void onExtendedCursorClosed(ExtendedCursorContainer.Type lastType) {
    cursorLayout.onExtendedCursorClosed();
    hideSendButtonIfNeeded();
    if (lastType == ExtendedCursorContainer.Type.EPHEMERAL) {
        EphemeralExpiration expiration = getStoreFactory().getConversationStore().getCurrentConversation().getEphemeralExpiration();
        if (!expiration.equals(EphemeralExpiration.NONE)) {
            getControllerFactory().getUserPreferencesController().setLastEphemeralValue(expiration.milliseconds);
        }
    }
    getControllerFactory().getGlobalLayoutController().resetScreenAwakeState();
}
Also used : EphemeralExpiration(com.waz.api.EphemeralExpiration)

Example 5 with EphemeralExpiration

use of com.waz.api.EphemeralExpiration in project wire-android by wireapp.

the class ConversationFragment method onEphemeralButtonDoubleClicked.

@Override
public void onEphemeralButtonDoubleClicked(EphemeralExpiration currentEphemeralExpiration) {
    EphemeralExpiration lastExpiraton = EphemeralExpiration.getForMillis(getControllerFactory().getUserPreferencesController().getLastEphemeralValue());
    if (lastExpiraton.equals(EphemeralExpiration.NONE)) {
        return;
    }
    if (currentEphemeralExpiration.equals(EphemeralExpiration.NONE)) {
        onEphemeralExpirationSelected(lastExpiraton, true);
        IConversation conversation = getStoreFactory().getConversationStore().getCurrentConversation();
        ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.ephemeral(conversation, true));
    } else {
        onEphemeralExpirationSelected(EphemeralExpiration.NONE, true);
    }
}
Also used : GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) EphemeralExpiration(com.waz.api.EphemeralExpiration) IConversation(com.waz.api.IConversation)

Aggregations

EphemeralExpiration (com.waz.api.EphemeralExpiration)5 IConversation (com.waz.api.IConversation)2 Intent (android.content.Intent)1 Handler (android.os.Handler)1 ContextThemeWrapper (android.support.v7.view.ContextThemeWrapper)1 View (android.view.View)1 NumberPicker (android.widget.NumberPicker)1 ConversationsList (com.waz.api.ConversationsList)1 SharingController (com.waz.zclient.controllers.SharingController)1 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExceptionHandler (net.hockeyapp.android.ExceptionHandler)1