use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project Tusky by Vavassor.
the class ComposeActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compose);
ButterKnife.bind(this);
// Setup the toolbar.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(null);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp);
ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint);
actionBar.setHomeAsUpIndicator(closeIcon);
}
// Setup the interface buttons.
floatingBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onSendClicked();
}
});
pickBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onMediaPick();
}
});
takeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
initiateCameraApp();
}
});
nsfwBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleNsfw();
}
});
visibilityBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showComposeOptions();
}
});
/* Initialise all the state, or restore it from a previous run, to determine a "starting"
* state. */
SharedPreferences preferences = getPrivatePreferences();
String startingVisibility;
boolean startingHideText;
String startingContentWarning = null;
ArrayList<SavedQueuedMedia> savedMediaQueued = null;
if (savedInstanceState != null) {
showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive");
startingVisibility = savedInstanceState.getString("statusVisibility");
statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive");
startingHideText = savedInstanceState.getBoolean("statusHideText");
// Keep these until everything needed to put them in the queue is finished initializing.
savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued");
// These are for restoring an in-progress commit content operation.
InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat.wrap(savedInstanceState.getParcelable("commitContentInputContentInfo"));
int previousFlags = savedInstanceState.getInt("commitContentFlags");
if (previousInputContentInfo != null) {
onCommitContentInternal(previousInputContentInfo, previousFlags);
}
} else {
showMarkSensitive = false;
startingVisibility = preferences.getString("rememberedVisibility", "public");
statusMarkSensitive = false;
startingHideText = false;
}
/* If the composer is started up as a reply to another post, override the "starting" state
* based on what the intent from the reply request passes. */
Intent intent = getIntent();
String[] mentionedUsernames = null;
inReplyToId = null;
if (intent != null) {
inReplyToId = intent.getStringExtra("in_reply_to_id");
String replyVisibility = intent.getStringExtra("reply_visibility");
if (replyVisibility != null && startingVisibility != null) {
// Lowest possible visibility setting in response
if (startingVisibility.equals("direct") || replyVisibility.equals("direct")) {
startingVisibility = "direct";
} else if (startingVisibility.equals("private") || replyVisibility.equals("private")) {
startingVisibility = "private";
} else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) {
startingVisibility = "unlisted";
} else {
startingVisibility = replyVisibility;
}
}
mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames");
if (inReplyToId != null) {
startingHideText = !intent.getStringExtra("content_warning").equals("");
if (startingHideText) {
startingContentWarning = intent.getStringExtra("content_warning");
}
}
}
/* If the currently logged in account is locked, its posts should default to private. This
* should override even the reply settings, so this must be done after those are set up. */
if (preferences.getBoolean("loggedInAccountLocked", false)) {
startingVisibility = "private";
}
// After the starting state is finalised, the interface can be set to reflect this state.
setStatusVisibility(startingVisibility);
postProgress.setVisibility(View.INVISIBLE);
updateNsfwButtonColor();
final ParserUtils parser = new ParserUtils(this);
// Setup the main text field.
// new String[] { "image/gif", "image/webp" }
setEditTextMimeTypes(null);
final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color);
SpanUtils.highlightSpans(textEditor.getText(), mentionColour);
textEditor.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
updateVisibleCharactersLeft();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable editable) {
SpanUtils.highlightSpans(editable, mentionColour);
}
});
textEditor.addOnPasteListener(new EditTextTyped.OnPasteListener() {
@Override
public void onPaste() {
parser.getPastedURLText(ComposeActivity.this);
}
});
// Add any mentions to the text field when a reply is first composed.
if (mentionedUsernames != null) {
StringBuilder builder = new StringBuilder();
for (String name : mentionedUsernames) {
builder.append('@');
builder.append(name);
builder.append(' ');
}
textEditor.setText(builder);
textEditor.setSelection(textEditor.length());
}
// Initialise the content warning editor.
contentWarningEditor.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
updateVisibleCharactersLeft();
}
@Override
public void afterTextChanged(Editable s) {
}
});
showContentWarning(startingHideText);
if (startingContentWarning != null) {
contentWarningEditor.setText(startingContentWarning);
}
// Initialise the empty media queue state.
mediaQueued = new ArrayList<>();
waitForMediaLatch = new CountUpDownLatch();
statusAlreadyInFlight = false;
// These can only be added after everything affected by the media queue is initialized.
if (savedMediaQueued != null) {
for (SavedQueuedMedia item : savedMediaQueued) {
addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize);
}
} else if (intent != null && savedInstanceState == null) {
/* Get incoming images being sent through a share action from another app. Only do this
* when savedInstanceState is null, otherwise both the images from the intent and the
* instance state will be re-queued. */
String type = intent.getType();
if (type != null) {
if (type.startsWith("image/")) {
List<Uri> uriList = new ArrayList<>();
switch(intent.getAction()) {
case Intent.ACTION_SEND:
{
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (uri != null) {
uriList.add(uri);
}
break;
}
case Intent.ACTION_SEND_MULTIPLE:
{
ArrayList<Uri> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if (list != null) {
for (Uri uri : list) {
if (uri != null) {
uriList.add(uri);
}
}
}
break;
}
}
for (Uri uri : uriList) {
long mediaSize = getMediaSize(getContentResolver(), uri);
pickMedia(uri, mediaSize);
}
} else if (type.equals("text/plain")) {
String action = intent.getAction();
if (action != null && action.equals(Intent.ACTION_SEND)) {
String text = intent.getStringExtra(Intent.EXTRA_TEXT);
if (text != null) {
int start = Math.max(textEditor.getSelectionStart(), 0);
int end = Math.max(textEditor.getSelectionEnd(), 0);
int left = Math.min(start, end);
int right = Math.max(start, end);
textEditor.getText().replace(left, right, text, 0, text.length());
parser.putInClipboardManager(this, text);
textEditor.onPaste();
}
}
}
}
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project simple-stack by Zhuinden.
the class MainActivity method onCreate.
/**
* Pay attention to the {@link #setContentView} call here. It's creating a responsive layout
* for us.
* <p>
* Notice that the app has two root_layout files. The main one, in {@code res/layout} is used by
* mobile devices and by tablets in portrait orientation. It holds a generic {@link
* com.example.stackmasterdetailfrag.util.pathview.SinglePaneRoot}.
* <p>
* The interesting one, loaded by tablets in landscape mode, is {@code res/layout-sw600dp-land}.
* It loads a {@link TabletMasterDetailRoot}, with a master list on the
* left and a detail view on the right.
* <p>
* But this master activity knows nothing about those two view types. It only requires that
* the view loaded by {@code root_layout.xml} implements the StateChanger interface,
* to render whatever is appropriate for the screens received from {@link com.zhuinden.simplestack.Backstack} via
* {@link #handleStateChange}.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(false);
backstackDelegate = new BackstackDelegate(null);
backstackDelegate.setStateClearStrategy(new MasterDetailStateClearStrategy());
backstackDelegate.onCreate(savedInstanceState, getLastCustomNonConfigurationInstance(), HistoryBuilder.single(ConversationListPath.create()));
setContentView(R.layout.root_layout);
container = (StateChanger) findViewById(R.id.container);
containerAsBackTarget = (HandlesBack) container;
backstackDelegate.setStateChanger(this);
}
use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project simple-stack by Zhuinden.
the class MainActivity method onCreate.
/**
* Pay attention to the {@link #setContentView} call here. It's creating a responsive layout
* for us.
* <p>
* Notice that the app has two root_layout files. The main one, in {@code res/layout} is used by
* mobile devices and by tablets in portrait orientation. It holds a generic {@link
* com.example.stackmasterdetail.util.pathview.FramePathContainerView}.
* <p>
* The interesting one, loaded by tablets in landscape mode, is {@code res/layout-sw600dp-land}.
* It loads a {@link TabletMasterDetailRoot}, with a master list on the
* left and a detail view on the right.
* <p>
* But this master activity knows nothing about those two view types. It only requires that
* the view loaded by {@code root_layout.xml} implements the {@link com.example.stackmasterdetail.util.Container} interface,
* to render whatever is appropriate for the screens received from {@link com.zhuinden.simplestack.Backstack} via
* {@link #handleStateChange}.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(false);
setContentView(R.layout.root_layout);
container = (ViewGroup) findViewById(R.id.container);
containerAsStateChanger = (StateChanger) container;
containerAsBackTarget = (HandlesBack) containerAsStateChanger;
Navigator.configure().setStateChanger(this).setStateClearStrategy(new MasterDetailStateClearStrategy()).setShouldPersistContainerChild(false).install(this, container, HistoryBuilder.single(ConversationListPath.create()));
}
use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConditionAdapterUtils method animateChange.
private static void animateChange(final View view, final View content, final View detailGroup, final boolean visible, final boolean hasButtons) {
setViewVisibility(detailGroup, R.id.divider, hasButtons);
setViewVisibility(detailGroup, R.id.buttonBar, hasButtons);
final int beforeBottom = content.getBottom();
setHeight(detailGroup, visible ? LayoutParams.WRAP_CONTENT : 0);
detailGroup.setVisibility(View.VISIBLE);
view.addOnLayoutChangeListener(new OnLayoutChangeListener() {
public static final long DURATION = 250;
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
final int afterBottom = content.getBottom();
v.removeOnLayoutChangeListener(this);
final ObjectAnimator animator = ObjectAnimator.ofInt(content, "bottom", beforeBottom, afterBottom);
animator.setDuration(DURATION);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (!visible) {
detailGroup.setVisibility(View.GONE);
}
}
});
animator.start();
}
});
}
use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PixelAnimDurationSettings method refreshSettings.
public void refreshSettings() {
PreferenceScreen prefs = getPreferenceScreen();
if (prefs != null) {
prefs.removeAll();
}
addPreferencesFromResource(R.xml.pixel_anim_duration);
mContext = getActivity().getApplicationContext();
mContentRes = getActivity().getContentResolver();
final Resources res = getResources();
int defaultValue;
mPixelx = (SeekBarPreference) findPreference(PIXEL_X);
int xanim = Settings.System.getIntForUser(getContentResolver(), Settings.System.OPA_ANIM_DURATION_X, 133, UserHandle.USER_CURRENT);
mPixelx.setValue(xanim / 1);
mPixelx.setOnPreferenceChangeListener(this);
mPixely = (SeekBarPreference) findPreference(PIXEL_Y);
int yanim = Settings.System.getIntForUser(getContentResolver(), Settings.System.OPA_ANIM_DURATION_Y, 255, UserHandle.USER_CURRENT);
mPixely.setValue(yanim / 1);
mPixely.setOnPreferenceChangeListener(this);
mCollapse = (SeekBarPreference) findPreference(PIXEL_COLLAPSE);
int xcol = Settings.System.getIntForUser(getContentResolver(), Settings.System.COLLAPSE_ANIMATION_DURATION_RY, 83, UserHandle.USER_CURRENT);
mCollapse.setValue(xcol / 1);
mCollapse.setOnPreferenceChangeListener(this);
mBg = (SeekBarPreference) findPreference(PIXEL_BG);
int bg = Settings.System.getIntForUser(getContentResolver(), Settings.System.COLLAPSE_ANIMATION_DURATION_BG, 100, UserHandle.USER_CURRENT);
mBg.setValue(yanim / 1);
mBg.setOnPreferenceChangeListener(this);
mRetract = (SeekBarPreference) findPreference(PIXEL_RETRACT);
int ret = Settings.System.getIntForUser(getContentResolver(), Settings.System.RETRACT_ANIMATION_DURATION, 300, UserHandle.USER_CURRENT);
mRetract.setValue(ret / 1);
mRetract.setOnPreferenceChangeListener(this);
mDiamond = (SeekBarPreference) findPreference(PIXEL_DIAMOND);
int diam = Settings.System.getIntForUser(getContentResolver(), Settings.System.DIAMOND_ANIMATION_DURATION, 200, UserHandle.USER_CURRENT);
mDiamond.setValue(diam / 1);
mDiamond.setOnPreferenceChangeListener(this);
mDots = (SeekBarPreference) findPreference(PIXEL_DOTS);
int dots = Settings.System.getIntForUser(getContentResolver(), Settings.System.DOTS_RESIZE_DURATION, 200, UserHandle.USER_CURRENT);
mDots.setValue(dots / 1);
mDots.setOnPreferenceChangeListener(this);
mHome = (SeekBarPreference) findPreference(PIXEL_HOME);
int home = Settings.System.getIntForUser(getContentResolver(), Settings.System.HOME_RESIZE_DURATION, 255, UserHandle.USER_CURRENT);
mHome.setValue(home / 1);
mHome.setOnPreferenceChangeListener(this);
mColorCat = (PreferenceCategory) findPreference(COLOR_CAT);
mTopColor = (ColorPickerPreference) findPreference(TOP_COLOR);
mTopColor.setOnPreferenceChangeListener(this);
int top = Settings.System.getInt(mContentRes, Settings.System.DOT_TOP_COLOR, Color.RED);
String topHexColor = String.format("#%08x", (0x00ffffff & top));
mTopColor.setSummary(topHexColor);
mTopColor.setNewPreviewColor(top);
mBottomColor = (ColorPickerPreference) findPreference(BOTTOM_COLOR);
mBottomColor.setOnPreferenceChangeListener(this);
int bottom = Settings.System.getInt(mContentRes, Settings.System.DOT_BOTTOM_COLOR, Color.YELLOW);
String bottomHexColor = String.format("#%08x", (0x00ffffff & bottom));
mBottomColor.setSummary(bottomHexColor);
mBottomColor.setNewPreviewColor(bottom);
mRightColor = (ColorPickerPreference) findPreference(RIGHT_COLOR);
mRightColor.setOnPreferenceChangeListener(this);
int right = Settings.System.getInt(mContentRes, Settings.System.DOT_RIGHT_COLOR, Color.GREEN);
String rightHexColor = String.format("#%08x", (0x00ffffff & right));
mRightColor.setSummary(rightHexColor);
mRightColor.setNewPreviewColor(right);
mLeftColor = (ColorPickerPreference) findPreference(LEFT_COLOR);
mLeftColor.setOnPreferenceChangeListener(this);
int left = Settings.System.getInt(mContentRes, Settings.System.DOT_LEFT_COLOR, Color.RED);
String leftHexColor = String.format("#%08x", (0x00ffffff & left));
mLeftColor.setSummary(leftHexColor);
mLeftColor.setNewPreviewColor(left);
mColorStyle = (ListPreference) findPreference(COLOR_STYLE);
int style = Settings.System.getIntForUser(mContentRes, Settings.System.DOT_COLOR_SWITCH, 0, UserHandle.USER_CURRENT);
mColorStyle.setValue(String.valueOf(style));
mColorStyle.setSummary(mColorStyle.getEntry());
mColorStyle.setOnPreferenceChangeListener(this);
UpdateSettings(style);
}
Aggregations