improved profile image appearance

bug fixes
This commit is contained in:
Mariotaku Lee 2015-01-22 19:16:22 +08:00
parent 549f478806
commit d5a5c437aa
49 changed files with 843 additions and 868 deletions

View File

@ -43,6 +43,7 @@ import java.util.Date;
import twitter4j.CardEntity;
import twitter4j.CardEntity.BindingValue;
import twitter4j.CardEntity.BooleanValue;
import twitter4j.CardEntity.ImageValue;
import twitter4j.CardEntity.StringValue;
import twitter4j.CardEntity.UserValue;
@ -767,13 +768,16 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
this.name = in.readString("name");
this.type = in.readString("type");
switch (type) {
case "STRING":
case BindingValue.TYPE_STRING:
value = in.readString("value");
break;
case "IMAGE":
case BindingValue.TYPE_BOOLEAN:
value = in.readBoolean("value");
break;
case BindingValue.TYPE_IMAGE:
value = in.readParcelable("value", ParcelableImageValue.JSON_CREATOR);
break;
case "USER":
case BindingValue.TYPE_USER:
value = in.readParcelable("value", ParcelableUserValue.JSON_CREATOR);
break;
default:
@ -791,13 +795,16 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
name = bindingValue.getName();
type = bindingValue.getType();
switch (type) {
case "STRING":
case BindingValue.TYPE_STRING:
value = ((StringValue) bindingValue).getValue();
break;
case "IMAGE":
case BindingValue.TYPE_BOOLEAN:
value = ((BooleanValue) bindingValue).getValue();
break;
case BindingValue.TYPE_IMAGE:
value = new ParcelableImageValue((ImageValue) bindingValue);
break;
case "USER":
case BindingValue.TYPE_USER:
value = new ParcelableUserValue((UserValue) bindingValue);
break;
default:

View File

@ -36,6 +36,11 @@ public interface CardEntity extends Serializable {
public interface BindingValue extends Serializable {
public static final String TYPE_STRING = "STRING";
public static final String TYPE_IMAGE = "IMAGE";
public static final String TYPE_USER = "USER";
public static final String TYPE_BOOLEAN = "BOOLEAN";
String getName();
String getType();
@ -50,6 +55,10 @@ public interface CardEntity extends Serializable {
String getValue();
}
public interface BooleanValue extends BindingValue {
boolean getValue();
}
public interface ImageValue extends BindingValue {
int getWidth();

View File

@ -98,12 +98,14 @@ public class CardEntityJSONImpl implements CardEntity {
private static BindingValue valueOf(String name, JSONObject json) throws JSONException {
final String type = json.optString("type");
if ("STRING".equals(type)) {
if (TYPE_STRING.equals(type)) {
return new StringValueImpl(name, json);
} else if ("IMAGE".equals(type)) {
} else if (TYPE_IMAGE.equals(type)) {
return new ImageValueImpl(name, json);
} else if ("USER".equals(type)) {
} else if (TYPE_USER.equals(type)) {
return new UserValueImpl(name, json);
} else if (TYPE_BOOLEAN.equals(type)) {
return new BooleanValueImpl(name, json);
}
throw new UnsupportedOperationException(String.format("Unsupported type %s", type));
}
@ -158,6 +160,30 @@ public class CardEntityJSONImpl implements CardEntity {
}
}
private static final class BooleanValueImpl extends BindingValueImpl implements BooleanValue {
@Override
public String toString() {
return "BooleanValueImpl{" +
"value=" + value +
'}';
}
private final boolean value;
BooleanValueImpl(String name, JSONObject json) throws JSONException {
super(name, json);
this.value = json.getBoolean("boolean_value");
}
@Override
public boolean getValue() {
return value;
}
}
private static final class StringValueImpl extends BindingValueImpl implements StringValue {
private final String value;

View File

@ -7,7 +7,7 @@ android {
defaultConfig {
applicationId "org.mariotaku.twidere"
minSdkVersion 14
minSdkVersion 21
targetSdkVersion 21
versionCode 99
versionName "0.3.0-dev"
@ -32,10 +32,10 @@ android {
}
productFlavors {
google {
versionName = android.defaultConfig.versionName + '-google'
versionName = versionName + '-google'
}
fdroid {
versionName = android.defaultConfig.versionName + '-fdroid'
versionName = versionName + '-fdroid'
}
}
}

View File

@ -52,7 +52,6 @@ import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.Action;
import android.support.v4.util.LongSparseArray;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.ActionMenuView.OnMenuItemClickListener;
import android.support.v7.widget.LinearLayoutManager;
@ -88,8 +87,6 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.fragment.support.BaseSupportDialogFragment;
import org.mariotaku.twidere.graphic.ActionIconDrawable;
import org.mariotaku.twidere.menu.ComposeAccountActionProvider;
import org.mariotaku.twidere.menu.ComposeAccountActionProvider.InvokedListener;
import org.mariotaku.twidere.model.DraftItem;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableLocation;
@ -116,6 +113,7 @@ import org.mariotaku.twidere.util.UserColorNameUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.accessor.ViewAccessor;
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
import org.mariotaku.twidere.view.BadgeView;
import org.mariotaku.twidere.view.ShapedImageView;
import org.mariotaku.twidere.view.StatusTextCountView;
import org.mariotaku.twidere.view.holder.StatusViewHolder;
@ -150,7 +148,7 @@ import static org.mariotaku.twidere.util.Utils.showErrorMessage;
import static org.mariotaku.twidere.util.Utils.showMenuItemToast;
public class ComposeActivity extends ThemedActionBarActivity implements TextWatcher, LocationListener,
OnMenuItemClickListener, OnClickListener, OnEditorActionListener, OnLongClickListener, InvokedListener {
OnMenuItemClickListener, View.OnClickListener, OnEditorActionListener, OnLongClickListener {
private static final String FAKE_IMAGE_LINK = "https://www.example.com/fake_image.jpg";
@ -188,14 +186,16 @@ public class ComposeActivity extends ThemedActionBarActivity implements TextWatc
private long mInReplyToStatusId;
private String mOriginalText;
private AccountIconsAdapter mAccountsAdapter;
private ComposeAccountActionProvider mAccountActionProvider;
private ShapedImageView mProfileImageView;
private BadgeView mCountView;
private View mAccountSelectorButton;
private ImageLoaderWrapper mImageLoader;
@Override
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
}
@Override
public void onInvoked() {
final boolean isVisible = mAccountSelectorContainer.getVisibility() == View.VISIBLE;
mAccountSelectorContainer.setVisibility(isVisible ? View.GONE : View.VISIBLE);
@ -433,6 +433,11 @@ public class ComposeActivity extends ThemedActionBarActivity implements TextWatc
setAccountSelectorVisible(false);
break;
}
case R.id.account_selector_button: {
final boolean isVisible = mAccountSelectorContainer.getVisibility() == View.VISIBLE;
mAccountSelectorContainer.setVisibility(isVisible ? View.GONE : View.VISIBLE);
break;
}
}
}
@ -514,6 +519,9 @@ public class ComposeActivity extends ThemedActionBarActivity implements TextWatc
mSendTextCountView = (StatusTextCountView) mSendView.findViewById(R.id.status_text_count);
mAccountSelector = (RecyclerView) findViewById(R.id.account_selector);
mAccountSelectorContainer = findViewById(R.id.account_selector_container);
mProfileImageView = (ShapedImageView) findViewById(R.id.account_profile_image);
mCountView = (BadgeView) findViewById(R.id.accounts_count);
mAccountSelectorButton = findViewById(R.id.account_selector_button);
ViewAccessor.setBackground(findViewById(R.id.compose_content), getWindowContentOverlayForCompose(this));
}
@ -544,9 +552,12 @@ public class ComposeActivity extends ThemedActionBarActivity implements TextWatc
super.onCreate(savedInstanceState);
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mPreferences = SharedPreferencesWrapper.getInstance(this, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
mTwitterWrapper = TwidereApplication.getInstance(this).getTwitterWrapper();
final TwidereApplication app = TwidereApplication.getInstance(this);
mTwitterWrapper = app.getTwitterWrapper();
mResolver = getContentResolver();
mValidator = new TwidereValidator(this);
mImageLoader = app.getImageLoaderWrapper();
setContentView(R.layout.activity_compose);
setProgressBarIndeterminateVisibility(false);
setFinishOnTouchOutside(false);
@ -563,6 +574,7 @@ public class ComposeActivity extends ThemedActionBarActivity implements TextWatc
mEditText.setOnEditorActionListener(mPreferences.getBoolean(KEY_QUICK_SEND, false) ? this : null);
mEditText.addTextChangedListener(this);
mAccountSelectorContainer.setOnClickListener(this);
mAccountSelectorButton.setOnClickListener(this);
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
@ -619,8 +631,6 @@ public class ComposeActivity extends ThemedActionBarActivity implements TextWatc
final Menu menu = mMenuBar.getMenu();
getMenuInflater().inflate(R.menu.menu_compose, menu);
mAccountActionProvider = (ComposeAccountActionProvider) MenuItemCompat.getActionProvider(menu.findItem(MENU_SELECT_ACCOUNT));
mAccountActionProvider.setInvokedListener(this);
ThemeUtils.wrapMenuIcon(mMenuBar);
mSendView.setOnClickListener(this);
@ -637,6 +647,20 @@ public class ComposeActivity extends ThemedActionBarActivity implements TextWatc
notifyAccountSelectionChanged();
}
public void setSelectedAccounts(ParcelableAccount... accounts) {
if (accounts.length == 1) {
mCountView.setText(null);
final ParcelableAccount account = accounts[0];
mImageLoader.displayProfileImage(mProfileImageView, account.profile_image_url);
mProfileImageView.setBorderColor(account.color);
} else {
mCountView.setText(String.valueOf(accounts.length));
mImageLoader.cancelDisplayTask(mProfileImageView);
mProfileImageView.setImageDrawable(null);
mProfileImageView.setBorderColors(Utils.getAccountColors(accounts));
}
}
@Override
protected void onStart() {
super.onStart();
@ -1228,7 +1252,8 @@ public class ComposeActivity extends ThemedActionBarActivity implements TextWatc
}
private void notifyAccountSelectionChanged() {
mAccountActionProvider.setSelectedAccounts(mAccountsAdapter.getSelectedAccounts());
setSelectedAccounts(mAccountsAdapter.getSelectedAccounts());
// mAccountActionProvider.setSelectedAccounts(mAccountsAdapter.getSelectedAccounts());
}
private static class AddBitmapTask extends AddMediaTask {

View File

@ -26,7 +26,6 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.database.ContentObserver;
import android.graphics.Canvas;
import android.graphics.PorterDuff.Mode;
@ -41,14 +40,12 @@ import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.NotificationCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v7.widget.Toolbar;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
@ -59,7 +56,6 @@ import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
@ -119,14 +115,12 @@ import static org.mariotaku.twidere.util.Utils.getTabDisplayOptionInt;
import static org.mariotaku.twidere.util.Utils.isDatabaseReady;
import static org.mariotaku.twidere.util.Utils.openDirectMessagesConversation;
import static org.mariotaku.twidere.util.Utils.openSearch;
import static org.mariotaku.twidere.util.Utils.setMenuItemAvailability;
import static org.mariotaku.twidere.util.Utils.showMenuItemToast;
public class HomeActivity extends BaseSupportActivity implements OnClickListener, OnPageChangeListener,
SupportFragmentCallback, SlidingMenu.OnOpenedListener, SlidingMenu.OnClosedListener,
OnLongClickListener {
private final Handler mHandler = new Handler();
private final ContentObserver mAccountChangeObserver = new AccountChangeObserver(this, mHandler);
@ -149,7 +143,6 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
private TabPagerIndicator mTabIndicator;
private HomeSlidingMenu mSlidingMenu;
private View mEmptyTabHint;
private ProgressBar mSmartBarProgress;
private View mActionsButton;
private View mTabsContainer;
private View mActionBarOverlay;
@ -174,12 +167,25 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
return mCurrentVisibleFragment;
}
public SlidingMenu getSlidingMenu() {
return mSlidingMenu;
@Override
public void onDetachFragment(final Fragment fragment) {
if (fragment instanceof IBaseFragment && ((IBaseFragment) fragment).getTabPosition() != -1) {
mAttachedFragments.remove(((IBaseFragment) fragment).getTabPosition());
}
}
public ViewPager getViewPager() {
return mViewPager;
@Override
public void onSetUserVisibleHint(final Fragment fragment, final boolean isVisibleToUser) {
if (isVisibleToUser) {
mCurrentVisibleFragment = fragment;
}
}
@Override
public boolean triggerRefresh(final int position) {
final Fragment f = mAttachedFragments.get(position);
return f instanceof RefreshScrollTopInterface && !f.isDetached()
&& ((RefreshScrollTopInterface) f).triggerRefresh();
}
@Override
@ -189,130 +195,13 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
notifyControlBarOffsetChanged();
}
public void notifyAccountsChanged() {
if (mPreferences == null) return;
final long[] account_ids = getAccountIds(this);
final long default_id = mPreferences.getLong(KEY_DEFAULT_ACCOUNT_ID, -1);
if (account_ids == null || account_ids.length == 0) {
finish();
} else if (account_ids.length > 0 && !ArrayUtils.contains(account_ids, default_id)) {
mPreferences.edit().putLong(KEY_DEFAULT_ACCOUNT_ID, account_ids[0]).apply();
}
public SlidingMenu getSlidingMenu() {
return mSlidingMenu;
}
@Override
public void onAttachFragment(final Fragment fragment) {
if (fragment instanceof IBaseFragment && ((IBaseFragment) fragment).getTabPosition() != -1) {
mAttachedFragments.put(((IBaseFragment) fragment).getTabPosition(), fragment);
}
}
@Override
public void onBackPressed() {
if (mSlidingMenu != null && mSlidingMenu.isMenuShowing()) {
mSlidingMenu.showContent();
return;
}
super.onBackPressed();
}
@Override
public void onClick(final View v) {
switch (v.getId()) {
case R.id.action_buttons: {
triggerActionsClick();
break;
}
}
}
@Subscribe
public void notifyTaskStateChanged(TaskStateChangedEvent event) {
updateActionsButton();
updateSmartBar();
}
@Subscribe
public void notifyUnreadCountUpdated(UnreadCountUpdatedEvent event) {
updateUnreadCount();
}
@Override
public void onClosed() {
updateDrawerPercentOpen(0, true);
}
@Override
public void onSupportContentChanged() {
super.onSupportContentChanged();
mActionBar = (Toolbar) findViewById(R.id.actionbar);
mTabIndicator = (TabPagerIndicator) findViewById(R.id.main_tabs);
mSlidingMenu = (HomeSlidingMenu) findViewById(R.id.home_menu);
mViewPager = (ExtendedViewPager) findViewById(R.id.main_pager);
mEmptyTabHint = findViewById(R.id.empty_tab_hint);
mActionsButton = findViewById(R.id.action_buttons);
mTabsContainer = findViewById(R.id.tabs_container);
mTabIndicator = (TabPagerIndicator) findViewById(R.id.main_tabs);
mActionBarOverlay = findViewById(R.id.actionbar_overlay);
mColorStatusFrameLayout = (TintedStatusFrameLayout) findViewById(R.id.home_content);
}
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_home, menu);
final MenuItem itemProgress = menu.findItem(MENU_PROGRESS);
mSmartBarProgress = (ProgressBar) MenuItemCompat.getActionView(itemProgress).findViewById(android.R.id.progress);
updateActionsButton();
return true;
}
@Override
public void onDetachFragment(final Fragment fragment) {
if (fragment instanceof IBaseFragment && ((IBaseFragment) fragment).getTabPosition() != -1) {
mAttachedFragments.remove(((IBaseFragment) fragment).getTabPosition());
}
}
@Override
public boolean getSystemWindowsInsets(Rect insets) {
final int height = mTabIndicator != null ? mTabIndicator.getHeight() : 0;
insets.top = height != 0 ? height : Utils.getActionBarHeight(this);
return true;
}
@Override
public boolean onKeyUp(final int keyCode, @NonNull final KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_MENU: {
if (mSlidingMenu != null) {
mSlidingMenu.toggle(true);
return true;
}
break;
}
default: {
if (mHotKeyHandler.handleKey(keyCode, event)) return true;
}
}
return super.onKeyUp(keyCode, event);
}
@Override
public boolean onLongClick(final View v) {
switch (v.getId()) {
case R.id.action_buttons: {
showMenuItemToast(v, v.getContentDescription(), true);
return true;
}
}
return false;
}
@Override
public void onOpened() {
updateDrawerPercentOpen(1, true);
public int getThemeResourceId() {
return ThemeUtils.getNoActionBarThemeResource(this);
}
@Override
@ -343,124 +232,6 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
return super.onOptionsItemSelected(item);
}
@Override
public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) {
final float pagerPosition = position + positionOffset;
if (!Float.isNaN(mPagerPosition)) {
setControlBarOffset(MathUtils.clamp(getControlBarOffset() + Math.abs(pagerPosition - mPagerPosition), 1, 0));
}
mPagerPosition = pagerPosition;
}
@Override
public void onPageScrollStateChanged(final int state) {
}
@Override
public void onPageSelected(final int position) {
if (mSlidingMenu.isMenuShowing()) {
mSlidingMenu.showContent();
}
updateSlidingMenuTouchMode();
updateActionsButton();
updateSmartBar();
}
@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
if (mViewPager == null || mPagerAdapter == null) return false;
final boolean useBottomActionItems = FlymeUtils.hasSmartBar();
setMenuItemAvailability(menu, MENU_ACTIONS, useBottomActionItems);
setMenuItemAvailability(menu, MENU_PROGRESS, useBottomActionItems);
if (useBottomActionItems) {
final int icon, title;
final int position = mViewPager.getCurrentItem();
final SupportTabSpec tab = mPagerAdapter.getTab(position);
if (tab == null) {
title = R.string.compose;
icon = R.drawable.ic_action_status_compose;
} else {
if (classEquals(DirectMessagesFragment.class, tab.cls)) {
icon = R.drawable.ic_action_add;
title = R.string.new_direct_message;
} else if (classEquals(TrendsSuggectionsFragment.class, tab.cls)) {
icon = R.drawable.ic_action_search;
title = android.R.string.search_go;
} else {
icon = R.drawable.ic_action_status_compose;
title = R.string.compose;
}
}
final MenuItem actionsItem = menu.findItem(MENU_ACTIONS);
actionsItem.setIcon(icon);
actionsItem.setTitle(title);
}
return true;
}
@Override
public boolean onSearchRequested() {
// final Bundle appSearchData = new Bundle();
// if (mSelectedAccountToSearch != null) {
// appSearchData.putLong(EXTRA_ACCOUNT_ID, mSelectedAccountToSearch.account_id);
// openSearch(this, mSelectedAccountToSearch.accountId, query);
// }
// startSearch(null, false, appSearchData, false);
final Intent intent = new Intent(this, QuickSearchBarActivity.class);
// intent.putExtra(EXTRA_ACCOUNT_ID, account.account_id);
startActivity(intent);
return true;
}
@Override
public void onSetUserVisibleHint(final Fragment fragment, final boolean isVisibleToUser) {
if (isVisibleToUser) {
mCurrentVisibleFragment = fragment;
}
}
@Override
public void onWindowFocusChanged(final boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (mSlidingMenu != null && mSlidingMenu.isMenuShowing()) {
updateDrawerPercentOpen(1, false);
} else {
updateDrawerPercentOpen(0, false);
}
}
public void openSearchView(final ParcelableAccount account) {
mSelectedAccountToSearch = account;
onSearchRequested();
}
@Override
public float getControlBarOffset() {
final float totalHeight = getControlBarHeight();
return 1 + mTabsContainer.getTranslationY() / totalHeight;
}
@Override
public int getControlBarHeight() {
return mTabIndicator.getHeight() - mTabIndicator.getStripHeight();
}
@Override
public boolean triggerRefresh(final int position) {
final Fragment f = mAttachedFragments.get(position);
return f instanceof RefreshScrollTopInterface && !f.isDetached()
&& ((RefreshScrollTopInterface) f).triggerRefresh();
}
public void updateUnreadCount() {
if (mTabIndicator == null || mUpdateUnreadCountTask != null
&& mUpdateUnreadCountTask.getStatus() == TwidereAsyncTask.Status.RUNNING) return;
mUpdateUnreadCountTask = new UpdateUnreadCountTask(mTabIndicator);
mUpdateUnreadCountTask.executeTask();
mTabIndicator.setDisplayBadge(mPreferences.getBoolean(KEY_UNREAD_COUNT, true));
}
@Override
protected IBasePullToRefreshFragment getCurrentPullToRefreshFragment() {
if (mCurrentVisibleFragment instanceof IBasePullToRefreshFragment)
@ -473,28 +244,11 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
return null;
}
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
switch (requestCode) {
case REQUEST_SWIPEBACK_ACTIVITY: {
// closeAccountsDrawer();
return;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public int getThemeResourceId() {
return ThemeUtils.getNoActionBarThemeResource(this);
}
/**
* Called when the context is first created.
*/
@Override
protected void onCreate(final Bundle savedInstanceState) {
setUiOptions(getWindow());
final Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
@ -568,57 +322,6 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
setupHomeTabs();
}
private void setupBars() {
final int themeColor = getThemeColor();
final int themeResId = getCurrentThemeResourceId();
final boolean isTransparent = ThemeUtils.isTransparentBackground(themeResId);
final int actionBarAlpha = isTransparent ? ThemeUtils.getUserThemeBackgroundAlpha(this) : 0xFF;
final IHomeActionButton homeActionButton = (IHomeActionButton) mActionsButton;
mTabIndicator.setItemContext(ThemeUtils.getActionBarContext(this));
if (ThemeUtils.isColoredActionBar(themeResId)) {
final int contrastColor = ColorUtils.getContrastYIQ(themeColor, 192);
ViewAccessor.setBackground(mActionBar, new ColorDrawable(themeColor));
homeActionButton.setButtonColor(themeColor);
homeActionButton.setIconColor(contrastColor, Mode.SRC_ATOP);
mTabIndicator.setStripColor(contrastColor);
mTabIndicator.setIconColor(contrastColor);
ActivityAccessor.setTaskDescription(this, new TaskDescriptionCompat(null, null, themeColor));
mColorStatusFrameLayout.setDrawColor(true);
mColorStatusFrameLayout.setDrawShadow(false);
mColorStatusFrameLayout.setColor(themeColor, actionBarAlpha);
mColorStatusFrameLayout.setFactor(1);
} else {
final int backgroundColor = ThemeUtils.getThemeBackgroundColor(mTabIndicator.getItemContext());
final int foregroundColor = ThemeUtils.getThemeForegroundColor(mTabIndicator.getItemContext());
ViewAccessor.setBackground(mActionBar, ThemeUtils.getActionBarBackground(this, themeResId));
homeActionButton.setButtonColor(backgroundColor);
homeActionButton.setIconColor(foregroundColor, Mode.SRC_ATOP);
mTabIndicator.setStripColor(themeColor);
mTabIndicator.setIconColor(foregroundColor);
mColorStatusFrameLayout.setDrawColor(false);
mColorStatusFrameLayout.setDrawShadow(false);
}
mTabIndicator.setAlpha(actionBarAlpha / 255f);
mActionsButton.setAlpha(actionBarAlpha / 255f);
ViewAccessor.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
}
@Override
protected void onDestroy() {
// Delete unused items in databases.
cleanDatabasesByItemLimit(this);
sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONDESTROY));
super.onDestroy();
}
@Override
protected void onNewIntent(final Intent intent) {
final int tab_position = handleIntent(intent, false);
if (tab_position >= 0) {
mViewPager.setCurrentItem(MathUtils.clamp(tab_position, mPagerAdapter.getCount(), 0));
}
}
@Override
protected void onPause() {
sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONPAUSE));
@ -668,6 +371,218 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
super.onStop();
}
@Override
public boolean getSystemWindowsInsets(Rect insets) {
final int height = mTabIndicator != null ? mTabIndicator.getHeight() : 0;
insets.top = height != 0 ? height : Utils.getActionBarHeight(this);
return true;
}
public ViewPager getViewPager() {
return mViewPager;
}
public void notifyAccountsChanged() {
if (mPreferences == null) return;
final long[] account_ids = getAccountIds(this);
final long default_id = mPreferences.getLong(KEY_DEFAULT_ACCOUNT_ID, -1);
if (account_ids == null || account_ids.length == 0) {
finish();
} else if (account_ids.length > 0 && !ArrayUtils.contains(account_ids, default_id)) {
mPreferences.edit().putLong(KEY_DEFAULT_ACCOUNT_ID, account_ids[0]).apply();
}
}
@Subscribe
public void notifyTaskStateChanged(TaskStateChangedEvent event) {
updateActionsButton();
updateSmartBar();
}
@Subscribe
public void notifyUnreadCountUpdated(UnreadCountUpdatedEvent event) {
updateUnreadCount();
}
@Override
public void onClick(final View v) {
switch (v.getId()) {
case R.id.action_buttons: {
triggerActionsClick();
break;
}
}
}
@Override
public void onClosed() {
updateDrawerPercentOpen(0, true);
}
@Override
public boolean onKeyUp(final int keyCode, @NonNull final KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_MENU: {
if (mSlidingMenu != null) {
mSlidingMenu.toggle(true);
return true;
}
break;
}
default: {
if (mHotKeyHandler.handleKey(keyCode, event)) return true;
}
}
return super.onKeyUp(keyCode, event);
}
@Override
public void onWindowFocusChanged(final boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (mSlidingMenu != null && mSlidingMenu.isMenuShowing()) {
updateDrawerPercentOpen(1, false);
} else {
updateDrawerPercentOpen(0, false);
}
}
@Override
public boolean onSearchRequested() {
startActivity(new Intent(this, QuickSearchBarActivity.class));
return true;
}
@Override
public boolean onLongClick(final View v) {
switch (v.getId()) {
case R.id.action_buttons: {
showMenuItemToast(v, v.getContentDescription(), true);
return true;
}
}
return false;
}
@Override
public void onOpened() {
updateDrawerPercentOpen(1, true);
}
@Override
public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) {
final float pagerPosition = position + positionOffset;
if (!Float.isNaN(mPagerPosition)) {
setControlBarOffset(MathUtils.clamp(getControlBarOffset() + Math.abs(pagerPosition - mPagerPosition), 1, 0));
}
mPagerPosition = pagerPosition;
}
@Override
public float getControlBarOffset() {
final float totalHeight = getControlBarHeight();
return 1 + mTabsContainer.getTranslationY() / totalHeight;
}
@Override
public void onPageSelected(final int position) {
if (mSlidingMenu.isMenuShowing()) {
mSlidingMenu.showContent();
}
updateSlidingMenuTouchMode();
updateActionsButton();
updateSmartBar();
}
@Override
public int getControlBarHeight() {
return mTabIndicator.getHeight() - mTabIndicator.getStripHeight();
}
@Override
public void onPageScrollStateChanged(final int state) {
}
public void openSearchView(final ParcelableAccount account) {
mSelectedAccountToSearch = account;
onSearchRequested();
}
public void setSystemWindowInsets(Rect insets) {
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.left_drawer);
if (fragment instanceof AccountsDashboardFragment) {
((AccountsDashboardFragment) fragment).setStatusBarHeight(insets.top);
}
//TODO
mColorStatusFrameLayout.setStatusBarHeight(insets.top);
}
public void updateUnreadCount() {
if (mTabIndicator == null || mUpdateUnreadCountTask != null
&& mUpdateUnreadCountTask.getStatus() == TwidereAsyncTask.Status.RUNNING) return;
mUpdateUnreadCountTask = new UpdateUnreadCountTask(mTabIndicator);
mUpdateUnreadCountTask.executeTask();
mTabIndicator.setDisplayBadge(mPreferences.getBoolean(KEY_UNREAD_COUNT, true));
}
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
switch (requestCode) {
case REQUEST_SWIPEBACK_ACTIVITY: {
// closeAccountsDrawer();
return;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onNewIntent(final Intent intent) {
final int tab_position = handleIntent(intent, false);
if (tab_position >= 0) {
mViewPager.setCurrentItem(MathUtils.clamp(tab_position, mPagerAdapter.getCount(), 0));
}
}
@Override
public void onAttachFragment(final Fragment fragment) {
if (fragment instanceof IBaseFragment && ((IBaseFragment) fragment).getTabPosition() != -1) {
mAttachedFragments.put(((IBaseFragment) fragment).getTabPosition(), fragment);
}
}
@Override
protected void onDestroy() {
// Delete unused items in databases.
cleanDatabasesByItemLimit(this);
sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONDESTROY));
super.onDestroy();
}
@Override
public void onBackPressed() {
if (mSlidingMenu != null && mSlidingMenu.isMenuShowing()) {
mSlidingMenu.showContent();
return;
}
super.onBackPressed();
}
@Override
public void onSupportContentChanged() {
super.onSupportContentChanged();
mActionBar = (Toolbar) findViewById(R.id.actionbar);
mTabIndicator = (TabPagerIndicator) findViewById(R.id.main_tabs);
mSlidingMenu = (HomeSlidingMenu) findViewById(R.id.home_menu);
mViewPager = (ExtendedViewPager) findViewById(R.id.main_pager);
mEmptyTabHint = findViewById(R.id.empty_tab_hint);
mActionsButton = findViewById(R.id.action_buttons);
mTabsContainer = findViewById(R.id.tabs_container);
mTabIndicator = (TabPagerIndicator) findViewById(R.id.main_tabs);
mActionBarOverlay = findViewById(R.id.actionbar_overlay);
mColorStatusFrameLayout = (TintedStatusFrameLayout) findViewById(R.id.home_content);
}
@Override
protected boolean shouldSetWindowBackground() {
return false;
@ -717,14 +632,6 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
return mTwitterWrapper.hasActivatedTask();
}
private void setupHomeTabs() {
mPagerAdapter.clear();
mPagerAdapter.addTabs(getHomeTabs(this));
final boolean hasNoTab = mPagerAdapter.getCount() == 0;
mEmptyTabHint.setVisibility(hasNoTab ? View.VISIBLE : View.GONE);
mViewPager.setVisibility(hasNoTab ? View.GONE : View.VISIBLE);
}
private void initUnreadCount() {
for (int i = 0, j = mTabIndicator.getCount(); i < j; i++) {
mTabIndicator.setBadge(i, 0);
@ -753,10 +660,47 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
}
}
private void setUiOptions(final Window window) {
if (FlymeUtils.hasSmartBar()) {
window.setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
private void setupBars() {
final int themeColor = getThemeColor();
final int themeResId = getCurrentThemeResourceId();
final boolean isTransparent = ThemeUtils.isTransparentBackground(themeResId);
final int actionBarAlpha = isTransparent ? ThemeUtils.getUserThemeBackgroundAlpha(this) : 0xFF;
final IHomeActionButton homeActionButton = (IHomeActionButton) mActionsButton;
mTabIndicator.setItemContext(ThemeUtils.getActionBarContext(this));
if (ThemeUtils.isColoredActionBar(themeResId)) {
final int contrastColor = ColorUtils.getContrastYIQ(themeColor, 192);
ViewAccessor.setBackground(mActionBar, new ColorDrawable(themeColor));
homeActionButton.setButtonColor(themeColor);
homeActionButton.setIconColor(contrastColor, Mode.SRC_ATOP);
mTabIndicator.setStripColor(contrastColor);
mTabIndicator.setIconColor(contrastColor);
ActivityAccessor.setTaskDescription(this, new TaskDescriptionCompat(null, null, themeColor));
mColorStatusFrameLayout.setDrawColor(true);
mColorStatusFrameLayout.setDrawShadow(false);
mColorStatusFrameLayout.setColor(themeColor, actionBarAlpha);
mColorStatusFrameLayout.setFactor(1);
} else {
final int backgroundColor = ThemeUtils.getThemeBackgroundColor(mTabIndicator.getItemContext());
final int foregroundColor = ThemeUtils.getThemeForegroundColor(mTabIndicator.getItemContext());
ViewAccessor.setBackground(mActionBar, ThemeUtils.getActionBarBackground(this, themeResId));
homeActionButton.setButtonColor(backgroundColor);
homeActionButton.setIconColor(foregroundColor, Mode.SRC_ATOP);
mTabIndicator.setStripColor(themeColor);
mTabIndicator.setIconColor(foregroundColor);
mColorStatusFrameLayout.setDrawColor(false);
mColorStatusFrameLayout.setDrawShadow(false);
}
mTabIndicator.setAlpha(actionBarAlpha / 255f);
mActionsButton.setAlpha(actionBarAlpha / 255f);
ViewAccessor.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
}
private void setupHomeTabs() {
mPagerAdapter.clear();
mPagerAdapter.addTabs(getHomeTabs(this));
final boolean hasNoTab = mPagerAdapter.getCount() == 0;
mEmptyTabHint.setVisibility(hasNoTab ? View.VISIBLE : View.GONE);
mViewPager.setVisibility(hasNoTab ? View.GONE : View.VISIBLE);
}
private void setupSlidingMenu() {
@ -846,10 +790,6 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
final IHomeActionButton hab = (IHomeActionButton) mActionsButton;
hab.setIcon(icon);
hab.setTitle(title);
// hab.setShowProgress(hasActivatedTask);
}
if (mSmartBarProgress != null) {
mSmartBarProgress.setVisibility(hasActivatedTask ? View.VISIBLE : View.INVISIBLE);
}
}
@ -883,31 +823,6 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
}
}
public void moveControlBarBy(float delta) {
final int min = -getControlBarHeight(), max = 0;
mTabsContainer.setTranslationY(MathUtils.clamp(mTabsContainer.getTranslationY() + delta, max, min));
final ViewGroup.LayoutParams ablp = mActionsButton.getLayoutParams();
final int totalHeight;
if (ablp instanceof MarginLayoutParams) {
final MarginLayoutParams mlp = (MarginLayoutParams) ablp;
totalHeight = mActionsButton.getHeight() + mlp.topMargin + mlp.bottomMargin;
} else {
totalHeight = mActionsButton.getHeight();
}
mActionsButton.setTranslationY(MathUtils.clamp(mActionsButton.getTranslationY() - delta, totalHeight, 0));
notifyControlBarOffsetChanged();
}
public void setSystemWindowInsets(Rect insets) {
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.left_drawer);
if (fragment instanceof AccountsDashboardFragment) {
((AccountsDashboardFragment) fragment).setStatusBarHeight(insets.top);
}
//TODO
mColorStatusFrameLayout.setStatusBarHeight(insets.top);
}
private static final class AccountChangeObserver extends ContentObserver {
private final HomeActivity mActivity;
@ -972,4 +887,19 @@ public class HomeActivity extends BaseSupportActivity implements OnClickListener
}
public void moveControlBarBy(float delta) {
final int min = -getControlBarHeight(), max = 0;
mTabsContainer.setTranslationY(MathUtils.clamp(mTabsContainer.getTranslationY() + delta, max, min));
final ViewGroup.LayoutParams ablp = mActionsButton.getLayoutParams();
final int totalHeight;
if (ablp instanceof MarginLayoutParams) {
final MarginLayoutParams mlp = (MarginLayoutParams) ablp;
totalHeight = mActionsButton.getHeight() + mlp.topMargin + mlp.bottomMargin;
} else {
totalHeight = mActionsButton.getHeight();
}
mActionsButton.setTranslationY(MathUtils.clamp(mActionsButton.getTranslationY() - delta, totalHeight, 0));
notifyControlBarOffsetChanged();
}
}

