use of androidx.appcompat.app.AppCompatActivity in project Slide by ccrama.
the class InboxAdapter method doInboxReply.
private void doInboxReply(final Message replyTo) {
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
final View dialoglayout = inflater.inflate(R.layout.edit_comment, null);
final EditText e = dialoglayout.findViewById(R.id.entry);
DoEditorActions.doActions(e, dialoglayout, ((AppCompatActivity) mContext).getSupportFragmentManager(), (Activity) mContext, replyTo.getBody(), null);
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext).setView(dialoglayout);
final Dialog d = builder.create();
d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
d.show();
dialoglayout.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d.dismiss();
}
});
dialoglayout.findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String text = e.getText().toString();
new AsyncReplyTask(replyTo, text).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
d.dismiss();
}
});
}
use of androidx.appcompat.app.AppCompatActivity in project fdroidclient by f-droid.
the class PreferencesFragment method updateSummary.
private void updateSummary(String key, boolean changing) {
switch(key) {
case Preferences.PREF_UPDATE_INTERVAL:
updateIntervalSeekBar.setMax(Preferences.UPDATE_INTERVAL_VALUES.length - 1);
int seekBarPosition = updateIntervalSeekBar.getValue();
updateIntervalSeekBar.setSummary(UPDATE_INTERVAL_NAMES[seekBarPosition]);
break;
case Preferences.PREF_OVER_WIFI:
overWifiSeekBar.setMax(Preferences.OVER_NETWORK_ALWAYS);
setNetworkSeekBarSummary(overWifiSeekBar);
enableUpdateInverval();
break;
case Preferences.PREF_OVER_DATA:
overDataSeekBar.setMax(Preferences.OVER_NETWORK_ALWAYS);
setNetworkSeekBarSummary(overDataSeekBar);
enableUpdateInverval();
break;
case Preferences.PREF_UPDATE_NOTIFICATION_ENABLED:
checkSummary(key, R.string.notify_on);
break;
case Preferences.PREF_THEME:
entrySummary(key);
if (changing) {
AppCompatActivity activity = (AppCompatActivity) getActivity();
FDroidApp fdroidApp = (FDroidApp) activity.getApplication();
fdroidApp.applyTheme();
}
break;
case Preferences.PREF_USE_PURE_BLACK_DARK_THEME:
if (changing) {
AppCompatActivity activity = (AppCompatActivity) getActivity();
// Theme will be applied upon activity creation
if (activity != null) {
ActivityCompat.recreate(activity);
}
}
break;
case Preferences.PREF_SHOW_INCOMPAT_VERSIONS:
checkSummary(key, R.string.show_incompat_versions_on);
break;
case Preferences.PREF_SHOW_ANTI_FEATURES:
checkSummary(key, R.string.show_anti_feature_apps_on);
break;
case Preferences.PREF_FORCE_TOUCH_APPS:
checkSummary(key, R.string.force_touch_apps_on);
break;
case Preferences.PREF_LOCAL_REPO_NAME:
textSummary(key, R.string.local_repo_name_summary);
break;
case Preferences.PREF_LOCAL_REPO_HTTPS:
checkSummary(key, R.string.local_repo_https_on);
break;
case Preferences.PREF_LANGUAGE:
entrySummary(key);
if (changing) {
AppCompatActivity activity = (AppCompatActivity) getActivity();
Languages.setLanguage(activity);
RepoProvider.Helper.clearEtags(getActivity());
UpdateService.updateNow(getActivity());
Languages.forceChangeLanguage(activity);
}
break;
case Preferences.PREF_KEEP_CACHE_TIME:
entrySummary(key);
if (changing && currentKeepCacheTime != Preferences.get().getKeepCacheTime()) {
CleanCacheWorker.schedule(requireContext());
}
break;
case Preferences.PREF_EXPERT:
checkSummary(key, R.string.expert_on);
int expertPreferencesCount = 0;
boolean isExpertMode = Preferences.get().expertMode();
for (int i = 0; i < otherPrefGroup.getPreferenceCount(); i++) {
Preference pref = otherPrefGroup.getPreference(i);
if (TextUtils.equals(Preferences.PREF_EXPERT, pref.getDependency())) {
pref.setVisible(isExpertMode);
expertPreferencesCount++;
}
}
if (changing) {
RecyclerView recyclerView = getListView();
int preferencesCount = recyclerView.getAdapter().getItemCount();
if (!isExpertMode) {
expertPreferencesCount = 0;
}
topScroller.setTargetPosition(preferencesCount - expertPreferencesCount - 1);
recyclerView.getLayoutManager().startSmoothScroll(topScroller);
}
break;
case Preferences.PREF_PRIVILEGED_INSTALLER:
// We may have removed this preference if it is not suitable to show the user.
// So lets check it is here first.
final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER);
if (pref != null) {
checkSummary(key, R.string.system_installer_on);
}
break;
case Preferences.PREF_ENABLE_PROXY:
SwitchPreferenceCompat checkPref = (SwitchPreferenceCompat) findPreference(key);
checkPref.setSummary(R.string.enable_proxy_summary);
break;
case Preferences.PREF_PROXY_HOST:
EditTextPreference textPref = (EditTextPreference) findPreference(key);
String text = Preferences.get().getProxyHost();
if (TextUtils.isEmpty(text) || text.equals(Preferences.DEFAULT_PROXY_HOST)) {
textPref.setSummary(R.string.proxy_host_summary);
} else {
textPref.setSummary(text);
}
break;
case Preferences.PREF_PROXY_PORT:
EditTextPreference textPref2 = (EditTextPreference) findPreference(key);
int port = Preferences.get().getProxyPort();
if (port == Preferences.DEFAULT_PROXY_PORT) {
textPref2.setSummary(R.string.proxy_port_summary);
} else {
textPref2.setSummary(String.valueOf(port));
}
break;
case Preferences.PREF_KEEP_INSTALL_HISTORY:
if (keepInstallHistoryPref.isChecked()) {
InstallHistoryService.register(getActivity());
installHistoryPref.setVisible(true);
sendToFDroidMetricsPref.setEnabled(true);
} else {
InstallHistoryService.unregister(getActivity());
installHistoryPref.setVisible(false);
sendToFDroidMetricsPref.setEnabled(false);
}
setFDroidMetricsWorker();
break;
case Preferences.PREF_SEND_TO_FDROID_METRICS:
setFDroidMetricsWorker();
break;
}
}
use of androidx.appcompat.app.AppCompatActivity in project fdroidclient by f-droid.
the class NearbyViewBinder method updateUsbOtg.
public static void updateUsbOtg(final Context context) {
if (Build.VERSION.SDK_INT < 24) {
return;
}
if (swapView == null) {
Utils.debugLog(TAG, "swapView == null");
return;
}
TextView storageVolumeText = swapView.findViewById(R.id.storage_volume_text);
Button requestStorageVolume = swapView.findViewById(R.id.request_storage_volume_button);
storageVolumeText.setVisibility(View.GONE);
requestStorageVolume.setVisibility(View.GONE);
final StorageManager storageManager = ContextCompat.getSystemService(context, StorageManager.class);
for (final StorageVolume storageVolume : storageManager.getStorageVolumes()) {
if (storageVolume.isRemovable() && !storageVolume.isPrimary()) {
Log.i(TAG, "StorageVolume: " + storageVolume);
Intent tmpIntent = null;
if (Build.VERSION.SDK_INT < 29) {
tmpIntent = storageVolume.createAccessIntent(null);
} else {
tmpIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
tmpIntent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Uri.parse("content://" + TreeUriScannerIntentService.EXTERNAL_STORAGE_PROVIDER_AUTHORITY + "/tree/" + storageVolume.getUuid() + "%3A/document/" + storageVolume.getUuid() + "%3A"));
}
if (tmpIntent == null) {
Utils.debugLog(TAG, "Got null Storage Volume access Intent");
return;
}
final Intent intent = tmpIntent;
storageVolumeText.setVisibility(View.VISIBLE);
String text = storageVolume.getDescription(context);
if (!TextUtils.isEmpty(text)) {
requestStorageVolume.setText(text);
UsbDevice usb = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (usb != null) {
text = String.format("%s (%s %s)", text, usb.getManufacturerName(), usb.getProductName());
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
}
}
requestStorageVolume.setVisibility(View.VISIBLE);
requestStorageVolume.setOnClickListener(new View.OnClickListener() {
@Override
@RequiresApi(api = 24)
public void onClick(View v) {
List<UriPermission> list = context.getContentResolver().getPersistedUriPermissions();
if (list != null)
for (UriPermission uriPermission : list) {
Uri uri = uriPermission.getUri();
if (uri.getPath().equals(String.format("/tree/%s:", storageVolume.getUuid()))) {
intent.setData(uri);
TreeUriScannerIntentService.onActivityResult(context, intent);
return;
}
}
AppCompatActivity activity = null;
if (context instanceof AppCompatActivity) {
activity = (AppCompatActivity) context;
} else if (swapView != null && swapView.getContext() instanceof AppCompatActivity) {
activity = (AppCompatActivity) swapView.getContext();
}
if (activity != null) {
activity.startActivityForResult(intent, MainActivity.REQUEST_STORAGE_ACCESS);
} else {
// scan in the background without requesting permissions
Toast.makeText(context.getApplicationContext(), context.getString(R.string.scan_removable_storage_toast, externalStorage), Toast.LENGTH_SHORT).show();
SDCardScannerService.scan(context);
}
}
});
}
}
}
use of androidx.appcompat.app.AppCompatActivity in project Signal-Android by signalapp.
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));
}
use of androidx.appcompat.app.AppCompatActivity in project Signal-Android by signalapp.
the class KbsSplashFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
title = view.findViewById(R.id.kbs_splash_title);
description = view.findViewById(R.id.kbs_splash_description);
primaryAction = view.findViewById(R.id.kbs_splash_primary_action);
secondaryAction = view.findViewById(R.id.kbs_splash_secondary_action);
primaryAction.setOnClickListener(v -> onCreatePin());
secondaryAction.setOnClickListener(v -> onLearnMore());
if (RegistrationLockUtil.userHasRegistrationLock(requireContext())) {
setUpRegLockEnabled();
} else {
setUpRegLockDisabled();
}
description.setMovementMethod(LinkMovementMethod.getInstance());
Toolbar toolbar = view.findViewById(R.id.kbs_splash_toolbar);
((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(null);
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
}
});
}
Aggregations