Search in sources :

Example 1 with FullscreenHelper

use of org.thoughtcrime.securesms.util.FullscreenHelper in project Signal-Android by WhisperSystems.

the class MediaPreviewActivity method onCreate.

@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle bundle, boolean ready) {
    this.setTheme(R.style.TextSecure_MediaPreview);
    setContentView(R.layout.media_preview_activity);
    setSupportActionBar(findViewById(R.id.toolbar));
    viewModel = ViewModelProviders.of(this).get(MediaPreviewViewModel.class);
    fullscreenHelper = new FullscreenHelper(this);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    initializeViews();
    initializeResources();
    initializeObservers();
}
Also used : MediaPreviewViewModel(org.thoughtcrime.securesms.mediapreview.MediaPreviewViewModel) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper)

Example 2 with FullscreenHelper

use of org.thoughtcrime.securesms.util.FullscreenHelper in project Signal-Android by WhisperSystems.

the class WebRtcCallActivity method onCreate.

@SuppressLint("SourceLockedOrientationActivity")
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate()");
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    super.onCreate(savedInstanceState);
    boolean isLandscapeEnabled = getResources().getConfiguration().smallestScreenWidthDp >= 480;
    if (!isLandscapeEnabled) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.webrtc_call_activity);
    fullscreenHelper = new FullscreenHelper(this);
    setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
    initializeResources();
    initializeViewModel(isLandscapeEnabled);
    processIntent(getIntent());
    enableVideoIfAvailable = getIntent().getBooleanExtra(EXTRA_ENABLE_VIDEO_IF_AVAILABLE, false);
    getIntent().removeExtra(EXTRA_ENABLE_VIDEO_IF_AVAILABLE);
    windowManager = new androidx.window.WindowManager(this);
    windowLayoutInfoConsumer = new WindowLayoutInfoConsumer();
    windowManager.registerLayoutChangeCallback(SignalExecutors.BOUNDED, windowLayoutInfoConsumer);
    requestNewSizesThrottle = new ThrottledDebouncer(TimeUnit.SECONDS.toMillis(1));
}
Also used : ThrottledDebouncer(org.thoughtcrime.securesms.util.ThrottledDebouncer) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper) SuppressLint(android.annotation.SuppressLint)

Example 3 with FullscreenHelper

use of org.thoughtcrime.securesms.util.FullscreenHelper in project Signal-Android by WhisperSystems.

