Search in sources :

Example 36 with ContextThemeWrapper

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;
}
Also used : Amenity(net.osmand.data.Amenity) LatLon(net.osmand.data.LatLon) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) PointDescription(net.osmand.core.samples.android.sample1.data.PointDescription) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) AppCompatButton(android.support.v7.widget.AppCompatButton)

Example 37 with ContextThemeWrapper

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;
}
Also used : ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) SharedPreferences(android.content.SharedPreferences)

Example 38 with ContextThemeWrapper

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());
}
Also used : ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper)

Example 39 with ContextThemeWrapper

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;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) ContextThemeWrapper(android.view.ContextThemeWrapper) BottomSheetDialog(android.support.design.widget.BottomSheetDialog) Dialog(android.app.Dialog) SuppressLint(android.annotation.SuppressLint) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) NonNull(android.support.annotation.NonNull)

Example 40 with ContextThemeWrapper

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());
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) VActivity(io.virtualapp.abs.ui.VActivity) Bundle(android.os.Bundle) ChooseTypeAndAccountActivity(com.lody.virtual.client.stub.ChooseTypeAndAccountActivity) PackageAppData(io.virtualapp.home.models.PackageAppData) Animator(android.animation.Animator) LEFT(android.support.v7.widget.helper.ItemTouchHelper.LEFT) END(android.support.v7.widget.helper.ItemTouchHelper.END) OrientationHelper(android.support.v7.widget.OrientationHelper) DOWN(android.support.v7.widget.helper.ItemTouchHelper.DOWN) Handler(android.os.Handler) Looper(android.os.Looper) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) ContextThemeWrapper(android.view.ContextThemeWrapper) View(android.view.View) Canvas(android.graphics.Canvas) EmptyAppData(io.virtualapp.home.models.EmptyAppData) START(android.support.v7.widget.helper.ItemTouchHelper.START) Method(java.lang.reflect.Method) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ACTION_STATE_DRAG(android.support.v7.widget.helper.ItemTouchHelper.ACTION_STATE_DRAG) ObjectAnimator(android.animation.ObjectAnimator) PopupMenu(android.support.v7.widget.PopupMenu) VCommends(io.virtualapp.VCommends) ViewGroup(android.view.ViewGroup) List(java.util.List) TextView(android.widget.TextView) Nullable(android.support.annotation.Nullable) RIGHT(android.support.v7.widget.helper.ItemTouchHelper.RIGHT) VUserInfo(com.lody.virtual.os.VUserInfo) Context(android.content.Context) VirtualLocationSettings(io.virtualapp.home.location.VirtualLocationSettings) UP(android.support.v7.widget.helper.ItemTouchHelper.UP) MultiplePackageAppData(io.virtualapp.home.models.MultiplePackageAppData) Intent(android.content.Intent) AppInfoLite(io.virtualapp.home.models.AppInfoLite) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) GmsSupport(com.lody.virtual.GmsSupport) Toast(android.widget.Toast) Menu(android.view.Menu) AddAppButton(io.virtualapp.home.models.AddAppButton) TwoGearsView(io.virtualapp.widgets.TwoGearsView) VUserManager(com.lody.virtual.os.VUserManager) LaunchpadAdapter(io.virtualapp.home.adapters.LaunchpadAdapter) AppData(io.virtualapp.home.models.AppData) ItemOffsetDecoration(io.virtualapp.home.adapters.decorations.ItemOffsetDecoration) Color(android.graphics.Color) RecyclerView(android.support.v7.widget.RecyclerView) AlertDialog(android.support.v7.app.AlertDialog) R(io.virtualapp.R) SmartRecyclerAdapter(io.virtualapp.abs.nestedadapter.SmartRecyclerAdapter) VUiKit(io.virtualapp.abs.ui.VUiKit) ChooseTypeAndAccountActivity(com.lody.virtual.client.stub.ChooseTypeAndAccountActivity) ArrayList(java.util.ArrayList) Intent(android.content.Intent) VirtualLocationSettings(io.virtualapp.home.location.VirtualLocationSettings) SuppressLint(android.annotation.SuppressLint) ContextThemeWrapper(android.view.ContextThemeWrapper) PopupMenu(android.support.v7.widget.PopupMenu) Menu(android.view.Menu) PopupMenu(android.support.v7.widget.PopupMenu) VUserInfo(com.lody.virtual.os.VUserInfo)

Aggregations

View (android.view.View)40 ContextThemeWrapper (android.support.v7.view.ContextThemeWrapper)38 ContextThemeWrapper (android.view.ContextThemeWrapper)31 Context (android.content.Context)25 DialogInterface (android.content.DialogInterface)24 TextView (android.widget.TextView)22 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)21 AlertDialog (android.support.v7.app.AlertDialog)20 LayoutInflater (android.view.LayoutInflater)18 Intent (android.content.Intent)13 Nullable (android.support.annotation.Nullable)10 ColorPreferences (me.ccrama.redditslide.ColorPreferences)10 Drawable (android.graphics.drawable.Drawable)9 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 EditText (android.widget.EditText)8 Bundle (android.os.Bundle)7 ArrayList (java.util.ArrayList)7 SuppressLint (android.annotation.SuppressLint)6 Dialog (android.app.Dialog)6