Search in sources :

Example 76 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project WilliamChart by diogobernardino.

the class SandboxFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.sandbox, container, false);
    ((AppCompatActivity) getActivity()).setSupportActionBar((Toolbar) layout.findViewById(R.id.toolbar));
    ((TextView) layout.findViewById(R.id.title)).setTypeface(Typeface.createFromAsset(getContext().getAssets(), "Ponsi-Regular.otf"));
    // Pager
    mSectionsPagerAdapter = new SandboxPagerAdapter(this.getChildFragmentManager());
    mViewPager = (ViewPager) layout.findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    //getActivity().setupViewPager(viewPager);
    TabLayout tabLayout = (TabLayout) layout.findViewById(R.id.tab_layout);
    tabLayout.setupWithViewPager(mViewPager);
    // Defaults
    mChartId = R.id.sandbox_chart_line;
    mChartColorId = 1;
    mLabelXId = R.id.sandbox_axis_x_outside;
    mAxisXId = R.id.sandbox_axis_x_axis;
    mLabelYId = R.id.sandbox_axis_y_outside;
    mAxisYId = R.id.sandbox_axis_y_axis;
    mAxisColorId = DEFAULT_COLOR;
    mLabelColorId = DEFAULT_COLOR;
    mLabelFormat = "";
    mOrderId = R.id.sandbox_anim_ordere;
    mEnterId = R.id.sandbox_anim_enterb;
    mAlphaId = -1;
    mGridTypeId = -1;
    mGridLineTypeId = R.id.sandbox_grid_solid;
    mGridThicknessId = R.id.sandbox_grid_thickness3;
    mLineTypeId = -1;
    mLineThicknessTypeId = R.id.sandbox_line_solid;
    mLineThicknessId = R.id.sandbox_line_thickness3;
    mLineColorId = DEFAULT_COLOR;
    mPointColorId = DEFAULT_COLOR;
    mBarSpacing = 10;
    mBarCornersSize = 0;
    mBarColorId = DEFAULT_COLOR;
    mHasBarBackground = false;
    mBarBackgroundId = -1;
    mBarBackgroundColorId = DEFAULT_COLOR;
    mBarSpacingId = R.id.sandbox_bar_spacing2;
    mBarCornersSizeId = R.id.sandbox_bar_corner1;
    mHasYAxis = true;
    mYLabelPosition = AxisRenderer.LabelPosition.OUTSIDE;
    mHasXAxis = true;
    mXLabelPosition = AxisRenderer.LabelPosition.OUTSIDE;
    mGridType = null;
    mIsGridDashed = false;
    mGridDashType = null;
    mGridThickness = 1f;
    mGridThicknessId = R.id.sandbox_grid_thickness3;
    mGridColorId = DEFAULT_COLOR;
    mIsLineSmooth = false;
    mIsLineDashed = false;
    mLineDashType = null;
    mLineThickness = 3;
    mLineThicknessId = R.id.sandbox_line_thickness3;
    mPointsSize = 0;
    mPointsSizeId = -1;
    mDuration = 1000;
    mOverlapFactor = 1;
    mOverlapOrder = mEqualOrder;
    mEasingId = 0;
    mInterpolator = new DecelerateInterpolator();
    mStartX = -1;
    mStartY = 0;
    mAlpha = -1;
    return layout;
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) TabLayout(android.support.design.widget.TabLayout) AppCompatActivity(android.support.v7.app.AppCompatActivity) TextView(android.widget.TextView) BaseStackBarChartView(com.db.chart.view.BaseStackBarChartView) View(android.view.View) AdapterView(android.widget.AdapterView) BaseBarChartView(com.db.chart.view.BaseBarChartView) BarChartView(com.db.chart.view.BarChartView) ChartView(com.db.chart.view.ChartView) TextView(android.widget.TextView) HorizontalBarChartView(com.db.chart.view.HorizontalBarChartView) StackBarChartView(com.db.chart.view.StackBarChartView) LineChartView(com.db.chart.view.LineChartView) HorizontalStackBarChartView(com.db.chart.view.HorizontalStackBarChartView)

Example 77 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project android by cSploit.

the class MainFragment method onViewCreated.