the class ChatWallpaperPreviewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
    dynamicTheme.onCreate(this);
    setContentView(R.layout.chat_wallpaper_preview_activity);
    adapter = new ChatWallpaperPreviewAdapter();
    colorizerView = findViewById(R.id.colorizer);
    bubble2 = findViewById(R.id.preview_bubble_2);
    viewPager = findViewById(R.id.preview_pager);
    View submit = findViewById(R.id.preview_set_wallpaper);
    ChatWallpaperRepository repository = new ChatWallpaperRepository();
    ChatWallpaper selected = getIntent().getParcelableExtra(EXTRA_CHAT_WALLPAPER);
    boolean dim = getIntent().getBooleanExtra(EXTRA_DIM_IN_DARK_MODE, false);
    Toolbar toolbar = findViewById(R.id.toolbar);
    TextView bubble2Text = findViewById(R.id.preview_bubble_2_text);
    toolbar.setNavigationOnClickListener(unused -> {
        finish();
    });
    viewPager.setAdapter(adapter);
    adapter.submitList(Collections.singletonList(new ChatWallpaperSelectionMappingModel(selected)));
    repository.getAllWallpaper(wallpapers -> adapter.submitList(Stream.of(wallpapers).map(wallpaper -> ChatWallpaperFactory.updateWithDimming(wallpaper, dim ? ChatWallpaper.FIXED_DIM_LEVEL_FOR_DARK_THEME : 0f)).<MappingModel<?>>map(ChatWallpaperSelectionMappingModel::new).toList()));
    submit.setOnClickListener(unused -> {
        ChatWallpaperSelectionMappingModel model = (ChatWallpaperSelectionMappingModel) adapter.getCurrentList().get(viewPager.getCurrentItem());
        setResult(RESULT_OK, new Intent().putExtra(EXTRA_CHAT_WALLPAPER, model.getWallpaper()));
        finish();
    });
    RecipientId recipientId = getIntent().getParcelableExtra(EXTRA_RECIPIENT_ID);
    final ChatColors chatColors;
    if (recipientId != null && Recipient.live(recipientId).get().hasOwnChatColors()) {
        Recipient recipient = Recipient.live(recipientId).get();
        bubble2Text.setText(getString(R.string.ChatWallpaperPreviewActivity__set_wallpaper_for_s, recipient.getDisplayName(this)));
        chatColors = recipient.getChatColors();
        bubble2.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
            updateChatColors(chatColors);
        });
    } else if (SignalStore.chatColorsValues().hasChatColors()) {
        chatColors = Objects.requireNonNull(SignalStore.chatColorsValues().getChatColors());
        bubble2.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
            updateChatColors(chatColors);
        });
    } else {
        onPageChanged = new OnPageChanged();
        viewPager.registerOnPageChangeCallback(onPageChanged);
        bubble2.addOnLayoutChangeListener(new UpdateChatColorsOnNextLayoutChange(selected.getAutoChatColors()));
    }
    new FullscreenHelper(this).showSystemUI();
    WindowUtil.setLightStatusBarFromTheme(this);
    WindowUtil.setLightNavigationBarFromTheme(this);
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Context(android.content.Context) Bundle(android.os.Bundle) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) ViewPager2(androidx.viewpager2.widget.ViewPager2) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) ChatColors(org.thoughtcrime.securesms.conversation.colors.ChatColors) Drawable(android.graphics.drawable.Drawable) R(org.thoughtcrime.securesms.R) DynamicTheme(org.thoughtcrime.securesms.util.DynamicTheme) ColorizerView(org.thoughtcrime.securesms.conversation.colors.ColorizerView) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) View(android.view.View) Recipient(org.thoughtcrime.securesms.recipients.Recipient) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper) MappingModel(org.thoughtcrime.securesms.util.adapter.mapping.MappingModel) WindowUtil(org.thoughtcrime.securesms.util.WindowUtil) Objects(java.util.Objects) TextView(android.widget.TextView) PassphraseRequiredActivity(org.thoughtcrime.securesms.PassphraseRequiredActivity) DynamicNoActionBarTheme(org.thoughtcrime.securesms.util.DynamicNoActionBarTheme) Toolbar(androidx.appcompat.widget.Toolbar) Projection(org.thoughtcrime.securesms.util.Projection) Collections(java.util.Collections) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) ChatColors(org.thoughtcrime.securesms.conversation.colors.ChatColors) Intent(android.content.Intent) Recipient(org.thoughtcrime.securesms.recipients.Recipient) ColorizerView(org.thoughtcrime.securesms.conversation.colors.ColorizerView) View(android.view.View) TextView(android.widget.TextView) TextView(android.widget.TextView) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper) Toolbar(androidx.appcompat.widget.Toolbar)

Example 4 with FullscreenHelper

use of org.thoughtcrime.securesms.util.FullscreenHelper in project Signal-Android by WhisperSystems.

