use of android.support.v7.widget.AppCompatImageButton in project ForPDA by RadiationX.
the class ThemeFragment method addSearchOnPageItem.
private void addSearchOnPageItem(Menu menu) {
toolbar.inflateMenu(R.menu.theme_search_menu);
searchOnPageMenuItem = menu.findItem(R.id.action_search);
MenuItemCompat.setOnActionExpandListener(searchOnPageMenuItem, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
toggleMessagePanelItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
return true;
}
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
toggleMessagePanelItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER);
return true;
}
});
SearchView searchView = (SearchView) searchOnPageMenuItem.getActionView();
searchView.setTag(searchViewTag);
searchView.setOnSearchClickListener(v -> {
if (searchView.getTag().equals(searchViewTag)) {
ImageView searchClose = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_close_btn);
if (searchClose != null)
((ViewGroup) searchClose.getParent()).removeView(searchClose);
ViewGroup.LayoutParams navButtonsParams = new ViewGroup.LayoutParams(App.px48, App.px48);
TypedValue outValue = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.actionBarItemBackground, outValue, true);
AppCompatImageButton btnNext = new AppCompatImageButton(searchView.getContext());
btnNext.setImageDrawable(App.getVecDrawable(getContext(), R.drawable.ic_toolbar_search_next));
btnNext.setBackgroundResource(outValue.resourceId);
AppCompatImageButton btnPrev = new AppCompatImageButton(searchView.getContext());
btnPrev.setImageDrawable(App.getVecDrawable(getContext(), R.drawable.ic_toolbar_search_prev));
btnPrev.setBackgroundResource(outValue.resourceId);
((LinearLayout) searchView.getChildAt(0)).addView(btnPrev, navButtonsParams);
((LinearLayout) searchView.getChildAt(0)).addView(btnNext, navButtonsParams);
btnNext.setOnClickListener(v1 -> findNext(true));
btnPrev.setOnClickListener(v1 -> findNext(false));
searchViewTag++;
}
});
SearchManager searchManager = (SearchManager) getMainActivity().getSystemService(Context.SEARCH_SERVICE);
if (null != searchManager) {
searchView.setSearchableInfo(searchManager.getSearchableInfo(getMainActivity().getComponentName()));
}
searchView.setIconifiedByDefault(true);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
findText(newText);
return false;
}
});
}
use of android.support.v7.widget.AppCompatImageButton in project ForPDA by RadiationX.
the class ArticleCommentsFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.article_comments, container, false);
refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_list);
recyclerView = (RecyclerView) view.findViewById(R.id.base_list);
writePanel = (RelativeLayout) view.findViewById(R.id.comment_write_panel);
messageField = (EditText) view.findViewById(R.id.message_field);
sendContainer = (FrameLayout) view.findViewById(R.id.send_container);
buttonSend = (AppCompatImageButton) view.findViewById(R.id.button_send);
progressBarSend = (ProgressBar) view.findViewById(R.id.send_progress);
additionalContent = (ViewGroup) view.findViewById(R.id.additional_content);
refreshLayout.setProgressBackgroundColorSchemeColor(App.getColorFromAttr(getContext(), R.attr.colorPrimary));
refreshLayout.setColorSchemeColors(App.getColorFromAttr(getContext(), R.attr.colorAccent));
refreshLayout.setOnRefreshListener(() -> {
refreshLayout.setRefreshing(true);
RxApi.NewsList().getDetails(article.getId()).map(page -> {
Comment commentTree = Api.NewsApi().updateComments(article, page);
article.setCommentTree(commentTree);
return Api.NewsApi().commentsToList(article.getCommentTree());
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(comments -> {
refreshLayout.setRefreshing(false);
createFunny(comments);
adapter.addAll(comments);
});
});
recyclerView.setBackgroundColor(App.getColorFromAttr(getContext(), R.attr.background_for_lists));
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new BrandFragment.SpacingItemDecoration(App.px12, false));
adapter = new ArticleCommentsAdapter();
adapter.setClickListener(this);
Observable.fromCallable(() -> {
if (article.getCommentTree() == null) {
Comment commentTree = Api.NewsApi().parseComments(article.getKarmaMap(), article.getCommentsSource());
article.setCommentTree(commentTree);
}
return Api.NewsApi().commentsToList(article.getCommentTree());
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(comments -> {
createFunny(comments);
adapter.addAll(comments);
if (article.getCommentId() > 0) {
for (int i = 0; i < comments.size(); i++) {
if (comments.get(i).getId() == article.getCommentId()) {
recyclerView.scrollToPosition(i);
break;
}
}
}
});
recyclerView.setAdapter(adapter);
messageField.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if (s.length() == 0) {
currentReplyComment = null;
}
buttonSend.setClickable(s.length() > 0);
}
});
buttonSend.setOnClickListener(v -> sendComment());
if (ClientHelper.getAuthState()) {
writePanel.setVisibility(View.VISIBLE);
} else {
writePanel.setVisibility(View.GONE);
}
ClientHelper.get().addLoginObserver(loginObserver);
contentController = new ContentController(null, additionalContent, refreshLayout);
return view;
}
use of android.support.v7.widget.AppCompatImageButton in project PhoneProfilesPlus by henrichg.
the class LocationGeofenceEditorActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
// must by called before super.onCreate() for PreferenceActivity
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
GlobalGUIRoutines.setTheme(this, false, true, false);
else
GlobalGUIRoutines.setTheme(this, false, false, false);
GlobalGUIRoutines.setLanguage(getBaseContext());
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_location_geofence_editor);
mResultReceiver = new AddressResultReceiver(new Handler(getMainLooper()));
// Create a GoogleApiClient instance
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
PPApplication.logE("LocationGeofenceEditorActivity.LocationCallback", "xxx");
if (locationResult == null) {
return;
}
for (Location location : locationResult.getLocations()) {
mLastLocation = location;
PPApplication.logE("LocationGeofenceEditorActivity.LocationCallback", "location=" + location);
if (mLocation == null) {
mLocation = new Location(mLastLocation);
refreshActivity(true);
} else
updateEditedMarker(false);
}
}
};
createLocationRequest();
mResolvingError = savedInstanceState != null && savedInstanceState.getBoolean(STATE_RESOLVING_ERROR, false);
Intent intent = getIntent();
geofenceId = intent.getLongExtra(LocationGeofencePreference.EXTRA_GEOFENCE_ID, 0);
if (geofenceId > 0) {
geofence = DatabaseHandler.getInstance(getApplicationContext()).getGeofence(geofenceId);
mLocation = new Location("LOC");
mLocation.setLatitude(geofence._latitude);
mLocation.setLongitude(geofence._longitude);
}
if (geofence == null) {
geofenceId = 0;
geofence = new Geofence();
geofence._name = getString(R.string.event_preferences_location_new_location_name) + "_" + String.valueOf(DatabaseHandler.getInstance(getApplicationContext()).getGeofenceCount() + 1);
geofence._radius = 100;
}
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.location_editor_map);
mapFragment.getMapAsync(this);
radiusLabel = findViewById(R.id.location_pref_dlg_radius_seekbar_label);
SeekBar radiusSeekBar = findViewById(R.id.location_pref_dlg_radius_seekbar);
radiusSeekBar.setProgress(Math.round(geofence._radius / (float) 20.0) - 1);
radiusSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
geofence._radius = (progress + 1) * 20;
updateEditedMarker(false);
// Log.d("LocationGeofenceEditorActivity.onProgressChanged", "radius="+geofence._radius);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
geofenceNameEditText = findViewById(R.id.location_editor_geofence_name);
geofenceNameEditText.setText(geofence._name);
addressText = findViewById(R.id.location_editor_address_text);
okButton = findViewById(R.id.location_editor_ok);
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = geofenceNameEditText.getText().toString();
if ((!name.isEmpty()) && (mLocation != null)) {
geofence._name = name;
geofence._latitude = mLocation.getLatitude();
geofence._longitude = mLocation.getLongitude();
if (geofenceId > 0) {
DatabaseHandler.getInstance(getApplicationContext()).updateGeofence(geofence);
} else {
DatabaseHandler.getInstance(getApplicationContext()).addGeofence(geofence);
/*synchronized (PPApplication.geofenceScannerMutex) {
// start location updates
if ((PhoneProfilesService.instance != null) && PhoneProfilesService.isGeofenceScannerStarted())
PhoneProfilesService.getGeofencesScanner().connectForResolve();
}*/
}
DatabaseHandler.getInstance(getApplicationContext()).checkGeofence(String.valueOf(geofence._id), 1);
Intent returnIntent = new Intent();
returnIntent.putExtra(LocationGeofencePreference.EXTRA_GEOFENCE_ID, geofence._id);
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
}
});
Button cancelButton = findViewById(R.id.location_editor_cancel);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent returnIntent = new Intent();
setResult(Activity.RESULT_CANCELED, returnIntent);
finish();
}
});
AppCompatImageButton myLocationButton = findViewById(R.id.location_editor_my_location);
myLocationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mLastLocation != null)
mLocation = new Location(mLastLocation);
refreshActivity(true);
}
});
addressButton = findViewById(R.id.location_editor_address_btn);
addressButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getGeofenceAddress();
}
});
}
use of android.support.v7.widget.AppCompatImageButton in project PhoneProfilesPlus by henrichg.
the class ApplicationsDialogPreference method showDialog.
@Override
protected void showDialog(Bundle state) {
MaterialDialog.Builder mBuilder = new MaterialDialog.Builder(getContext()).title(getDialogTitle()).icon(getDialogIcon()).autoDismiss(false).content(getDialogMessage()).customView(R.layout.activity_applications_pref_dialog, false).dividerColor(0);
mBuilder.positiveText(getPositiveButtonText()).negativeText(getNegativeButtonText());
mBuilder.onPositive(new MaterialDialog.SingleButtonCallback() {
@SuppressWarnings("StringConcatenationInLoop")
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
if (shouldPersist()) {
// fill with application strings separated with |
value = "";
if (applicationsList != null) {
for (Application application : applicationsList) {
if (!value.isEmpty())
value = value + "|";
if (application.shortcut)
value = value + "(s)";
value = value + application.packageName + "/" + application.activityName;
if (application.shortcut && (application.shortcutId > 0))
value = value + "#" + application.shortcutId;
value = value + "#" + application.startApplicationDelay;
PPApplication.logE("ApplicationsDialogPreference.onPositive", "value=" + value);
}
}
persistString(value);
setIcons();
setSummaryAMSDP();
}
mDialog.dismiss();
}
});
mBuilder.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
mDialog.dismiss();
}
});
mBuilder.showListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
ApplicationsDialogPreference.this.onShow();
}
});
mDialog = mBuilder.build();
View layout = mDialog.getCustomView();
// noinspection ConstantConditions
AppCompatImageButton addButton = layout.findViewById(R.id.applications_pref_dlg_add);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
applicationsListView = layout.findViewById(R.id.applications_pref_dlg_listview);
// applicationsListView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
applicationsListView.setLayoutManager(layoutManager);
applicationsListView.setHasFixedSize(true);
linlaProgress = layout.findViewById(R.id.applications_pref_dlg_linla_progress);
rellaDialog = layout.findViewById(R.id.applications_pref_dlg_rella_dialog);
listAdapter = new ApplicationsDialogPreferenceAdapter(context, this, this);
// added touch helper for drag and drop items
ItemTouchHelper.Callback callback = new ItemTouchHelperCallback(listAdapter, false, false);
itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(applicationsListView);
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startEditor(null);
}
});
GlobalGUIRoutines.registerOnActivityDestroyListener(this, this);
if (state != null)
mDialog.onRestoreInstanceState(state);
mDialog.setOnDismissListener(this);
mDialog.show();
}
use of android.support.v7.widget.AppCompatImageButton in project krypton-android by kryptco.
the class CreateInviteDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_teams_invite_modal, container, false);
String myEmail = getArguments().getString("myEmail");
// TODO: filter on common email endings and hide team link in that case
String[] emailToks = myEmail.split("@");
AppCompatImageButton teamLinkButton = rootView.findViewById(R.id.teamLinkButton);
if (emailToks.length == 2) {
String domain = emailToks[1];
AppCompatTextView teamLinkDetail = rootView.findViewById(R.id.teamEmailLinkDetail);
teamLinkDetail.setText("Anyone with an @" + domain + " email address");
teamLinkButton.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("Create a team-only invite link?").setMessage("This will create a secret invite link that can only be used by people with an @" + domain + " email address.").setPositiveButton("Yes", (dialog, which) -> {
Sigchain.RequestableTeamOperation request = new Sigchain.RequestableTeamOperation(new Sigchain.IndirectInvitationRestriction(domain));
EventBus.getDefault().post(new TeamService.RequestTeamOperation(request, TeamService.C.withStatusCallback(getActivity(), this::onCreateInvite)));
getFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
}).setNegativeButton("No", (dialog, which) -> {
getFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
}).show();
});
} else {
// TODO: hide teamLinkButton if no domain on email or user has a common domain like gmail
}
AppCompatImageButton individualLinkButton = rootView.findViewById(R.id.individualsLinkButton);
individualLinkButton.setOnClickListener(v -> {
getFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right).replace(R.id.fragmentOverlay, SelectIndividualsFragment.newInstance()).addToBackStack(null).commitAllowingStateLoss();
});
AppCompatImageButton inpersonButton = rootView.findViewById(R.id.inPersonButton);
inpersonButton.setOnClickListener(v -> {
Transitions.beginFade(this).replace(R.id.fragmentOverlay, new AdminQR()).addToBackStack(null).commitAllowingStateLoss();
});
return rootView;
}
Aggregations