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;
}
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();
}
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;
}
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))));
}
}
}
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);
}
}
Aggregations