the class ConversationParentFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    if (requireActivity() instanceof Callback) {
        callback = (Callback) requireActivity();
    } else if (getParentFragment() instanceof Callback) {
        callback = (Callback) getParentFragment();
    } else {
        throw new ClassCastException("Cannot cast activity or parent fragment into a Callback object");
    }
    // TODO [alex] LargeScreenSupport -- This check will no longer be valid / necessary
    if (ConversationIntents.isInvalid(requireActivity().getIntent())) {
        Log.w(TAG, "[onCreate] Missing recipientId!");
        // TODO [greyson] Navigation
        startActivity(MainActivity.clearTop(requireContext()));
        requireActivity().finish();
        return;
    }
    isDefaultSms = Util.isDefaultSmsProvider(requireContext());
    voiceNoteMediaController = new VoiceNoteMediaController(requireActivity());
    voiceRecorderWakeLock = new VoiceRecorderWakeLock(requireActivity());
    // TODO [alex] LargeScreenSupport -- Should be removed once we move to multi-pane layout.
    new FullscreenHelper(requireActivity()).showSystemUI();
    // TODO [alex] LargeScreenSupport -- This will need to be built from requireArguments()
    ConversationIntents.Args args = ConversationIntents.Args.from(requireActivity().getIntent());
    isSearchRequested = args.isWithSearchOpen();
    reportShortcutLaunch(args.getRecipientId());
    requireActivity().getWindow().getDecorView().setBackgroundResource(R.color.signal_background_primary);
    fragment = (ConversationFragment) getChildFragmentManager().findFragmentById(R.id.fragment_content);
    if (fragment == null) {
        fragment = new ConversationFragment();
        getChildFragmentManager().beginTransaction().replace(R.id.fragment_content, fragment).commitNow();
    }
    final boolean typingIndicatorsEnabled = TextSecurePreferences.isTypingIndicatorsEnabled(requireContext());
    initializeReceivers();
    initializeViews(view);
    updateWallpaper(args.getWallpaper());
    initializeResources(args);
    initializeLinkPreviewObserver();
    initializeSearchObserver();
    initializeStickerObserver();
    initializeViewModel(args);
    initializeGroupViewModel();
    initializeMentionsViewModel();
    initializeGroupCallViewModel();
    initializeDraftViewModel();
    initializeEnabledCheck();
    initializePendingRequestsBanner();
    initializeGroupV1MigrationsBanners();
    initializeSecurity(recipient.get().isRegistered(), isDefaultSms).addListener(new AssertedSuccessListener<Boolean>() {

        @Override
        public void onSuccess(Boolean result) {
            if (getActivity() == null) {
                Log.w(TAG, "Activity is not attached. Not proceeding with initialization.");
                return;
            }
            if (requireActivity().isFinishing()) {
                Log.w(TAG, "Activity is finishing. Not proceeding with initialization.");
                return;
            }
            initializeProfiles();
            initializeGv1Migration();
            initializeDraft(args).addListener(new AssertedSuccessListener<Boolean>() {

                @Override
                public void onSuccess(Boolean loadedDraft) {
                    if (loadedDraft != null && loadedDraft) {
                        Log.i(TAG, "Finished loading draft");
                        ThreadUtil.runOnMain(() -> {
                            if (fragment != null && fragment.isResumed()) {
                                fragment.moveToLastSeen();
                            } else {
                                Log.w(TAG, "Wanted to move to the last seen position, but the fragment was in an invalid state");
                            }
                        });
                    }
                    if (typingIndicatorsEnabled) {
                        composeText.addTextChangedListener(typingTextWatcher);
                    }
                    composeText.setSelection(composeText.length(), composeText.length());
                    screenInitialized = true;
                }
            });
        }
    });
    initializeInsightObserver();
    initializeActionBar();
    requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {

        @Override
        public void handleOnBackPressed() {
            onBackPressed();
        }
    });
}
Also used : VoiceNoteMediaController(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController) AssertedSuccessListener(org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) AsynchronousCallback(org.thoughtcrime.securesms.util.AsynchronousCallback) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper)

Example 5 with FullscreenHelper

use of org.thoughtcrime.securesms.util.FullscreenHelper in project Signal-Android by WhisperSystems.

