improved theme

This commit is contained in:
Mariotaku Lee 2015-04-18 00:36:16 +08:00
parent bf42c3d792
commit f4a2fdc207
15 changed files with 296 additions and 204 deletions

View File

@ -373,7 +373,8 @@
android:name=".activity.support.DraftsActivity"
android:exported="false"
android:label="@string/drafts"
android:launchMode="singleTop">
android:launchMode="singleTop"
android:theme="@style/Theme.Twidere.Dark.DialogWhenLarge">
<intent-filter>
<action android:name="org.mariotaku.twidere.DRAFTS"/>
@ -388,7 +389,8 @@
android:name=".activity.support.AccountsManagerActivity"
android:exported="false"
android:label="@string/accounts"
android:launchMode="singleTop">
android:launchMode="singleTop"
android:theme="@style/Theme.Twidere.Dark.DialogWhenLarge">
<intent-filter>
<action android:name="org.mariotaku.twidere.ACCOUNTS"/>

View File

@ -29,7 +29,7 @@ import android.view.MenuItem;
import android.view.WindowManager.LayoutParams;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.support.BaseActionBarActivity;
import org.mariotaku.twidere.activity.support.BaseDialogWhenLargeActivity;
import org.mariotaku.twidere.adapter.support.SupportTabsAdapter;
import org.mariotaku.twidere.fragment.BaseFiltersFragment.FilteredKeywordsFragment;
import org.mariotaku.twidere.fragment.BaseFiltersFragment.FilteredLinksFragment;
@ -38,11 +38,9 @@ import org.mariotaku.twidere.fragment.BaseFiltersFragment.FilteredUsersFragment;
import org.mariotaku.twidere.graphic.EmptyDrawable;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.view.TabPagerIndicator;
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
public class FiltersActivity extends BaseActionBarActivity {
public class FiltersActivity extends BaseDialogWhenLargeActivity {
private TintedStatusFrameLayout mMainContent;
private TabPagerIndicator mPagerIndicator;
private ViewPager mViewPager;
@ -53,12 +51,6 @@ public class FiltersActivity extends BaseActionBarActivity {
return false;
}
@Override
public void onFitSystemWindows(Rect insets) {
super.onFitSystemWindows(insets);
mMainContent.setPadding(insets.left, insets.top, insets.right, insets.bottom);
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
@ -79,10 +71,7 @@ public class FiltersActivity extends BaseActionBarActivity {
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_MODE_OVERLAY);
super.onCreate(savedInstanceState);
ThemeUtils.applyActionBarBackground(getSupportActionBar(), this, getCurrentThemeResourceId(),
getCurrentThemeColor(), getThemeBackgroundOption(), false);
setContentView(R.layout.activity_content_pages);
mMainContent.setOnFitSystemWindowsListener(this);
setContentView(R.layout.activity_filters);
mAdapter = new SupportTabsAdapter(this, getSupportFragmentManager(), null, 1);
mViewPager.setAdapter(mAdapter);
mViewPager.setOffscreenPageLimit(2);
@ -99,22 +88,16 @@ public class FiltersActivity extends BaseActionBarActivity {
ThemeUtils.initPagerIndicatorAsActionBarTab(this, mPagerIndicator);
ThemeUtils.setCompatToolbarOverlay(this, new EmptyDrawable());
mMainContent.setDrawShadow(false);
mMainContent.setDrawColor(true);
mMainContent.setFactor(1);
final int color = getCurrentThemeColor();
final int alpha = ThemeUtils.isTransparentBackground(getThemeBackgroundOption()) ? getCurrentThemeBackgroundAlpha() : 0xFF;
if (ThemeUtils.isDarkTheme(getCurrentThemeResourceId())) {
mMainContent.setColor(getResources().getColor(R.color.background_color_action_bar_dark), alpha);
} else {
mMainContent.setColor(color, alpha);
}
}
@Override
protected boolean isActionBarOutlineEnabled() {
return false;
}
@Override
public void onSupportContentChanged() {
super.onSupportContentChanged();
mMainContent = (TintedStatusFrameLayout) findViewById(R.id.main_content);
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mPagerIndicator = (TabPagerIndicator) findViewById(R.id.view_pager_tabs);
}

View File

@ -18,9 +18,17 @@ import org.mariotaku.twidere.view.TintedStatusFrameLayout;
* Accounts manager
* Created by mariotaku on 14/10/26.
*/
public class AccountsManagerActivity extends BaseActionBarActivity {
public class AccountsManagerActivity extends BaseDialogWhenLargeActivity {
private TintedStatusFrameLayout mMainContent;
@Override
public void onFitSystemWindows(Rect insets) {
super.onFitSystemWindows(insets);
final FragmentManager fm = getSupportFragmentManager();
final Fragment f = fm.findFragmentById(R.id.main_content);
if (f instanceof IBaseFragment) {
((IBaseFragment) f).requestFitSystemWindows();
}
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
@ -33,12 +41,6 @@ public class AccountsManagerActivity extends BaseActionBarActivity {
return super.onOptionsItemSelected(item);
}
@Override
public void onSupportContentChanged() {
super.onSupportContentChanged();
mMainContent = (TintedStatusFrameLayout) findViewById(R.id.main_content);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
@ -48,20 +50,9 @@ public class AccountsManagerActivity extends BaseActionBarActivity {
actionBar.setDisplayHomeAsUpEnabled(true);
}
setContentView(R.layout.activity_content_fragment);
mMainContent.setOnFitSystemWindowsListener(this);
final FragmentManager fm = getSupportFragmentManager();
final FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.main_content, new AccountsManagerFragment());
ft.commit();
}
@Override
public void onFitSystemWindows(Rect insets) {
super.onFitSystemWindows(insets);
final FragmentManager fm = getSupportFragmentManager();
final Fragment f = fm.findFragmentById(R.id.main_content);
if (f instanceof IBaseFragment) {
((IBaseFragment) f).requestFitSystemWindows();
}
}
}

View File

@ -24,8 +24,12 @@ import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.activity.iface.IControlBarActivity;
@ -34,6 +38,7 @@ import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCal
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.ShortcutCallback;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.ViewUtils;
import org.mariotaku.twidere.view.iface.IExtendedView.OnFitSystemWindowsListener;
import java.util.ArrayList;
@ -136,6 +141,7 @@ public class BaseActionBarActivity extends ThemedActionBarActivity implements Co
super.onCreate(savedInstanceState);
}
@Override
protected void onStart() {
super.onStart();
@ -207,4 +213,5 @@ public class BaseActionBarActivity extends ThemedActionBarActivity implements Co
public void unregisterControlBarOffsetListener(ControlBarOffsetListener listener) {
mControlBarOffsetListeners.remove(listener);
}
}

View File

@ -0,0 +1,114 @@
/*
* 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.activity.support;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.ViewUtils;
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
/**
* Created by mariotaku on 15/4/17.
*/
public class BaseDialogWhenLargeActivity extends BaseActionBarActivity {
private TintedStatusFrameLayout mMainContent;
@Override
public final int getThemeResourceId() {
return ThemeUtils.getDialogWhenLargeThemeResource(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupActionBar();
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
final boolean result = super.onPrepareOptionsMenu(menu);
if (!shouldSetActionItemColor()) return result;
final View actionBarView = getWindow().findViewById(android.support.v7.appcompat.R.id.action_bar);
if (actionBarView instanceof Toolbar) {
final int themeColor = getCurrentThemeColor();
final int themeId = getCurrentThemeResourceId();
final int itemColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor);
final Toolbar toolbar = (Toolbar) actionBarView;
ThemeUtils.setActionBarOverflowColor(toolbar, itemColor);
ThemeUtils.wrapToolbarMenuIcon(ViewUtils.findViewByType(actionBarView, ActionMenuView.class), itemColor, itemColor);
}
return result;
}
@Override
public void onSupportContentChanged() {
super.onSupportContentChanged();
mMainContent = (TintedStatusFrameLayout) findViewById(R.id.main_content);
setupTintStatusBar();
}
protected TintedStatusFrameLayout getMainContent() {
return mMainContent;
}
protected boolean isActionBarOutlineEnabled() {
return true;
}
protected boolean shouldSetActionItemColor() {
return true;
}
private void setupActionBar() {
final ActionBar actionBar = getSupportActionBar();
if (actionBar == null) return;
final int themeColor = getCurrentThemeColor();
final int themeId = getCurrentThemeResourceId();
final String option = getThemeBackgroundOption();
final int actionBarItemsColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor);
ThemeUtils.applyActionBarBackground(actionBar, this, themeId, themeColor, option, isActionBarOutlineEnabled());
ThemeUtils.setActionBarItemsColor(getWindow(), actionBar, actionBarItemsColor);
}
private void setupTintStatusBar() {
if (mMainContent == null) return;
final int color = getCurrentThemeColor();
final int alpha = ThemeUtils.isTransparentBackground(getThemeBackgroundOption()) ? getCurrentThemeBackgroundAlpha() : 0xFF;
if (ThemeUtils.isDarkTheme(getCurrentThemeResourceId())) {
mMainContent.setColor(getResources().getColor(R.color.background_color_action_bar_dark), alpha);
} else {
mMainContent.setColor(color, alpha);
}
mMainContent.setDrawShadow(false);
mMainContent.setDrawColor(true);
mMainContent.setFactor(1);
}
}

View File

@ -29,8 +29,10 @@ import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
@ -48,6 +50,7 @@ import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.AbsListView.MultiChoiceModeListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@ -69,6 +72,7 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Drafts;
import org.mariotaku.twidere.util.AsyncTaskUtils;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
import java.io.File;
import java.util.ArrayList;
@ -76,7 +80,7 @@ import java.util.List;
import static org.mariotaku.twidere.util.Utils.getDefaultTextSize;
public class DraftsActivity extends BaseActionBarActivity implements LoaderCallbacks<Cursor>, OnItemClickListener,
public class DraftsActivity extends BaseDialogWhenLargeActivity implements LoaderCallbacks<Cursor>, OnItemClickListener,
MultiChoiceModeListener {
private ContentResolver mResolver;
@ -194,12 +198,19 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
@Override
protected void onCreate(final Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_MODE_OVERLAY);
super.onCreate(savedInstanceState);
mResolver = getContentResolver();
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
mTextSize = mPreferences.getInt(KEY_TEXT_SIZE, getDefaultTextSize(this));
setContentView(R.layout.layout_list_with_empty_view);
setContentView(R.layout.activity_drafts);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
@ -216,6 +227,15 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
setListShown(false);
}
@Override
protected void onStart() {
final AsyncTwitterWrapper twitter = getTwitterWrapper();
if (twitter != null) {
twitter.clearNotificationAsync(NOTIFICATION_ID_DRAFTS);
}
super.onStart();
}
@Override
protected void onResume() {
super.onResume();
@ -227,15 +247,6 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
}
}
@Override
protected void onStart() {
final AsyncTwitterWrapper twitter = getTwitterWrapper();
if (twitter != null) {
twitter.clearNotificationAsync(NOTIFICATION_ID_DRAFTS);
}
super.onStart();
}
@Override
protected void onStop() {
super.onStop();

View File

@ -47,6 +47,7 @@ import org.mariotaku.twidere.fragment.iface.IBaseFragment;
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCallback;
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
import org.mariotaku.twidere.fragment.support.SearchFragment;
import org.mariotaku.twidere.fragment.support.UserFragment;
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.ShortcutCallback;
import org.mariotaku.twidere.util.MultiSelectEventHandler;
@ -294,6 +295,11 @@ public class LinkHandlerActivity extends BaseActionBarActivity implements System
}
}
@Override
protected boolean shouldSetActionItemColor() {
return !(getCurrentVisibleFragment() instanceof UserFragment);
}
private void setTaskInfo(int linkId, Uri uri) {
switch (linkId) {
case LINK_ID_USER: {

View File

@ -21,7 +21,6 @@ package org.mariotaku.twidere.activity.support;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.AsyncTask.Status;
@ -62,7 +61,6 @@ import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.TwitterWrapper;
import org.mariotaku.twidere.view.ForegroundColorView;
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
import org.mariotaku.twidere.view.iface.IExtendedView.OnSizeChangedListener;
import twitter4j.Twitter;
@ -74,7 +72,7 @@ import static org.mariotaku.twidere.util.Utils.getTwitterInstance;
import static org.mariotaku.twidere.util.Utils.isMyAccount;
import static org.mariotaku.twidere.util.Utils.showErrorMessage;
public class UserProfileEditorActivity extends BaseActionBarActivity implements OnSizeChangedListener, TextWatcher,
public class UserProfileEditorActivity extends BaseDialogWhenLargeActivity implements OnSizeChangedListener, TextWatcher,
OnClickListener, LoaderCallbacks<SingleResponse<ParcelableUser>> {
private static final int LOADER_ID_USER = 1;
@ -86,7 +84,6 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
private MediaLoaderWrapper mLazyImageLoader;
private AsyncTaskManager mAsyncTaskManager;
private AsyncTask<Object, Object, ?> mTask;
private TintedStatusFrameLayout mMainContent;
private ImageView mProfileImageView;
private ImageView mProfileBannerView;
private EditText mEditName, mEditDescription, mEditLocation, mEditUrl;
@ -113,124 +110,6 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
public void afterTextChanged(final Editable s) {
}
@Override
public int getThemeResourceId() {
return ThemeUtils.getDialogWhenLargeThemeResource(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_HOME: {
finish();
return true;
}
case MENU_SAVE: {
final String name = ParseUtils.parseString(mEditName.getText());
final String url = ParseUtils.parseString(mEditUrl.getText());
final String location = ParseUtils.parseString(mEditLocation.getText());
final String description = ParseUtils.parseString(mEditDescription.getText());
final int linkColor = mLinkColor.getColor();
final int backgroundColor = mBackgroundColor.getColor();
mTask = new UpdateProfileTaskInternal(this, mAccountId, mUser, name, url, location,
description, linkColor, backgroundColor);
AsyncTaskUtils.executeTask(mTask);
return true;
}
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
final Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
window.addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
mAsyncTaskManager = TwidereApplication.getInstance(this).getAsyncTaskManager();
mLazyImageLoader = TwidereApplication.getInstance(this).getMediaLoaderWrapper();
final Intent intent = getIntent();
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
mAccountId = accountId;
if (!isMyAccount(this, accountId)) {
finish();
return;
}
final ActionBar actionBar = getSupportActionBar();
final int themeColor = getCurrentThemeColor();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
final int themeId = getCurrentThemeResourceId();
final String option = getThemeBackgroundOption();
final int actionBarItemsColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor);
ThemeUtils.applyActionBarBackground(actionBar, this, themeId, themeColor, option, true);
ThemeUtils.setActionBarItemsColor(getWindow(), actionBar, actionBarItemsColor);
}
setContentView(R.layout.activity_user_profile_editor);
mMainContent.setOnFitSystemWindowsListener(this);
if (ThemeUtils.isDarkTheme(getCurrentThemeResourceId())) {
mMainContent.setColor(getResources().getColor(R.color.background_color_action_bar_dark));
} else {
mMainContent.setColor(themeColor);
}
mMainContent.setDrawColor(true);
// 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);
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
public void onFitSystemWindows(Rect insets) {
mMainContent.setPadding(insets.left, insets.top, insets.right, insets.bottom);
super.onFitSystemWindows(insets);
}
@Override
protected void onStart() {
super.onStart();
}
@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 onStop() {
super.onStop();
}
@Override
public void onClick(final View view) {
final ParcelableUser user = mUser;
@ -311,6 +190,100 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_HOME: {
finish();
return true;
}
case MENU_SAVE: {
final String name = ParseUtils.parseString(mEditName.getText());
final String url = ParseUtils.parseString(mEditUrl.getText());
final String location = ParseUtils.parseString(mEditLocation.getText());
final String description = ParseUtils.parseString(mEditDescription.getText());
final int linkColor = mLinkColor.getColor();
final int backgroundColor = mBackgroundColor.getColor();
mTask = new UpdateProfileTaskInternal(this, mAccountId, mUser, name, url, location,
description, linkColor, backgroundColor);
AsyncTaskUtils.executeTask(mTask);
return true;
}
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
final Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
window.addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
mAsyncTaskManager = TwidereApplication.getInstance(this).getAsyncTaskManager();
mLazyImageLoader = TwidereApplication.getInstance(this).getMediaLoaderWrapper();
final Intent intent = getIntent();
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
mAccountId = accountId;
if (!isMyAccount(this, accountId)) {
finish();
return;
}
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
setContentView(R.layout.activity_user_profile_editor);
// 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);
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 onStart() {
super.onStart();
}
@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 onStop() {
super.onStop();
}
@Override
public void onSizeChanged(final View view, final int w, final int h, final int oldw, final int oldh) {
}
@ -318,7 +291,6 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
@Override
public void onSupportContentChanged() {
super.onSupportContentChanged();
mMainContent = (TintedStatusFrameLayout) findViewById(R.id.main_content);
mProgressContainer = findViewById(R.id.progress_container);
mEditProfileContent = findViewById(R.id.edit_profile_content);
mProfileBannerView = (ImageView) findViewById(R.id.profile_banner);

View File

@ -933,6 +933,7 @@ public class ThemeUtils implements Constants {
}
actionBar.setHomeAsUpIndicator(drawable);
setActionBarTitleTextColor(window, itemColor);
setActionBarSubtitleTextColor(window, itemColor);
}
public static void setActionBarOverflowColor(Toolbar toolbar, int itemColor) {

View File

@ -20,6 +20,7 @@
package org.mariotaku.twidere.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@ -27,6 +28,7 @@ import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.util.MathUtils;
import org.mariotaku.twidere.util.Utils;
@ -36,6 +38,7 @@ import org.mariotaku.twidere.util.Utils;
public class TintedStatusFrameLayout extends ExtendedFrameLayout {
private final Paint mBlackPaint, mShadowPaint, mColorPaint;
private final boolean mSetPadding;
private int mStatusBarHeight;
private float mFactor;
@ -52,6 +55,8 @@ public class TintedStatusFrameLayout extends ExtendedFrameLayout {
public TintedStatusFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TintedStatusLayout);
mSetPadding = a.getBoolean(R.styleable.TintedStatusLayout_setPadding, false);
mBlackPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBlackPaint.setColor(Color.BLACK);
mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
@ -111,6 +116,9 @@ public class TintedStatusFrameLayout extends ExtendedFrameLayout {
@Override
protected boolean fitSystemWindows(@NonNull Rect insets) {
setStatusBarHeight(Utils.getInsetsTopWithoutActionBarHeight(getContext(), insets.top));
if (mSetPadding) {
setPadding(insets.left, insets.top, insets.right, insets.bottom);
}
return super.fitSystemWindows(insets);
}

View File

@ -21,9 +21,7 @@
<org.mariotaku.twidere.view.TintedStatusFrameLayout
android:id="@+id/main_content"
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">
<include layout="@layout/layout_content_pages_common"/>
</org.mariotaku.twidere.view.TintedStatusFrameLayout>
android:layout_height="match_parent"
app:setPadding="true"/>

View File

@ -17,13 +17,15 @@
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout
<org.mariotaku.twidere.view.TintedStatusFrameLayout
android:id="@+id/main_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="match_parent"
android:animateLayoutChanges="true">
android:animateLayoutChanges="true"
app:setPadding="true">
<FrameLayout
android:id="@+id/list_container"
@ -72,4 +74,4 @@
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
</FrameLayout>
</org.mariotaku.twidere.view.TintedStatusFrameLayout>

View File

@ -2,7 +2,7 @@
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~ 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
@ -18,17 +18,14 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<org.mariotaku.twidere.view.MainFrameLayout
<org.mariotaku.twidere.view.TintedStatusFrameLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activity.FiltersActivity">
app:setPadding="true">
<org.mariotaku.twidere.view.ExtendedViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<include layout="@layout/layout_content_pages_common"/>
</org.mariotaku.twidere.view.MainFrameLayout>
</org.mariotaku.twidere.view.TintedStatusFrameLayout>

View File

@ -19,21 +19,20 @@
-->
<org.mariotaku.twidere.view.TintedStatusFrameLayout
android:id="@+id/main_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:id="@+id/main_content"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">
android:orientation="vertical"
app:setPadding="true">
<ScrollView
android:id="@+id/edit_profile_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/done_bar"
android:visibility="gone"
tools:visibility="visible">
@ -344,8 +343,6 @@
android:id="@+id/progress_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/done_bar"
android:visibility="visible"
tools:visibility="gone">

View File

@ -90,6 +90,9 @@
<attr name="headerLayout" format="reference"/>
<attr name="contentLayout" format="reference"/>
</declare-styleable>
<declare-styleable name="TintedStatusLayout">
<attr name="setPadding" format="boolean"/>
</declare-styleable>
<attr name="notificationType">
<flag name="none" value="0"/>
<flag name="ringtone" value="1"/>