improved card preview preference

This commit is contained in:
Mariotaku Lee 2016-02-14 22:22:21 +08:00
parent 76645a6ecd
commit 3998cb8e64
10 changed files with 37 additions and 49 deletions

View File

@ -215,7 +215,7 @@
<activity
android:name=".activity.support.BrowserSignInActivity"
android:label="@string/browser_sign_in"
android:theme="@style/Theme.Twidere.Dark.Dialog"
android:theme="@style/Theme.Twidere.Dark"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="org.mariotaku.twidere.TWITTER_BROWSER_LOGIN"/>

View File

@ -1,20 +0,0 @@
package okhttp3;
import android.support.annotation.Nullable;
import okhttp3.internal.http.HttpEngine;
/**
* Created by mariotaku on 16/2/13.
*/
public class RealCallAccessor {
@Nullable
public static HttpEngine getHttpEngine(Call call) {
if (call instanceof RealCall) {
return ((RealCall) call).engine;
}
return null;
}
}

View File

@ -58,12 +58,10 @@ import static android.text.TextUtils.isEmpty;
import static org.mariotaku.twidere.util.Utils.getNonEmptyString;
@SuppressLint("SetJavaScriptEnabled")
public class BrowserSignInActivity extends BaseSupportDialogActivity {
public class BrowserSignInActivity extends BaseAppCompatActivity {
private static final String INJECT_CONTENT = "javascript:window.injector.processHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');";
private SharedPreferences mPreferences;
private WebView mWebView;
private View mProgressContainer;
@ -102,7 +100,6 @@ public class BrowserSignInActivity extends BaseSupportDialogActivity {
protected void onCreate(final Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
setContentView(R.layout.activity_browser_sign_in);
mWebView.setWebViewClient(new AuthorizationWebViewClient(this));
mWebView.setVerticalScrollBarEnabled(false);

View File

@ -20,7 +20,6 @@
package org.mariotaku.twidere.adapter;
import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
@ -42,13 +41,12 @@ public abstract class AbsUsersAdapter<D> extends LoadMoreSupportAdapter<ViewHold
private final LayoutInflater mInflater;
private final int mCardBackgroundColor;
private final boolean mCompactCards;
private final int mProfileImageStyle;
private final int mTextSize;
private final boolean mDisplayProfileImage;
private final boolean mShowAbsoluteTime;
public AbsUsersAdapter(final Context context, final boolean compact) {
public AbsUsersAdapter(final Context context) {
super(context);
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context, ThemeUtils.getThemeBackgroundOption(context), ThemeUtils.getUserThemeBackgroundAlpha(context));
mInflater = LayoutInflater.from(context);
@ -56,7 +54,6 @@ public abstract class AbsUsersAdapter<D> extends LoadMoreSupportAdapter<ViewHold
mProfileImageStyle = Utils.getProfileImageStyle(mPreferences.getString(KEY_PROFILE_IMAGE_STYLE, null));
mDisplayProfileImage = mPreferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE);
mShowAbsoluteTime = mPreferences.getBoolean(KEY_SHOW_ABSOLUTE_TIME);
mCompactCards = compact;
}
@Override
@ -90,15 +87,9 @@ public abstract class AbsUsersAdapter<D> extends LoadMoreSupportAdapter<ViewHold
switch (viewType) {
case ITEM_VIEW_TYPE_USER: {
final View view;
if (mCompactCards) {
view = mInflater.inflate(R.layout.card_item_user_compact, parent, false);
final View itemContent = view.findViewById(R.id.item_content);
itemContent.setBackgroundColor(mCardBackgroundColor);
} else {
view = mInflater.inflate(R.layout.card_item_user, parent, false);
final CardView cardView = (CardView) view.findViewById(R.id.card);
cardView.setCardBackgroundColor(mCardBackgroundColor);
}
view = mInflater.inflate(R.layout.card_item_user_compact, parent, false);
final View itemContent = view.findViewById(R.id.item_content);
itemContent.setBackgroundColor(mCardBackgroundColor);
final UserViewHolder holder = new UserViewHolder(this, view);
holder.setOnClickListeners();
holder.setupViewOptions();

View File

@ -31,8 +31,8 @@ public class ParcelableUsersAdapter extends AbsUsersAdapter<List<ParcelableUser>
private List<ParcelableUser> mData;
public ParcelableUsersAdapter(Context context, boolean compact) {
super(context, compact);
public ParcelableUsersAdapter(Context context) {
super(context);
}
@Override

View File

@ -122,15 +122,16 @@ abstract class AbsUsersFragment<Data> extends AbsContentListRecyclerViewFragment
return true;
}
protected ParcelableUser getSelectedUser() {
//TODO return selected
return null;
}
protected abstract boolean hasMoreData(Data data);
protected abstract Loader<Data> onCreateUsersLoader(final Context context,
@NonNull final Bundle args,
final boolean fromUser);
@Override
protected void setupRecyclerView(Context context, boolean compact) {
}
}

View File

@ -25,6 +25,7 @@ import android.support.annotation.NonNull;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
import org.mariotaku.twidere.adapter.AbsUsersAdapter;
import org.mariotaku.twidere.adapter.ParcelableUsersAdapter;
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
import org.mariotaku.twidere.model.ParcelableUser;
@ -41,8 +42,8 @@ public abstract class ParcelableUsersFragment extends AbsUsersFragment<List<Parc
@NonNull
@Override
protected final ParcelableUsersAdapter onCreateAdapter(Context context, boolean compact) {
return new ParcelableUsersAdapter(context, compact);
protected AbsUsersAdapter<List<ParcelableUser>> onCreateAdapter(Context context, boolean compact) {
return new ParcelableUsersAdapter(context);
}
protected long getAccountId() {

View File

@ -74,9 +74,9 @@ public class CardPreviewPreference extends Preference implements Constants, OnSh
protected void setLayoutResources(SharedPreferences preferences) {
if (preferences.getBoolean(KEY_COMPACT_CARDS, false)) {
setLayoutResource(R.layout.card_item_status_compact);
setLayoutResource(R.layout.layout_preferences_card_preview_compact);
} else {
setLayoutResource(R.layout.card_item_status);
setLayoutResource(R.layout.layout_preferences_card_preview);
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/card_item_status"/>
</FrameLayout>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/card_item_status_compact"/>
</FrameLayout>