@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
    SharedPreferences themePrefs = getActivity().getSharedPreferences("THEME", 0);
    Boolean isDark = themePrefs.getBoolean("isDark", false);
    if (isDark) {
        getActivity().setTheme(R.style.DarkTheme);
        v.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.background_window_dark));
    } else {
        getActivity().setTheme(R.style.AppTheme);
        v.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.background_window));
    }
    mEmptyTextView = (TextView) v.findViewById(R.id.emptyTextView);
    lv = (ListView) v.findViewById(R.id.android_list);
    mTextView = (TextView) v.findViewById(R.id.textView);
    lv.setOnItemClickListener(new ListView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mActionMode != null) {
                mTargetAdapter.toggleSelection(position);
                return;
            }
            Target target = (Target) mTargetAdapter.getItem(position);
            System.setCurrentTarget(target);
            ThreadHelper.getSharedExecutor().execute(new Runnable() {

                @Override
                public void run() {
                    startActivityForResult(new Intent(getActivity(), ActionActivity.class), WIFI_CONNECTION_REQUEST);
                    getActivity().overridePendingTransition(R.anim.fadeout, R.anim.fadein);
                }
            });
            Toast.makeText(getActivity(), getString(R.string.selected_) + System.getCurrentTarget(), Toast.LENGTH_SHORT).show();
        }
    });
    lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Target t = (Target) mTargetAdapter.getItem(position);
            if (t.getType() == Target.Type.NETWORK) {
                if (mActionMode == null)
                    targetAliasPrompt(t);
                return true;
            }
            if (mActionMode == null) {
                mTargetAdapter.clearSelection();
                mActionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(mActionModeCallback);
            }
            mTargetAdapter.toggleSelection(position);
            return true;
        }
    });
    mTargetAdapter = new TargetAdapter();
    lv.setEmptyView(v.findViewById(android.R.id.empty));
    lv.setAdapter(mTargetAdapter);
    System.setTargetListObserver(mTargetAdapter);
    mRadarReceiver.register(getActivity());
    mUpdateReceiver.register(getActivity());
    mWipeReceiver.register(getActivity());
    mMsfReceiver.register(getActivity());
    mConnectivityReceiver.register(getActivity());
    init();
    startAllServices();
}
Also used : SharedPreferences(android.content.SharedPreferences) AppCompatActivity(android.support.v7.app.AppCompatActivity) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) Target(org.csploit.android.net.Target) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView)

Example 78 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project actor-platform by actorapp.

the class MessagesDefaultFragment method onLongClick.