View File

@ -28,11 +28,11 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
@ -100,6 +100,7 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
private boolean mUserInfoLoaderInitialized;
private boolean mGetUserInfoCalled;
private Toolbar mToolbar;
@Override
public void beforeTextChanged(final CharSequence s, final int length, final int start, final int end) {
@ -114,6 +115,78 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
public void afterTextChanged(final Editable s) {
}
@Override
public int getThemeResourceId() {
return ThemeUtils.getNoActionBarThemeResource(this);
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = getIntent();
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
if (!isMyAccount(this, accountId)) {
finish();
return;
}
mAsyncTaskManager = TwidereApplication.getInstance(this).getAsyncTaskManager();
mLazyImageLoader = TwidereApplication.getInstance(this).getImageLoaderWrapper();
mAccountId = accountId;
setContentView(R.layout.activity_user_profile_editor);
setSupportActionBar(mToolbar);
ViewAccessor.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
ViewAccessor.setBackground(mToolbar, ThemeUtils.getActionBarBackground(mToolbar.getContext(),
getCurrentThemeResourceId()));
// setOverrideExitAniamtion(false);
mEditName.addTextChangedListener(this);
mEditDescription.addTextChangedListener(this);
mEditLocation.addTextChangedListener(this);
mEditUrl.addTextChangedListener(this);
mProfileImageView.setOnClickListener(this);
mProfileBannerView.setOnClickListener(this);
mProfileImageCamera.setOnClickListener(this);
mProfileImageGallery.setOnClickListener(this);
mProfileBannerGallery.setOnClickListener(this);
mProfileBannerRemove.setOnClickListener(this);
mCancelButton.setOnClickListener(this);
mDoneButton.setOnClickListener(this);
mSetLinkColor.setOnClickListener(this);
mSetBackgroundColor.setOnClickListener(this);
if (savedInstanceState != null && savedInstanceState.getParcelable(EXTRA_USER) != null) {
final ParcelableUser user = savedInstanceState.getParcelable(EXTRA_USER);
displayUser(user);
mEditName.setText(savedInstanceState.getString(EXTRA_NAME, user.name));
mEditLocation.setText(savedInstanceState.getString(EXTRA_LOCATION, user.location));
mEditDescription.setText(savedInstanceState.getString(EXTRA_DESCRIPTION, user.description_expanded));
mEditUrl.setText(savedInstanceState.getString(EXTRA_URL, user.url_expanded));
} else {
getUserInfo();
}
}
@Override
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(EXTRA_USER, mUser);
outState.putString(EXTRA_NAME, ParseUtils.parseString(mEditName.getText()));
outState.putString(EXTRA_DESCRIPTION, ParseUtils.parseString(mEditDescription.getText()));
outState.putString(EXTRA_LOCATION, ParseUtils.parseString(mEditLocation.getText()));
outState.putString(EXTRA_URL, ParseUtils.parseString(mEditUrl.getText()));
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
public void onClick(final View view) {
final ParcelableUser user = mUser;
@ -184,9 +257,37 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
}
}
@Override
public Loader<SingleResponse<ParcelableUser>> onCreateLoader(final int id, final Bundle args) {
mProgressContainer.setVisibility(View.VISIBLE);
mContent.setVisibility(View.GONE);
return new ParcelableUserLoader(UserProfileEditorActivity.this, mAccountId, mAccountId, null, getIntent()
.getExtras(), false, false);
}
@Override
public void onLoadFinished(final Loader<SingleResponse<ParcelableUser>> loader,
final SingleResponse<ParcelableUser> data) {
if (data.getData() != null && data.getData().id > 0) {
displayUser(data.getData());
} else if (mUser == null) {
finish();
}
}
@Override
public void onLoaderReset(final Loader<SingleResponse<ParcelableUser>> loader) {
}
@Override
public void onSizeChanged(final View view, final int w, final int h, final int oldw, final int oldh) {
}
@Override
public void onSupportContentChanged() {
super.onSupportContentChanged();
mToolbar = (Toolbar) findViewById(R.id.done_bar);
mProgressContainer = findViewById(R.id.progress_container);
mContent = findViewById(R.id.content);
mProfileBannerView = (ImageView) findViewById(R.id.profile_banner);
@ -208,35 +309,6 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
mSetBackgroundColor = findViewById(R.id.set_background_color);
}
@Override
public Loader<SingleResponse<ParcelableUser>> onCreateLoader(final int id, final Bundle args) {
mProgressContainer.setVisibility(View.VISIBLE);
mContent.setVisibility(View.GONE);
setProgressBarIndeterminateVisibility(true);
return new ParcelableUserLoader(UserProfileEditorActivity.this, mAccountId, mAccountId, null, getIntent()
.getExtras(), false, false);
}
@Override
public void onLoadFinished(final Loader<SingleResponse<ParcelableUser>> loader,
final SingleResponse<ParcelableUser> data) {
if (data.getData() != null && data.getData().id > 0) {
displayUser(data.getData());
} else if (mUser == null) {
finish();
}
setProgressBarIndeterminateVisibility(false);
}
@Override
public void onLoaderReset(final Loader<SingleResponse<ParcelableUser>> loader) {
}
@Override
public void onSizeChanged(final View view, final int w, final int h, final int oldw, final int oldh) {
}
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
if (resultCode == RESULT_CANCELED) return;
@ -269,71 +341,6 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
final Intent intent = getIntent();
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
if (!isMyAccount(this, accountId)) {
finish();
return;
}
mAsyncTaskManager = TwidereApplication.getInstance(this).getAsyncTaskManager();
mLazyImageLoader = TwidereApplication.getInstance(this).getImageLoaderWrapper();
mAccountId = accountId;
setContentView(R.layout.activity_user_profile_editor);
ViewAccessor.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
// setOverrideExitAniamtion(false);
mEditName.addTextChangedListener(this);
mEditDescription.addTextChangedListener(this);
mEditLocation.addTextChangedListener(this);
mEditUrl.addTextChangedListener(this);
mProfileImageView.setOnClickListener(this);
mProfileBannerView.setOnClickListener(this);
mProfileImageCamera.setOnClickListener(this);
mProfileImageGallery.setOnClickListener(this);
mProfileBannerGallery.setOnClickListener(this);
mProfileBannerRemove.setOnClickListener(this);
mCancelButton.setOnClickListener(this);
mDoneButton.setOnClickListener(this);
mSetLinkColor.setOnClickListener(this);
mSetBackgroundColor.setOnClickListener(this);
if (savedInstanceState != null && savedInstanceState.getParcelable(EXTRA_USER) != null) {
final ParcelableUser user = savedInstanceState.getParcelable(EXTRA_USER);
displayUser(user);
mEditName.setText(savedInstanceState.getString(EXTRA_NAME, user.name));
mEditLocation.setText(savedInstanceState.getString(EXTRA_LOCATION, user.location));
mEditDescription.setText(savedInstanceState.getString(EXTRA_DESCRIPTION, user.description_expanded));
mEditUrl.setText(savedInstanceState.getString(EXTRA_URL, user.url_expanded));
} else {
getUserInfo();
}
}
@Override
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(EXTRA_USER, mUser);
outState.putString(EXTRA_NAME, ParseUtils.parseString(mEditName.getText()));
outState.putString(EXTRA_DESCRIPTION, ParseUtils.parseString(mEditDescription.getText()));
outState.putString(EXTRA_LOCATION, ParseUtils.parseString(mEditLocation.getText()));
outState.putString(EXTRA_URL, ParseUtils.parseString(mEditUrl.getText()));
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
super.onStop();
}
boolean isProfileChanged() {
final ParcelableUser user = mUser;
if (user == null) return true;
@ -389,7 +396,6 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
}
private void setUpdateState(final boolean start) {
setProgressBarIndeterminateVisibility(start);
mEditName.setEnabled(!start);
mEditDescription.setEnabled(!start);
mEditLocation.setEnabled(!start);
@ -443,26 +449,6 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
mBackgroundColor = backgroundColor;
}
private boolean isColorChanged() {
final ParcelableUser orig = mOriginal;
if (orig == null) return true;
if (mLinkColor != orig.link_color) return true;
if (mBackgroundColor != orig.background_color) return true;
return false;
}
private boolean isProfileChanged() {
final ParcelableUser orig = mOriginal;
if (orig == null) return true;
if (!stringEquals(mName, orig.name)) return true;
if (!stringEquals(mDescription, isEmpty(orig.description_expanded) ? orig.description_plain : orig.description_expanded))
return true;
if (!stringEquals(mLocation, orig.location)) return true;
if (!stringEquals(mUrl, isEmpty(orig.url_expanded) ? orig.url : orig.url_expanded))
return true;
return false;
}
@Override
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
final Twitter twitter = getTwitterInstance(mActivity, mAccountId, true);
@ -486,6 +472,26 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
}
}
private boolean isColorChanged() {
final ParcelableUser orig = mOriginal;
if (orig == null) return true;
if (mLinkColor != orig.link_color) return true;
if (mBackgroundColor != orig.background_color) return true;
return false;
}
private boolean isProfileChanged() {
final ParcelableUser orig = mOriginal;
if (orig == null) return true;
if (!stringEquals(mName, orig.name)) return true;
if (!stringEquals(mDescription, isEmpty(orig.description_expanded) ? orig.description_plain : orig.description_expanded))
return true;
if (!stringEquals(mLocation, orig.location)) return true;
if (!stringEquals(mUrl, isEmpty(orig.url_expanded) ? orig.url : orig.url_expanded))
return true;
return false;
}
@Override
protected void onPostExecute(final SingleResponse<ParcelableUser> result) {
super.onPostExecute(result);
@ -504,6 +510,41 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
}
class RemoveProfileBannerTaskInternal extends TwidereAsyncTask<Void, Void, SingleResponse<Boolean>> {
private final long account_id;
RemoveProfileBannerTaskInternal(final long account_id) {
this.account_id = account_id;
}
@Override
protected SingleResponse<Boolean> doInBackground(final Void... params) {
return TwitterWrapper.deleteProfileBannerImage(UserProfileEditorActivity.this, account_id);
}
@Override
protected void onPostExecute(final SingleResponse<Boolean> result) {
super.onPostExecute(result);
if (result.getData() != null && result.getData()) {
getUserInfo();
Toast.makeText(UserProfileEditorActivity.this, R.string.profile_banner_image_updated,
Toast.LENGTH_SHORT).show();
} else {
showErrorMessage(UserProfileEditorActivity.this, R.string.action_removing_profile_banner_image,
result.getException(), true);
}
setUpdateState(false);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
setUpdateState(true);
}
}
private class UpdateProfileBannerImageTaskInternal extends UpdateProfileBannerImageTask {
public UpdateProfileBannerImageTaskInternal(final Context context, final AsyncTaskManager manager,
@ -549,39 +590,4 @@ public class UserProfileEditorActivity extends BaseSupportActivity implements On
}
}
class RemoveProfileBannerTaskInternal extends TwidereAsyncTask<Void, Void, SingleResponse<Boolean>> {
private final long account_id;
RemoveProfileBannerTaskInternal(final long account_id) {
this.account_id = account_id;
}
@Override
protected SingleResponse<Boolean> doInBackground(final Void... params) {
return TwitterWrapper.deleteProfileBannerImage(UserProfileEditorActivity.this, account_id);
}
@Override
protected void onPostExecute(final SingleResponse<Boolean> result) {
super.onPostExecute(result);
if (result.getData() != null && result.getData()) {
getUserInfo();
Toast.makeText(UserProfileEditorActivity.this, R.string.profile_banner_image_updated,
Toast.LENGTH_SHORT).show();
} else {
showErrorMessage(UserProfileEditorActivity.this, R.string.action_removing_profile_banner_image,
result.getException(), true);
}
setUpdateState(false);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
setUpdateState(true);
}
}
}

