Search in sources :

Example 56 with Toolbar

use of androidx.appcompat.widget.Toolbar 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 57 with Toolbar

use of androidx.appcompat.widget.Toolbar in project Signal-Android by WhisperSystems.

the class ChatWallpaperSelectionFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = view.findViewById(R.id.toolbar);
    View chooseFromPhotos = view.findViewById(R.id.chat_wallpaper_choose_from_photos);
    RecyclerView recyclerView = view.findViewById(R.id.chat_wallpaper_recycler);
    chooseFromPhotos.setOnClickListener(unused -> {
        askForPermissionIfNeededAndLaunchPhotoSelection();
    });
    toolbar.setTitle(R.string.preferences__chat_color_and_wallpaper);
    toolbar.setNavigationOnClickListener(nav -> Navigation.findNavController(nav).popBackStack());
    @SuppressWarnings("CodeBlock2Expr") ChatWallpaperSelectionAdapter adapter = new ChatWallpaperSelectionAdapter(chatWallpaper -> {
        startActivityForResult(ChatWallpaperPreviewActivity.create(requireActivity(), chatWallpaper, viewModel.getRecipientId(), viewModel.getDimInDarkTheme().getValue()), CHOOSE_WALLPAPER);
    });
    recyclerView.setAdapter(adapter);
    viewModel = ViewModelProviders.of(requireActivity()).get(ChatWallpaperViewModel.class);
    viewModel.getWallpapers().observe(getViewLifecycleOwner(), adapter::submitList);
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 58 with Toolbar

use of androidx.appcompat.widget.Toolbar in project Signal-Android by WhisperSystems.

the class ConversationListFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    constraintLayout = view.findViewById(R.id.constraint_layout);
    list = view.findViewById(R.id.list);
    fab = view.findViewById(R.id.fab);
    cameraFab = view.findViewById(R.id.camera_fab);
    searchEmptyState = view.findViewById(R.id.search_no_results);
    searchAction = view.findViewById(R.id.search_action);
    toolbarShadow = view.findViewById(R.id.conversation_list_toolbar_shadow);
    notificationProfileStatus = view.findViewById(R.id.conversation_list_notification_profile_status);
    proxyStatus = view.findViewById(R.id.conversation_list_proxy_status);
    unreadPaymentsDot = view.findViewById(R.id.unread_payments_indicator);
    bottomActionBar = view.findViewById(R.id.conversation_list_bottom_action_bar);
    reminderView = new Stub<>(view.findViewById(R.id.reminder));
    emptyState = new Stub<>(view.findViewById(R.id.empty_state));
    searchToolbar = new Stub<>(view.findViewById(R.id.search_toolbar));
    megaphoneContainer = new Stub<>(view.findViewById(R.id.megaphone_container));
    paymentNotificationView = new Stub<>(view.findViewById(R.id.payments_notification));
    voiceNotePlayerViewStub = new Stub<>(view.findViewById(R.id.voice_note_player));
    Toolbar toolbar = getToolbar(view);
    toolbar.setVisibility(View.VISIBLE);
    ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
    notificationProfileStatus.setOnClickListener(v -> handleNotificationProfile());
    proxyStatus.setOnClickListener(v -> onProxyStatusClicked());
    fab.show();
    cameraFab.show();
    archiveDecoration = new ConversationListArchiveItemDecoration(new ColorDrawable(getResources().getColor(R.color.conversation_list_archive_background_end)));
    itemAnimator = new ConversationListItemAnimator();
    list.setLayoutManager(new LinearLayoutManager(requireActivity()));
    list.setItemAnimator(itemAnimator);
    list.addOnScrollListener(new ScrollListener());
    list.addItemDecoration(archiveDecoration);
    snapToTopDataObserver = new SnapToTopDataObserver(list);
    new ItemTouchHelper(new ArchiveListenerCallback(getResources().getColor(R.color.conversation_list_archive_background_start), getResources().getColor(R.color.conversation_list_archive_background_end))).attachToRecyclerView(list);
    fab.setOnClickListener(v -> startActivity(new Intent(getActivity(), NewConversationActivity.class)));
    cameraFab.setOnClickListener(v -> {
        Permissions.with(this).request(Manifest.permission.CAMERA).ifNecessary().withRationaleDialog(getString(R.string.ConversationActivity_to_capture_photos_and_video_allow_signal_access_to_the_camera), R.drawable.ic_camera_24).withPermanentDenialDialog(getString(R.string.ConversationActivity_signal_needs_the_camera_permission_to_take_photos_or_video)).onAllGranted(() -> startActivity(MediaSelectionActivity.camera(requireContext()))).onAnyDenied(() -> Toast.makeText(requireContext(), R.string.ConversationActivity_signal_needs_camera_permissions_to_take_photos_or_video, Toast.LENGTH_LONG).show()).execute();
    });
    initializeViewModel();
    initializeListAdapters();
    initializeTypingObserver();
    initializeSearchListener();
    initializeVoiceNotePlayer();
    RatingManager.showRatingDialogIfNecessary(requireContext());
    TooltipCompat.setTooltipText(searchAction, getText(R.string.SearchToolbar_search_for_conversations_contacts_and_messages));
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) ColorDrawable(android.graphics.drawable.ColorDrawable) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) SnapToTopDataObserver(org.thoughtcrime.securesms.util.SnapToTopDataObserver) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) SearchToolbar(org.thoughtcrime.securesms.components.SearchToolbar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 59 with Toolbar

use of androidx.appcompat.widget.Toolbar in project xabber-android by redsolution.

the class AccountActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    account = getAccount(intent);
    if (account == null) {
        LogManager.i(LOG_TAG, "Account is null, finishing!");
        finish();
        return;
    }
    accountItem = AccountManager.getInstance().getAccount(account);
    if (accountItem == null) {
        Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
        finish();
        return;
    }
    if (ACTION_CONNECTION_SETTINGS.equals(intent.getAction())) {
        isConnectionSettingsAction = true;
        startAccountSettingsActivity();
        setIntent(null);
    }
    setContentView(R.layout.activity_account);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NavUtils.navigateUpFromSameTask(AccountActivity.this);
        }
    });
    toolbar.setTitle(R.string.contact_account);
    toolbar.inflateMenu(R.menu.toolbar_account);
    MenuItem item = toolbar.getMenu().findItem(R.id.action_account_switch);
    switchCompat = (SwitchCompat) item.getActionView().findViewById(R.id.account_switch_view);
    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            AccountManager.getInstance().setEnabled(accountItem.getAccount(), isChecked);
        }
    });
    barPainter = new BarPainter(this, toolbar);
    UserJid fakeAccountUser;
    try {
        fakeAccountUser = UserJid.from(account.getFullJid().asBareJid());
    } catch (UserJid.UserJidCreateException e) {
        throw new IllegalStateException();
    }
    bestContact = RosterManager.getInstance().getBestContact(account, fakeAccountUser);
    contactTitleView = findViewById(R.id.contact_title_expanded);
    statusIcon = findViewById(R.id.ivStatus);
    statusText = (TextView) findViewById(R.id.status_text);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.account_options_recycler_view);
    accountOptionsAdapter = new AccountOptionsAdapter(AccountOption.getValues(), this, accountItem);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(accountOptionsAdapter);
    recyclerView.setNestedScrollingEnabled(false);
    Fragment fragmentById = getFragmentManager().findFragmentById(R.id.account_fragment_container);
    if (fragmentById == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.account_fragment_container, ContactVcardViewerFragment.newInstance(account)).commit();
    }
}
Also used : UserJid(com.xabber.android.data.entity.UserJid) Intent(android.content.Intent) MenuItem(android.view.MenuItem) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ContactVcardViewerFragment(com.xabber.android.ui.fragment.ContactVcardViewerFragment) Fragment(android.app.Fragment) BarPainter(com.xabber.android.ui.color.BarPainter) AccountOptionsAdapter(com.xabber.android.ui.adapter.accountoptions.AccountOptionsAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) CompoundButton(android.widget.CompoundButton) Toolbar(androidx.appcompat.widget.Toolbar)

Example 60 with Toolbar

use of androidx.appcompat.widget.Toolbar in project xabber-android by redsolution.

the class AccountAddActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isFinishing())
        return;
    setContentView(R.layout.activity_with_toolbar_and_container);
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction().add(R.id.fragment_container, AccountAddFragment.newInstance()).commit();
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    toolbar.inflateMenu(R.menu.toolbar_add_account);
    toolbar.getMenu().findItem(R.id.action_add_account).setIcon(null);
    toolbar.setOnMenuItemClickListener(this);
    BarPainter barPainter = new BarPainter(this, toolbar);
    barPainter.setDefaultColor();
}
Also used : View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) BarPainter(com.xabber.android.ui.color.BarPainter)

Aggregations

Toolbar (androidx.appcompat.widget.Toolbar)284 View (android.view.View)116 TextView (android.widget.TextView)58 RecyclerView (androidx.recyclerview.widget.RecyclerView)44 Bundle (android.os.Bundle)43 Intent (android.content.Intent)39 NonNull (androidx.annotation.NonNull)36 Fragment (androidx.fragment.app.Fragment)33 ActionBar (androidx.appcompat.app.ActionBar)29 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)29 Nullable (androidx.annotation.Nullable)28 BarPainter (com.xabber.android.ui.color.BarPainter)26 R (org.thoughtcrime.securesms.R)26 Context (android.content.Context)25 ViewGroup (android.view.ViewGroup)25 EditText (android.widget.EditText)23 MenuItem (android.view.MenuItem)21 ImageView (android.widget.ImageView)20 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)20 Navigation (androidx.navigation.Navigation)20