@Override
public boolean onLongClick(final Message message, final boolean hasMyReaction) {
    if (actionMode == null) {
        messagesAdapter.clearSelection();
        messagesAdapter.setSelected(message, true);
        actionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(new ActionMode.Callback() {

            @Override
            public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                getActivity().getMenuInflater().inflate(R.menu.messages_context, menu);
                return true;
            }

            @Override
            public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                Message[] selected = messagesAdapter.getSelected();
                if (selected.length > 0) {
                    actionMode.setTitle("" + selected.length);
                }
                boolean isAllText = true;
                for (Message k : selected) {
                    if (!(k.getContent() instanceof TextContent)) {
                        isAllText = false;
                        break;
                    }
                }
                menu.findItem(R.id.copy).setVisible(isAllText);
                menu.findItem(R.id.quote).setVisible(isAllText);
                menu.findItem(R.id.forward).setVisible(selected.length == 1 || isAllText);
                menu.findItem(R.id.like).setVisible(selected.length == 1);
                return false;
            }

            @Override
            public boolean onActionItemClicked(final ActionMode actionMode, MenuItem menuItem) {
                if (menuItem.getItemId() == R.id.delete) {
                    Message[] selected = messagesAdapter.getSelected();
                    final long[] rids = new long[selected.length];
                    for (int i = 0; i < rids.length; i++) {
                        rids[i] = selected[i].getRid();
                    }
                    new AlertDialog.Builder(getActivity()).setMessage(getString(R.string.alert_delete_messages_text).replace("{0}", "" + rids.length)).setPositiveButton(R.string.alert_delete_messages_yes, (dialog, which) -> {
                        messenger().deleteMessages(peer, rids);
                        actionMode.finish();
                    }).setNegativeButton(R.string.dialog_cancel, null).show().setCanceledOnTouchOutside(true);
                    return true;
                } else if (menuItem.getItemId() == R.id.copy) {
                    String text = messenger().getFormatter().formatMessagesExport(messagesAdapter.getSelected());
                    android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                    android.content.ClipData clip = android.content.ClipData.newPlainText("Messages", text);
                    clipboard.setPrimaryClip(clip);
                    Toast.makeText(getActivity(), R.string.toast_messages_copied, Toast.LENGTH_SHORT).show();
                    actionMode.finish();
                    return true;
                } else if (menuItem.getItemId() == R.id.like) {
                    Message currentMessage = messagesAdapter.getSelected()[0];
                    if (hasMyReaction) {
                        ActorSDK.sharedActor().getMessenger().removeReaction(getPeer(), currentMessage.getRid(), "❤").start(new CommandCallback<Void>() {

                            @Override
                            public void onResult(Void res) {
                            }

                            @Override
                            public void onError(Exception e) {
                            }
                        });
                    } else {
                        ActorSDK.sharedActor().getMessenger().addReaction(getPeer(), currentMessage.getRid(), "❤").start(new CommandCallback<Void>() {

                            @Override
                            public void onResult(Void res) {
                            }

                            @Override
                            public void onError(Exception e) {
                            }
                        });
                    }
                    actionMode.finish();
                    return true;
                } else if (menuItem.getItemId() == R.id.quote) {
                    String rawQuote = "";
                    int i = 0;
                    for (Message m : messagesAdapter.getSelected()) {
                        if (m.getContent() instanceof TextContent) {
                            UserVM user = users().get(m.getSenderId());
                            String nick = user.getNick().get();
                            String name = (nick != null && !nick.isEmpty()) ? "@" + nick : user.getName().get();
                            String text = ((TextContent) m.getContent()).getText();
                            rawQuote = rawQuote + name + ": " + text + "\n";
                        }
                    }
                    Fragment fragment = getParentFragment();
                    if (fragment instanceof MessagesFragmentCallback) {
                        ((MessagesFragmentCallback) fragment).onMessageQuote(rawQuote);
                    }
                    actionMode.finish();
                    return true;
                } else if (menuItem.getItemId() == R.id.forward) {
                    Intent i = new Intent(getActivity(), ShareActivity.class);
                    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    if (messagesAdapter.getSelected().length == 1) {
                        Message m = messagesAdapter.getSelected()[0];
                        if (m.getContent() instanceof TextContent) {
                            UserVM user = users().get(m.getSenderId());
                            String nick = user.getNick().get();
                            String name = (nick != null && !nick.isEmpty()) ? "@".concat(nick) : user.getName().get();
                            String text = ((TextContent) m.getContent()).getText();
                            String forward = name.concat(": ").concat(text).concat("\n");
                            i.putExtra(Intents.EXTRA_FORWARD_TEXT, forward);
                            i.putExtra(Intents.EXTRA_FORWARD_TEXT_RAW, forward);
                        } else if (!(m.getContent() instanceof UnsupportedContent)) {
                            AbsContent fileMessage = m.getContent();
                            try {
                                i.putExtra(Intents.EXTRA_FORWARD_CONTENT, AbsContent.serialize(fileMessage));
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
                    } else {
                        String quote = "";
                        String rawQuote = "";
                        int j = 0;
                        for (Message m : messagesAdapter.getSelected()) {
                            if (m.getContent() instanceof TextContent) {
                                UserVM user = users().get(m.getSenderId());
                                String nick = user.getNick().get();
                                String name = (nick != null && !nick.isEmpty()) ? "@".concat(nick) : user.getName().get();
                                String text = ((TextContent) m.getContent()).getText();
                                quote = quote.concat(name).concat(": ").concat(text);
                                rawQuote = rawQuote.concat(name).concat(": ").concat(text).concat("\n");
                                if (j++ != messagesAdapter.getSelectedCount() - 1) {
                                    quote += ";\n";
                                } else {
                                    quote += "\n";
                                }
                            }
                        }
                        i.putExtra(Intents.EXTRA_FORWARD_TEXT, quote);
                        i.putExtra(Intents.EXTRA_FORWARD_TEXT_RAW, rawQuote);
                    }
                    actionMode.finish();
                    startActivity(i);
                    getActivity().finish();
                    return true;
                }
                return false;
            }

            @Override
            public void onDestroyActionMode(ActionMode actionMode) {
                MessagesDefaultFragment.this.actionMode = null;
                messagesAdapter.clearSelection();
            }
        });
    } else {
        if (messagesAdapter.isSelected(message)) {
            messagesAdapter.setSelected(message, false);
            if (messagesAdapter.getSelectedCount() == 0) {
                actionMode.finish();
                actionMode = null;
            } else {
                actionMode.invalidate();
            }
        } else {
            messagesAdapter.setSelected(message, true);
            actionMode.invalidate();
        }
    }
    return true;
}
Also used : AlertDialog(android.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) ActorSDKMessenger.myUid(im.actor.sdk.util.ActorSDKMessenger.myUid) ActorSDKMessenger.messenger(im.actor.sdk.util.ActorSDKMessenger.messenger) Intent(android.content.Intent) MenuItem(android.view.MenuItem) Toast(android.widget.Toast) Menu(android.view.Menu) CommandCallback(im.actor.core.viewmodel.CommandCallback) TextContent(im.actor.core.entity.content.TextContent) Intents(im.actor.sdk.controllers.Intents) ActorSDK(im.actor.sdk.ActorSDK) AbsContent(im.actor.core.entity.content.AbsContent) ActorSDKLauncher(im.actor.sdk.ActorSDKLauncher) ActionMode(android.support.v7.view.ActionMode) Void(im.actor.runtime.actors.messages.Void) Fragment(android.support.v4.app.Fragment) ActorSDKMessenger.users(im.actor.sdk.util.ActorSDKMessenger.users) IOException(java.io.IOException) UnsupportedContent(im.actor.core.entity.content.UnsupportedContent) AppCompatActivity(android.support.v7.app.AppCompatActivity) AlertDialog(android.app.AlertDialog) UserVM(im.actor.core.viewmodel.UserVM) R(im.actor.sdk.R) ChatActivity(im.actor.sdk.controllers.conversation.ChatActivity) Peer(im.actor.core.entity.Peer) ShareActivity(im.actor.sdk.controllers.share.ShareActivity) Message(im.actor.core.entity.Message) Message(im.actor.core.entity.Message) UnsupportedContent(im.actor.core.entity.content.UnsupportedContent) Fragment(android.support.v4.app.Fragment) Menu(android.view.Menu) Void(im.actor.runtime.actors.messages.Void) AbsContent(im.actor.core.entity.content.AbsContent) MenuItem(android.view.MenuItem) Intent(android.content.Intent) IOException(java.io.IOException) IOException(java.io.IOException) UserVM(im.actor.core.viewmodel.UserVM) CommandCallback(im.actor.core.viewmodel.CommandCallback) ActionMode(android.support.v7.view.ActionMode) TextContent(im.actor.core.entity.content.TextContent)