View File

@ -924,10 +924,6 @@ public class StatusFragment extends BaseSupportFragment
final AsyncTwitterWrapper twitter = fragment.getTwitterWrapper();
final FragmentActivity activity = fragment.getActivity();
switch (item.getItemId()) {
case MENU_SHARE: {
startStatusShareChooser(activity, status);
break;
}
case MENU_COPY: {
if (ClipboardUtils.setText(activity, status.text_plain)) {
showOkMessage(activity, R.string.text_copied, false);

View File

@ -440,9 +440,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mProfileImageLoader.displayProfileImage(mProfileImageView, getOriginalTwitterProfileImage(user.profile_image_url));
if (userColor != 0) {
setUserColor(userColor);
setUserUiColor(userColor);
} else {
setUserColor(user.link_color);
setUserUiColor(user.link_color);
}
final int defWidth = res.getDisplayMetrics().widthPixels;
final int width = mBannerWidth > 0 ? mBannerWidth : defWidth;
@ -1223,7 +1223,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
actionBar.setBackgroundDrawable(mActionBarBackground);
}
private void setUserColor(int color) {
private void setUserUiColor(int color) {
if (mActionBarBackground == null) {
setupBaseActionBar();
}
@ -1402,11 +1402,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
public void setColor(int color) {
mColor = color;
final float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] = Math.min(hsv[2], 0.8f);
final int processedColor = Color.HSVToColor(hsv);
mColorDrawable.setColor(processedColor);
mColorDrawable.setColor(color);
mLineDrawable.setColor(color);
setFactor(mFactor);
}

View File

@ -1,110 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.menu;
import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v4.view.ActionProvider;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.util.ImageLoaderWrapper;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.BadgeView;
import org.mariotaku.twidere.view.ShapedImageView;
/**
* Created by mariotaku on 15/1/17.
*/
public class ComposeAccountActionProvider extends ActionProvider implements OnClickListener {
private final ImageLoaderWrapper mImageLoader;
private ShapedImageView mProfileImageView;
private BadgeView mCountView;
private InvokedListener mInvokedListener;
@Override
public void onClick(View v) {
if (mInvokedListener == null) return;
mInvokedListener.onInvoked();
}
@Override
public boolean onPerformDefaultAction() {
if (mInvokedListener == null) return false;
mInvokedListener.onInvoked();
return true;
}
@Override
public boolean hasSubMenu() {
return false;
}
/**
* Creates a new instance.
*
* @param context Context for accessing resources.
*/
public ComposeAccountActionProvider(Context context) {
super(context);
mImageLoader = TwidereApplication.getInstance(context).getImageLoaderWrapper();
}
@Override
public View onCreateActionView() {
final Context context = getContext();
final LayoutInflater inflater = LayoutInflater.from(context);
@SuppressLint("InflateParams")
final View view = inflater.inflate(R.layout.action_item_account_selector, null);
view.setOnClickListener(this);
mProfileImageView = (ShapedImageView) view.findViewById(R.id.account_profile_image);
mCountView = (BadgeView) view.findViewById(R.id.accounts_count);
return view;
}
public void setInvokedListener(InvokedListener listener) {
mInvokedListener = listener;
}
public void setSelectedAccounts(ParcelableAccount... accounts) {
if (accounts.length == 1) {
mCountView.setText(null);
final ParcelableAccount account = accounts[0];
mImageLoader.displayProfileImage(mProfileImageView, account.profile_image_url);
mProfileImageView.setBorderColor(account.color);
} else {
mCountView.setText(String.valueOf(accounts.length));
mImageLoader.cancelDisplayTask(mProfileImageView);
mProfileImageView.setImageDrawable(null);
mProfileImageView.setBorderColors(Utils.getAccountColors(accounts));
}
}
public static interface InvokedListener {
void onInvoked();
}
}

View File

@ -55,6 +55,11 @@ public class StatusShareProvider extends ActionProvider implements Constants {
return null;
}
@Override
public boolean onPerformDefaultAction() {
return true;
}
@Override
public boolean hasSubMenu() {
return true;

View File

@ -316,7 +316,6 @@ public class ThemeUtils implements Constants {
}
private static void applyColorTintForView(View view, int tintColor) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
if (view instanceof IThemedView) {
final ColorStateList tintList = ColorStateList.valueOf(tintColor);
((IThemedView) view).setThemeTintColor(tintList);
@ -344,11 +343,25 @@ public class ThemeUtils implements Constants {
}
public static Drawable getActionBarBackground(final Context context, final int themeRes) {
final TypedArray a = context.obtainStyledAttributes(null, new int[]{android.R.attr.background},
final TypedArray a1 = context.obtainStyledAttributes(null, new int[]{android.R.attr.background},
R.attr.actionBarStyle, themeRes);
try {
if (a1.hasValue(0)) {
return applyActionBarDrawable(context, a1.getDrawable(0), isTransparentBackground(themeRes));
}
} finally {
a1.recycle();
}
final TypedArray a2 = context.obtainStyledAttributes(null, new int[]{android.R.attr.background},
android.R.attr.actionBarStyle, themeRes);
final Drawable d = a.getDrawable(0);
a.recycle();
return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
try {
if (a2.hasValue(0)) {
return applyActionBarDrawable(context, a2.getDrawable(0), isTransparentBackground(themeRes));
}
} finally {
a2.recycle();
}
return null;
}
public static Drawable getActionBarBackground(final Context context, final int themeRes,
@ -364,15 +377,31 @@ public class ThemeUtils implements Constants {
return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}
public static Context getActionBarContext(final Context context) {
final TypedArray a = context.obtainStyledAttributes(new int[]{android.R.attr.actionBarTheme,
public static int getActionBarThemeResource(final Context context) {
final TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.actionBarTheme,
R.attr.actionBarWidgetTheme, android.R.attr.actionBarTheme,
android.R.attr.actionBarWidgetTheme});
final int resId;
try {
if (a.hasValue(0) || a.hasValue(1)) {
resId = a.hasValue(0) ? a.getResourceId(0, 0) : a.getResourceId(1, 0);
} finally {
a.recycle();
} else {
resId = a.hasValue(2) ? a.getResourceId(2, 0) : a.getResourceId(3, 0);
}
a.recycle();
return resId;
}
public static Context getActionBarContext(final Context context) {
final TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.actionBarTheme,
R.attr.actionBarWidgetTheme, android.R.attr.actionBarTheme,
android.R.attr.actionBarWidgetTheme});
final int resId;
if (a.hasValue(0) || a.hasValue(1)) {
resId = a.hasValue(0) ? a.getResourceId(0, 0) : a.getResourceId(1, 0);
} else {
resId = a.hasValue(2) ? a.getResourceId(2, 0) : a.getResourceId(3, 0);
}
a.recycle();
if (resId == 0) return context;
return new ContextThemeWrapper(context, resId);
}
@ -708,7 +737,6 @@ public class ThemeUtils implements Constants {
else if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(background))
return R.style.Theme_Twidere_Light_Transparent_NoActionBar;
return R.style.Theme_Twidere_Light_NoActionBar;
} else if (VALUE_THEME_NAME_DARK.equals(name)) {
if (VALUE_THEME_BACKGROUND_SOLID.equals(background))
return R.style.Theme_Twidere_Dark_SolidBackground_NoActionBar;

View File

@ -203,13 +203,28 @@ public class ShapedImageView extends ImageView {
shader.setLocalMatrix(mMatrix);
mBitmapPaint.setShader(shader);
if (getStyle() == SHAPE_CIRCLE) {
canvas.drawCircle(dest.centerX(), dest.centerY(), Math.min(dest.width(), dest.height()) / 2f,
mBitmapPaint);
if (mBorderEnabled) {
final float inset = mBorderPaint.getStrokeWidth() / 2;
if (getStyle() == SHAPE_CIRCLE) {
final float circleRadius = Math.min(dest.width(), dest.height()) / 2f - inset / 2;
canvas.drawCircle(dest.centerX(), dest.centerY(), circleRadius, mBitmapPaint);
} else {
final float cornerRadius = getCalculatedCornerRadius();
dest.inset(inset, inset);
canvas.drawRoundRect(dest, cornerRadius, cornerRadius, mBitmapPaint);
dest.inset(-inset, -inset);
}
} else {
final float cornerRadius = getCalculatedCornerRadius();
canvas.drawRoundRect(dest, cornerRadius, cornerRadius, mBitmapPaint);
if (getStyle() == SHAPE_CIRCLE) {
final float circleRadius = Math.min(dest.width(), dest.height()) / 2f;
canvas.drawCircle(dest.centerX(), dest.centerY(), circleRadius, mBitmapPaint);
} else {
final float cornerRadius = getCalculatedCornerRadius();
canvas.drawRoundRect(dest, cornerRadius, cornerRadius, mBitmapPaint);
}
}
}
@ShapeStyle
@ -305,7 +320,7 @@ public class ShapedImageView extends ImageView {
// Then draw the border.
if (mBorderEnabled) {
drawBorder(canvas);
drawBorder(canvas, mDestination);
}
}
@ -346,8 +361,10 @@ public class ShapedImageView extends ImageView {
public void setBackground(Drawable background) {
}
@Deprecated
@Override
public void setBackgroundDrawable(Drawable background) {
// No-op
}
@Override
@ -363,25 +380,30 @@ public class ShapedImageView extends ImageView {
updateBounds();
}
private void drawBorder(@NonNull final Canvas canvas) {
private void drawBorder(@NonNull final Canvas canvas, @NonNull final RectF dest) {
final RectF transitionSrc = mTransitionSource, transitionDst = mTransitionDestination;
final float strokeWidth;
if (transitionSrc != null && transitionDst != null) {
final float progress = 1 - (mDestination.width() - transitionDst.width())
final float progress = 1 - (dest.width() - transitionDst.width())
/ (transitionSrc.width() - transitionDst.width());
mBorderPaint.setStrokeWidth(mStrokeWidth * progress);
strokeWidth = mStrokeWidth * progress;
mBorderPaint.setAlpha(Math.round(mBorderAlpha * progress));
ViewCompat.setTranslationZ(this, -ViewCompat.getElevation(this) * (1 - progress));
} else {
mBorderPaint.setStrokeWidth(mStrokeWidth);
strokeWidth = mStrokeWidth;
mBorderPaint.setAlpha(mBorderAlpha);
ViewCompat.setTranslationZ(this, 0);
}
mBorderPaint.setStrokeWidth(strokeWidth);
if (getStyle() == SHAPE_CIRCLE) {
canvas.drawCircle(mDestination.centerX(), mDestination.centerY(),
mDestination.width() / 2f - mBorderPaint.getStrokeWidth() / 2, mBorderPaint);
final float circleRadius = Math.min(dest.width(), dest.height()) / 2f - strokeWidth / 2;
canvas.drawCircle(dest.centerX(), dest.centerY(), circleRadius, mBorderPaint);
} else {
final float radius = getCalculatedCornerRadius();
canvas.drawRoundRect(mDestination, radius, radius, mBorderPaint);
final float inset = mStrokeWidth / 2;
dest.inset(inset, inset);
canvas.drawRoundRect(dest, radius, radius, mBorderPaint);
dest.inset(-inset, -inset);
}
}
@ -394,10 +416,6 @@ public class ShapedImageView extends ImageView {
return 0;
}
private float getCornerRadius() {
return mCornerRadius;
}
public void setCornerRadius(float radius) {
mCornerRadius = radius;
}
@ -462,10 +480,18 @@ public class ShapedImageView extends ImageView {
paint.setColor(Color.WHITE);
paint.setShadowLayer(radius, 0, radius * 1.5f / 2, SHADOW_START_COLOR);
final RectF rect = new RectF(radius, radius, size - radius, size - radius);
canvas.drawOval(rect, paint);
paint.setShadowLayer(0, 0, 0, 0);
paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
canvas.drawOval(rect, paint);
if (getStyle() == SHAPE_CIRCLE) {
canvas.drawOval(rect, paint);
paint.setShadowLayer(0, 0, 0, 0);
paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
canvas.drawOval(rect, paint);
} else {
final float cr = getCalculatedCornerRadius();
canvas.drawRoundRect(rect, cr, cr, paint);
paint.setShadowLayer(0, 0, 0, 0);
paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
canvas.drawRoundRect(rect, cr, cr, paint);
}
invalidate();
}

View File

@ -20,6 +20,7 @@
package org.mariotaku.twidere.view;
import android.content.Context;
import android.content.res.ColorStateList;
import android.text.InputType;
import android.text.SpannableString;
import android.text.Spanned;
@ -28,9 +29,10 @@ import android.text.method.ArrowKeyMovementMethod;
import android.util.AttributeSet;
import org.mariotaku.twidere.adapter.UserHashtagAutoCompleteAdapter;
import org.mariotaku.twidere.view.iface.IThemedView;
import org.mariotaku.twidere.view.themed.ThemedMultiAutoCompleteTextView;
public class StatusComposeEditText extends ThemedMultiAutoCompleteTextView implements InputType {
public class StatusComposeEditText extends ThemedMultiAutoCompleteTextView implements IThemedView {
private UserHashtagAutoCompleteAdapter mAdapter;
@ -47,7 +49,8 @@ public class StatusComposeEditText extends ThemedMultiAutoCompleteTextView imple
mAdapter = new UserHashtagAutoCompleteAdapter(this);
setTokenizer(new ScreenNameTokenizer());
setMovementMethod(ArrowKeyMovementMethod.getInstance());
setRawInputType(TYPE_CLASS_TEXT | TYPE_TEXT_FLAG_CAP_SENTENCES | TYPE_TEXT_FLAG_MULTI_LINE);
setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
| InputType.TYPE_TEXT_FLAG_MULTI_LINE);
}
@Override

View File

@ -0,0 +1,56 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.view;
import android.content.Context;
import android.support.v7.internal.view.menu.MenuPopupHelper;
import android.support.v7.widget.ActionMenuView;
import android.util.AttributeSet;
import java.lang.reflect.Field;
/**
* Created by mariotaku on 15/1/22.
*/
public class TwidereActionMenuView extends ActionMenuView {
public TwidereActionMenuView(Context context) {
super(context);
}
public TwidereActionMenuView(Context context, AttributeSet attrs) {
super(context, attrs);
}
// @Override
// public boolean post(Runnable action) {
// try {
// final Class<?> actionCls = action.getClass();
// final Field popupField = actionCls.getField("mPopup");
// popupField.setAccessible(true);
// final Object popupObject = popupField.get(action);
// if (popupObject instanceof MenuPopupHelper) {
// ((MenuPopupHelper) popupObject).setForceShowIcon(true);
// }
// } catch (NoSuchFieldException | IllegalAccessException ignore) {
// }
// return super.post(action);
// }
}

View File

@ -26,6 +26,7 @@ import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.util.ThemeUtils;
/**
* Created by mariotaku on 15/1/16.
@ -40,8 +41,12 @@ public class TwidereToolbar extends Toolbar {
}
public TwidereToolbar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(attrs, new int[]{R.attr.elevation}, defStyleAttr, 0);
super(getThemedContext(context, attrs, defStyleAttr), attrs, defStyleAttr);
final TypedArray a = getContext().obtainStyledAttributes(attrs, new int[]{R.attr.elevation}, defStyleAttr, 0);
ViewCompat.setElevation(this, a.getDimension(0, 0));
}
private static Context getThemedContext(Context context, AttributeSet attrs, int defStyleAttr) {
return ThemeUtils.getActionBarContext(context);
}
}

View File

@ -28,7 +28,7 @@ import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.accessor.ViewAccessor;
import org.mariotaku.twidere.view.iface.IThemedView;
public class ThemedMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements IThemedView {
public class ThemedMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements IThemedView {
public ThemedMultiAutoCompleteTextView(final Context context) {
this(context, null);
@ -46,5 +46,7 @@ public class ThemedMultiAutoCompleteTextView extends MultiAutoCompleteTextView
@Override
public void setThemeTintColor(ColorStateList color) {
ViewAccessor.setBackgroundTintList(this, color);
setLinkTextColor(color);
setHighlightColor(color.getDefaultColor());
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 B

View File

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

View File

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 321 B

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 592 B

After

Width:  |  Height:  |  Size: 592 B

View File

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout
style="?android:actionButtonStyle"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:paddingBottom="@dimen/element_spacing_msmall"
android:paddingLeft="@dimen/element_spacing_small"
android:paddingRight="@dimen/element_spacing_small"
android:paddingTop="@dimen/element_spacing_msmall"
tools:layout_height="?actionBarSize"
tools:showIn="@layout/menu_compose">
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/account_profile_image"
style="?profileImageStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
app:sivBackgroundColor="?android:colorBackground"
app:sivBorder="true"
app:sivBorderWidth="@dimen/line_width_compose_account_profile_image"
tools:src="@drawable/ic_profile_image_default"/>
<org.mariotaku.twidere.view.BadgeView
android:id="@+id/accounts_count"
android:layout_alignTop="@id/account_profile_image"
android:layout_alignBottom="@id/account_profile_image"
android:layout_alignRight="@id/account_profile_image"
android:layout_alignLeft="@id/account_profile_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:textColor="?android:colorForeground"/>
</RelativeLayout>

View File

@ -16,18 +16,27 @@
-->
<LinearLayout
style="?android:actionBarStyle"
<org.mariotaku.twidere.view.TwidereToolbar
android:id="@+id/done_bar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="?android:attr/dividerVertical"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="middle">
android:layout_height="?actionBarSize"
style="?actionBarStyle"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp">
<include layout="@layout/include_cancel_button"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="?android:attr/dividerVertical"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="middle">
<include layout="@layout/include_done_button"/>
</LinearLayout>
<include layout="@layout/include_cancel_button"/>
<include layout="@layout/include_done_button"/>
</LinearLayout>
</org.mariotaku.twidere.view.TwidereToolbar>

View File

@ -110,10 +110,7 @@
android:layout_width="?actionBarSize"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginLeft="@dimen/element_spacing_xsmall"
android:overScrollMode="never"
android:paddingLeft="@dimen/element_spacing_msmall"
android:paddingRight="@dimen/element_spacing_msmall"/>
android:overScrollMode="never"/>
</FrameLayout>
</RelativeLayout>

View File

@ -22,25 +22,72 @@
android:id="@+id/compose_bottombar"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
android:layout_height="?actionBarSize"
android:baselineAligned="false"
android:divider="?android:dividerHorizontal"
android:dividerPadding="@dimen/element_spacing_normal"
android:gravity="center_vertical"
android:orientation="horizontal"
android:showDividers="middle">
android:showDividers="middle"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<android.support.v7.widget.ActionMenuView
android:id="@+id/menu_bar"
android:layout_width="match_parent"
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@null"/>
android:orientation="horizontal">
<RelativeLayout
style="?actionButtonStyle"
android:layout_width="wrap_content"
android:id="@+id/account_selector_button"
android:layout_height="match_parent"
android:clickable="true"
android:padding="@dimen/element_spacing_msmall">
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/account_profile_image"
style="?profileImageStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
app:sivBackgroundColor="?android:colorBackground"
app:sivBorder="true"
app:sivBorderWidth="@dimen/line_width_compose_account_profile_image"
tools:src="@drawable/ic_profile_image_default"/>
<org.mariotaku.twidere.view.BadgeView
android:id="@+id/accounts_count"
android:layout_alignTop="@id/account_profile_image"
android:layout_alignBottom="@id/account_profile_image"
android:layout_alignRight="@id/account_profile_image"
android:layout_alignLeft="@id/account_profile_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:textColor="?android:colorForeground"/>
</RelativeLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/account_selector_button">
<org.mariotaku.twidere.view.TwidereActionMenuView
android:id="@+id/menu_bar"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@null"/>
</HorizontalScrollView>
</RelativeLayout>
<LinearLayout
android:id="@+id/send"
style="?android:actionButtonStyle"
style="?actionButtonStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0"

View File

@ -386,12 +386,35 @@
</FrameLayout>
<org.mariotaku.twidere.view.ActionBarThemedContainer
<!--<org.mariotaku.twidere.view.ActionBarThemedContainer-->
<!--android:id="@+id/done_bar_container"-->
<!--style="?actionBarStyle"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="?actionBarSize"-->
<!--android:layout="@layout/actionbar_custom_view_done_cancel"/>-->
<org.mariotaku.twidere.view.TwidereToolbar
android:id="@+id/done_bar"
style="?android:actionBarStyle"
style="?actionBarStyle"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
android:layout="@layout/actionbar_custom_view_done_cancel"/>
android:layout_height="?actionBarSize"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="?android:attr/dividerVertical"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="middle">
<include layout="@layout/include_cancel_button"/>
<include layout="@layout/include_done_button"/>
</LinearLayout>
</org.mariotaku.twidere.view.TwidereToolbar>
<View
android:id="@+id/actionbar_overlay"
@ -400,5 +423,4 @@
android:layout_alignParentBottom="true"
android:layout_below="@+id/done_bar"/>
</RelativeLayout>

View File

@ -25,8 +25,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/element_spacing_small"
android:layout_marginBottom="@dimen/element_spacing_small"
android:layout_margin="@dimen/element_spacing_msmall"
app:sivBorder="true"
app:sivBorderWidth="@dimen/line_width_compose_account_profile_image"
tools:layout_width="48dp"/>

View File

@ -37,7 +37,7 @@
tools:visiblity="visible">
<Space
android:layout_width="@dimen/element_size_mlarge"
android:layout_width="@dimen/icon_size_card_list_item"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_profile_image_detail_page"/>
@ -64,8 +64,8 @@
<org.mariotaku.twidere.view.ShapedImageView
android:id="@+id/profile_image"
style="?profileImageStyle"
android:layout_width="@dimen/element_size_mlarge"
android:layout_height="@dimen/element_size_mlarge"
android:layout_width="@dimen/icon_size_card_details"
android:layout_height="@dimen/icon_size_card_details"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="@dimen/padding_profile_image_detail_page"
@ -321,7 +321,7 @@
</LinearLayout>
<android.support.v7.widget.ActionMenuView
<org.mariotaku.twidere.view.TwidereActionMenuView
android:id="@+id/menu_bar"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"/>

View File

@ -133,7 +133,7 @@
android:id="@+id/uucky_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/card"
android:layout_below="@+id/profile_details_container"
android:alpha="0.2"
android:gravity="center"
android:padding="@dimen/element_spacing_small"

View File

@ -65,20 +65,15 @@
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:orientation="vertical"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/element_spacing_small"
android:singleLine="true"
android:text="@string/location"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"
android:visibility="gone"/>
<org.mariotaku.twidere.view.ActionIconView
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:color="?android:textColorPrimary"
android:src="@drawable/ic_action_location"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/location"
@ -98,20 +93,15 @@
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:orientation="vertical"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/element_spacing_small"
android:singleLine="true"
android:text="@string/url"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"
android:visibility="gone"/>
<org.mariotaku.twidere.view.ActionIconView
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:color="?android:textColorPrimary"
android:src="@drawable/ic_action_web"/>
<org.mariotaku.twidere.view.HandleSpanClickTextView
android:id="@+id/url"
@ -132,20 +122,15 @@
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:orientation="vertical"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/element_spacing_small"
android:singleLine="true"
android:text="@string/created_at"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"
android:visibility="gone"/>
<org.mariotaku.twidere.view.ActionIconView
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:color="?android:textColorPrimary"
android:src="@drawable/ic_action_time"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/created_at"
@ -156,7 +141,7 @@
android:singleLine="true"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorPrimary"
tools:text="July 18, 2009 17:00 (20 tweets per day)"/>
tools:text="July 17, 2009 18:35 (20 tweets per day)"/>
</LinearLayout>
<View

View File

@ -21,10 +21,13 @@
<org.mariotaku.twidere.view.ColorLabelRelativeLayout
android:id="@+id/content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/element_spacing_normal"
app:ignorePadding="true"
tools:context=".adapter.DirectMessagesEntryAdapter">
<org.mariotaku.twidere.view.ShapedImageView

View File

@ -2,12 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@id/select_account"
android:icon="@drawable/ic_action_accounts"
android:title="@string/select_accounts"
app:actionProviderClass="org.mariotaku.twidere.menu.ComposeAccountActionProvider"
app:showAsAction="always"/>
<item
android:id="@id/take_photo"
android:icon="@drawable/ic_action_camera"

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@id/progress"
android:title="@string/progress"
app:actionLayout="@layout/action_item_home_progress_smartbar"
app:showAsAction="always"/>
<item
android:id="@id/actions"
android:icon="@drawable/ic_action_status_compose"
android:title="@string/compose"
app:showAsAction="always"/>
</menu>

View File

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/new_user_list"
android:icon="@drawable/ic_action_add"
android:showAsAction="ifRoom"
android:title="@string/new_user_list"
android:visible="false"/>
android:visible="false"
app:showAsAction="ifRoom"/>
</menu>

View File

@ -22,7 +22,7 @@
<dimen name="icon_size_list_item">56dp</dimen>
<dimen name="icon_size_list_item_small">42dp</dimen>
<dimen name="icon_size_card_list_item">48dp</dimen>
<dimen name="icon_size_card_details">56dp</dimen>
<dimen name="icon_size_card_details">@dimen/element_size_mlarge</dimen>
<dimen name="icon_size_wizard_large">240dp</dimen>
<dimen name="icon_size_user_profile">84dp</dimen>
<dimen name="profile_image_size_activity_small">32dp</dimen>

View File

@ -119,50 +119,32 @@
<style name="Theme.Twidere.Dark.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.Twidere.Light.NoActionBar" parent="Theme.Compat.Base.Light.NoActionBar">
<!-- Card UI styles -->
<item name="cardActionButtonStyle">@style/Widget.Light.CardActionButton</item>
<item name="profileImageStyle">@style/Widget.Light.ProfileImage</item>
<item name="profileImageStyleLarge">@style/Widget.Light.ProfileImage.Large</item>
<item name="cardItemBackgroundColor">#f8f8f8</item>
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_dark</item>
<item name="menuIconColorDisabled">@color/action_icon_dark_disabled</item>
<item name="menuIconColorActionBar">@color/action_icon_light</item>
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
<style name="Theme.Twidere.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.Twidere.Dark.Transparent.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.Twidere.Light.Transparent.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.Twidere.Dark.SolidBackground.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.Twidere.Light.SolidBackground.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowNoTitle">true</item>
</style>

View File

@ -12,7 +12,7 @@
</header>
<header
android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment"
android:icon="@drawable/ic_action_interface"
android:icon="@drawable/ic_action_view_quilt"
android:title="@string/settings_interface">
<extra
android:name="resid"