Commit ace6c83d authored by Gilbert Ndresaj's avatar Gilbert Ndresaj

Shitty Stuff per Dony

parent fd7fba0c
......@@ -410,13 +410,22 @@ public class SettingsActivity extends ThemedActivity {
private void cardViewDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this);
View layout = getLayoutInflater().inflate(R.layout.dialog_selec_cardview, null);
ViewPager mViewPager = (ViewPager) layout.findViewById(R.id.viewPager);
CardPagerAdapter mCardAdapter = new CardPagerAdapter();
final ViewPager mViewPager = (ViewPager) layout.findViewById(R.id.viewPager);
CardPagerAdapter mCardAdapter = new CardPagerAdapter(getBaseContext());
ShadowTransformer mCardShadowTransformer = new ShadowTransformer(mViewPager, mCardAdapter);
mViewPager.setAdapter(mCardAdapter);
mViewPager.setPageTransformer(false, mCardShadowTransformer);
mViewPager.setOffscreenPageLimit(3);
mViewPager.setCurrentItem(1);
mViewPager.setCurrentItem(SP.getInt("card_view_style", 0));
builder.setNegativeButton(getString(R.string.cancel).toUpperCase(), null);
builder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getBaseContext(), "ITEM: " + mViewPager.getCurrentItem(), Toast.LENGTH_LONG).show();
SP.putInt("card_view_style", mViewPager.getCurrentItem());
}
});
builder.setView(layout);
builder.show();
}
......
package org.horaapps.leafpic.views.cardviewpager;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v7.widget.CardView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.util.CardViewStyle;
import org.horaapps.leafpic.util.ColorPalette;
import org.horaapps.leafpic.util.ThemeHelper;
import org.horaapps.leafpic.views.SquareImageView;
import java.util.ArrayList;
import java.util.List;
......@@ -16,16 +24,13 @@ public class CardPagerAdapter extends PagerAdapter {
public static int MAX_ELEVATION_FACTOR = 8;
private List<CardView> mViews;
private List<String> mData;
private float mBaseElevation;
private ThemeHelper theme;
public CardPagerAdapter() {
mData = new ArrayList<>();
public CardPagerAdapter(Context context) {
theme = new ThemeHelper(context);
mViews = new ArrayList<>();
for (int i = 0; i < 3; i++) {
mData.add("");
mViews.add(null);
}
}
......@@ -40,7 +45,7 @@ public class CardPagerAdapter extends PagerAdapter {
@Override
public int getCount() {
return mData.size();
return 3;
}
@Override
......@@ -51,6 +56,60 @@ public class CardPagerAdapter extends PagerAdapter {
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = LayoutInflater.from(container.getContext()).inflate(R.layout.card_view_sample, container, false);
/**OBJECTS**/
final SquareImageView imgPreviewAlbumCardStyle = (SquareImageView) view.findViewById(R.id.preview_album_card_style_image);
imgPreviewAlbumCardStyle.setBackgroundColor(theme.getPrimaryColor());
LinearLayout llPreview = (LinearLayout) view.findViewById(R.id.ll_preview_album_card);
//llPreview.setBackgroundColor(theme.getInvertedBackgroundColor());
final LinearLayout llPreviewFlatCompactText = (LinearLayout) view.findViewById(R.id.preview_album_card_style_linear_card_text2);
final TextView txtPreviewFlatCompactAlbum = (TextView) view.findViewById(R.id.preview_album_card_style_name2);
final TextView txtPreviewFlatCompactMedia = (TextView) view.findViewById(R.id.preview_album_card_style_photos_count2);
final LinearLayout llPreviewMaterialText = (LinearLayout) view.findViewById(R.id.preview_album_card_style_linear_card_text);
final TextView txtPreviewMaterialAlbum = (TextView) view.findViewById(R.id.preview_album_card_style_name);
final TextView txtPreviewMaterialMedia = (TextView) view.findViewById(R.id.preview_album_card_style_photos_count);
llPreviewMaterialText.setBackgroundColor(theme.getCardBackgroundColor());
llPreviewFlatCompactText.setBackgroundColor(ColorPalette.getTransparentColor(theme.getCardBackgroundColor(), 150));
int color=theme.getTextColor();
String albumNameHtml = "<i><font color='" + color+ "'>" + container.getContext().getString(R.string.album) + "</font></i>";
txtPreviewFlatCompactAlbum.setTextColor(color);
txtPreviewMaterialAlbum.setTextColor(color);
txtPreviewFlatCompactAlbum.setText(Html.fromHtml(albumNameHtml));
txtPreviewMaterialAlbum.setText(Html.fromHtml(albumNameHtml));
color=theme.getSubTextColor();
String hexAccentColor = String.format("#%06X", (0xFFFFFF & theme.getAccentColor()));
String albumPhotoCountHtml = "<b><font color='" + hexAccentColor + "'>" + "n" + "</font></b>" + "<font " +
"color='" + color + "'> " + container.getContext().getString(R.string.media) + "</font>";
txtPreviewFlatCompactMedia.setTextColor(color);
txtPreviewMaterialMedia.setTextColor(color);
txtPreviewFlatCompactMedia.setText(Html.fromHtml(albumPhotoCountHtml));
txtPreviewMaterialMedia.setText(Html.fromHtml(albumPhotoCountHtml));
switch (CardViewStyle.fromValue(position)){
default:
case CARD_MATERIAL:
llPreviewFlatCompactText.setVisibility(View.GONE);
llPreviewMaterialText.setVisibility(View.VISIBLE);
break;
case CARD_FLAT:
llPreviewFlatCompactText.setVisibility(View.VISIBLE);
txtPreviewFlatCompactMedia.setVisibility(View.VISIBLE);
llPreviewMaterialText.setVisibility(View.GONE);
break;
case CARD_COMPACT:
llPreviewFlatCompactText.setVisibility(View.VISIBLE);
txtPreviewFlatCompactMedia.setVisibility(View.GONE);
llPreviewMaterialText.setVisibility(View.GONE);
break;
}
container.addView(view);
CardView cardView = (CardView) view.findViewById(R.id.cardView);
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardView"
app:cardUseCompatPadding="true"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<FrameLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_preview_album_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="24dp">
<TextView
style="@style/TextAppearance.AppCompat.Title"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Card title" />
android:orientation="vertical">
<TextView
style="@style/TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eget ligula eu lectus lobortis condimentum." />
<RelativeLayout
android:layout_width="144dp"
android:layout_height="144dp"
android:id="@+id/preview_album_card_header"
>
<org.horaapps.leafpic.views.SquareImageView
android:id="@+id/preview_album_card_style_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/ic_holder"
/>
<LinearLayout
android:id="@+id/preview_album_card_style_linear_card_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:orientation="vertical"
android:paddingBottom="5dp"
>
<TextView
android:id="@+id/preview_album_card_style_name2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:paddingEnd="10dp"
android:paddingStart="@dimen/small_spacing"
android:paddingTop="5dp"
android:textColor="@android:color/black"
android:textSize="14sp"
android:text="@string/album"
/>
<TextView
android:id="@+id/preview_album_card_style_photos_count2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:paddingEnd="5dp"
android:paddingStart="@dimen/small_spacing"
android:textColor="@android:color/black"
android:textSize="12sp"
android:text="@string/media"
/>
</LinearLayout>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="Button" />
</RelativeLayout>
<View
android:id="@+id/preview_album_card_style_divider"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/header_album_card"
/>
<LinearLayout
android:id="@+id/preview_album_card_style_linear_card_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_below="@id/preview_album_card_style_divider"
android:orientation="vertical"
>
<TextView
android:id="@+id/preview_album_card_style_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:paddingEnd="10dp"
android:paddingStart="@dimen/small_spacing"
android:paddingTop="5dp"
android:textColor="@android:color/white"
android:text="@string/album"
android:textSize="14sp"
/>
<TextView
android:id="@+id/preview_album_card_style_photos_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:paddingBottom="5dp"
android:paddingEnd="5dp"
android:paddingStart="@dimen/small_spacing"
android:textColor="@android:color/white"
android:text="@string/media"
android:textSize="12sp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</android.support.v7.widget.CardView>
......@@ -4,16 +4,36 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="330dp"
android:layout_gravity="bottom"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingStart="60dp"
android:paddingEnd="60dp"/>
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/dialog_card_view_style_title"
android:layout_width="match_parent"
android:textColor="@color/md_dark_primary_text"
android:layout_height="wrap_content"
android:background="@color/md_dark_appbar"
android:padding="@dimen/big_spacing"
android:text="@string/album_card_view"
android:textSize="18sp"
android:textStyle="bold"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingTop="@dimen/big_spacing"
android:paddingBottom="@dimen/big_spacing"
android:paddingStart="60dp"
android:paddingEnd="60dp"
/>
<!--
-->
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment