Search in sources :

Example 36 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project apps-android-commons by commons-app.

the class MediaDetailPagerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_media_detail_pager, container, false);
    ButterKnife.bind(this, view);
    pager.addOnPageChangeListener(this);
    adapter = new MediaDetailAdapter(getChildFragmentManager());
    ((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (getActivity() != null) {
        final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }
    pager.setAdapter(adapter);
    if (savedInstanceState != null) {
        final int pageNumber = savedInstanceState.getInt("current-page");
        pager.setCurrentItem(pageNumber, false);
        getActivity().invalidateOptionsMenu();
    }
    adapter.notifyDataSetChanged();
    if (getActivity() instanceof MainActivity) {
        ((MainActivity) getActivity()).hideTabs();
    }
    return view;
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) MainActivity(fr.free.nrw.commons.contributions.MainActivity) BindView(butterknife.BindView) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) SuppressLint(android.annotation.SuppressLint)

Example 37 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project MiMangaNu by raulhaag.

the class AppUpdateUtil method generateUpdateDialog.

@SuppressLint("StaticFieldLeak")
public static void generateUpdateDialog(final Context context) {
    if (NetworkUtilsAndReceiver.isConnectedNonDestructive(context))
        new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... voids) {
                try {
                    final Triple<String, String, String> info = getCurrentVersion();
                    ((AppCompatActivity) context).runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                            View rootView = inflater.inflate(R.layout.dialog_update, null);
                            final TextView desc = rootView.findViewById(R.id.descrption);
                            final ProgressBar progressBar = rootView.findViewById(R.id.progress);
                            final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
                            desc.setText(info.getThird());
                            dialogBuilder.setTitle(context.getString(R.string.new_version) + " " + info.getFirst());
                            dialogBuilder.setView(rootView);
                            dialogBuilder.setPositiveButton(context.getString(R.string.download), null);
                            dialogBuilder.setNegativeButton(context.getString(R.string.close), null);
                            AlertDialog dialog = dialogBuilder.create();
                            dialog.setOnShowListener(new DialogInterface.OnShowListener() {

                                @Override
                                public void onShow(final DialogInterface dialog) {
                                    final Button cancel = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
                                    cancel.setOnClickListener(new View.OnClickListener() {

                                        @Override
                                        public void onClick(View view) {
                                            dialog.dismiss();
                                            if (context instanceof MessageActivity) {
                                                ((MessageActivity) context).onBackPressed();
                                            }
                                        }
                                    });
                                    final Button accept = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
                                    accept.setOnClickListener(new View.OnClickListener() {

                                        @Override
                                        public void onClick(View view) {
                                            try {
                                                AppCompatActivity activity = (AppCompatActivity) context;
                                                activity.runOnUiThread(new Runnable() {

                                                    @Override
                                                    public void run() {
                                                        ((AlertDialog) dialog).setCancelable(false);
                                                        String init_download_text = context.getString(R.string.downloading) + " 0%";
                                                        desc.setText(init_download_text);
                                                        accept.setEnabled(false);
                                                        cancel.setEnabled(false);
                                                        progressBar.setVisibility(View.VISIBLE);
                                                        progressBar.setIndeterminate(true);
                                                    }
                                                });
                                                download(activity, info.getSecond(), progressBar, desc, dialog);
                                            } catch (Exception e) {
                                                Log.e(TAG, "Error while starting download");
                                                e.printStackTrace();
                                            }
                                        }
                                    });
                                }
                            });
                            dialog.show();
                        }
                    });
                } catch (Exception e) {
                    Log.e(TAG, "Error while searching for new update");
                    e.printStackTrace();
                }
                return null;
            }
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) AsyncTask(android.os.AsyncTask) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) View(android.view.View) TextView(android.widget.TextView) Button(android.widget.Button) MessageActivity(ar.rulosoft.mimanganu.MessageActivity) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar) SuppressLint(android.annotation.SuppressLint)

Example 38 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project Signal-Android by WhisperSystems.

the class BaseKbsPinFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    initializeViews(view);
    viewModel = initializeViewModel();
    viewModel.getUserEntry().observe(getViewLifecycleOwner(), kbsPin -> {
        boolean isEntryValid = kbsPin.length() >= KbsConstants.MINIMUM_PIN_LENGTH;
        confirm.setEnabled(isEntryValid);
        confirm.setAlpha(isEntryValid ? 1f : 0.5f);
    });
    viewModel.getKeyboard().observe(getViewLifecycleOwner(), keyboardType -> {
        updateKeyboard(keyboardType);
        keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
    });
    description.setOnLinkClickListener(v -> {
        CommunicationActions.openBrowserLink(requireContext(), getString(R.string.BaseKbsPinFragment__learn_more_url));
    });
    Toolbar toolbar = view.findViewById(R.id.kbs_pin_toolbar);
    ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
    ((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(null);
    initializeListeners();
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) Toolbar(androidx.appcompat.widget.Toolbar)

Example 39 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project xabber-android by redsolution.

the class ContextMenuHelper method setContactContextMenuActions.

private static void setContactContextMenuActions(final Activity activity, final ContactListPresenter presenter, ContextMenu menu, final AccountJid account, final UserJid user) {
    menu.findItem(R.id.action_edit_conference).setIntent(ConferenceAddActivity.createIntent(activity, account, user.getBareUserJid()));
    menu.findItem(R.id.action_delete_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            MUCDeleteDialogFragment.newInstance(account, user).show(activity.getFragmentManager(), "MUC_DELETE");
            return true;
        }
    });
    menu.findItem(R.id.action_join_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            MUCManager.getInstance().joinRoom(account, user.getJid().asEntityBareJidIfPossible(), true);
            return true;
        }
    });
    menu.findItem(R.id.action_leave_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            MUCManager.getInstance().leaveRoom(account, user.getJid().asEntityBareJidIfPossible());
            MessageManager.getInstance().closeChat(account, user);
            NotificationManager.getInstance().removeMessageNotification(account, user);
            presenter.updateContactList();
            return true;
        }
    });
    menu.findItem(R.id.action_edit_contact_groups).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            activity.startActivity(GroupEditActivity.createIntent(activity, account, user));
            return true;
        }
    });
    menu.findItem(R.id.action_delete_contact).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            ContactDeleteDialogFragment.newInstance(account, user).show(activity.getFragmentManager(), "CONTACT_DELETE");
            return true;
        }
    });
    menu.findItem(R.id.action_block_contact).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            BlockContactDialog.newInstance(account, user).show(activity.getFragmentManager(), BlockContactDialog.class.getName());
            return true;
        }
    });
    menu.findItem(R.id.action_accept_subscription).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            try {
                PresenceManager.getInstance().acceptSubscription(account, user);
            } catch (NetworkException e) {
                Application.getInstance().onError(e);
            }
            activity.startActivity(GroupEditActivity.createIntent(activity, account, user));
            return true;
        }
    });
    menu.findItem(R.id.action_discard_subscription).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            try {
                PresenceManager.getInstance().discardSubscription(account, user);
            } catch (NetworkException e) {
                Application.getInstance().onError(e);
            }
            return true;
        }
    });
    menu.findItem(R.id.action_mute_chat).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            AbstractChat chat = MessageManager.getInstance().getChat(account, user);
            showSnoozeDialog((AppCompatActivity) activity, chat, presenter);
            return true;
        }
    });
    menu.findItem(R.id.action_unmute_chat).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            AbstractChat chat = MessageManager.getInstance().getChat(account, user);
            if (chat != null)
                chat.setNotificationStateOrDefault(new NotificationState(NotificationState.NotificationMode.enabled, 0), true);
            presenter.updateContactList();
            return true;
        }
    });
    menu.findItem(R.id.action_configure_notifications).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            activity.startActivity(CustomNotifySettings.createIntent(activity, account, user));
            return true;
        }
    });
}
Also used : AbstractChat(com.xabber.android.data.message.AbstractChat) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) MenuItem(android.view.MenuItem) NetworkException(com.xabber.android.data.NetworkException) NotificationState(com.xabber.android.data.message.NotificationState)

Example 40 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project Signal-Android by WhisperSystems.

the class MediaOverviewPageFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    voiceNoteMediaController = new VoiceNoteMediaController((AppCompatActivity) requireActivity());
}
Also used : VoiceNoteMediaController(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController) AppCompatActivity(androidx.appcompat.app.AppCompatActivity)

Aggregations

AppCompatActivity (androidx.appcompat.app.AppCompatActivity)76 ActionBar (androidx.appcompat.app.ActionBar)23 View (android.view.View)20 Toolbar (androidx.appcompat.widget.Toolbar)19 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)10 TextView (android.widget.TextView)7 RecyclerView (androidx.recyclerview.widget.RecyclerView)7 Intent (android.content.Intent)6 Fragment (androidx.fragment.app.Fragment)6 BindView (butterknife.BindView)6 Activity (android.app.Activity)5 LayoutInflater (android.view.LayoutInflater)5 Bundle (android.os.Bundle)4 ImageView (android.widget.ImageView)4 ScrollView (android.widget.ScrollView)4 List (java.util.List)4 Nullable (androidx.annotation.Nullable)3 SuppressLint (android.annotation.SuppressLint)2 TargetApi (android.annotation.TargetApi)2 Dialog (android.app.Dialog)2