supports android L
This commit is contained in:
parent
a0ad70b573
commit
059360a942
|
@ -38,8 +38,6 @@ import android.view.animation.TranslateAnimation;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import me.imid.swipebacklayout.lib.SwipeBackLayout.SwipeListener;
|
||||
|
||||
import org.mariotaku.gallery3d.ui.GLRoot;
|
||||
import org.mariotaku.gallery3d.ui.GLRootView;
|
||||
import org.mariotaku.gallery3d.ui.GLView;
|
||||
|
@ -51,520 +49,523 @@ import org.mariotaku.menucomponent.widget.MenuBar;
|
|||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.support.TwidereSwipeBackActivity;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.SaveImageTask;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.imid.swipebacklayout.lib.SwipeBackLayout.SwipeListener;
|
||||
|
||||
public final class ImageViewerGLActivity extends TwidereSwipeBackActivity implements Constants, PhotoView.Listener,
|
||||
GLImageLoader.DownloadListener, LoaderManager.LoaderCallbacks<GLImageLoader.Result>, OnMenuVisibilityListener,
|
||||
SwipeListener, OnMenuItemClickListener {
|
||||
GLImageLoader.DownloadListener, LoaderManager.LoaderCallbacks<GLImageLoader.Result>, OnMenuVisibilityListener,
|
||||
SwipeListener, OnMenuItemClickListener {
|
||||
|
||||
private final GLView mRootPane = new GLView() {
|
||||
@Override
|
||||
protected void onLayout(final boolean changed, final int left, final int top, final int right, final int bottom) {
|
||||
mPhotoView.layout(0, 0, right - left, bottom - top);
|
||||
}
|
||||
};
|
||||
protected static final int FLAG_HIDE_ACTION_BAR = 1;
|
||||
protected static final int FLAG_HIDE_STATUS_BAR = 2;
|
||||
private final GLView mRootPane = new GLView() {
|
||||
@Override
|
||||
protected void onLayout(final boolean changed, final int left, final int top, final int right, final int bottom) {
|
||||
mPhotoView.layout(0, 0, right - left, bottom - top);
|
||||
}
|
||||
};
|
||||
protected static final int FLAG_HIDE_ACTION_BAR = 1;
|
||||
protected static final int FLAG_HIDE_STATUS_BAR = 2;
|
||||
|
||||
private static final int MSG_HIDE_BARS = 1;
|
||||
private static final int MSG_ON_FULL_SCREEN_CHANGED = 4;
|
||||
private static final int MSG_UPDATE_ACTION_BAR = 5;
|
||||
private static final int MSG_UNFREEZE_GLROOT = 6;
|
||||
private static final int MSG_WANT_BARS = 7;
|
||||
private static final int MSG_REFRESH_BOTTOM_CONTROLS = 8;
|
||||
private static final int UNFREEZE_GLROOT_TIMEOUT = 250;
|
||||
private static final int MSG_HIDE_BARS = 1;
|
||||
private static final int MSG_ON_FULL_SCREEN_CHANGED = 4;
|
||||
private static final int MSG_UPDATE_ACTION_BAR = 5;
|
||||
private static final int MSG_UNFREEZE_GLROOT = 6;
|
||||
private static final int MSG_WANT_BARS = 7;
|
||||
private static final int MSG_REFRESH_BOTTOM_CONTROLS = 8;
|
||||
private static final int UNFREEZE_GLROOT_TIMEOUT = 250;
|
||||
|
||||
private ActionBar mActionBar;
|
||||
private ActionBar mActionBar;
|
||||
|
||||
private GLView mContentPane;
|
||||
private GLRootView mGLRootView;
|
||||
private ProgressBar mProgress;
|
||||
private ImageView mImageViewer;
|
||||
private MenuBar mMenuBar;
|
||||
private GLView mContentPane;
|
||||
private GLRootView mGLRootView;
|
||||
private ProgressBar mProgress;
|
||||
private ImageView mImageViewer;
|
||||
private MenuBar mMenuBar;
|
||||
|
||||
private PhotoView mPhotoView;
|
||||
private PhotoView mPhotoView;
|
||||
|
||||
private PhotoView.ITileImageAdapter mAdapter;
|
||||
private Handler mHandler;
|
||||
protected int mFlags;
|
||||
private PhotoView.ITileImageAdapter mAdapter;
|
||||
private Handler mHandler;
|
||||
protected int mFlags;
|
||||
|
||||
private boolean mShowBars = true;
|
||||
private boolean mActionBarAllowed = true;
|
||||
private boolean mLoaderInitialized;
|
||||
private boolean mShowBars = true;
|
||||
private boolean mActionBarAllowed = true;
|
||||
private boolean mLoaderInitialized;
|
||||
|
||||
private long mContentLength;
|
||||
private ThreadPool mThreadPool;
|
||||
private long mContentLength;
|
||||
private ThreadPool mThreadPool;
|
||||
|
||||
private File mImageFile;
|
||||
private File mImageFile;
|
||||
|
||||
public GLRoot getGLRoot() {
|
||||
return mGLRootView;
|
||||
}
|
||||
public GLRoot getGLRoot() {
|
||||
return mGLRootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId() {
|
||||
return ThemeUtils.getViewerThemeResource(this);
|
||||
}
|
||||
@Override
|
||||
public int getThemeResourceId() {
|
||||
return ThemeUtils.getViewerThemeResource(this);
|
||||
}
|
||||
|
||||
public ThreadPool getThreadPool() {
|
||||
if (mThreadPool != null) return mThreadPool;
|
||||
return mThreadPool = new ThreadPool();
|
||||
}
|
||||
public ThreadPool getThreadPool() {
|
||||
if (mThreadPool != null) return mThreadPool;
|
||||
return mThreadPool = new ThreadPool();
|
||||
}
|
||||
|
||||
public void hideProgress() {
|
||||
mProgress.setVisibility(View.GONE);
|
||||
mProgress.setProgress(0);
|
||||
}
|
||||
public void hideProgress() {
|
||||
mProgress.setVisibility(View.GONE);
|
||||
mProgress.setProgress(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionBarAllowed(final boolean allowed) {
|
||||
mActionBarAllowed = allowed;
|
||||
mHandler.sendEmptyMessage(MSG_UPDATE_ACTION_BAR);
|
||||
}
|
||||
@Override
|
||||
public void onActionBarAllowed(final boolean allowed) {
|
||||
mActionBarAllowed = allowed;
|
||||
mHandler.sendEmptyMessage(MSG_UPDATE_ACTION_BAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionBarWanted() {
|
||||
mHandler.sendEmptyMessage(MSG_WANT_BARS);
|
||||
}
|
||||
@Override
|
||||
public void onActionBarWanted() {
|
||||
mHandler.sendEmptyMessage(MSG_WANT_BARS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentChanged() {
|
||||
super.onContentChanged();
|
||||
mGLRootView = (GLRootView) findViewById(R.id.gl_root_view);
|
||||
mImageViewer = (ImageView) findViewById(R.id.image_viewer);
|
||||
mProgress = (ProgressBar) findViewById(R.id.progress);
|
||||
mMenuBar = (MenuBar) findViewById(R.id.menu_bar);
|
||||
}
|
||||
@Override
|
||||
public void onContentChanged() {
|
||||
super.onContentChanged();
|
||||
mGLRootView = (GLRootView) findViewById(R.id.gl_root_view);
|
||||
mImageViewer = (ImageView) findViewById(R.id.image_viewer);
|
||||
mProgress = (ProgressBar) findViewById(R.id.progress);
|
||||
mMenuBar = (MenuBar) findViewById(R.id.menu_bar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<GLImageLoader.Result> onCreateLoader(final int id, final Bundle args) {
|
||||
mProgress.setVisibility(View.VISIBLE);
|
||||
mProgress.setIndeterminate(true);
|
||||
invalidateOptionsMenu();
|
||||
final Uri uri = args.getParcelable(EXTRA_URI);
|
||||
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
return new GLImageLoader(this, this, accountId, uri);
|
||||
}
|
||||
@Override
|
||||
public Loader<GLImageLoader.Result> onCreateLoader(final int id, final Bundle args) {
|
||||
mProgress.setVisibility(View.VISIBLE);
|
||||
mProgress.setIndeterminate(true);
|
||||
invalidateOptionsMenu();
|
||||
final Uri uri = args.getParcelable(EXTRA_URI);
|
||||
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
return new GLImageLoader(this, this, accountId, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_image_viewer_action_bar, menu);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu, TwidereMenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_image_viewer_action_bar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentImageUpdated() {
|
||||
mGLRootView.unfreeze();
|
||||
}
|
||||
@Override
|
||||
public void onCurrentImageUpdated() {
|
||||
mGLRootView.unfreeze();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadError(final Throwable t) {
|
||||
mContentLength = 0;
|
||||
}
|
||||
@Override
|
||||
public void onDownloadError(final Throwable t) {
|
||||
mContentLength = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadFinished() {
|
||||
mContentLength = 0;
|
||||
}
|
||||
@Override
|
||||
public void onDownloadFinished() {
|
||||
mContentLength = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadStart(final long total) {
|
||||
mContentLength = total;
|
||||
mProgress.setIndeterminate(total <= 0);
|
||||
mProgress.setMax(total > 0 ? (int) (total / 1024) : 0);
|
||||
}
|
||||
@Override
|
||||
public void onDownloadStart(final long total) {
|
||||
mContentLength = total;
|
||||
mProgress.setIndeterminate(total <= 0);
|
||||
mProgress.setMax(total > 0 ? (int) (total / 1024) : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEdgeTouch(final int edgeFlag) {
|
||||
showBars();
|
||||
}
|
||||
@Override
|
||||
public void onEdgeTouch(final int edgeFlag) {
|
||||
showBars();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<GLImageLoader.Result> loader) {
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<GLImageLoader.Result> loader) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(final Loader<GLImageLoader.Result> loader, final GLImageLoader.Result data) {
|
||||
if (data != null && (data.decoder != null || data.bitmap != null)) {
|
||||
if (data.decoder != null) {
|
||||
mGLRootView.setVisibility(View.VISIBLE);
|
||||
mImageViewer.setVisibility(View.GONE);
|
||||
mAdapter.setData(data.decoder, data.bitmap, data.orientation);
|
||||
mImageViewer.setImageBitmap(null);
|
||||
} else if (data.bitmap != null) {
|
||||
mGLRootView.setVisibility(View.GONE);
|
||||
mImageViewer.setVisibility(View.VISIBLE);
|
||||
mImageViewer.setImageBitmap(data.bitmap);
|
||||
}
|
||||
mImageFile = data.file;
|
||||
} else {
|
||||
mImageFile = null;
|
||||
if (data != null) {
|
||||
Utils.showErrorMessage(this, null, data.exception, true);
|
||||
}
|
||||
}
|
||||
mProgress.setVisibility(View.GONE);
|
||||
mProgress.setProgress(0);
|
||||
invalidateOptionsMenu();
|
||||
updateShareIntent();
|
||||
}
|
||||
@Override
|
||||
public void onLoadFinished(final Loader<GLImageLoader.Result> loader, final GLImageLoader.Result data) {
|
||||
if (data != null && (data.decoder != null || data.bitmap != null)) {
|
||||
if (data.decoder != null) {
|
||||
mGLRootView.setVisibility(View.VISIBLE);
|
||||
mImageViewer.setVisibility(View.GONE);
|
||||
mAdapter.setData(data.decoder, data.bitmap, data.orientation);
|
||||
mImageViewer.setImageBitmap(null);
|
||||
} else if (data.bitmap != null) {
|
||||
mGLRootView.setVisibility(View.GONE);
|
||||
mImageViewer.setVisibility(View.VISIBLE);
|
||||
mImageViewer.setImageBitmap(data.bitmap);
|
||||
}
|
||||
mImageFile = data.file;
|
||||
} else {
|
||||
mImageFile = null;
|
||||
if (data != null) {
|
||||
Utils.showErrorMessage(this, null, data.exception, true);
|
||||
}
|
||||
}
|
||||
mProgress.setVisibility(View.GONE);
|
||||
mProgress.setProgress(0);
|
||||
invalidateOptionsMenu();
|
||||
updateShareIntent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_SAVE: {
|
||||
if (mImageFile != null) {
|
||||
new SaveImageTask(this, mImageFile).execute();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MENU_OPEN_IN_BROWSER: {
|
||||
final Intent intent = getIntent();
|
||||
intent.setExtrasClassLoader(getClassLoader());
|
||||
final Uri uri = intent.getData();
|
||||
final Uri orig = intent.getParcelableExtra(EXTRA_URI_ORIG);
|
||||
final Uri uriPreferred = orig != null ? orig : uri;
|
||||
if (uriPreferred == null) return false;
|
||||
final String scheme = uriPreferred.getScheme();
|
||||
if ("http".equals(scheme) || "https".equals(scheme)) {
|
||||
final Intent open_intent = new Intent(Intent.ACTION_VIEW, uriPreferred);
|
||||
open_intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
try {
|
||||
startActivity(open_intent);
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
final Intent intent = item.getIntent();
|
||||
if (intent != null) {
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
// Ignore.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_SAVE: {
|
||||
if (mImageFile != null) {
|
||||
new SaveImageTask(this, mImageFile).execute();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MENU_OPEN_IN_BROWSER: {
|
||||
final Intent intent = getIntent();
|
||||
intent.setExtrasClassLoader(getClassLoader());
|
||||
final Uri uri = intent.getData();
|
||||
final Uri orig = intent.getParcelableExtra(EXTRA_URI_ORIG);
|
||||
final Uri uriPreferred = orig != null ? orig : uri;
|
||||
if (uriPreferred == null) return false;
|
||||
final String scheme = uriPreferred.getScheme();
|
||||
if ("http".equals(scheme) || "https".equals(scheme)) {
|
||||
final Intent open_intent = new Intent(Intent.ACTION_VIEW, uriPreferred);
|
||||
open_intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
try {
|
||||
startActivity(open_intent);
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
final Intent intent = item.getIntent();
|
||||
if (intent != null) {
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
// Ignore.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenuVisibilityChanged(final boolean isVisible) {
|
||||
}
|
||||
@Override
|
||||
public void onMenuVisibilityChanged(final boolean isVisible) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_HOME: {
|
||||
onBackPressed();
|
||||
break;
|
||||
}
|
||||
case MENU_REFRESH: {
|
||||
loadImage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_HOME: {
|
||||
onBackPressed();
|
||||
break;
|
||||
}
|
||||
case MENU_REFRESH: {
|
||||
loadImage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPictureCenter() {
|
||||
mPhotoView.setWantPictureCenterCallbacks(false);
|
||||
}
|
||||
@Override
|
||||
public void onPictureCenter() {
|
||||
mPhotoView.setWantPictureCenterCallbacks(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(final Menu menu) {
|
||||
final LoaderManager lm = getSupportLoaderManager();
|
||||
Utils.setMenuItemAvailability(menu, MENU_REFRESH, !lm.hasRunningLoaders());
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(final Menu menu) {
|
||||
final LoaderManager lm = getSupportLoaderManager();
|
||||
Utils.setMenuItemAvailability(menu, MENU_REFRESH, !lm.hasRunningLoaders());
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressUpdate(final long downloaded) {
|
||||
if (mContentLength == 0) {
|
||||
mProgress.setIndeterminate(true);
|
||||
return;
|
||||
}
|
||||
mProgress.setIndeterminate(false);
|
||||
mProgress.setProgress((int) (downloaded / 1024));
|
||||
}
|
||||
@Override
|
||||
public void onProgressUpdate(final long downloaded) {
|
||||
if (mContentLength == 0) {
|
||||
mProgress.setIndeterminate(true);
|
||||
return;
|
||||
}
|
||||
mProgress.setIndeterminate(false);
|
||||
mProgress.setProgress((int) (downloaded / 1024));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollOverThreshold() {
|
||||
@Override
|
||||
public void onScrollOverThreshold() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChange(final int state, final float scrollPercent) {
|
||||
@Override
|
||||
public void onScrollStateChange(final int state, final float scrollPercent) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSingleTapUp(final int x, final int y) {
|
||||
toggleBars();
|
||||
}
|
||||
@Override
|
||||
public void onSingleTapUp(final int x, final int y) {
|
||||
toggleBars();
|
||||
}
|
||||
|
||||
public void showProgress() {
|
||||
mProgress.setVisibility(View.VISIBLE);
|
||||
mProgress.setIndeterminate(true);
|
||||
}
|
||||
public void showProgress() {
|
||||
mProgress.setVisibility(View.VISIBLE);
|
||||
mProgress.setIndeterminate(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.image_viewer_gl);
|
||||
mActionBar = getActionBar();
|
||||
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
mActionBar.addOnMenuVisibilityListener(this);
|
||||
mHandler = new MyHandler(this);
|
||||
mPhotoView = new PhotoView(this);
|
||||
mPhotoView.setListener(this);
|
||||
final int bgColor = ThemeUtils.getColorBackgroundCacheHint(this);
|
||||
final int r = Color.red(bgColor), g = Color.green(bgColor), b = Color.blue(bgColor);
|
||||
final float[] rootBg = { r / 255f, g / 255f, b / 255f, 1 };
|
||||
mRootPane.setBackgroundColor(rootBg);
|
||||
mRootPane.addComponent(mPhotoView);
|
||||
mAdapter = new PhotoViewAdapter(mPhotoView);
|
||||
mPhotoView.setModel(mAdapter);
|
||||
if (savedInstanceState == null) {
|
||||
loadImage();
|
||||
}
|
||||
mMenuBar.setOnMenuItemClickListener(this);
|
||||
mMenuBar.inflate(R.menu.menu_image_viewer);
|
||||
mMenuBar.setIsBottomBar(true);
|
||||
mMenuBar.show();
|
||||
setSwipeListener(this);
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.image_viewer_gl);
|
||||
mActionBar = getActionBar();
|
||||
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
mActionBar.addOnMenuVisibilityListener(this);
|
||||
mHandler = new MyHandler(this);
|
||||
mPhotoView = new PhotoView(this);
|
||||
mPhotoView.setListener(this);
|
||||
final int bgColor = ThemeUtils.getColorBackgroundCacheHint(this);
|
||||
final int r = Color.red(bgColor), g = Color.green(bgColor), b = Color.blue(bgColor);
|
||||
final float[] rootBg = {r / 255f, g / 255f, b / 255f, 1};
|
||||
mRootPane.setBackgroundColor(rootBg);
|
||||
mRootPane.addComponent(mPhotoView);
|
||||
mAdapter = new PhotoViewAdapter(mPhotoView);
|
||||
mPhotoView.setModel(mAdapter);
|
||||
if (savedInstanceState == null) {
|
||||
loadImage();
|
||||
}
|
||||
mMenuBar.setOnMenuItemClickListener(this);
|
||||
mMenuBar.inflate(R.menu.menu_image_viewer);
|
||||
mMenuBar.setIsBottomBar(true);
|
||||
mMenuBar.show();
|
||||
setSwipeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mActionBar.removeOnMenuVisibilityListener(this);
|
||||
super.onDestroy();
|
||||
mGLRootView.lockRenderThread();
|
||||
try {
|
||||
// Remove all pending messages.
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
} finally {
|
||||
mGLRootView.unlockRenderThread();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mActionBar.removeOnMenuVisibilityListener(this);
|
||||
super.onDestroy();
|
||||
mGLRootView.lockRenderThread();
|
||||
try {
|
||||
// Remove all pending messages.
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
} finally {
|
||||
mGLRootView.unlockRenderThread();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(final Intent intent) {
|
||||
setIntent(intent);
|
||||
loadImage();
|
||||
}
|
||||
@Override
|
||||
protected void onNewIntent(final Intent intent) {
|
||||
setIntent(intent);
|
||||
loadImage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mGLRootView.onPause();
|
||||
mGLRootView.lockRenderThread();
|
||||
try {
|
||||
mGLRootView.unfreeze();
|
||||
mHandler.removeMessages(MSG_UNFREEZE_GLROOT);
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mGLRootView.onPause();
|
||||
mGLRootView.lockRenderThread();
|
||||
try {
|
||||
mGLRootView.unfreeze();
|
||||
mHandler.removeMessages(MSG_UNFREEZE_GLROOT);
|
||||
|
||||
if (mAdapter != null) {
|
||||
mAdapter.recycleScreenNail();
|
||||
}
|
||||
mPhotoView.pause();
|
||||
mHandler.removeMessages(MSG_HIDE_BARS);
|
||||
mHandler.removeMessages(MSG_REFRESH_BOTTOM_CONTROLS);
|
||||
} finally {
|
||||
mGLRootView.unlockRenderThread();
|
||||
}
|
||||
if (mAdapter != null) {
|
||||
mAdapter.recycleScreenNail();
|
||||
}
|
||||
mPhotoView.pause();
|
||||
mHandler.removeMessages(MSG_HIDE_BARS);
|
||||
mHandler.removeMessages(MSG_REFRESH_BOTTOM_CONTROLS);
|
||||
} finally {
|
||||
mGLRootView.unlockRenderThread();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mGLRootView.lockRenderThread();
|
||||
try {
|
||||
if (mAdapter == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
mGLRootView.freeze();
|
||||
setContentPane(mRootPane);
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mGLRootView.lockRenderThread();
|
||||
try {
|
||||
if (mAdapter == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
mGLRootView.freeze();
|
||||
setContentPane(mRootPane);
|
||||
|
||||
mPhotoView.resume();
|
||||
if (!mShowBars) {
|
||||
hideBars();
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed(MSG_UNFREEZE_GLROOT, UNFREEZE_GLROOT_TIMEOUT);
|
||||
} finally {
|
||||
mGLRootView.unlockRenderThread();
|
||||
}
|
||||
mGLRootView.onResume();
|
||||
}
|
||||
mPhotoView.resume();
|
||||
if (!mShowBars) {
|
||||
hideBars();
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed(MSG_UNFREEZE_GLROOT, UNFREEZE_GLROOT_TIMEOUT);
|
||||
} finally {
|
||||
mGLRootView.unlockRenderThread();
|
||||
}
|
||||
mGLRootView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(final Bundle outState) {
|
||||
mGLRootView.lockRenderThread();
|
||||
try {
|
||||
super.onSaveInstanceState(outState);
|
||||
} finally {
|
||||
mGLRootView.unlockRenderThread();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onSaveInstanceState(final Bundle outState) {
|
||||
mGLRootView.lockRenderThread();
|
||||
try {
|
||||
super.onSaveInstanceState(outState);
|
||||
} finally {
|
||||
mGLRootView.unlockRenderThread();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setContentPane(final GLView content) {
|
||||
mContentPane = content;
|
||||
mContentPane.setBackgroundColor(GalleryUtils.intColorToFloatARGBArray(Color.BLACK));
|
||||
mGLRootView.setContentPane(mContentPane);
|
||||
}
|
||||
protected void setContentPane(final GLView content) {
|
||||
mContentPane = content;
|
||||
mContentPane.setBackgroundColor(GalleryUtils.intColorToFloatARGBArray(Color.BLACK));
|
||||
mGLRootView.setContentPane(mContentPane);
|
||||
}
|
||||
|
||||
private boolean canShowBars() {
|
||||
// No bars if it's not allowed.
|
||||
if (!mActionBarAllowed) return false;
|
||||
return true;
|
||||
}
|
||||
private boolean canShowBars() {
|
||||
// No bars if it's not allowed.
|
||||
if (!mActionBarAllowed) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void hideBars() {
|
||||
if (!mShowBars || isSwiping()) return;
|
||||
mShowBars = false;
|
||||
mActionBar.hide();
|
||||
final TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
|
||||
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1);
|
||||
anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
|
||||
anim.setAnimationListener(new AnimationListener() {
|
||||
private void hideBars() {
|
||||
if (!mShowBars || isSwiping()) return;
|
||||
mShowBars = false;
|
||||
mActionBar.hide();
|
||||
final TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
|
||||
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1);
|
||||
anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
|
||||
anim.setAnimationListener(new AnimationListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(final Animation animation) {
|
||||
mMenuBar.setVisibility(View.GONE);
|
||||
}
|
||||
@Override
|
||||
public void onAnimationEnd(final Animation animation) {
|
||||
mMenuBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(final Animation animation) {
|
||||
@Override
|
||||
public void onAnimationRepeat(final Animation animation) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(final Animation animation) {
|
||||
@Override
|
||||
public void onAnimationStart(final Animation animation) {
|
||||
|
||||
}
|
||||
});
|
||||
mMenuBar.startAnimation(anim);
|
||||
mHandler.removeMessages(MSG_HIDE_BARS);
|
||||
}
|
||||
}
|
||||
});
|
||||
mMenuBar.startAnimation(anim);
|
||||
mHandler.removeMessages(MSG_HIDE_BARS);
|
||||
}
|
||||
|
||||
private void loadImage() {
|
||||
getSupportLoaderManager().destroyLoader(0);
|
||||
final Intent intent = getIntent();
|
||||
final Uri uri = intent.getData();
|
||||
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
|
||||
if (uri == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
final Bundle args = new Bundle();
|
||||
args.putParcelable(EXTRA_URI, uri);
|
||||
args.putLong(EXTRA_ACCOUNT_ID, accountId);
|
||||
if (!mLoaderInitialized) {
|
||||
getSupportLoaderManager().initLoader(0, args, this);
|
||||
mLoaderInitialized = true;
|
||||
} else {
|
||||
getSupportLoaderManager().restartLoader(0, args, this);
|
||||
}
|
||||
}
|
||||
private void loadImage() {
|
||||
getSupportLoaderManager().destroyLoader(0);
|
||||
final Intent intent = getIntent();
|
||||
final Uri uri = intent.getData();
|
||||
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
|
||||
if (uri == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
final Bundle args = new Bundle();
|
||||
args.putParcelable(EXTRA_URI, uri);
|
||||
args.putLong(EXTRA_ACCOUNT_ID, accountId);
|
||||
if (!mLoaderInitialized) {
|
||||
getSupportLoaderManager().initLoader(0, args, this);
|
||||
mLoaderInitialized = true;
|
||||
} else {
|
||||
getSupportLoaderManager().restartLoader(0, args, this);
|
||||
}
|
||||
}
|
||||
|
||||
private void showBars() {
|
||||
if (mShowBars) return;
|
||||
mShowBars = true;
|
||||
mActionBar.show();
|
||||
mMenuBar.setVisibility(View.VISIBLE);
|
||||
final TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
|
||||
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
|
||||
anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
|
||||
mMenuBar.startAnimation(anim);
|
||||
}
|
||||
private void showBars() {
|
||||
if (mShowBars) return;
|
||||
mShowBars = true;
|
||||
mActionBar.show();
|
||||
mMenuBar.setVisibility(View.VISIBLE);
|
||||
final TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
|
||||
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
|
||||
anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
|
||||
mMenuBar.startAnimation(anim);
|
||||
}
|
||||
|
||||
private void toggleBars() {
|
||||
if (mShowBars) {
|
||||
hideBars();
|
||||
} else {
|
||||
if (canShowBars()) {
|
||||
showBars();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void toggleBars() {
|
||||
if (mShowBars) {
|
||||
hideBars();
|
||||
} else {
|
||||
if (canShowBars()) {
|
||||
showBars();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBars() {
|
||||
if (!canShowBars()) {
|
||||
hideBars();
|
||||
}
|
||||
}
|
||||
private void updateBars() {
|
||||
if (!canShowBars()) {
|
||||
hideBars();
|
||||
}
|
||||
}
|
||||
|
||||
private void wantBars() {
|
||||
if (canShowBars()) {
|
||||
showBars();
|
||||
}
|
||||
}
|
||||
private void wantBars() {
|
||||
if (canShowBars()) {
|
||||
showBars();
|
||||
}
|
||||
}
|
||||
|
||||
void updateShareIntent() {
|
||||
final MenuItem item = mMenuBar.getMenu().findItem(MENU_SHARE);
|
||||
if (item == null || !item.hasSubMenu()) return;
|
||||
final SubMenu subMenu = item.getSubMenu();
|
||||
subMenu.clear();
|
||||
final Intent intent = getIntent();
|
||||
final Uri uri = intent.getData();
|
||||
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
if (mImageFile != null && mImageFile.exists()) {
|
||||
shareIntent.setType("image/*");
|
||||
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mImageFile));
|
||||
} else {
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, uri.toString());
|
||||
}
|
||||
Utils.addIntentToMenu(this, subMenu, shareIntent);
|
||||
}
|
||||
void updateShareIntent() {
|
||||
final MenuItem item = mMenuBar.getMenu().findItem(MENU_SHARE);
|
||||
if (item == null || !item.hasSubMenu()) return;
|
||||
final SubMenu subMenu = item.getSubMenu();
|
||||
subMenu.clear();
|
||||
final Intent intent = getIntent();
|
||||
final Uri uri = intent.getData();
|
||||
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
if (mImageFile != null && mImageFile.exists()) {
|
||||
shareIntent.setType("image/*");
|
||||
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mImageFile));
|
||||
} else {
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, uri.toString());
|
||||
}
|
||||
Utils.addIntentToMenu(this, subMenu, shareIntent);
|
||||
}
|
||||
|
||||
private static class MyHandler extends SynchronizedHandler {
|
||||
ImageViewerGLActivity activity;
|
||||
private static class MyHandler extends SynchronizedHandler {
|
||||
ImageViewerGLActivity activity;
|
||||
|
||||
private MyHandler(final ImageViewerGLActivity activity) {
|
||||
super(activity.getGLRoot());
|
||||
this.activity = activity;
|
||||
}
|
||||
private MyHandler(final ImageViewerGLActivity activity) {
|
||||
super(activity.getGLRoot());
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(final Message message) {
|
||||
switch (message.what) {
|
||||
case MSG_HIDE_BARS: {
|
||||
activity.hideBars();
|
||||
break;
|
||||
}
|
||||
case MSG_REFRESH_BOTTOM_CONTROLS: {
|
||||
break;
|
||||
}
|
||||
case MSG_ON_FULL_SCREEN_CHANGED: {
|
||||
break;
|
||||
}
|
||||
case MSG_UPDATE_ACTION_BAR: {
|
||||
activity.updateBars();
|
||||
break;
|
||||
}
|
||||
case MSG_WANT_BARS: {
|
||||
activity.wantBars();
|
||||
break;
|
||||
}
|
||||
case MSG_UNFREEZE_GLROOT: {
|
||||
mGLRoot.unfreeze();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void handleMessage(final Message message) {
|
||||
switch (message.what) {
|
||||
case MSG_HIDE_BARS: {
|
||||
activity.hideBars();
|
||||
break;
|
||||
}
|
||||
case MSG_REFRESH_BOTTOM_CONTROLS: {
|
||||
break;
|
||||
}
|
||||
case MSG_ON_FULL_SCREEN_CHANGED: {
|
||||
break;
|
||||
}
|
||||
case MSG_UPDATE_ACTION_BAR: {
|
||||
activity.updateBars();
|
||||
break;
|
||||
}
|
||||
case MSG_WANT_BARS: {
|
||||
activity.wantBars();
|
||||
break;
|
||||
}
|
||||
case MSG_UNFREEZE_GLROOT: {
|
||||
mGLRoot.unfreeze();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class AccentActivity extends Activity {
|
|||
return mAccentHelper.getResources(this, super.getResources());
|
||||
}
|
||||
|
||||
public Resources getDefaultResources() {
|
||||
public final Resources getDefaultResources() {
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,18 @@
|
|||
|
||||
package org.mariotaku.twidere.activity;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.Resources.Theme;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.Menu;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.content.res.NoAccentResources;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.theme.TwidereResourceHelper;
|
||||
|
||||
|
@ -39,6 +42,27 @@ public abstract class BasePreferenceActivity extends PreferenceActivity implemen
|
|||
private TwidereResourceHelper mResourceHelper;
|
||||
private int mCurrentThemeResource;
|
||||
private Theme mTheme;
|
||||
private TwidereMenuInflater mMenuInflater;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onCreateOptionsMenu(Menu menu) {
|
||||
return onCreateOptionsMenu(menu, getTwidereMenuInflater());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TwidereMenuInflater getTwidereMenuInflater() {
|
||||
if (mMenuInflater != null) return mMenuInflater;
|
||||
final ActionBar actionBar = getActionBar();
|
||||
if (actionBar != null) {
|
||||
return mMenuInflater = new TwidereMenuInflater(actionBar.getThemedContext());
|
||||
}
|
||||
return mMenuInflater = new TwidereMenuInflater(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
|
|
|
@ -19,13 +19,16 @@
|
|||
|
||||
package org.mariotaku.twidere.activity;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.content.res.Resources.Theme;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.Menu;
|
||||
|
||||
import com.negusoft.holoaccent.AccentResources;
|
||||
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.CompareUtils;
|
||||
import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
@ -38,6 +41,7 @@ public abstract class BaseThemedActivity extends AccentActivity implements IThem
|
|||
private int mCurrentThemeResource, mCurrentThemeColor, mCurrentThemeBackgroundAlpha;
|
||||
private String mCurrentThemeFontFamily;
|
||||
private Theme mTheme;
|
||||
private TwidereMenuInflater mMenuInflater;
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
|
@ -45,6 +49,26 @@ public abstract class BaseThemedActivity extends AccentActivity implements IThem
|
|||
overrideCloseAnimationIfNeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onCreateOptionsMenu(Menu menu) {
|
||||
return onCreateOptionsMenu(menu, getTwidereMenuInflater());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TwidereMenuInflater getTwidereMenuInflater() {
|
||||
if (mMenuInflater != null) return mMenuInflater;
|
||||
final ActionBar actionBar = getActionBar();
|
||||
if (actionBar != null) {
|
||||
return mMenuInflater = new TwidereMenuInflater(actionBar.getThemedContext());
|
||||
}
|
||||
return mMenuInflater = new TwidereMenuInflater(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getCurrentThemeResourceId() {
|
||||
return mCurrentThemeResource;
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.mariotaku.twidere.fragment.BaseFiltersFragment.FilteredLinksFragment;
|
|||
import org.mariotaku.twidere.fragment.BaseFiltersFragment.FilteredSourcesFragment;
|
||||
import org.mariotaku.twidere.fragment.BaseFiltersFragment.FilteredUsersFragment;
|
||||
import org.mariotaku.twidere.fragment.support.BaseSupportDialogFragment;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.provider.TweetStore.Filters;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
|
@ -100,8 +101,8 @@ public class FiltersActivity extends BaseSupportActivity implements TabListener,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_filters, menu);
|
||||
public boolean onCreateOptionsMenu(final Menu menu, final TwidereMenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_filters, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.mariotaku.twidere.R;
|
|||
import org.mariotaku.twidere.activity.support.DataExportActivity;
|
||||
import org.mariotaku.twidere.activity.support.DataImportActivity;
|
||||
import org.mariotaku.twidere.adapter.ArrayAdapter;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.CompareUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.view.holder.ViewHolder;
|
||||
|
@ -97,9 +98,9 @@ public class SettingsActivity extends BasePreferenceActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
public boolean onCreateOptionsMenu(final Menu menu, final TwidereMenuInflater inflater) {
|
||||
if (getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT) != null) return false;
|
||||
getMenuInflater().inflate(R.menu.menu_settings, menu);
|
||||
inflater.inflate(R.menu.menu_settings, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,10 @@
|
|||
package org.mariotaku.twidere.activity.iface;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.view.Menu;
|
||||
|
||||
import org.mariotaku.twidere.content.iface.ITwidereContextWrapper;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
|
||||
public interface IThemedActivity extends ITwidereContextWrapper {
|
||||
|
||||
|
@ -33,6 +35,8 @@ public interface IThemedActivity extends ITwidereContextWrapper {
|
|||
|
||||
public int getThemeColor();
|
||||
|
||||
public TwidereMenuInflater getTwidereMenuInflater();
|
||||
|
||||
public String getThemeFontFamily();
|
||||
|
||||
public boolean isDarkDrawerEnabled();
|
||||
|
@ -43,5 +47,7 @@ public interface IThemedActivity extends ITwidereContextWrapper {
|
|||
|
||||
public void restart();
|
||||
|
||||
public boolean onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater);
|
||||
|
||||
public boolean shouldOverrideActivityAnimation();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class AccentFragmentActivity extends FragmentActivity {
|
|||
return mAccentHelper.getResources(this, super.getResources());
|
||||
}
|
||||
|
||||
public Resources getDefaultResources() {
|
||||
public final Resources getDefaultResources() {
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,16 @@
|
|||
|
||||
package org.mariotaku.twidere.activity.support;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.app.ActionBar;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.Menu;
|
||||
|
||||
import com.negusoft.holoaccent.AccentResources;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
@ -36,6 +38,7 @@ import static org.mariotaku.twidere.util.Utils.restartActivity;
|
|||
public abstract class BaseSupportThemedActivity extends AccentFragmentActivity implements Constants, IThemedActivity {
|
||||
|
||||
private int mCurrentThemeResource, mCurrentThemeColor, mCurrentThemeBackgroundAlpha;
|
||||
private TwidereMenuInflater mMenuInflater;
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
|
@ -44,13 +47,28 @@ public abstract class BaseSupportThemedActivity extends AccentFragmentActivity i
|
|||
}
|
||||
|
||||
@Override
|
||||
public final int getCurrentThemeResourceId() {
|
||||
return mCurrentThemeResource;
|
||||
public boolean onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Resources getDefaultResources() {
|
||||
return super.getResources();
|
||||
public final boolean onCreateOptionsMenu(Menu menu) {
|
||||
return onCreateOptionsMenu(menu, getTwidereMenuInflater());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TwidereMenuInflater getTwidereMenuInflater() {
|
||||
if (mMenuInflater != null) return mMenuInflater;
|
||||
final ActionBar actionBar = getActionBar();
|
||||
if (actionBar != null) {
|
||||
return mMenuInflater = new TwidereMenuInflater(actionBar.getThemedContext());
|
||||
}
|
||||
return mMenuInflater = new TwidereMenuInflater(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getCurrentThemeResourceId() {
|
||||
return mCurrentThemeResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,6 +34,7 @@ import org.mariotaku.twidere.R;
|
|||
import org.mariotaku.twidere.fragment.iface.IMapFragment;
|
||||
import org.mariotaku.twidere.fragment.support.NativeMapFragment;
|
||||
import org.mariotaku.twidere.fragment.support.WebMapFragment;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
||||
public class MapViewerActivity extends TwidereSwipeBackActivity implements Constants {
|
||||
|
@ -44,8 +45,8 @@ public class MapViewerActivity extends TwidereSwipeBackActivity implements Const
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_map_viewer, menu);
|
||||
public boolean onCreateOptionsMenu(final Menu menu, final TwidereMenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_map_viewer, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -100,7 +100,7 @@ public class UserHashtagAutoCompleteAdapter extends SimpleCursorAdapter implemen
|
|||
themeRes = ThemeUtils.getThemeResource(context);
|
||||
accentColor = ThemeUtils.getUserThemeColor(context);
|
||||
}
|
||||
mResources = ThemeUtils.getAccentResourcesForActionIcons(context, themeRes, accentColor);
|
||||
mResources = ThemeUtils.getThemedResourcesForActionIcons(context, themeRes, accentColor);
|
||||
}
|
||||
|
||||
public UserHashtagAutoCompleteAdapter(final EditText view) {
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package org.mariotaku.twidere.content.res;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
|
||||
import com.negusoft.holoaccent.AccentResources;
|
||||
|
||||
import org.mariotaku.twidere.content.res.iface.IThemedResources;
|
||||
|
||||
public class TwidereAccentResources extends AccentResources implements IThemedResources {
|
||||
|
||||
private final Helper mHelper;
|
||||
|
||||
public TwidereAccentResources(final Context context, final Resources res, final int overrideThemeRes,
|
||||
final int accentColor) {
|
||||
super(context, res, accentColor);
|
||||
mHelper = new Helper(this, context, overrideThemeRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDrawableInterceptor(final DrawableInterceptor interceptor) {
|
||||
mHelper.addDrawableInterceptor(interceptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getDrawable(final int id) throws NotFoundException {
|
||||
final Drawable d = mHelper.getDrawable(id);
|
||||
if (d != null) return d;
|
||||
return super.getDrawable(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package org.mariotaku.twidere.content.res;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import org.mariotaku.twidere.content.res.iface.IThemedResources;
|
||||
|
||||
public class TwidereResources extends Resources implements IThemedResources {
|
||||
|
||||
private final Helper mHelper;
|
||||
|
||||
public TwidereResources(final Context context, final Resources res, final int overrideThemeRes) {
|
||||
super(res.getAssets(), res.getDisplayMetrics(), res.getConfiguration());
|
||||
mHelper = new Helper(this, context, overrideThemeRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDrawableInterceptor(final DrawableInterceptor interceptor) {
|
||||
mHelper.addDrawableInterceptor(interceptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getDrawable(final int id) throws NotFoundException {
|
||||
final Drawable d = mHelper.getDrawable(id);
|
||||
if (d != null) return d;
|
||||
return super.getDrawable(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package org.mariotaku.twidere.content.res.iface;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.Resources.NotFoundException;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface IThemedResources {
|
||||
|
||||
public static final String RESOURCES_LOGTAG = "Twidere.Resources";
|
||||
|
||||
public void addDrawableInterceptor(final DrawableInterceptor interceptor);
|
||||
|
||||
public interface DrawableInterceptor {
|
||||
|
||||
public Drawable getDrawable(final Resources res, final int resId);
|
||||
}
|
||||
|
||||
public static final class Helper {
|
||||
|
||||
private final ArrayList<DrawableInterceptor> mDrawableInterceptors = new ArrayList<DrawableInterceptor>();
|
||||
private final Resources mResources;
|
||||
|
||||
public Helper(final Resources res, final Context context, final int overrideThemeRes) {
|
||||
mResources = res;
|
||||
}
|
||||
|
||||
public void addDrawableInterceptor(final DrawableInterceptor interceptor) {
|
||||
mDrawableInterceptors.add(interceptor);
|
||||
}
|
||||
|
||||
public Drawable getDrawable(final int resId) throws NotFoundException {
|
||||
for (final DrawableInterceptor interceptor : mDrawableInterceptors) {
|
||||
final Drawable d = interceptor.getDrawable(mResources, resId);
|
||||
if (d != null) return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -25,75 +25,89 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.ContentResolver;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.BaseSupportActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
|
||||
public class BaseFragment extends Fragment implements Constants {
|
||||
|
||||
public BaseFragment() {
|
||||
@Override
|
||||
public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof IThemedActivity) {
|
||||
onCreateOptionsMenu(menu, ((IThemedActivity) activity).getTwidereMenuInflater());
|
||||
} else {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
|
||||
public TwidereApplication getApplication() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return (TwidereApplication) activity.getApplication();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
public TwidereApplication getApplication() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return (TwidereApplication) activity.getApplication();
|
||||
return null;
|
||||
}
|
||||
|
||||
public MultiSelectManager getMultiSelectManager() {
|
||||
final TwidereApplication app = getApplication();
|
||||
return app != null ? app.getMultiSelectManager() : null;
|
||||
}
|
||||
public ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
|
||||
public SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
public MultiSelectManager getMultiSelectManager() {
|
||||
final TwidereApplication app = getApplication();
|
||||
return app != null ? app.getMultiSelectManager() : null;
|
||||
}
|
||||
|
||||
public Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
public SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
final TwidereApplication app = getApplication();
|
||||
return app != null ? app.getTwitterWrapper() : null;
|
||||
}
|
||||
public Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void invalidateOptionsMenu() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
final TwidereApplication app = getApplication();
|
||||
return app != null ? app.getTwitterWrapper() : null;
|
||||
}
|
||||
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
public void invalidateOptionsMenu() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof BaseSupportActivity) {
|
||||
((BaseSupportActivity) activity).setProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
}
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof BaseSupportActivity) {
|
||||
((BaseSupportActivity) activity).setProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import android.content.IntentFilter;
|
|||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
|
@ -34,176 +36,192 @@ import android.widget.AbsListView.OnScrollListener;
|
|||
import android.widget.ListView;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
public class BaseListFragment extends ListFragment implements Constants, OnScrollListener, RefreshScrollTopInterface {
|
||||
|
||||
private boolean mActivityFirstCreated;
|
||||
private boolean mIsInstanceStateSaved;
|
||||
private boolean mActivityFirstCreated;
|
||||
private boolean mIsInstanceStateSaved;
|
||||
|
||||
private boolean mReachedBottom, mNotReachedBottomBefore = true;
|
||||
private boolean mReachedBottom, mNotReachedBottomBefore = true;
|
||||
|
||||
public final TwidereApplication getApplication() {
|
||||
return TwidereApplication.getInstance(getActivity());
|
||||
}
|
||||
public final TwidereApplication getApplication() {
|
||||
return TwidereApplication.getInstance(getActivity());
|
||||
}
|
||||
|
||||
public final ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
public final ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
|
||||
public final MultiSelectManager getMultiSelectManager() {
|
||||
return getApplication() != null ? getApplication().getMultiSelectManager() : null;
|
||||
}
|
||||
public final MultiSelectManager getMultiSelectManager() {
|
||||
return getApplication() != null ? getApplication().getMultiSelectManager() : null;
|
||||
}
|
||||
|
||||
public final SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
public final SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
|
||||
public final Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
public final Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public final int getTabPosition() {
|
||||
final Bundle args = getArguments();
|
||||
return args != null ? args.getInt(EXTRA_TAB_POSITION, -1) : -1;
|
||||
}
|
||||
public final int getTabPosition() {
|
||||
final Bundle args = getArguments();
|
||||
return args != null ? args.getInt(EXTRA_TAB_POSITION, -1) : -1;
|
||||
}
|
||||
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
return getApplication() != null ? getApplication().getTwitterWrapper() : null;
|
||||
}
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
return getApplication() != null ? getApplication().getTwitterWrapper() : null;
|
||||
}
|
||||
|
||||
public void invalidateOptionsMenu() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
public void invalidateOptionsMenu() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
public boolean isActivityFirstCreated() {
|
||||
return mActivityFirstCreated;
|
||||
}
|
||||
@Override
|
||||
public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof IThemedActivity) {
|
||||
onCreateOptionsMenu(menu, ((IThemedActivity) activity).getTwidereMenuInflater());
|
||||
} else {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInstanceStateSaved() {
|
||||
return mIsInstanceStateSaved;
|
||||
}
|
||||
public void onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
|
||||
public boolean isReachedBottom() {
|
||||
return mReachedBottom;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mIsInstanceStateSaved = savedInstanceState != null;
|
||||
final ListView lv = getListView();
|
||||
lv.setOnScrollListener(this);
|
||||
}
|
||||
public boolean isActivityFirstCreated() {
|
||||
return mActivityFirstCreated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(final Activity activity) {
|
||||
super.onAttach(activity);
|
||||
}
|
||||
public boolean isInstanceStateSaved() {
|
||||
return mIsInstanceStateSaved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mActivityFirstCreated = true;
|
||||
}
|
||||
public boolean isReachedBottom() {
|
||||
return mReachedBottom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mIsInstanceStateSaved = savedInstanceState != null;
|
||||
final ListView lv = getListView();
|
||||
lv.setOnScrollListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mActivityFirstCreated = true;
|
||||
}
|
||||
@Override
|
||||
public void onAttach(final Activity activity) {
|
||||
super.onAttach(activity);
|
||||
}
|
||||
|
||||
public void onPostStart() {
|
||||
}
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mActivityFirstCreated = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount,
|
||||
final int totalItemCount) {
|
||||
final boolean reached = firstVisibleItem + visibleItemCount >= totalItemCount
|
||||
&& totalItemCount >= visibleItemCount;
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
if (mReachedBottom != reached) {
|
||||
mReachedBottom = reached;
|
||||
if (mReachedBottom && mNotReachedBottomBefore) {
|
||||
mNotReachedBottomBefore = false;
|
||||
return;
|
||||
}
|
||||
if (mReachedBottom && getListAdapter().getCount() > visibleItemCount) {
|
||||
onReachedBottom();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mActivityFirstCreated = true;
|
||||
}
|
||||
|
||||
}
|
||||
public void onPostStart() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(final AbsListView view, final int scrollState) {
|
||||
@Override
|
||||
public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount,
|
||||
final int totalItemCount) {
|
||||
final boolean reached = firstVisibleItem + visibleItemCount >= totalItemCount
|
||||
&& totalItemCount >= visibleItemCount;
|
||||
|
||||
}
|
||||
if (mReachedBottom != reached) {
|
||||
mReachedBottom = reached;
|
||||
if (mReachedBottom && mNotReachedBottomBefore) {
|
||||
mNotReachedBottomBefore = false;
|
||||
return;
|
||||
}
|
||||
if (mReachedBottom && getListAdapter().getCount() > visibleItemCount) {
|
||||
onReachedBottom();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
onPostStart();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mActivityFirstCreated = false;
|
||||
super.onStop();
|
||||
}
|
||||
@Override
|
||||
public void onScrollStateChanged(final AbsListView view, final int scrollState) {
|
||||
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean scrollToStart() {
|
||||
Utils.scrollListToTop(getListView());
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
onPostStart();
|
||||
}
|
||||
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.setProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
@Override
|
||||
public void onStop() {
|
||||
mActivityFirstCreated = false;
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(final int position) {
|
||||
Utils.scrollListToPosition(getListView(), position);
|
||||
}
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean scrollToStart() {
|
||||
Utils.scrollListToTop(getListView());
|
||||
return true;
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.setProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
|
||||
protected void onReachedBottom() {
|
||||
@Override
|
||||
public void setSelection(final int position) {
|
||||
Utils.scrollListToPosition(getListView(), position);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
protected void onReachedBottom() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,16 +19,35 @@
|
|||
|
||||
package org.mariotaku.twidere.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
|
||||
public class BasePreferenceFragment extends PreferenceFragment implements Constants {
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getPreferenceManager().setSharedPreferencesName(SHARED_PREFERENCES_NAME);
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getPreferenceManager().setSharedPreferencesName(SHARED_PREFERENCES_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof IThemedActivity) {
|
||||
onCreateOptionsMenu(menu, ((IThemedActivity) activity).getTwidereMenuInflater());
|
||||
} else {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.mariotaku.querybuilder.Where;
|
|||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.CustomTabEditorActivity;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.model.CustomTabConfiguration;
|
||||
import org.mariotaku.twidere.model.CustomTabConfiguration.CustomTabConfigurationComparator;
|
||||
import org.mariotaku.twidere.model.Panes;
|
||||
|
@ -176,7 +177,7 @@ public class CustomTabsFragment extends BaseListFragment implements LoaderCallba
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
||||
public void onCreateOptionsMenu(final Menu menu, final TwidereMenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_custom_tabs, menu);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.mariotaku.twidere.fragment;
|
||||
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
|
@ -49,6 +47,7 @@ import android.widget.TextView;
|
|||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.ArrayAdapter;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.task.AsyncTask;
|
||||
import org.mariotaku.twidere.util.HostsFileParser;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
|
@ -56,252 +55,254 @@ import org.mariotaku.twidere.util.ThemeUtils;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
|
||||
public class HostMappingsListFragment extends BaseListFragment implements MultiChoiceModeListener,
|
||||
OnSharedPreferenceChangeListener {
|
||||
OnSharedPreferenceChangeListener {
|
||||
|
||||
private ListView mListView;
|
||||
private HostMappingAdapter mAdapter;
|
||||
private SharedPreferences mPreferences;
|
||||
private ListView mListView;
|
||||
private HostMappingAdapter mAdapter;
|
||||
private SharedPreferences mPreferences;
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_DELETE: {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
final SparseBooleanArray array = mListView.getCheckedItemPositions();
|
||||
if (array == null) return false;
|
||||
for (int i = 0, size = array.size(); i < size; i++) {
|
||||
if (array.valueAt(i)) {
|
||||
editor.remove(mAdapter.getItem(i));
|
||||
}
|
||||
}
|
||||
editor.apply();
|
||||
reloadHostMappings();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mode.finish();
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_DELETE: {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
final SparseBooleanArray array = mListView.getCheckedItemPositions();
|
||||
if (array == null) return false;
|
||||
for (int i = 0, size = array.size(); i < size; i++) {
|
||||
if (array.valueAt(i)) {
|
||||
editor.remove(mAdapter.getItem(i));
|
||||
}
|
||||
}
|
||||
editor.apply();
|
||||
reloadHostMappings();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mode.finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
mPreferences = getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
mAdapter = new HostMappingAdapter(getActivity());
|
||||
setListAdapter(mAdapter);
|
||||
mListView = getListView();
|
||||
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
|
||||
mListView.setMultiChoiceModeListener(this);
|
||||
reloadHostMappings();
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
mPreferences = getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
mAdapter = new HostMappingAdapter(getActivity());
|
||||
setListAdapter(mAdapter);
|
||||
mListView = getListView();
|
||||
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
|
||||
mListView.setMultiChoiceModeListener(this);
|
||||
reloadHostMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(final ActionMode mode, final Menu menu) {
|
||||
new MenuInflater(getActivity()).inflate(R.menu.action_multi_select_items, menu);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onCreateActionMode(final ActionMode mode, final Menu menu) {
|
||||
new MenuInflater(getActivity()).inflate(R.menu.action_multi_select_items, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_host_mapping, menu);
|
||||
}
|
||||
@Override
|
||||
public void onCreateOptionsMenu(final Menu menu, final TwidereMenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_host_mapping, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(final ActionMode mode) {
|
||||
@Override
|
||||
public void onDestroyActionMode(final ActionMode mode) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemCheckedStateChanged(final ActionMode mode, final int position, final long id,
|
||||
final boolean checked) {
|
||||
updateTitle(mode);
|
||||
}
|
||||
@Override
|
||||
public void onItemCheckedStateChanged(final ActionMode mode, final int position, final long id,
|
||||
final boolean checked) {
|
||||
updateTitle(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_ADD:
|
||||
final DialogFragment df = new AddMappingDialogFragment();
|
||||
df.show(getFragmentManager(), "add_mapping");
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_ADD:
|
||||
final DialogFragment df = new AddMappingDialogFragment();
|
||||
df.show(getFragmentManager(), "add_mapping");
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
|
||||
updateTitle(mode);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
|
||||
updateTitle(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) {
|
||||
reloadHostMappings();
|
||||
}
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) {
|
||||
reloadHostMappings();
|
||||
}
|
||||
|
||||
public void reloadHostMappings() {
|
||||
if (mAdapter == null) return;
|
||||
mAdapter.reload();
|
||||
}
|
||||
public void reloadHostMappings() {
|
||||
if (mAdapter == null) return;
|
||||
mAdapter.reload();
|
||||
}
|
||||
|
||||
private void updateTitle(final ActionMode mode) {
|
||||
if (mListView == null || mode == null || getActivity() == null) return;
|
||||
final int count = mListView.getCheckedItemCount();
|
||||
mode.setTitle(getResources().getQuantityString(R.plurals.Nitems_selected, count, count));
|
||||
}
|
||||
private void updateTitle(final ActionMode mode) {
|
||||
if (mListView == null || mode == null || getActivity() == null) return;
|
||||
final int count = mListView.getCheckedItemCount();
|
||||
mode.setTitle(getResources().getQuantityString(R.plurals.Nitems_selected, count, count));
|
||||
}
|
||||
|
||||
public static class AddMappingDialogFragment extends BaseDialogFragment implements DialogInterface.OnClickListener,
|
||||
OnShowListener, TextWatcher {
|
||||
public static class AddMappingDialogFragment extends BaseDialogFragment implements DialogInterface.OnClickListener,
|
||||
OnShowListener, TextWatcher {
|
||||
|
||||
private EditText mEditHost, mEditAddress;
|
||||
private EditText mEditHost, mEditAddress;
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(final Editable s) {
|
||||
@Override
|
||||
public void afterTextChanged(final Editable s) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
|
||||
@Override
|
||||
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE: {
|
||||
final String mHost = ParseUtils.parseString(mEditHost.getText());
|
||||
final String mAddress = ParseUtils.parseString(mEditAddress.getText());
|
||||
if (isEmpty(mHost) || isEmpty(mAddress)) return;
|
||||
final SharedPreferences prefs = getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
final SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString(mHost, mAddress);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE: {
|
||||
final String mHost = ParseUtils.parseString(mEditHost.getText());
|
||||
final String mAddress = ParseUtils.parseString(mEditAddress.getText());
|
||||
if (isEmpty(mHost) || isEmpty(mAddress)) return;
|
||||
final SharedPreferences prefs = getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
final SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString(mHost, mAddress);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
|
||||
final View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_host_mapping, null);
|
||||
builder.setView(view);
|
||||
mEditHost = (EditText) view.findViewById(R.id.host);
|
||||
mEditAddress = (EditText) view.findViewById(R.id.address);
|
||||
mEditHost.addTextChangedListener(this);
|
||||
mEditAddress.addTextChangedListener(this);
|
||||
final Bundle args = getArguments();
|
||||
if (savedInstanceState == null && args != null) {
|
||||
mEditHost.setText(args.getCharSequence(EXTRA_TEXT1));
|
||||
mEditAddress.setText(args.getCharSequence(EXTRA_TEXT2));
|
||||
}
|
||||
builder.setTitle(R.string.add_host_mapping);
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(this);
|
||||
return dialog;
|
||||
}
|
||||
@Override
|
||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
|
||||
final View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_host_mapping, null);
|
||||
builder.setView(view);
|
||||
mEditHost = (EditText) view.findViewById(R.id.host);
|
||||
mEditAddress = (EditText) view.findViewById(R.id.address);
|
||||
mEditHost.addTextChangedListener(this);
|
||||
mEditAddress.addTextChangedListener(this);
|
||||
final Bundle args = getArguments();
|
||||
if (savedInstanceState == null && args != null) {
|
||||
mEditHost.setText(args.getCharSequence(EXTRA_TEXT1));
|
||||
mEditAddress.setText(args.getCharSequence(EXTRA_TEXT2));
|
||||
}
|
||||
builder.setTitle(R.string.add_host_mapping);
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(this);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(final Bundle outState) {
|
||||
outState.putCharSequence(EXTRA_TEXT1, mEditHost.getText());
|
||||
outState.putCharSequence(EXTRA_TEXT2, mEditAddress.getText());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
@Override
|
||||
public void onSaveInstanceState(final Bundle outState) {
|
||||
outState.putCharSequence(EXTRA_TEXT1, mEditHost.getText());
|
||||
outState.putCharSequence(EXTRA_TEXT2, mEditAddress.getText());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
final boolean text_valid = !isEmpty(mEditHost.getText()) && !isEmpty(mEditAddress.getText());
|
||||
((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(text_valid);
|
||||
}
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
final boolean text_valid = !isEmpty(mEditHost.getText()) && !isEmpty(mEditAddress.getText());
|
||||
((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(text_valid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
|
||||
final AlertDialog dialog = (AlertDialog) getDialog();
|
||||
if (dialog == null) return;
|
||||
final boolean text_valid = !isEmpty(mEditHost.getText()) && !isEmpty(mEditAddress.getText());
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(text_valid);
|
||||
}
|
||||
@Override
|
||||
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
|
||||
final AlertDialog dialog = (AlertDialog) getDialog();
|
||||
if (dialog == null) return;
|
||||
final boolean text_valid = !isEmpty(mEditHost.getText()) && !isEmpty(mEditAddress.getText());
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(text_valid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static class HostMappingAdapter extends ArrayAdapter<String> {
|
||||
static class HostMappingAdapter extends ArrayAdapter<String> {
|
||||
|
||||
private final SharedPreferences mPreferences;
|
||||
private final SharedPreferences mPreferences;
|
||||
|
||||
public HostMappingAdapter(final Context context) {
|
||||
super(context, android.R.layout.simple_list_item_activated_2);
|
||||
mPreferences = context.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
public HostMappingAdapter(final Context context) {
|
||||
super(context, android.R.layout.simple_list_item_activated_2);
|
||||
mPreferences = context.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
||||
final TextView text2 = (TextView) view.findViewById(android.R.id.text2);
|
||||
final String key = getItem(position);
|
||||
text1.setText(key);
|
||||
text2.setText(mPreferences.getString(key, null));
|
||||
return view;
|
||||
}
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
||||
final TextView text2 = (TextView) view.findViewById(android.R.id.text2);
|
||||
final String key = getItem(position);
|
||||
text1.setText(key);
|
||||
text2.setText(mPreferences.getString(key, null));
|
||||
return view;
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
clear();
|
||||
final Map<String, ?> all = mPreferences.getAll();
|
||||
addAll(all.keySet());
|
||||
}
|
||||
public void reload() {
|
||||
clear();
|
||||
final Map<String, ?> all = mPreferences.getAll();
|
||||
addAll(all.keySet());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static class ImportHostsTask extends AsyncTask<Void, Void, Boolean> {
|
||||
static class ImportHostsTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
private final SharedPreferences mPreferences;
|
||||
private final HostMappingsListFragment mActivity;
|
||||
private final String mPath;
|
||||
private final SharedPreferences mPreferences;
|
||||
private final HostMappingsListFragment mActivity;
|
||||
private final String mPath;
|
||||
|
||||
ImportHostsTask(final HostMappingsListFragment activity, final String path) {
|
||||
mActivity = activity;
|
||||
mPath = path;
|
||||
mPreferences = activity.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
ImportHostsTask(final HostMappingsListFragment activity, final String path) {
|
||||
mActivity = activity;
|
||||
mPath = path;
|
||||
mPreferences = activity.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(final Void... params) {
|
||||
final HostsFileParser hosts = new HostsFileParser(mPath);
|
||||
final boolean result = hosts.reload();
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
for (final Map.Entry<String, String> entry : hosts.getAll().entrySet()) {
|
||||
editor.putString(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return result && editor.commit();
|
||||
}
|
||||
@Override
|
||||
protected Boolean doInBackground(final Void... params) {
|
||||
final HostsFileParser hosts = new HostsFileParser(mPath);
|
||||
final boolean result = hosts.reload();
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
for (final Map.Entry<String, String> entry : hosts.getAll().entrySet()) {
|
||||
editor.putString(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return result && editor.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Boolean result) {
|
||||
final FragmentManager fm = mActivity.getFragmentManager();
|
||||
final Fragment f = fm.findFragmentByTag("import_hosts_progress");
|
||||
if (f instanceof DialogFragment) {
|
||||
((DialogFragment) f).dismiss();
|
||||
}
|
||||
mActivity.reloadHostMappings();
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(final Boolean result) {
|
||||
final FragmentManager fm = mActivity.getFragmentManager();
|
||||
final Fragment f = fm.findFragmentByTag("import_hosts_progress");
|
||||
if (f instanceof DialogFragment) {
|
||||
((DialogFragment) f).dismiss();
|
||||
}
|
||||
mActivity.reloadHostMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
final FragmentManager fm = mActivity.getFragmentManager();
|
||||
final DialogFragment f = new ProgressDialogFragment();
|
||||
f.setCancelable(false);
|
||||
f.show(fm, "import_hosts_progress");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
final FragmentManager fm = mActivity.getFragmentManager();
|
||||
final DialogFragment f = new ProgressDialogFragment();
|
||||
f.setCancelable(false);
|
||||
f.show(fm, "import_hosts_progress");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -620,7 +620,7 @@ public class AccountsDrawerFragment extends BaseSupportListFragment implements L
|
|||
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
||||
final ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
|
||||
text1.setText(option.name);
|
||||
icon.setImageResource(option.icon);
|
||||
icon.setImageDrawable(getContext().getResources().getDrawable(option.icon));
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,61 +25,80 @@ import android.content.ContentResolver;
|
|||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
|
||||
public class BaseSupportDialogFragment extends DialogFragment implements Constants {
|
||||
|
||||
public BaseSupportDialogFragment() {
|
||||
public BaseSupportDialogFragment() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public TwidereApplication getApplication() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return (TwidereApplication) activity.getApplication();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity instanceof IThemedActivity) {
|
||||
onCreateOptionsMenu(menu, ((IThemedActivity) activity).getTwidereMenuInflater());
|
||||
} else {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
public ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
public void onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
|
||||
public SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
public TwidereApplication getApplication() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return (TwidereApplication) activity.getApplication();
|
||||
return null;
|
||||
}
|
||||
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
final TwidereApplication app = getApplication();
|
||||
return app != null ? app.getTwitterWrapper() : null;
|
||||
}
|
||||
public ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
public SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.setProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
public Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
final TwidereApplication app = getApplication();
|
||||
return app != null ? app.getTwitterWrapper() : null;
|
||||
}
|
||||
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.setProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,83 +26,102 @@ import android.content.IntentFilter;
|
|||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.BaseSupportActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
||||
public class BaseSupportFragment extends Fragment implements Constants {
|
||||
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
|
||||
public BaseSupportFragment() {
|
||||
public BaseSupportFragment() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public TwidereApplication getApplication() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return (TwidereApplication) activity.getApplication();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity instanceof IThemedActivity) {
|
||||
onCreateOptionsMenu(menu, ((IThemedActivity) activity).getTwidereMenuInflater());
|
||||
} else {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
public ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
public void onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
|
||||
@Override
|
||||
public LayoutInflater getLayoutInflater(final Bundle savedInstanceState) {
|
||||
if (mLayoutInflater != null) return mLayoutInflater;
|
||||
return mLayoutInflater = ThemeUtils.getThemedLayoutInflaterForActionIcons(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
public MultiSelectManager getMultiSelectManager() {
|
||||
return getApplication() != null ? getApplication().getMultiSelectManager() : null;
|
||||
}
|
||||
public TwidereApplication getApplication() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return (TwidereApplication) activity.getApplication();
|
||||
return null;
|
||||
}
|
||||
|
||||
public SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
public ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public LayoutInflater getLayoutInflater(final Bundle savedInstanceState) {
|
||||
if (mLayoutInflater != null) return mLayoutInflater;
|
||||
return mLayoutInflater = ThemeUtils.getThemedLayoutInflaterForActionIcons(getActivity());
|
||||
}
|
||||
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
return getApplication() != null ? getApplication().getTwitterWrapper() : null;
|
||||
}
|
||||
public MultiSelectManager getMultiSelectManager() {
|
||||
return getApplication() != null ? getApplication().getMultiSelectManager() : null;
|
||||
}
|
||||
|
||||
public void invalidateOptionsMenu() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
public SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
public Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof BaseSupportActivity) {
|
||||
((BaseSupportActivity) activity).setProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
}
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
return getApplication() != null ? getApplication().getTwitterWrapper() : null;
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
public void invalidateOptionsMenu() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof BaseSupportActivity) {
|
||||
((BaseSupportActivity) activity).setProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ import android.support.v4.app.FragmentActivity;
|
|||
import android.support.v4.app.ListFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
|
@ -47,11 +49,13 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.HomeActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment;
|
||||
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
@ -70,6 +74,21 @@ public class BaseSupportListFragment extends ListFragment implements IBaseFragme
|
|||
|
||||
private boolean mStoppedPreviously;
|
||||
|
||||
|
||||
@Override
|
||||
public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity instanceof IThemedActivity) {
|
||||
onCreateOptionsMenu(menu, ((IThemedActivity) activity).getTwidereMenuInflater());
|
||||
} else {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
|
||||
}
|
||||
|
||||
public final TwidereApplication getApplication() {
|
||||
return TwidereApplication.getInstance(getActivity());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,10 @@ import android.content.IntentFilter;
|
|||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
|
@ -35,220 +38,236 @@ import android.widget.AbsListView.OnScrollListener;
|
|||
import com.etsy.android.grid.StaggeredGridView;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.HomeActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment;
|
||||
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
public class BaseSupportStaggeredGridFragment extends StaggeredGridFragment implements IBaseFragment, Constants,
|
||||
OnScrollListener, RefreshScrollTopInterface {
|
||||
OnScrollListener, RefreshScrollTopInterface {
|
||||
|
||||
private boolean mActivityFirstCreated;
|
||||
private boolean mIsInstanceStateSaved;
|
||||
private boolean mReachedBottom, mNotReachedBottomBefore = true;
|
||||
private boolean mActivityFirstCreated;
|
||||
private boolean mIsInstanceStateSaved;
|
||||
private boolean mReachedBottom, mNotReachedBottomBefore = true;
|
||||
|
||||
public final TwidereApplication getApplication() {
|
||||
return TwidereApplication.getInstance(getActivity());
|
||||
}
|
||||
public final TwidereApplication getApplication() {
|
||||
return TwidereApplication.getInstance(getActivity());
|
||||
}
|
||||
|
||||
public final ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
public final ContentResolver getContentResolver() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getContentResolver();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle getExtraConfiguration() {
|
||||
final Bundle args = getArguments();
|
||||
final Bundle extras = new Bundle();
|
||||
if (args != null && args.containsKey(EXTRA_EXTRAS)) {
|
||||
extras.putAll(args.getBundle(EXTRA_EXTRAS));
|
||||
}
|
||||
return extras;
|
||||
}
|
||||
@Override
|
||||
public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity instanceof IThemedActivity) {
|
||||
onCreateOptionsMenu(menu, ((IThemedActivity) activity).getTwidereMenuInflater());
|
||||
} else {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
public final MultiSelectManager getMultiSelectManager() {
|
||||
return getApplication() != null ? getApplication().getMultiSelectManager() : null;
|
||||
}
|
||||
public void onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
|
||||
public final SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Bundle getExtraConfiguration() {
|
||||
final Bundle args = getArguments();
|
||||
final Bundle extras = new Bundle();
|
||||
if (args != null && args.containsKey(EXTRA_EXTRAS)) {
|
||||
extras.putAll(args.getBundle(EXTRA_EXTRAS));
|
||||
}
|
||||
return extras;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getTabPosition() {
|
||||
final Bundle args = getArguments();
|
||||
return args != null ? args.getInt(EXTRA_TAB_POSITION, -1) : -1;
|
||||
}
|
||||
public final MultiSelectManager getMultiSelectManager() {
|
||||
return getApplication() != null ? getApplication().getMultiSelectManager() : null;
|
||||
}
|
||||
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
return getApplication() != null ? getApplication().getTwitterWrapper() : null;
|
||||
}
|
||||
public final SharedPreferences getSharedPreferences(final String name, final int mode) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSharedPreferences(name, mode);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void invalidateOptionsMenu() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
public final Object getSystemService(final String name) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) return activity.getSystemService(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isActivityFirstCreated() {
|
||||
return mActivityFirstCreated;
|
||||
}
|
||||
@Override
|
||||
public final int getTabPosition() {
|
||||
final Bundle args = getArguments();
|
||||
return args != null ? args.getInt(EXTRA_TAB_POSITION, -1) : -1;
|
||||
}
|
||||
|
||||
public boolean isInstanceStateSaved() {
|
||||
return mIsInstanceStateSaved;
|
||||
}
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
return getApplication() != null ? getApplication().getTwitterWrapper() : null;
|
||||
}
|
||||
|
||||
public boolean isReachedBottom() {
|
||||
return mReachedBottom;
|
||||
}
|
||||
public void invalidateOptionsMenu() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mIsInstanceStateSaved = savedInstanceState != null;
|
||||
final StaggeredGridView lv = getListView();
|
||||
lv.setOnScrollListener(this);
|
||||
}
|
||||
public boolean isActivityFirstCreated() {
|
||||
return mActivityFirstCreated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(final Activity activity) {
|
||||
super.onAttach(activity);
|
||||
}
|
||||
public boolean isInstanceStateSaved() {
|
||||
return mIsInstanceStateSaved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mActivityFirstCreated = true;
|
||||
}
|
||||
public boolean isReachedBottom() {
|
||||
return mReachedBottom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mIsInstanceStateSaved = savedInstanceState != null;
|
||||
final StaggeredGridView lv = getListView();
|
||||
lv.setOnScrollListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mActivityFirstCreated = true;
|
||||
}
|
||||
@Override
|
||||
public void onAttach(final Activity activity) {
|
||||
super.onAttach(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) activity).onDetachFragment(this);
|
||||
}
|
||||
final Fragment fragment = getParentFragment();
|
||||
if (fragment instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) fragment).onDetachFragment(this);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mActivityFirstCreated = true;
|
||||
}
|
||||
|
||||
public void onPostStart() {
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount,
|
||||
final int totalItemCount) {
|
||||
final boolean reached = firstVisibleItem + visibleItemCount >= totalItemCount
|
||||
&& totalItemCount >= visibleItemCount;
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mActivityFirstCreated = true;
|
||||
}
|
||||
|
||||
if (mReachedBottom != reached) {
|
||||
mReachedBottom = reached;
|
||||
if (mReachedBottom && mNotReachedBottomBefore) {
|
||||
mNotReachedBottomBefore = false;
|
||||
return;
|
||||
}
|
||||
if (mReachedBottom && getListAdapter().getCount() > visibleItemCount) {
|
||||
onReachedBottom();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) activity).onDetachFragment(this);
|
||||
}
|
||||
final Fragment fragment = getParentFragment();
|
||||
if (fragment instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) fragment).onDetachFragment(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void onPostStart() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(final AbsListView view, final int scrollState) {
|
||||
@Override
|
||||
public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount,
|
||||
final int totalItemCount) {
|
||||
final boolean reached = firstVisibleItem + visibleItemCount >= totalItemCount
|
||||
&& totalItemCount >= visibleItemCount;
|
||||
|
||||
}
|
||||
if (mReachedBottom != reached) {
|
||||
mReachedBottom = reached;
|
||||
if (mReachedBottom && mNotReachedBottomBefore) {
|
||||
mNotReachedBottomBefore = false;
|
||||
return;
|
||||
}
|
||||
if (mReachedBottom && getListAdapter().getCount() > visibleItemCount) {
|
||||
onReachedBottom();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
onPostStart();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mActivityFirstCreated = false;
|
||||
super.onStop();
|
||||
}
|
||||
@Override
|
||||
public void onScrollStateChanged(final AbsListView view, final int scrollState) {
|
||||
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean scrollToStart() {
|
||||
if (!isAdded() || getActivity() == null) return false;
|
||||
Utils.scrollListToTop(getListView());
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
onPostStart();
|
||||
}
|
||||
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.setProgressBarIndeterminateVisibility(visible);
|
||||
if (activity instanceof HomeActivity) {
|
||||
((HomeActivity) activity).setHomeProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onStop() {
|
||||
mActivityFirstCreated = false;
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(final int position) {
|
||||
Utils.scrollListToPosition(getListView(), position);
|
||||
}
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.registerReceiver(receiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(final boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) activity).onSetUserVisibleHint(this, isVisibleToUser);
|
||||
}
|
||||
final Fragment fragment = getParentFragment();
|
||||
if (fragment instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) fragment).onSetUserVisibleHint(this, isVisibleToUser);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean scrollToStart() {
|
||||
if (!isAdded() || getActivity() == null) return false;
|
||||
Utils.scrollListToTop(getListView());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
return false;
|
||||
}
|
||||
public void setProgressBarIndeterminateVisibility(final boolean visible) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.setProgressBarIndeterminateVisibility(visible);
|
||||
if (activity instanceof HomeActivity) {
|
||||
((HomeActivity) activity).setHomeProgressBarIndeterminateVisibility(visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
@Override
|
||||
public void setSelection(final int position) {
|
||||
Utils.scrollListToPosition(getListView(), position);
|
||||
}
|
||||
|
||||
protected void onReachedBottom() {
|
||||
@Override
|
||||
public void setUserVisibleHint(final boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) activity).onSetUserVisibleHint(this, isVisibleToUser);
|
||||
}
|
||||
final Fragment fragment = getParentFragment();
|
||||
if (fragment instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) fragment).onSetUserVisibleHint(this, isVisibleToUser);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void unregisterReceiver(final BroadcastReceiver receiver) {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
activity.unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
protected void onReachedBottom() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,24 +21,43 @@ package org.mariotaku.twidere.fragment.support;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.util.accessor.WebSettingsAccessor;
|
||||
import org.mariotaku.twidere.util.webkit.DefaultWebViewClient;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public class BaseSupportWebViewFragment extends SupportWebViewFragment implements Constants {
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
final WebView view = getWebView();
|
||||
view.setWebViewClient(new DefaultWebViewClient(getActivity()));
|
||||
final WebSettings settings = view.getSettings();
|
||||
settings.setBuiltInZoomControls(true);
|
||||
settings.setJavaScriptEnabled(true);
|
||||
WebSettingsAccessor.setAllowUniversalAccessFromFileURLs(settings, true);
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
final WebView view = getWebView();
|
||||
view.setWebViewClient(new DefaultWebViewClient(getActivity()));
|
||||
final WebSettings settings = view.getSettings();
|
||||
settings.setBuiltInZoomControls(true);
|
||||
settings.setJavaScriptEnabled(true);
|
||||
WebSettingsAccessor.setAllowUniversalAccessFromFileURLs(settings, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity instanceof IThemedActivity) {
|
||||
onCreateOptionsMenu(menu, ((IThemedActivity) activity).getTwidereMenuInflater());
|
||||
} else {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateOptionsMenu(Menu menu, TwidereMenuInflater inflater) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getTableNameByUri;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
|
@ -24,85 +22,98 @@ import org.mariotaku.twidere.fragment.support.TrendsSuggectionsFragment.TrendsAd
|
|||
import org.mariotaku.twidere.provider.TweetStore.CachedTrends;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.view.ResourceImageButton;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getTableNameByUri;
|
||||
|
||||
public class QuickMenuFragment extends BaseSupportFragment {
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
private Context mThemedContext;
|
||||
private ListView mListView;
|
||||
private SlidingUpPanelLayout mSlidingUpPanel;
|
||||
private SharedPreferences mPreferences;
|
||||
private Context mThemedContext;
|
||||
private ListView mListView;
|
||||
private SlidingUpPanelLayout mSlidingUpPanel;
|
||||
private ResourceImageButton mActivitiesConfigButton;
|
||||
|
||||
private MergeAdapter mAdapter;
|
||||
private TrendsAdapter mTrendsAdapter;
|
||||
private MergeAdapter mAdapter;
|
||||
private TrendsAdapter mTrendsAdapter;
|
||||
|
||||
private static final int LOADER_ID_TRENDS = 1;
|
||||
private static final int LOADER_ID_TRENDS = 1;
|
||||
|
||||
private final LoaderCallbacks<Cursor> mTrendsCallback = new LoaderCallbacks<Cursor>() {
|
||||
private final LoaderCallbacks<Cursor> mTrendsCallback = new LoaderCallbacks<Cursor>() {
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
|
||||
final Uri uri = CachedTrends.Local.CONTENT_URI;
|
||||
final String table = getTableNameByUri(uri);
|
||||
final String where = table != null ? CachedTrends.TIMESTAMP + " = " + "(SELECT " + CachedTrends.TIMESTAMP
|
||||
+ " FROM " + table + " ORDER BY " + CachedTrends.TIMESTAMP + " DESC LIMIT 1)" : null;
|
||||
return new CursorLoader(getActivity(), uri, CachedTrends.COLUMNS, where, null, null);
|
||||
}
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
|
||||
final Uri uri = CachedTrends.Local.CONTENT_URI;
|
||||
final String table = getTableNameByUri(uri);
|
||||
final String where = table != null ? CachedTrends.TIMESTAMP + " = " + "(SELECT " + CachedTrends.TIMESTAMP
|
||||
+ " FROM " + table + " ORDER BY " + CachedTrends.TIMESTAMP + " DESC LIMIT 1)" : null;
|
||||
return new CursorLoader(getActivity(), uri, CachedTrends.COLUMNS, where, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<Cursor> loader) {
|
||||
mTrendsAdapter.swapCursor(null);
|
||||
}
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<Cursor> loader) {
|
||||
mTrendsAdapter.swapCursor(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) {
|
||||
mTrendsAdapter.swapCursor(data);
|
||||
}
|
||||
@Override
|
||||
public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) {
|
||||
mTrendsAdapter.swapCursor(data);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
if (mPreferences.getBoolean(KEY_QUICK_MENU_EXPANDED, false)) {
|
||||
} else {
|
||||
}
|
||||
mAdapter = new MergeAdapter();
|
||||
mTrendsAdapter = new TrendsAdapter(getThemedContext());
|
||||
mAdapter.addAdapter(mTrendsAdapter);
|
||||
mListView.setAdapter(mAdapter);
|
||||
getLoaderManager().initLoader(LOADER_ID_TRENDS, null, mTrendsCallback);
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
if (mPreferences.getBoolean(KEY_QUICK_MENU_EXPANDED, false)) {
|
||||
} else {
|
||||
}
|
||||
mAdapter = new MergeAdapter();
|
||||
mTrendsAdapter = new TrendsAdapter(getThemedContext());
|
||||
mAdapter.addAdapter(mTrendsAdapter);
|
||||
mListView.setAdapter(mAdapter);
|
||||
getLoaderManager().initLoader(LOADER_ID_TRENDS, null, mTrendsCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return LayoutInflater.from(getThemedContext()).inflate(R.layout.fragment_quick_menu, container, false);
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return LayoutInflater.from(getThemedContext()).inflate(R.layout.fragment_quick_menu, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(KEY_QUICK_MENU_EXPANDED, mSlidingUpPanel.isPanelExpanded());
|
||||
editor.apply();
|
||||
}
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(KEY_QUICK_MENU_EXPANDED, mSlidingUpPanel.isPanelExpanded());
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(final View view, final Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mListView = (ListView) view.findViewById(android.R.id.list);
|
||||
mSlidingUpPanel = (SlidingUpPanelLayout) view.findViewById(R.id.activities_drawer);
|
||||
final View activitiesContainer = view.findViewById(R.id.activities_container);
|
||||
ViewAccessor.setBackground(activitiesContainer, ThemeUtils.getWindowBackground(getThemedContext()));
|
||||
}
|
||||
@Override
|
||||
public void onViewCreated(final View view, final Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mListView = (ListView) view.findViewById(android.R.id.list);
|
||||
mSlidingUpPanel = (SlidingUpPanelLayout) view.findViewById(R.id.activities_drawer);
|
||||
mActivitiesConfigButton = (ResourceImageButton) view.findViewById(R.id.activities_config_button);
|
||||
final View activitiesContainer = view.findViewById(R.id.activities_container);
|
||||
ViewAccessor.setBackground(activitiesContainer, ThemeUtils.getWindowBackground(getThemedContext()));
|
||||
}
|
||||
|
||||
private Context getThemedContext() {
|
||||
if (mThemedContext != null) return mThemedContext;
|
||||
final Context context = getActivity();
|
||||
if (!ThemeUtils.isDarkDrawerEnabled(context)) return mThemedContext = context;
|
||||
final int themeResource = ThemeUtils.getDrawerThemeResource(context);
|
||||
final int accentColor = ThemeUtils.getUserThemeColor(context);
|
||||
return mThemedContext = new TwidereContextThemeWrapper(context, themeResource, accentColor);
|
||||
}
|
||||
private Context getThemedContext() {
|
||||
if (mThemedContext != null) return mThemedContext;
|
||||
final Context context = getActivity();
|
||||
final int currentThemeResource = ThemeUtils.getThemeResource(context);
|
||||
final int themeResource;
|
||||
if (!ThemeUtils.isDarkDrawerEnabled(context)) {
|
||||
if (ThemeUtils.isDarkTheme(currentThemeResource)) {
|
||||
return mThemedContext = context;
|
||||
}
|
||||
themeResource = ThemeUtils.getLightDrawerThemeResource(currentThemeResource);
|
||||
} else {
|
||||
themeResource = ThemeUtils.getDrawerThemeResource(currentThemeResource);
|
||||
}
|
||||
final int accentColor = ThemeUtils.getUserThemeColor(context);
|
||||
return mThemedContext = new TwidereContextThemeWrapper(context, themeResource, accentColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import android.support.v4.app.FragmentActivity;
|
|||
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -37,6 +36,7 @@ import org.mariotaku.twidere.activity.support.LinkHandlerActivity;
|
|||
import org.mariotaku.twidere.adapter.support.SupportTabsAdapter;
|
||||
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.model.Panes;
|
||||
import org.mariotaku.twidere.provider.RecentSearchProvider;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
|
@ -92,7 +92,7 @@ public class SearchFragment extends BaseSupportFragment implements Panes.Left, O
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
||||
public void onCreateOptionsMenu(final Menu menu, final TwidereMenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_search, menu);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getAccountScreenName;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -29,95 +27,97 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.ParcelableUserListsAdapter;
|
||||
import org.mariotaku.twidere.loader.support.UserListsLoader;
|
||||
import org.mariotaku.twidere.menu.TwidereMenuInflater;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getAccountScreenName;
|
||||
|
||||
public class UserListsListFragment extends BaseUserListsListFragment {
|
||||
|
||||
private final BroadcastReceiver mStatusReceiver = new BroadcastReceiver() {
|
||||
private final BroadcastReceiver mStatusReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_USER_LIST_DELETED.equals(action)) {
|
||||
final ParcelableUserList list = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (list != null && intent.getBooleanExtra(EXTRA_SUCCEED, false)) {
|
||||
removeUserList(list.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
if (BROADCAST_USER_LIST_DELETED.equals(action)) {
|
||||
final ParcelableUserList list = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (list != null && intent.getBooleanExtra(EXTRA_SUCCEED, false)) {
|
||||
removeUserList(list.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public Loader<List<ParcelableUserList>> newLoaderInstance(final long accountId, final long userId,
|
||||
final String screenName) {
|
||||
return new UserListsLoader(getActivity(), accountId, userId, screenName, getData());
|
||||
}
|
||||
@Override
|
||||
public Loader<List<ParcelableUserList>> newLoaderInstance(final long accountId, final long userId,
|
||||
final String screenName) {
|
||||
return new UserListsLoader(getActivity(), accountId, userId, screenName, getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_user_list_created, menu);
|
||||
}
|
||||
@Override
|
||||
public void onCreateOptionsMenu(final Menu menu, final TwidereMenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_user_list_created, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.new_user_list: {
|
||||
final DialogFragment f = new CreateUserListDialogFragment();
|
||||
final Bundle args = new Bundle();
|
||||
args.putLong(EXTRA_ACCOUNT_ID, getAccountId());
|
||||
f.setArguments(args);
|
||||
f.show(getFragmentManager(), null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.new_user_list: {
|
||||
final DialogFragment f = new CreateUserListDialogFragment();
|
||||
final Bundle args = new Bundle();
|
||||
args.putLong(EXTRA_ACCOUNT_ID, getAccountId());
|
||||
f.setArguments(args);
|
||||
f.show(getFragmentManager(), null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(final Menu menu) {
|
||||
final MenuItem item = menu.findItem(R.id.new_user_list);
|
||||
if (item == null) return;
|
||||
final long account_id = getAccountId(), user_id = getUserId();
|
||||
final String screen_name = getAccountScreenName(getActivity(), account_id);
|
||||
item.setVisible(user_id == account_id || screen_name != null && screen_name.equalsIgnoreCase(getScreenName()));
|
||||
}
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(final Menu menu) {
|
||||
final MenuItem item = menu.findItem(R.id.new_user_list);
|
||||
if (item == null) return;
|
||||
final long account_id = getAccountId(), user_id = getUserId();
|
||||
final String screen_name = getAccountScreenName(getActivity(), account_id);
|
||||
item.setVisible(user_id == account_id || screen_name != null && screen_name.equalsIgnoreCase(getScreenName()));
|
||||
}
|
||||
|
||||
public void onPullUpToRefresh() {
|
||||
}
|
||||
public void onPullUpToRefresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
registerReceiver(mStatusReceiver, new IntentFilter(BROADCAST_USER_LIST_DELETED));
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
registerReceiver(mStatusReceiver, new IntentFilter(BROADCAST_USER_LIST_DELETED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
unregisterReceiver(mStatusReceiver);
|
||||
super.onStop();
|
||||
}
|
||||
@Override
|
||||
public void onStop() {
|
||||
unregisterReceiver(mStatusReceiver);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void removeUserList(final long id) {
|
||||
final ParcelableUserListsAdapter adapter = getListAdapter();
|
||||
final int listsIdx = adapter.findItemPosition(id);
|
||||
if (listsIdx >= 0) {
|
||||
adapter.remove(listsIdx);
|
||||
}
|
||||
}
|
||||
private void removeUserList(final long id) {
|
||||
final ParcelableUserListsAdapter adapter = getListAdapter();
|
||||
final int listsIdx = adapter.findItemPosition(id);
|
||||
if (listsIdx >= 0) {
|
||||
adapter.remove(listsIdx);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,551 @@
|
|||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.menu;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
import android.view.ActionProvider;
|
||||
import android.view.InflateException;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* This class is used to instantiate menu XML files into Menu objects.
|
||||
* <p/>
|
||||
* For performance reasons, menu inflation relies heavily on pre-processing of
|
||||
* XML files that is done at build time. Therefore, it is not currently possible
|
||||
* to use MenuInflater with an XmlPullParser over a plain XML file at runtime;
|
||||
* it only works with an XmlPullParser returned from a compiled resource (R.
|
||||
* <em>something</em> file.)
|
||||
*/
|
||||
public class TwidereMenuInflater {
|
||||
private static final String LOG_TAG = "MenuInflater";
|
||||
|
||||
/**
|
||||
* Menu tag name in XML.
|
||||
*/
|
||||
private static final String XML_MENU = "menu";
|
||||
|
||||
/**
|
||||
* Group tag name in XML.
|
||||
*/
|
||||
private static final String XML_GROUP = "group";
|
||||
|
||||
/**
|
||||
* Item tag name in XML.
|
||||
*/
|
||||
private static final String XML_ITEM = "item";
|
||||
|
||||
private static final int NO_ID = 0;
|
||||
|
||||
private static final Class<?>[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[]{Context.class};
|
||||
|
||||
private static final Class<?>[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE;
|
||||
|
||||
private final Object[] mActionViewConstructorArguments;
|
||||
|
||||
private final Object[] mActionProviderConstructorArguments;
|
||||
|
||||
private final Context mContext;
|
||||
private final Resources mResources;
|
||||
private final Object mRealOwner;
|
||||
|
||||
/**
|
||||
* Constructs a menu inflater.
|
||||
*
|
||||
* @see Activity#getMenuInflater()
|
||||
*/
|
||||
public TwidereMenuInflater(Context context) {
|
||||
this(context, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a menu inflater.
|
||||
*
|
||||
* @hide
|
||||
* @see Activity#getMenuInflater()
|
||||
*/
|
||||
public TwidereMenuInflater(Context context, Object realOwner) {
|
||||
mContext = context;
|
||||
mResources = context.getResources();
|
||||
mRealOwner = realOwner;
|
||||
mActionViewConstructorArguments = new Object[]{context};
|
||||
mActionProviderConstructorArguments = mActionViewConstructorArguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflate a menu hierarchy from the specified XML resource. Throws
|
||||
* {@link InflateException} if there is an error.
|
||||
*
|
||||
* @param menuRes Resource ID for an XML layout resource to load (e.g.,
|
||||
* <code>R.menu.main_activity</code>)
|
||||
* @param menu The Menu to inflate into. The items and submenus will be
|
||||
* added to this Menu.
|
||||
*/
|
||||
public void inflate(int menuRes, Menu menu) {
|
||||
XmlResourceParser parser = null;
|
||||
try {
|
||||
parser = mContext.getResources().getLayout(menuRes);
|
||||
AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
|
||||
parseMenu(parser, attrs, menu);
|
||||
} catch (XmlPullParserException e) {
|
||||
throw new InflateException("Error inflating menu XML", e);
|
||||
} catch (IOException e) {
|
||||
throw new InflateException("Error inflating menu XML", e);
|
||||
} finally {
|
||||
if (parser != null) parser.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called internally to fill the given menu. If a sub menu is seen, it will
|
||||
* call this recursively.
|
||||
*/
|
||||
private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu)
|
||||
throws XmlPullParserException, IOException {
|
||||
MenuState menuState = new MenuState(menu);
|
||||
|
||||
int eventType = parser.getEventType();
|
||||
String tagName;
|
||||
boolean lookingForEndOfUnknownTag = false;
|
||||
String unknownTagName = null;
|
||||
|
||||
// This loop will skip to the menu start tag
|
||||
do {
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
tagName = parser.getName();
|
||||
if (tagName.equals(XML_MENU)) {
|
||||
// Go to next tag
|
||||
eventType = parser.next();
|
||||
break;
|
||||
}
|
||||
|
||||
throw new RuntimeException("Expecting menu, got " + tagName);
|
||||
}
|
||||
eventType = parser.next();
|
||||
} while (eventType != XmlPullParser.END_DOCUMENT);
|
||||
|
||||
boolean reachedEndOfMenu = false;
|
||||
while (!reachedEndOfMenu) {
|
||||
switch (eventType) {
|
||||
case XmlPullParser.START_TAG:
|
||||
if (lookingForEndOfUnknownTag) {
|
||||
break;
|
||||
}
|
||||
|
||||
tagName = parser.getName();
|
||||
if (tagName.equals(XML_GROUP)) {
|
||||
menuState.readGroup(attrs);
|
||||
} else if (tagName.equals(XML_ITEM)) {
|
||||
menuState.readItem(attrs);
|
||||
} else if (tagName.equals(XML_MENU)) {
|
||||
// A menu start tag denotes a submenu for an item
|
||||
SubMenu subMenu = menuState.addSubMenuItem();
|
||||
|
||||
// Parse the submenu into returned SubMenu
|
||||
parseMenu(parser, attrs, subMenu);
|
||||
} else {
|
||||
lookingForEndOfUnknownTag = true;
|
||||
unknownTagName = tagName;
|
||||
}
|
||||
break;
|
||||
|
||||
case XmlPullParser.END_TAG:
|
||||
tagName = parser.getName();
|
||||
if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) {
|
||||
lookingForEndOfUnknownTag = false;
|
||||
unknownTagName = null;
|
||||
} else if (tagName.equals(XML_GROUP)) {
|
||||
menuState.resetGroup();
|
||||
} else if (tagName.equals(XML_ITEM)) {
|
||||
// Add the item if it hasn't been added (if the item was
|
||||
// a submenu, it would have been added already)
|
||||
if (!menuState.hasAddedItem()) {
|
||||
if (menuState.itemActionProvider != null &&
|
||||
menuState.itemActionProvider.hasSubMenu()) {
|
||||
menuState.addSubMenuItem();
|
||||
} else {
|
||||
menuState.addItem();
|
||||
}
|
||||
}
|
||||
} else if (tagName.equals(XML_MENU)) {
|
||||
reachedEndOfMenu = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case XmlPullParser.END_DOCUMENT:
|
||||
throw new RuntimeException("Unexpected end of document");
|
||||
}
|
||||
|
||||
eventType = parser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static class InflatedOnMenuItemClickListener
|
||||
implements MenuItem.OnMenuItemClickListener {
|
||||
private static final Class<?>[] PARAM_TYPES = new Class[]{MenuItem.class};
|
||||
|
||||
private Object mRealOwner;
|
||||
private Method mMethod;
|
||||
|
||||
public InflatedOnMenuItemClickListener(Object realOwner, String methodName) {
|
||||
mRealOwner = realOwner;
|
||||
Class<?> c = realOwner.getClass();
|
||||
try {
|
||||
mMethod = c.getMethod(methodName, PARAM_TYPES);
|
||||
} catch (Exception e) {
|
||||
InflateException ex = new InflateException(
|
||||
"Couldn't resolve menu item onClick handler " + methodName +
|
||||
" in class " + c.getName()
|
||||
);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
try {
|
||||
if (mMethod.getReturnType() == Boolean.TYPE) {
|
||||
return (Boolean) mMethod.invoke(mRealOwner, item);
|
||||
} else {
|
||||
mMethod.invoke(mRealOwner, item);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Styleable {
|
||||
|
||||
public static final int[] MenuGroup = {android.R.attr.id, android.R.attr.menuCategory,
|
||||
android.R.attr.orderInCategory, android.R.attr.checkableBehavior,
|
||||
android.R.attr.visible, android.R.attr.enabled};
|
||||
public static final int MenuGroup_id = 0;
|
||||
public static final int MenuGroup_menuCategory = 1;
|
||||
public static final int MenuGroup_orderInCategory = 2;
|
||||
public static final int MenuGroup_checkableBehavior = 3;
|
||||
public static final int MenuGroup_visible = 4;
|
||||
public static final int MenuGroup_enabled = 5;
|
||||
|
||||
public static final int[] MenuItem = {android.R.attr.id, android.R.attr.menuCategory,
|
||||
android.R.attr.orderInCategory, android.R.attr.title, android.R.attr.titleCondensed,
|
||||
android.R.attr.icon, android.R.attr.alphabeticShortcut, android.R.attr.numericShortcut,
|
||||
android.R.attr.checkable, android.R.attr.checked, android.R.attr.visible,
|
||||
android.R.attr.enabled, android.R.attr.showAsAction, android.R.attr.onClick,
|
||||
android.R.attr.actionLayout, android.R.attr.actionViewClass,
|
||||
android.R.attr.actionProviderClass};
|
||||
public static final int MenuItem_id = 0;
|
||||
public static final int MenuItem_menuCategory = 1;
|
||||
public static final int MenuItem_orderInCategory = 2;
|
||||
public static final int MenuItem_title = 3;
|
||||
public static final int MenuItem_titleCondensed = 4;
|
||||
public static final int MenuItem_icon = 5;
|
||||
public static final int MenuItem_alphabeticShortcut = 6;
|
||||
public static final int MenuItem_numericShortcut = 7;
|
||||
public static final int MenuItem_checkable = 8;
|
||||
public static final int MenuItem_checked = 9;
|
||||
public static final int MenuItem_visible = 10;
|
||||
public static final int MenuItem_enabled = 11;
|
||||
public static final int MenuItem_showAsAction = 12;
|
||||
public static final int MenuItem_onClick = 13;
|
||||
public static final int MenuItem_actionLayout = 14;
|
||||
public static final int MenuItem_actionViewClass = 15;
|
||||
public static final int MenuItem_actionProviderClass = 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* State for the current menu.
|
||||
* <p/>
|
||||
* Groups can not be nested unless there is another menu (which will have
|
||||
* its state class).
|
||||
*/
|
||||
private class MenuState {
|
||||
|
||||
|
||||
/**
|
||||
* This is the part of an order integer that the user can provide.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
static final int USER_MASK = 0x0000ffff;
|
||||
/**
|
||||
* Bit shift of the user portion of the order integer.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
static final int USER_SHIFT = 0;
|
||||
|
||||
/**
|
||||
* This is the part of an order integer that supplies the category of the
|
||||
* item.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
static final int CATEGORY_MASK = 0xffff0000;
|
||||
|
||||
private Menu menu;
|
||||
|
||||
/*
|
||||
* Group state is set on items as they are added, allowing an item to
|
||||
* override its group state. (As opposed to set on items at the group end tag.)
|
||||
*/
|
||||
private int groupId;
|
||||
private int groupCategory;
|
||||
private int groupOrder;
|
||||
private int groupCheckable;
|
||||
private boolean groupVisible;
|
||||
private boolean groupEnabled;
|
||||
|
||||
private boolean itemAdded;
|
||||
private int itemId;
|
||||
private int itemCategoryOrder;
|
||||
private CharSequence itemTitle;
|
||||
private CharSequence itemTitleCondensed;
|
||||
private int itemIconResId;
|
||||
private char itemAlphabeticShortcut;
|
||||
private char itemNumericShortcut;
|
||||
/**
|
||||
* Sync to attrs.xml enum:
|
||||
* - 0: none
|
||||
* - 1: all
|
||||
* - 2: exclusive
|
||||
*/
|
||||
private int itemCheckable;
|
||||
private boolean itemChecked;
|
||||
private boolean itemVisible;
|
||||
private boolean itemEnabled;
|
||||
|
||||
/**
|
||||
* Sync to attrs.xml enum, values in MenuItem:
|
||||
* - 0: never
|
||||
* - 1: ifRoom
|
||||
* - 2: always
|
||||
* - -1: Safe sentinel for "no value".
|
||||
*/
|
||||
private int itemShowAsAction;
|
||||
|
||||
private int itemActionViewLayout;
|
||||
private String itemActionViewClassName;
|
||||
private String itemActionProviderClassName;
|
||||
|
||||
private String itemListenerMethodName;
|
||||
|
||||
private ActionProvider itemActionProvider;
|
||||
|
||||
private static final int defaultGroupId = NO_ID;
|
||||
private static final int defaultItemId = NO_ID;
|
||||
private static final int defaultItemCategory = 0;
|
||||
private static final int defaultItemOrder = 0;
|
||||
private static final int defaultItemCheckable = 0;
|
||||
private static final boolean defaultItemChecked = false;
|
||||
private static final boolean defaultItemVisible = true;
|
||||
private static final boolean defaultItemEnabled = true;
|
||||
|
||||
public MenuState(final Menu menu) {
|
||||
this.menu = menu;
|
||||
|
||||
resetGroup();
|
||||
}
|
||||
|
||||
public void resetGroup() {
|
||||
groupId = defaultGroupId;
|
||||
groupCategory = defaultItemCategory;
|
||||
groupOrder = defaultItemOrder;
|
||||
groupCheckable = defaultItemCheckable;
|
||||
groupVisible = defaultItemVisible;
|
||||
groupEnabled = defaultItemEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the parser is pointing to a group tag.
|
||||
*/
|
||||
public void readGroup(AttributeSet attrs) {
|
||||
TypedArray a = mContext.obtainStyledAttributes(attrs,
|
||||
Styleable.MenuGroup);
|
||||
|
||||
groupId = a.getResourceId(Styleable.MenuGroup_id, defaultGroupId);
|
||||
groupCategory = a.getInt(Styleable.MenuGroup_menuCategory, defaultItemCategory);
|
||||
groupOrder = a.getInt(Styleable.MenuGroup_orderInCategory, defaultItemOrder);
|
||||
groupCheckable = a.getInt(Styleable.MenuGroup_checkableBehavior, defaultItemCheckable);
|
||||
groupVisible = a.getBoolean(Styleable.MenuGroup_visible, defaultItemVisible);
|
||||
groupEnabled = a.getBoolean(Styleable.MenuGroup_enabled, defaultItemEnabled);
|
||||
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the parser is pointing to an item tag.
|
||||
*/
|
||||
public void readItem(AttributeSet attrs) {
|
||||
TypedArray a = mContext.obtainStyledAttributes(attrs,
|
||||
Styleable.MenuItem);
|
||||
|
||||
// Inherit attributes from the group as default value
|
||||
itemId = a.getResourceId(Styleable.MenuItem_id, defaultItemId);
|
||||
final int category = a.getInt(Styleable.MenuItem_menuCategory, groupCategory);
|
||||
final int order = a.getInt(Styleable.MenuItem_orderInCategory, groupOrder);
|
||||
itemCategoryOrder = (category & CATEGORY_MASK) | (order & USER_MASK);
|
||||
itemTitle = a.getText(Styleable.MenuItem_title);
|
||||
itemTitleCondensed = a.getText(Styleable.MenuItem_titleCondensed);
|
||||
itemIconResId = ThemeUtils.findAttributeResourceValue(attrs, "icon", 0);
|
||||
itemAlphabeticShortcut =
|
||||
getShortcut(a.getString(Styleable.MenuItem_alphabeticShortcut));
|
||||
itemNumericShortcut =
|
||||
getShortcut(a.getString(Styleable.MenuItem_numericShortcut));
|
||||
if (a.hasValue(Styleable.MenuItem_checkable)) {
|
||||
// Item has attribute checkable, use it
|
||||
itemCheckable = a.getBoolean(Styleable.MenuItem_checkable, false) ? 1 : 0;
|
||||
} else {
|
||||
// Item does not have attribute, use the group's (group can have one more state
|
||||
// for checkable that represents the exclusive checkable)
|
||||
itemCheckable = groupCheckable;
|
||||
}
|
||||
itemChecked = a.getBoolean(Styleable.MenuItem_checked, defaultItemChecked);
|
||||
itemVisible = a.getBoolean(Styleable.MenuItem_visible, groupVisible);
|
||||
itemEnabled = a.getBoolean(Styleable.MenuItem_enabled, groupEnabled);
|
||||
itemShowAsAction = a.getInt(Styleable.MenuItem_showAsAction, -1);
|
||||
itemListenerMethodName = a.getString(Styleable.MenuItem_onClick);
|
||||
itemActionViewLayout = a.getResourceId(Styleable.MenuItem_actionLayout, 0);
|
||||
itemActionViewClassName = a.getString(Styleable.MenuItem_actionViewClass);
|
||||
itemActionProviderClassName = a.getString(Styleable.MenuItem_actionProviderClass);
|
||||
|
||||
final boolean hasActionProvider = itemActionProviderClassName != null;
|
||||
if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
|
||||
itemActionProvider = newInstance(itemActionProviderClassName,
|
||||
ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE,
|
||||
mActionProviderConstructorArguments);
|
||||
} else {
|
||||
if (hasActionProvider) {
|
||||
Log.w(LOG_TAG, "Ignoring attribute 'actionProviderClass'."
|
||||
+ " Action view already specified.");
|
||||
}
|
||||
itemActionProvider = null;
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
|
||||
itemAdded = false;
|
||||
}
|
||||
|
||||
private char getShortcut(String shortcutString) {
|
||||
if (shortcutString == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return shortcutString.charAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void setItem(MenuItem item) {
|
||||
item.setChecked(itemChecked)
|
||||
.setVisible(itemVisible)
|
||||
.setEnabled(itemEnabled)
|
||||
.setCheckable(itemCheckable >= 1)
|
||||
.setTitleCondensed(itemTitleCondensed)
|
||||
.setIcon(itemIconResId > 0 ? mResources.getDrawable(itemIconResId) : null)
|
||||
.setAlphabeticShortcut(itemAlphabeticShortcut)
|
||||
.setNumericShortcut(itemNumericShortcut);
|
||||
|
||||
if (itemShowAsAction >= 0) {
|
||||
item.setShowAsAction(itemShowAsAction);
|
||||
}
|
||||
|
||||
if (itemListenerMethodName != null) {
|
||||
if (mContext.isRestricted()) {
|
||||
throw new IllegalStateException("The android:onClick attribute cannot "
|
||||
+ "be used within a restricted context");
|
||||
}
|
||||
item.setOnMenuItemClickListener(
|
||||
new InflatedOnMenuItemClickListener(mRealOwner, itemListenerMethodName));
|
||||
}
|
||||
|
||||
// if (item instanceof MenuItemImpl) {
|
||||
// MenuItemImpl impl = (MenuItemImpl) item;
|
||||
// if (itemCheckable >= 2) {
|
||||
// impl.setExclusiveCheckable(true);
|
||||
// }
|
||||
// }
|
||||
|
||||
boolean actionViewSpecified = false;
|
||||
if (itemActionViewClassName != null) {
|
||||
View actionView = (View) newInstance(itemActionViewClassName,
|
||||
ACTION_VIEW_CONSTRUCTOR_SIGNATURE, mActionViewConstructorArguments);
|
||||
item.setActionView(actionView);
|
||||
actionViewSpecified = true;
|
||||
}
|
||||
if (itemActionViewLayout > 0) {
|
||||
if (!actionViewSpecified) {
|
||||
item.setActionView(itemActionViewLayout);
|
||||
actionViewSpecified = true;
|
||||
} else {
|
||||
Log.w(LOG_TAG, "Ignoring attribute 'itemActionViewLayout'."
|
||||
+ " Action view already specified.");
|
||||
}
|
||||
}
|
||||
if (itemActionProvider != null) {
|
||||
item.setActionProvider(itemActionProvider);
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem() {
|
||||
itemAdded = true;
|
||||
setItem(menu.add(groupId, itemId, itemCategoryOrder, itemTitle));
|
||||
}
|
||||
|
||||
public SubMenu addSubMenuItem() {
|
||||
itemAdded = true;
|
||||
SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle);
|
||||
setItem(subMenu.getItem());
|
||||
return subMenu;
|
||||
}
|
||||
|
||||
public boolean hasAddedItem() {
|
||||
return itemAdded;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T newInstance(String className, Class<?>[] constructorSignature,
|
||||
Object[] arguments) {
|
||||
try {
|
||||
Class<?> clazz = mContext.getClassLoader().loadClass(className);
|
||||
Constructor<?> constructor = clazz.getConstructor(constructorSignature);
|
||||
return (T) constructor.newInstance(arguments);
|
||||
} catch (Exception e) {
|
||||
Log.w(LOG_TAG, "Cannot instantiate class: " + className, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.mariotaku.twidere.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14-7-28.
|
||||
*/
|
||||
public class ResourceIconPreference extends Preference {
|
||||
public ResourceIconPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
final TypedArray array = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.ResourceImageView, defStyle, 0);
|
||||
final int resId = array.getResourceId(R.styleable.ResourceImageView_image, -1);
|
||||
if (resId > 0) {
|
||||
setIcon(context.getResources().getDrawable(resId));
|
||||
}
|
||||
array.recycle();
|
||||
}
|
||||
|
||||
public ResourceIconPreference(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, android.R.attr.preferenceStyle);
|
||||
}
|
||||
|
||||
public ResourceIconPreference(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
}
|
|
@ -50,8 +50,6 @@ import org.mariotaku.twidere.content.TwidereContextThemeWrapper;
|
|||
import org.mariotaku.twidere.content.TwidereContextWrapper;
|
||||
import org.mariotaku.twidere.content.iface.ITwidereContextWrapper;
|
||||
import org.mariotaku.twidere.content.res.NoAccentResources;
|
||||
import org.mariotaku.twidere.content.res.TwidereAccentResources;
|
||||
import org.mariotaku.twidere.content.res.TwidereResources;
|
||||
import org.mariotaku.twidere.util.theme.ActionIconsInterceptor;
|
||||
import org.mariotaku.twidere.util.theme.ActivityIconsInterceptor;
|
||||
import org.mariotaku.twidere.util.theme.WhiteDrawableInterceptor;
|
||||
|
@ -157,10 +155,6 @@ public class ThemeUtils implements Constants {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static Resources getAccentResourcesForActionIcons(final Context baseContext, final int themeRes,
|
||||
final int accentColor) {
|
||||
return new TwidereAccentResources(baseContext, baseContext.getResources(), themeRes, accentColor);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Drawable getActionBarBackground(final Context context, final boolean applyAlpha) {
|
||||
|
@ -238,6 +232,8 @@ public class ThemeUtils implements Constants {
|
|||
case R.style.Theme_Twidere_Colored_Compose:
|
||||
case R.style.Theme_Twidere_ActionBar_Colored_Light:
|
||||
case R.style.Theme_Twidere_Settings_Light:
|
||||
case R.style.Theme_Twidere_Drawer_Light:
|
||||
case R.style.Theme_Twidere_Drawer_Light_Transparent:
|
||||
case R.style.Theme_Twidere_Light_DarkActionBar_DarkIcon:
|
||||
case R.style.Theme_Twidere_Light_DarkActionBar_SolidBackground_DarkIcon:
|
||||
case R.style.Theme_Twidere_Light_DarkActionBar_Transparent_DarkIcon:
|
||||
|
@ -326,6 +322,21 @@ public class ThemeUtils implements Constants {
|
|||
return R.style.Theme_Twidere_Drawer_Dark;
|
||||
}
|
||||
|
||||
public static int getLightDrawerThemeResource(final Context context) {
|
||||
return getLightDrawerThemeResource(getThemeResource(context));
|
||||
}
|
||||
|
||||
public static int getLightDrawerThemeResource(final int themeRes) {
|
||||
switch (themeRes) {
|
||||
case R.style.Theme_Twidere_Light_Transparent:
|
||||
case R.style.Theme_Twidere_Light_DarkActionBar_Transparent:
|
||||
case R.style.Theme_Twidere_Colored_DarkActionBar_Transparent:
|
||||
case R.style.Theme_Twidere_Colored_Transparent:
|
||||
return R.style.Theme_Twidere_Drawer_Light_Transparent;
|
||||
}
|
||||
return R.style.Theme_Twidere_Drawer_Light;
|
||||
}
|
||||
|
||||
public static Drawable getImageHighlightDrawable(final Context context) {
|
||||
final Drawable d = getSelectableItemBackgroundDrawable(context);
|
||||
if (d != null) {
|
||||
|
@ -391,9 +402,6 @@ public class ThemeUtils implements Constants {
|
|||
return context.getResources();
|
||||
}
|
||||
|
||||
public static Resources getResourcesForActionIcons(final Context baseContext, final int themeRes) {
|
||||
return new TwidereResources(baseContext, baseContext.getResources(), themeRes);
|
||||
}
|
||||
|
||||
public static Drawable getSelectableItemBackgroundDrawable(final Context context) {
|
||||
final TypedArray a = context.obtainStyledAttributes(new int[]{android.R.attr.selectableItemBackground});
|
||||
|
@ -853,9 +861,8 @@ public class ThemeUtils implements Constants {
|
|||
}
|
||||
|
||||
public static void overrideNormalActivityCloseAnimation(final Activity activity) {
|
||||
|
||||
final TypedArray a = activity
|
||||
.obtainStyledAttributes(android.R.style.Animation_Activity, ANIM_CLOSE_STYLE_ATTRS);
|
||||
final TypedArray a = activity.obtainStyledAttributes(null, ANIM_CLOSE_STYLE_ATTRS,
|
||||
0, android.R.style.Animation_Activity);
|
||||
final int activityCloseEnterAnimation = a.getResourceId(0, 0);
|
||||
final int activityCloseExitAnimation = a.getResourceId(1, 0);
|
||||
a.recycle();
|
||||
|
@ -924,4 +931,16 @@ public class ThemeUtils implements Constants {
|
|||
resources.addInterceptor(new ActivityIconsInterceptor(context, resources.getDisplayMetrics(), 0));
|
||||
resources.addInterceptor(new WhiteDrawableInterceptor(resources));
|
||||
}
|
||||
|
||||
public static int findAttributeResourceValue(AttributeSet attrs, String name, int defaultValue) {
|
||||
for (int i = 0, j = attrs.getAttributeCount(); i < j; i++) {
|
||||
if (attrs.getAttributeName(i).equals(name))
|
||||
return attrs.getAttributeResourceValue(i, defaultValue);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static Resources getThemedResourcesForActionIcons(Context context, int themeRes, int accentColor) {
|
||||
return getThemedContextForActionIcons(context, themeRes, accentColor).getResources();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,109 +13,105 @@ import com.negusoft.holoaccent.AccentResources;
|
|||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.content.iface.ITwidereContextWrapper;
|
||||
import org.mariotaku.twidere.content.res.iface.IThemedResources.DrawableInterceptor;
|
||||
import org.mariotaku.twidere.graphic.icon.TwidereIcon;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
||||
public class ActionIconsInterceptor implements DrawableInterceptor , AccentResources.Interceptor{
|
||||
public class ActionIconsInterceptor implements AccentResources.Interceptor {
|
||||
|
||||
private static final SparseArray<Icon> sIconMap = new SparseArray<Icon>();
|
||||
private static final SparseArray<Icon> sIconMap = new SparseArray<Icon>();
|
||||
|
||||
static {
|
||||
sIconMap.put(R.drawable.ic_iconic_action_twidere, TwidereIcon.TWIDERE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_twidere_square, TwidereIcon.TWIDERE_SQUARE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_web, TwidereIcon.WEB);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_compose, TwidereIcon.COMPOSE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_color_palette, TwidereIcon.COLOR_PALETTE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_camera, TwidereIcon.CAMERA);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_new_message, TwidereIcon.NEW_MESSAGE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_server, TwidereIcon.SERVER);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_gallery, TwidereIcon.GALLERY);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_save, TwidereIcon.SAVE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_star, TwidereIcon.STAR);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_search, TwidereIcon.SEARCH);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_retweet, TwidereIcon.RETWEET);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_reply, TwidereIcon.REPLY);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_delete, TwidereIcon.DELETE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_add, TwidereIcon.ADD);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_share, TwidereIcon.SHARE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_inbox, TwidereIcon.INBOX);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_outbox, TwidereIcon.OUTBOX);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_copy, TwidereIcon.COPY);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_select_all, TwidereIcon.SELECT_ALL);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_translate, TwidereIcon.TRANSLATE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_user, TwidereIcon.USER);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_accounts, TwidereIcon.USER_GROUP);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_send, TwidereIcon.SEND);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_edit, TwidereIcon.EDIT);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_ok, TwidereIcon.OK);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_cancel, TwidereIcon.CANCEL);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_preferences, TwidereIcon.PREFERENCES);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_mylocation, TwidereIcon.LOCATION_FOUND);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_speaker_muted, TwidereIcon.SPEAKER_MUTED);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_quote, TwidereIcon.QUOTE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_message, TwidereIcon.MESSAGE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_twitter, TwidereIcon.TWITTER);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_home, TwidereIcon.HOME);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_mention, TwidereIcon.AT);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_hashtag, TwidereIcon.HASHTAG);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_trends, TwidereIcon.TRENDS);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_list, TwidereIcon.LIST);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_staggered, TwidereIcon.STAGGERED);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_tab, TwidereIcon.TAB);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_extension, TwidereIcon.EXTENSION);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_card, TwidereIcon.CARD);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_refresh, TwidereIcon.REFRESH);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_grid, TwidereIcon.GRID);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_about, TwidereIcon.INFO);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_more, TwidereIcon.MORE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_open_source, TwidereIcon.OPEN_SOURCE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_notification, TwidereIcon.NOTIFICATION);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_interface, TwidereIcon.INTERFACE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_block, TwidereIcon.BLOCK);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_warning, TwidereIcon.WARNING);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_heart, TwidereIcon.HEART);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_checked, TwidereIcon.CHECKED);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_drafts, TwidereIcon.DRAFTS);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_import, TwidereIcon.IMPORT);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_export, TwidereIcon.EXPORT);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_storage, TwidereIcon.STORAGE);
|
||||
}
|
||||
static {
|
||||
sIconMap.put(R.drawable.ic_iconic_action_twidere, TwidereIcon.TWIDERE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_twidere_square, TwidereIcon.TWIDERE_SQUARE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_web, TwidereIcon.WEB);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_compose, TwidereIcon.COMPOSE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_color_palette, TwidereIcon.COLOR_PALETTE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_camera, TwidereIcon.CAMERA);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_new_message, TwidereIcon.NEW_MESSAGE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_server, TwidereIcon.SERVER);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_gallery, TwidereIcon.GALLERY);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_save, TwidereIcon.SAVE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_star, TwidereIcon.STAR);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_search, TwidereIcon.SEARCH);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_retweet, TwidereIcon.RETWEET);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_reply, TwidereIcon.REPLY);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_delete, TwidereIcon.DELETE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_add, TwidereIcon.ADD);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_share, TwidereIcon.SHARE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_inbox, TwidereIcon.INBOX);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_outbox, TwidereIcon.OUTBOX);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_copy, TwidereIcon.COPY);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_select_all, TwidereIcon.SELECT_ALL);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_translate, TwidereIcon.TRANSLATE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_user, TwidereIcon.USER);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_accounts, TwidereIcon.USER_GROUP);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_send, TwidereIcon.SEND);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_edit, TwidereIcon.EDIT);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_ok, TwidereIcon.OK);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_cancel, TwidereIcon.CANCEL);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_preferences, TwidereIcon.PREFERENCES);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_mylocation, TwidereIcon.LOCATION_FOUND);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_speaker_muted, TwidereIcon.SPEAKER_MUTED);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_quote, TwidereIcon.QUOTE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_message, TwidereIcon.MESSAGE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_twitter, TwidereIcon.TWITTER);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_home, TwidereIcon.HOME);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_mention, TwidereIcon.AT);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_hashtag, TwidereIcon.HASHTAG);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_trends, TwidereIcon.TRENDS);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_list, TwidereIcon.LIST);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_staggered, TwidereIcon.STAGGERED);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_tab, TwidereIcon.TAB);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_extension, TwidereIcon.EXTENSION);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_card, TwidereIcon.CARD);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_refresh, TwidereIcon.REFRESH);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_grid, TwidereIcon.GRID);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_about, TwidereIcon.INFO);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_more, TwidereIcon.MORE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_open_source, TwidereIcon.OPEN_SOURCE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_notification, TwidereIcon.NOTIFICATION);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_interface, TwidereIcon.INTERFACE);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_block, TwidereIcon.BLOCK);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_warning, TwidereIcon.WARNING);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_heart, TwidereIcon.HEART);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_checked, TwidereIcon.CHECKED);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_drafts, TwidereIcon.DRAFTS);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_import, TwidereIcon.IMPORT);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_export, TwidereIcon.EXPORT);
|
||||
sIconMap.put(R.drawable.ic_iconic_action_storage, TwidereIcon.STORAGE);
|
||||
}
|
||||
|
||||
private static int MENU_ICON_SIZE_DP = 32;
|
||||
private final Context mContext;
|
||||
private final int mIconSize;
|
||||
private final int mIconColor;
|
||||
private final float mDensity;
|
||||
private static int MENU_ICON_SIZE_DP = 32;
|
||||
private final Context mContext;
|
||||
private final int mIconSize;
|
||||
private final int mIconColor;
|
||||
private final float mDensity;
|
||||
|
||||
public ActionIconsInterceptor(final Context context, final DisplayMetrics dm, final int overrideThemeRes) {
|
||||
mContext = context;
|
||||
if (overrideThemeRes != 0) {
|
||||
mIconColor = ThemeUtils.getActionIconColor(overrideThemeRes);
|
||||
} else if (context instanceof ITwidereContextWrapper) {
|
||||
final int resId = ((ITwidereContextWrapper) context).getThemeResourceId();
|
||||
mIconColor = ThemeUtils.getActionIconColor(resId);
|
||||
} else {
|
||||
mIconColor = ThemeUtils.getActionIconColor(context);
|
||||
}
|
||||
mDensity = dm.density;
|
||||
mIconSize = Math.round(mDensity * MENU_ICON_SIZE_DP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getDrawable(final Resources res, final int resId) {
|
||||
final Icon icon = sIconMap.get(resId, null);
|
||||
if (icon == null) return null;
|
||||
final IconicFontDrawable drawable = new IconicFontDrawable(mContext, icon);
|
||||
drawable.setIntrinsicWidth(mIconSize);
|
||||
drawable.setIntrinsicHeight(mIconSize);
|
||||
drawable.setIconColor(mIconColor);
|
||||
drawable.setBounds(0, 0, mIconSize, mIconSize);
|
||||
return drawable;
|
||||
}
|
||||
public ActionIconsInterceptor(final Context context, final DisplayMetrics dm,
|
||||
final int overrideThemeRes) {
|
||||
mContext = context;
|
||||
if (overrideThemeRes != 0) {
|
||||
mIconColor = ThemeUtils.getActionIconColor(overrideThemeRes);
|
||||
} else if (context instanceof ITwidereContextWrapper) {
|
||||
final int resId = ((ITwidereContextWrapper) context).getThemeResourceId();
|
||||
mIconColor = ThemeUtils.getActionIconColor(resId);
|
||||
} else {
|
||||
mIconColor = ThemeUtils.getActionIconColor(context);
|
||||
}
|
||||
mDensity = dm.density;
|
||||
mIconSize = Math.round(mDensity * MENU_ICON_SIZE_DP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getDrawable(Resources resources, AccentPalette accentPalette, int resId) {
|
||||
return getDrawable(resources, resId);
|
||||
public Drawable getDrawable(final Resources resources, final AccentPalette accentPalette,
|
||||
final int resId) {
|
||||
final Icon icon = sIconMap.get(resId, null);
|
||||
if (icon == null) return null;
|
||||
final IconicFontDrawable drawable = new IconicFontDrawable(mContext, icon);
|
||||
drawable.setIntrinsicWidth(mIconSize);
|
||||
drawable.setIntrinsicHeight(mIconSize);
|
||||
drawable.setIconColor(mIconColor);
|
||||
drawable.setBounds(0, 0, mIconSize, mIconSize);
|
||||
return drawable;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.mariotaku.twidere.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14-7-27.
|
||||
*/
|
||||
public class ResourceImageButton extends ResourceImageView {
|
||||
|
||||
public ResourceImageButton(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ResourceImageButton(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, android.R.attr.imageButtonStyle);
|
||||
}
|
||||
|
||||
public ResourceImageButton(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
setFocusable(true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.mariotaku.twidere.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14-7-27.
|
||||
*/
|
||||
public class ResourceImageView extends ImageButton {
|
||||
|
||||
public ResourceImageView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ResourceImageView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public ResourceImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
if (!isInEditMode()) {
|
||||
final TypedArray array = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.ResourceImageView, defStyle, 0);
|
||||
final int resId = array.getResourceId(R.styleable.ResourceImageView_image, -1);
|
||||
if (resId > 0) {
|
||||
setImageResource(resId);
|
||||
}
|
||||
array.recycle();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/ic_iconic_action_gallery"/>
|
||||
|
||||
</layer-list>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/ic_iconic_action_preferences"/>
|
||||
|
||||
</layer-list>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/ic_iconic_action_send"/>
|
||||
|
||||
</layer-list>
|
|
@ -1,28 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/send"
|
||||
style="?android:actionButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/send"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="?android:actionButtonStyle"
|
||||
android:id="@+id/send"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/send"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
<org.mariotaku.twidere.view.StatusTextCountView
|
||||
android:id="@+id/status_text_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textAppearance="?android:textAppearanceSmall"/>
|
||||
<org.mariotaku.twidere.view.StatusTextCountView
|
||||
android:id="@+id/status_text_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textAppearance="?android:textAppearanceSmall" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/send"
|
||||
android:cropToPadding="false"
|
||||
android:padding="@dimen/element_spacing_extra_small"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_menu_send"/>
|
||||
<org.mariotaku.twidere.view.ResourceImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/send"
|
||||
android:cropToPadding="false"
|
||||
android:padding="@dimen/element_spacing_extra_small"
|
||||
android:scaleType="centerCrop"
|
||||
app:image="@drawable/ic_iconic_action_send" />
|
||||
|
||||
</LinearLayout>
|
|
@ -9,7 +9,7 @@
|
|||
android:layout_gravity="center"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
<org.mariotaku.twidere.view.ResourceImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -1,87 +1,88 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/compose_actionbar"
|
||||
style="?android:actionBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/compose_actionbar"
|
||||
style="?android:actionBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="8dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="8dp">
|
||||
|
||||
<org.mariotaku.twidere.view.ActionBarHomeAsUpIndicator
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"/>
|
||||
<org.mariotaku.twidere.view.ActionBarHomeAsUpIndicator
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="?android:actionBarSize"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="-8dp"
|
||||
android:layout_marginRight="-8dp"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingTop="6dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_launcher_twidere_iconic"/>
|
||||
<org.mariotaku.twidere.view.ResourceImageView
|
||||
android:layout_width="?android:actionBarSize"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="-8dp"
|
||||
android:layout_marginRight="-8dp"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingTop="6dp"
|
||||
android:scaleType="centerInside"
|
||||
app:image="@drawable/ic_launcher_twidere_iconic" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="4dp">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="4dp">
|
||||
|
||||
<org.mariotaku.twidere.view.ActionBarTitleView
|
||||
android:id="@+id/actionbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"/>
|
||||
<org.mariotaku.twidere.view.ActionBarTitleView
|
||||
android:id="@+id/actionbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true" />
|
||||
|
||||
<org.mariotaku.twidere.view.ActionBarSubtitleView
|
||||
android:id="@+id/actionbar_subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/quote_protected_status_notice"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<org.mariotaku.twidere.view.ActionBarSubtitleView
|
||||
android:id="@+id/actionbar_subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/quote_protected_status_notice"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/actionbar_progress_indeterminate"
|
||||
style="?android:progressBarStyle"
|
||||
android:layout_width="?android:actionBarSize"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0"
|
||||
android:indeterminateOnly="true"
|
||||
android:padding="2dp"
|
||||
android:visibility="gone"/>
|
||||
<ProgressBar
|
||||
android:id="@+id/actionbar_progress_indeterminate"
|
||||
style="?android:progressBarStyle"
|
||||
android:layout_width="?android:actionBarSize"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0"
|
||||
android:indeterminateOnly="true"
|
||||
android:padding="2dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<org.mariotaku.menucomponent.widget.MenuBar
|
||||
android:id="@+id/action_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="@null"
|
||||
android:max="@integer/max_compose_menu_buttons_top"/>
|
||||
<org.mariotaku.menucomponent.widget.MenuBar
|
||||
android:id="@+id/action_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="@null"
|
||||
android:max="@integer/max_compose_menu_buttons_top" />
|
||||
|
||||
<include layout="@layout/action_item_compose"/>
|
||||
<include layout="@layout/action_item_compose" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,98 +1,100 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center">
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
<RelativeLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/username_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/username_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/username"
|
||||
android:inputType="textEmailAddress"
|
||||
android:singleLine="true"
|
||||
android:typeface="normal"/>
|
||||
<EditText
|
||||
android:id="@+id/username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/username"
|
||||
android:inputType="textEmailAddress"
|
||||
android:singleLine="true"
|
||||
android:typeface="normal" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/password"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:typeface="normal"/>
|
||||
</LinearLayout>
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/password"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:typeface="normal" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sign_in_sign_up"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/username_password"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/sign_in_sign_up"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/username_password"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/sign_in"
|
||||
style="?android:buttonStyleSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="48dp"
|
||||
android:onClick="onClick"
|
||||
android:text="@string/sign_in"/>
|
||||
<Button
|
||||
android:id="@+id/sign_in"
|
||||
style="?android:buttonStyleSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="48dp"
|
||||
android:onClick="onClick"
|
||||
android:text="@string/sign_in" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/sign_up"
|
||||
style="?android:buttonStyleSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="48dp"
|
||||
android:onClick="onClick"
|
||||
android:text="@string/sign_up"/>
|
||||
</LinearLayout>
|
||||
<Button
|
||||
android:id="@+id/sign_up"
|
||||
style="?android:buttonStyleSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="48dp"
|
||||
android:onClick="onClick"
|
||||
android:text="@string/sign_up" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/sign_in_method_introduction"
|
||||
style="?android:borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/sign_in_sign_up"
|
||||
android:layout_margin="8dp"
|
||||
android:clickable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="36dp"
|
||||
android:onClick="onClick"
|
||||
android:text="@string/sign_in_method_introduction_title"
|
||||
android:textAppearance="?android:textAppearanceSmall"/>
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
||||
<Button
|
||||
android:id="@+id/sign_in_method_introduction"
|
||||
style="?android:borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/sign_in_sign_up"
|
||||
android:layout_margin="8dp"
|
||||
android:clickable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="36dp"
|
||||
android:onClick="onClick"
|
||||
android:text="@string/sign_in_method_introduction_title"
|
||||
android:textAppearance="?android:textAppearanceSmall" />
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/set_color"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_weight="0"
|
||||
android:contentDescription="@string/set_color"
|
||||
android:onClick="onClick"/>
|
||||
<org.mariotaku.twidere.view.ResourceImageButton
|
||||
android:id="@+id/set_color"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_weight="0"
|
||||
android:contentDescription="@string/set_color"
|
||||
android:onClick="onClick"
|
||||
app:image="@drawable/ic_iconic_action_color_palette" />
|
||||
|
||||
</merge>
|
|
@ -1,11 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="wrap_content"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
<org.mariotaku.twidere.view.ResourceImageView
|
||||
android:id="@+id/add_image"
|
||||
style="?android:borderlessButtonStyle"
|
||||
android:layout_width="?android:actionBarSize"
|
||||
|
@ -13,7 +14,7 @@
|
|||
android:layout_weight="0"
|
||||
android:contentDescription="@string/add_image"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_menu_gallery"/>
|
||||
app:image="@drawable/ic_iconic_action_gallery"/>
|
||||
|
||||
<org.mariotaku.twidere.view.StatusComposeEditText
|
||||
android:id="@+id/edit_text"
|
||||
|
@ -36,12 +37,12 @@
|
|||
android:layout_height="?android:actionBarSize"
|
||||
android:layout_weight="0">
|
||||
|
||||
<ImageView
|
||||
<org.mariotaku.twidere.view.ResourceImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/send"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_menu_send"/>
|
||||
app:image="@drawable/ic_iconic_action_send"/>
|
||||
|
||||
<org.mariotaku.twidere.view.StatusTextCountView
|
||||
android:id="@+id/text_count"
|
||||
|
|
|
@ -1,65 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/activities_drawer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
app:dragView="@+id/activities_header_title"
|
||||
app:panelHeight="@dimen/header_height_quick_menu">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/activities_drawer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
app:dragView="@+id/activities_header_title"
|
||||
app:panelHeight="@dimen/header_height_quick_menu">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/quick_menu_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<FrameLayout
|
||||
android:id="@+id/quick_menu_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
</ListView>
|
||||
</FrameLayout>
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"></ListView>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/activities_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:id="@+id/activities_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/activities_header"
|
||||
style="?android:listSeparatorTextViewStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/header_height_quick_menu"
|
||||
android:orientation="horizontal">
|
||||
<LinearLayout
|
||||
android:id="@+id/activities_header"
|
||||
style="?android:listSeparatorTextViewStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/header_height_quick_menu"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activities_header_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/notifications"
|
||||
android:textAllCaps="true"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textStyle="bold"/>
|
||||
<TextView
|
||||
android:id="@+id/activities_header_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/notifications"
|
||||
android:textAllCaps="true"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="@dimen/element_size_default"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:contentDescription="@string/customize"
|
||||
android:src="@drawable/ic_menu_preferences"
|
||||
android:text="@string/notifications"/>
|
||||
</LinearLayout>
|
||||
<org.mariotaku.twidere.view.ResourceImageButton
|
||||
android:id="@+id/activities_config_button"
|
||||
android:layout_width="@dimen/element_size_default"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:contentDescription="@string/customize"
|
||||
android:text="@string/notifications"
|
||||
app:image="@drawable/ic_iconic_action_preferences" />
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/activities_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/activities_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"></FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
|
|
@ -1,31 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/image_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/image_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/image_grid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/image_grid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/load_images"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/action_button_size"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:visibility="gone">
|
||||
<LinearLayout
|
||||
android:id="@+id/load_images"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/action_button_size"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:drawableLeft="@drawable/ic_menu_gallery"
|
||||
android:gravity="center"
|
||||
android:text="@string/load_images"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textStyle="bold"/>
|
||||
</FrameLayout>
|
||||
<org.mariotaku.twidere.view.ResourceImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/load_images"
|
||||
app:image="@drawable/ic_iconic_action_gallery" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/load_images"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -1,57 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<View
|
||||
android:id="@+id/theme_preview_window_wallpaper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@+id/theme_preview_window_content"
|
||||
android:layout_alignTop="@+id/theme_preview_window_content"
|
||||
android:background="@drawable/nyan_stars_background"/>
|
||||
<View
|
||||
android:id="@+id/theme_preview_window_wallpaper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@+id/theme_preview_window_content"
|
||||
android:layout_alignTop="@+id/theme_preview_window_content"
|
||||
android:background="@drawable/nyan_stars_background" />
|
||||
|
||||
<View
|
||||
android:id="@+id/theme_preview_window_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@+id/theme_preview_window_content"
|
||||
android:layout_alignTop="@+id/theme_preview_window_content"/>
|
||||
<View
|
||||
android:id="@+id/theme_preview_window_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@+id/theme_preview_window_content"
|
||||
android:layout_alignTop="@+id/theme_preview_window_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/theme_preview_window_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:id="@+id/theme_preview_window_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/actionbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
<LinearLayout
|
||||
android:id="@+id/actionbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:actionBarSize"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:padding="@dimen/element_spacing_small"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_launcher_twidere_iconic"/>
|
||||
<org.mariotaku.twidere.view.ResourceImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:padding="@dimen/element_spacing_small"
|
||||
android:scaleType="centerInside"
|
||||
app:image="@drawable/ic_launcher_twidere_iconic" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/app_name"
|
||||
android:textAppearance="?android:textAppearanceMedium"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/app_name"
|
||||
android:textAppearance="?android:textAppearanceMedium" />
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/theme_preview_status_content"/>
|
||||
</LinearLayout>
|
||||
<include layout="@layout/theme_preview_status_content" />
|
||||
</LinearLayout>
|
||||
|
||||
</merge>
|
|
@ -1,20 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@id/open_in_browser"
|
||||
android:icon="@drawable/ic_iconic_action_web"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/browser_sign_in"/>
|
||||
<item
|
||||
android:id="@id/edit_api"
|
||||
android:icon="@drawable/ic_iconic_action_server"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/edit_api"/>
|
||||
<item
|
||||
android:id="@id/settings"
|
||||
android:icon="@drawable/ic_iconic_action_preferences"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/settings"/>
|
||||
|
||||
<item
|
||||
android:id="@id/open_in_browser"
|
||||
android:icon="@drawable/ic_iconic_action_web"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/browser_sign_in" />
|
||||
<item
|
||||
android:id="@id/edit_api"
|
||||
android:icon="@drawable/ic_iconic_action_server"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/edit_api" />
|
||||
<item
|
||||
android:id="@id/settings"
|
||||
android:icon="@drawable/ic_iconic_action_preferences"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/settings" />
|
||||
</menu>
|
|
@ -63,6 +63,9 @@
|
|||
<attr name="min" format="integer" />
|
||||
<attr name="progressTextSuffix" format="string" />
|
||||
</declare-styleable>
|
||||
<declare-styleable name="ResourceImageView">
|
||||
<attr name="image" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<attr name="notificationType">
|
||||
<flag name="none" value="0" />
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
<!-- ActionBar styles -->
|
||||
<item name="android:actionBarStyle">@style/Widget.Twidere.ActionBar.Colored</item>
|
||||
<item name="android:actionBarWidgetTheme">@style/Theme.Twidere.ActionBar.Colored.Light</item>
|
||||
<item name="android:actionBarItemBackground">@drawable/list_selector_light_white</item>
|
||||
<!--<item name="android:actionBarItemBackground">@drawable/list_selector_light_white</item>-->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Colored.DarkActionBar" parent="Theme.Twidere.Light.DarkActionBar">
|
||||
|
@ -128,7 +128,7 @@
|
|||
<!-- ActionBar styles -->
|
||||
<item name="android:actionBarStyle">@style/Widget.Twidere.ActionBar.Colored.Inverse</item>
|
||||
<item name="android:actionBarWidgetTheme">@style/Theme.Twidere.ActionBar.Colored.Dark</item>
|
||||
<item name="android:actionBarItemBackground">@drawable/list_selector_white</item>
|
||||
<!--<item name="android:actionBarItemBackground">@drawable/list_selector_white</item>-->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Colored.DarkActionBar.DarkIcon"/>
|
||||
|
@ -225,12 +225,12 @@
|
|||
|
||||
<style name="Theme.Twidere.ActionBar.Colored.Light" parent="Theme.Twidere.Light">
|
||||
<item name="accentColor">@color/accent_white</item>
|
||||
<item name="android:actionBarItemBackground">@drawable/list_selector_light_white</item>
|
||||
<!--<item name="android:actionBarItemBackground">@drawable/list_selector_light_white</item>-->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.ActionBar.Colored.Dark" parent="Theme.Twidere.Dark">
|
||||
<item name="accentColor">@color/accent_white</item>
|
||||
<item name="android:actionBarItemBackground">@drawable/list_selector_white</item>
|
||||
<!--<item name="android:actionBarItemBackground">@drawable/list_selector_white</item>-->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Dark.Dialog" parent="android:Theme.Holo.Dialog">
|
||||
|
@ -383,6 +383,16 @@
|
|||
<item name="android:windowBackground">@color/bg_color_drawer_transparent_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Drawer.Light" parent="Theme.Twidere.Light">
|
||||
|
||||
<!-- Window attributes -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Drawer.Light.Transparent" parent="Theme.Twidere.Light.Transparent">
|
||||
|
||||
<!-- Window attributes -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Dark.NoDisplay" parent="android:Theme.Holo">
|
||||
<item name="android:windowBackground">@null</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/hints">
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_iconic_action_accounts"
|
||||
<org.mariotaku.twidere.preference.ResourceIconPreference
|
||||
app:image="@drawable/ic_iconic_action_accounts"
|
||||
android:order="11"
|
||||
android:summary="@string/wizard_hint_compose_select_account"
|
||||
android:title="@string/select_account"/>
|
||||
<Preference
|
||||
android:icon="@drawable/ic_iconic_action_quote"
|
||||
<org.mariotaku.twidere.preference.ResourceIconPreference
|
||||
app:image="@drawable/ic_iconic_action_quote"
|
||||
android:order="12"
|
||||
android:summary="@string/wizard_hint_quote_format"
|
||||
android:title="@string/quote_format"/>
|
||||
<Preference
|
||||
android:icon="@drawable/ic_iconic_action_speaker_muted"
|
||||
<org.mariotaku.twidere.preference.ResourceIconPreference
|
||||
app:image="@drawable/ic_iconic_action_speaker_muted"
|
||||
android:order="13"
|
||||
android:summary="@string/wizard_hint_filters"
|
||||
android:title="@string/filters"/>
|
||||
<Preference
|
||||
android:icon="@drawable/ic_iconic_action_refresh"
|
||||
<org.mariotaku.twidere.preference.ResourceIconPreference
|
||||
app:image="@drawable/ic_iconic_action_refresh"
|
||||
android:order="14"
|
||||
android:summary="@string/wizard_hint_rate_limit"
|
||||
android:title="@string/rate_limit"/>
|
||||
|
|
Loading…
Reference in New Issue