Example 79 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project actor-platform by actorapp.

the class ProfileFragment method updateBar.

private void updateBar(int offset) {
    ActionBar bar = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (bar != null) {
        int fullColor = style.getToolBarColor();
        if (Math.abs(offset) > Screen.dp(248 - 56)) {
            bar.setBackgroundDrawable(new ColorDrawable(fullColor));
        } else {
            float alpha = Math.abs(offset) / (float) Screen.dp(248 - 56);
            bar.setBackgroundDrawable(new ColorDrawable(Color.argb((int) (255 * alpha), Color.red(fullColor), Color.green(fullColor), Color.blue(fullColor))));
        }
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) AppCompatActivity(android.support.v7.app.AppCompatActivity) ActionBar(android.support.v7.app.ActionBar)

Example 80 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Signal-Android by WhisperSystems.

the class ColorPreference method onAttachedToActivity.

@Override
protected void onAttachedToActivity() {
    super.onAttachedToActivity();
    AppCompatActivity activity = (AppCompatActivity) getContext();
    ColorDialogFragment fragment = (ColorDialogFragment) activity.getSupportFragmentManager().findFragmentByTag(getFragmentTag());
    if (fragment != null) {
        // re-bind preference to fragment
        fragment.setPreference(this);
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)99 View (android.view.View)43 ActionBar (android.support.v7.app.ActionBar)36 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)17 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 Toolbar (android.support.v7.widget.Toolbar)14 BindView (butterknife.BindView)11 Fragment (android.support.v4.app.Fragment)8 PopupMenu (android.support.v7.widget.PopupMenu)8 Transition (android.transition.Transition)7 MenuItem (android.view.MenuItem)7 Intent (android.content.Intent)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 Bundle (android.os.Bundle)4 FragmentManager (android.support.v4.app.FragmentManager)4