the class AvatarPreviewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
    super.onCreate(savedInstanceState, ready);
    setTheme(R.style.TextSecure_MediaPreview);
    setContentView(R.layout.contact_photo_preview_activity);
    if (Build.VERSION.SDK_INT >= 21) {
        postponeEnterTransition();
        TransitionInflater inflater = TransitionInflater.from(this);
        getWindow().setSharedElementEnterTransition(inflater.inflateTransition(R.transition.full_screen_avatar_image_enter_transition_set));
        getWindow().setSharedElementReturnTransition(inflater.inflateTransition(R.transition.full_screen_avatar_image_return_transition_set));
    }
    Toolbar toolbar = findViewById(R.id.toolbar);
    EmojiTextView title = findViewById(R.id.title);
    ImageView avatar = findViewById(R.id.avatar);
    setSupportActionBar(toolbar);
    requireSupportActionBar().setDisplayHomeAsUpEnabled(true);
    requireSupportActionBar().setDisplayShowTitleEnabled(false);
    Context context = getApplicationContext();
    RecipientId recipientId = RecipientId.from(getIntent().getStringExtra(RECIPIENT_ID_EXTRA));
    Recipient.live(recipientId).observe(this, recipient -> {
        ContactPhoto contactPhoto = recipient.isSelf() ? new ProfileContactPhoto(recipient, recipient.getProfileAvatar()) : recipient.getContactPhoto();
        FallbackContactPhoto fallbackPhoto = recipient.isSelf() ? new ResourceContactPhoto(R.drawable.ic_profile_outline_40, R.drawable.ic_profile_outline_20, R.drawable.ic_person_large) : recipient.getFallbackContactPhoto();
        Resources resources = this.getResources();
        GlideApp.with(this).asBitmap().load(contactPhoto).fallback(fallbackPhoto.asCallCard(this)).error(fallbackPhoto.asCallCard(this)).diskCacheStrategy(DiskCacheStrategy.ALL).addListener(new RequestListener<Bitmap>() {

            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
                Log.w(TAG, "Unable to load avatar, or avatar removed, closing");
                finish();
                return false;
            }

            @Override
            public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
                return false;
            }
        }).into(new CustomTarget<Bitmap>() {

            @Override
            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                avatar.setImageDrawable(RoundedBitmapDrawableFactory.create(resources, resource));
                if (Build.VERSION.SDK_INT >= 21) {
                    startPostponedEnterTransition();
                }
            }

            @Override
            public void onLoadCleared(@Nullable Drawable placeholder) {
            }
        });
        title.setText(recipient.getDisplayName(context));
    });
    FullscreenHelper fullscreenHelper = new FullscreenHelper(this);
    findViewById(android.R.id.content).setOnClickListener(v -> fullscreenHelper.toggleUiVisibility());
    fullscreenHelper.configureToolbarSpacer(findViewById(R.id.toolbar_cutout_spacer));
    fullscreenHelper.showAndHideWithSystemUI(getWindow(), findViewById(R.id.toolbar_layout));
}
Also used : Context(android.content.Context) ProfileContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) TransitionInflater(android.transition.TransitionInflater) ContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ContactPhoto) ProfileContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto) FallbackContactPhoto(org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) DataSource(com.bumptech.glide.load.DataSource) FallbackContactPhoto(org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto) CustomTarget(com.bumptech.glide.request.target.CustomTarget) Target(com.bumptech.glide.request.target.Target) Bitmap(android.graphics.Bitmap) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) ImageView(android.widget.ImageView) Resources(android.content.res.Resources) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(androidx.annotation.Nullable) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

FullscreenHelper (org.thoughtcrime.securesms.util.FullscreenHelper)5 Context (android.content.Context)2 Drawable (android.graphics.drawable.Drawable)2 Toolbar (androidx.appcompat.widget.Toolbar)2 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Bundle (android.os.Bundle)1 TransitionInflater (android.transition.TransitionInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 OnBackPressedCallback (androidx.activity.OnBackPressedCallback)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 ViewPager2 (androidx.viewpager2.widget.ViewPager2)1 Stream (com.annimon.stream.Stream)1 DataSource (com.bumptech.glide.load.DataSource)1