use of android.support.v7.view.ContextThemeWrapper in project Osmand by osmandapp.
the class MenuBuilder method getCollapsableWikiView.
protected View getCollapsableWikiView(Context context, boolean collapsed) {
final LinearLayout view = new LinearLayout(context);
view.setOrientation(LinearLayout.VERTICAL);
view.setVisibility(collapsed ? View.GONE : View.VISIBLE);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llParams.setMargins(dpToPx(68f), 0, dpToPx(12f), dpToPx(13f));
view.setLayoutParams(llParams);
for (final Amenity wiki : nearestWiki) {
AppCompatButton wikiButton = new AppCompatButton(new ContextThemeWrapper(view.getContext(), R.style.AppTheme));
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
wikiButton.setLayoutParams(llWikiButtonParams);
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
wikiButton.setTextColor(app.getResources().getColor(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark));
wikiButton.setText(wiki.getName());
wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
wikiButton.setSingleLine(true);
wikiButton.setEllipsize(TextUtils.TruncateAt.END);
wikiButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PointDescription pointDescription = MenuController.getObjectName(wiki);
mainActivity.getContextMenu().show(new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude()), pointDescription, wiki);
}
});
view.addView(wikiButton);
}
return view;
}
use of android.support.v7.view.ContextThemeWrapper in project Taskbar by farmerbb.
the class U method wrapContext.
public static Context wrapContext(Context context) {
SharedPreferences pref = getSharedPreferences(context);
int theme = -1;
switch(pref.getString("theme", "light")) {
case "light":
theme = R.style.AppTheme;
break;
case "dark":
theme = R.style.AppTheme_Dark;
break;
}
return theme > -1 ? new ContextThemeWrapper(context, theme) : context;
}
use of android.support.v7.view.ContextThemeWrapper in project Memento-Calendar by alexstyl.
the class ThemeViewHolder method bind.
public void bind(MementoTheme theme) {
ContextThemeWrapper wrapper = new ContextThemeWrapper(themeName.getContext(), theme.androidTheme());
int primaryColor = extractor.extractPrimaryColorFrom(wrapper);
primaryColorView.setBackgroundColor(primaryColor);
int accentColor = extractor.extractAccentColorFrom(wrapper);
boolean darkIcons = extractor.extractDarkIconsFrom(wrapper);
themeName.setTextColor(wrapper.getResources().getColor(darkIcons ? android.R.color.black : android.R.color.white));
accentColorView.setBackgroundColor(accentColor);
themeName.setText(theme.getThemeName());
}
use of android.support.v7.view.ContextThemeWrapper in project focus-android by mozilla-mobile.
the class OpenWithFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
ContextThemeWrapper wrapper = new ContextThemeWrapper(getContext(), android.R.style.Theme_Material_Light);
// This View will have it's params ignored anyway:
@SuppressLint("InflateParams") final View view = LayoutInflater.from(wrapper).inflate(R.layout.fragment_open_with, null);
final Dialog dialog = new CustomWidthBottomSheetDialog(wrapper);
dialog.setContentView(view);
final RecyclerView appList = view.findViewById(R.id.apps);
appList.setLayoutManager(new LinearLayoutManager(wrapper, LinearLayoutManager.VERTICAL, false));
AppAdapter adapter = new AppAdapter(wrapper, (ActivityInfo[]) getArguments().getParcelableArray(ARGUMENT_KEY_APPS), (ActivityInfo) getArguments().getParcelable(ARGUMENT_STORE));
adapter.setOnAppSelectedListener(this);
appList.setAdapter(adapter);
return dialog;
}
use of android.support.v7.view.ContextThemeWrapper in project VirtualApp by asLody.
the class HomeActivity method initMenu.
private void initMenu() {
mPopupMenu = new PopupMenu(new ContextThemeWrapper(this, R.style.Theme_AppCompat_Light), mMenuView);
Menu menu = mPopupMenu.getMenu();
setIconEnable(menu, true);
menu.add("Accounts").setIcon(R.drawable.ic_account).setOnMenuItemClickListener(item -> {
List<VUserInfo> users = VUserManager.get().getUsers();
List<String> names = new ArrayList<>(users.size());
for (VUserInfo info : users) {
names.add(info.name);
}
CharSequence[] items = new CharSequence[names.size()];
for (int i = 0; i < names.size(); i++) {
items[i] = names.get(i);
}
new AlertDialog.Builder(this).setTitle("Please select an user").setItems(items, (dialog, which) -> {
VUserInfo info = users.get(which);
Intent intent = new Intent(this, ChooseTypeAndAccountActivity.class);
intent.putExtra(ChooseTypeAndAccountActivity.KEY_USER_ID, info.id);
startActivity(intent);
}).show();
return false;
});
menu.add("Virtual Storage").setIcon(R.drawable.ic_vs).setOnMenuItemClickListener(item -> {
Toast.makeText(this, "The coming", Toast.LENGTH_SHORT).show();
return false;
});
menu.add("Notification").setIcon(R.drawable.ic_notification).setOnMenuItemClickListener(item -> {
Toast.makeText(this, "The coming", Toast.LENGTH_SHORT).show();
return false;
});
menu.add("Virtual Location").setIcon(R.drawable.ic_notification).setOnMenuItemClickListener(item -> {
startActivity(new Intent(this, VirtualLocationSettings.class));
return true;
});
menu.add("Settings").setIcon(R.drawable.ic_settings).setOnMenuItemClickListener(item -> {
Toast.makeText(this, "The coming", Toast.LENGTH_SHORT).show();
return false;
});
mMenuView.setOnClickListener(v -> mPopupMenu.show());
}
Aggregations