Commit 2ce39a6a authored by Gilbert Ndresaj's avatar Gilbert Ndresaj

F**k ViewPager (it's your turn)

I can't fix this shit so i have just made some stupid clean.
parent a2bc6a77
......@@ -8,12 +8,10 @@ import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.support.v7.widget.SwitchCompat;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
......@@ -32,13 +30,12 @@ import com.mikepenz.iconics.view.IconicsImageView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.CardViewStyle;
import org.horaapps.leafpic.util.ColorPalette;
import org.horaapps.leafpic.util.CustomViewPager;
import org.horaapps.leafpic.util.PreferenceUtil;
import org.horaapps.leafpic.util.Security;
import org.horaapps.leafpic.util.StaticMapProvider;
import org.horaapps.leafpic.util.ThemeHelper;
import org.horaapps.leafpic.views.SquareImageView;
import org.horaapps.leafpic.views.cardviewpager.CardPagerAdapter;
import org.horaapps.leafpic.views.cardviewpager.ShadowTransformer;
......@@ -409,8 +406,8 @@ public class SettingsActivity extends ThemedActivity {
private void cardViewDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
View layout = getLayoutInflater().inflate(R.layout.dialog_selec_cardview, null);
final ViewPager mViewPager = (ViewPager) layout.findViewById(R.id.viewPager);
View layout = getLayoutInflater().inflate(R.layout.dialog_select_cardview, null);
final CustomViewPager mViewPager = (CustomViewPager) layout.findViewById(R.id.viewPager);
CardPagerAdapter mCardAdapter = new CardPagerAdapter(getBaseContext());
ShadowTransformer mCardShadowTransformer = new ShadowTransformer(mViewPager, mCardAdapter);
mViewPager.setAdapter(mCardAdapter);
......@@ -430,121 +427,6 @@ public class SettingsActivity extends ThemedActivity {
builder.show();
}
@Deprecated
private void cardViewStyleDialog() {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_card_view_style, null);
TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.dialog_card_view_style_title);
((CardView) dialogLayout.findViewById(R.id.dialog_card_view_style)).setCardBackgroundColor(getCardBackgroundColor());
dialogTitle.setBackgroundColor(getPrimaryColor());
final RadioGroup cardStyle = (RadioGroup) dialogLayout.findViewById(R.id.radio_group_card_view_style);
final RadioButton radioCardMaterial = (RadioButton) dialogLayout.findViewById(R.id.radio_card_material);
RadioButton radioCardFlat = (RadioButton) dialogLayout.findViewById(R.id.radio_card_flat);
RadioButton radioCardCompact = (RadioButton) dialogLayout.findViewById(R.id.radio_card_compact);
setRadioTextButtonColor(radioCardMaterial, getTextColor());
setRadioTextButtonColor(radioCardFlat, getTextColor());
setRadioTextButtonColor(radioCardCompact, getTextColor());
//PREVIEW ALBUM CARD STYLE
final SquareImageView imgPreviewAlbumCardStyle = (SquareImageView) dialogLayout.findViewById(R.id.preview_album_card_style_image);
imgPreviewAlbumCardStyle.setBackgroundColor(getPrimaryColor());
LinearLayout llPreview = (LinearLayout) dialogLayout.findViewById(R.id.ll_preview_album_card);
llPreview.setBackgroundColor(getInvertedBackgroundColor());
final LinearLayout llPreviewFlatCompactText = (LinearLayout) dialogLayout.findViewById(R.id.preview_album_card_style_linear_card_text2);
final TextView txtPreviewFlatCompactAlbum = (TextView) dialogLayout.findViewById(R.id.preview_album_card_style_name2);
final TextView txtPreviewFlatCompactMedia = (TextView) dialogLayout.findViewById(R.id.preview_album_card_style_photos_count2);
final LinearLayout llPreviewMaterialText = (LinearLayout) dialogLayout .findViewById(R.id.preview_album_card_style_linear_card_text);
final TextView txtPreviewMaterialAlbum = (TextView) dialogLayout.findViewById(R.id.preview_album_card_style_name);
final TextView txtPreviewMaterialMedia = (TextView) dialogLayout.findViewById(R.id.preview_album_card_style_photos_count);
llPreviewMaterialText.setBackgroundColor(getCardBackgroundColor());
llPreviewFlatCompactText.setBackgroundColor(ColorPalette.getTransparentColor(getCardBackgroundColor(), 150));
int color=getTextColor();
String albumNameHtml = "<i><font color='" + color+ "'>" + getString(R.string.album) + "</font></i>";
txtPreviewFlatCompactAlbum.setTextColor(color);
txtPreviewMaterialAlbum.setTextColor(color);
txtPreviewFlatCompactAlbum.setText(Html.fromHtml(albumNameHtml));
txtPreviewMaterialAlbum.setText(Html.fromHtml(albumNameHtml));
color=getSubTextColor();
String hexAccentColor = String.format("#%06X", (0xFFFFFF & getAccentColor()));
String albumPhotoCountHtml = "<b><font color='" + hexAccentColor + "'>" + "n" + "</font></b>" + "<font " +
"color='" + color + "'> " + getString(R.string.media) + "</font>";
txtPreviewFlatCompactMedia.setTextColor(color);
txtPreviewMaterialMedia.setTextColor(color);
txtPreviewFlatCompactMedia.setText(Html.fromHtml(albumPhotoCountHtml));
txtPreviewMaterialMedia.setText(Html.fromHtml(albumPhotoCountHtml));
//SP.putInt("card_view_style",CardViewStyle.CARD_MATERIAL.getValue());
switch (CardViewStyle.fromValue(SP.getInt("card_view_style", CardViewStyle.CARD_MATERIAL.getValue()))) {
case CARD_MATERIAL:
default:
radioCardMaterial.setChecked(true);
llPreviewFlatCompactText.setVisibility(View.GONE);
llPreviewMaterialText.setVisibility(View.VISIBLE);
break;
case CARD_FLAT:
radioCardFlat.setChecked(true);
llPreviewFlatCompactText.setVisibility(View.VISIBLE);
txtPreviewFlatCompactMedia.setVisibility(View.VISIBLE);
llPreviewMaterialText.setVisibility(View.GONE);
break;
case CARD_COMPACT:
radioCardCompact.setChecked(true);
llPreviewFlatCompactText.setVisibility(View.VISIBLE);
txtPreviewFlatCompactMedia.setVisibility(View.GONE);
llPreviewMaterialText.setVisibility(View.GONE);
break;
}
View.OnClickListener radioClickLIstener = new View.OnClickListener() {
public void onClick(View v) {
switch (v.getId()){
case R.id.radio_card_material:
llPreviewFlatCompactText.setVisibility(View.GONE);
llPreviewMaterialText.setVisibility(View.VISIBLE);
break;
case R.id.radio_card_flat:
llPreviewFlatCompactText.setVisibility(View.VISIBLE);
txtPreviewFlatCompactMedia.setVisibility(View.VISIBLE);
llPreviewMaterialText.setVisibility(View.GONE);
break;
case R.id.radio_card_compact:
llPreviewFlatCompactText.setVisibility(View.VISIBLE);
txtPreviewFlatCompactMedia.setVisibility(View.GONE);
llPreviewMaterialText.setVisibility(View.GONE);
break;
}
}
};
radioCardMaterial.setOnClickListener(radioClickLIstener);
radioCardFlat.setOnClickListener(radioClickLIstener);
radioCardCompact.setOnClickListener(radioClickLIstener);
dialogBuilder.setNegativeButton(getString(R.string.cancel).toUpperCase(), null);
dialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (cardStyle.getCheckedRadioButtonId()) {
case R.id.radio_card_material:
default: SP.putInt("card_view_style", CardViewStyle.CARD_MATERIAL.getValue()); break;
case R.id.radio_card_flat: SP.putInt("card_view_style", CardViewStyle.CARD_FLAT.getValue()); break;
case R.id.radio_card_compact: SP.putInt("card_view_style", CardViewStyle.CARD_COMPACT.getValue()); break;
}
}
});
dialogBuilder.setView(dialogLayout);
dialogBuilder.show();
}
private void mapProviderDialog() {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
......
package org.horaapps.leafpic.util;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by Jibo on 25/11/2016.
*/
public class CustomViewPager extends ViewPager {
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = 0;
for(int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if(h > height) height = h;
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
......@@ -65,10 +65,12 @@ public class CardPagerAdapter extends PagerAdapter {
case CARD_COMPACT: v = LayoutInflater.from(container.getContext()).inflate(R.layout.card_album_compact, container, false); break;
}
ImageView img = (ImageView) v.findViewById(org.horaapps.leafpic.R.id.album_preview);
img.setBackgroundColor(theme.getPrimaryColor());
Glide.with(container.getContext())
.load(R.drawable.gilbert_profile)
.into(((ImageView) v.findViewById(org.horaapps.leafpic.R.id.album_preview)));
.into(img);
String hexPrimaryColor = ColorPalette.getHexColor(theme.getPrimaryColor());
String hexAccentColor = ColorPalette.getHexColor(theme.getAccentColor());
......@@ -78,7 +80,6 @@ public class CardPagerAdapter extends PagerAdapter {
String textColor = theme.getBaseTheme() != ThemeHelper.LIGHT_THEME ? "#FAFAFA" : "#2b2b2b";
switch (CardViewStyle.fromValue(position)){
default:
case CARD_MATERIAL:v.findViewById(R.id.linear_card_text).setBackgroundColor(theme.getCardBackgroundColor());break;
......@@ -86,7 +87,6 @@ public class CardPagerAdapter extends PagerAdapter {
case CARD_COMPACT:v.findViewById(R.id.linear_card_text).setBackgroundColor(ColorPalette.getTransparentColor(theme.getBackgroundColor(), 150)); break;
}
String albumNameHtml = "<i><font color='" + textColor + "'>#PraiseDuarte</font></i>";
String albumPhotoCountHtml = "<b><font color='" + hexAccentColor + "'>420</font></b>" + "<font " +
"color='" + textColor + "'> " + container.getContext().getString(R.string.media) + "</font>";
......
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<FrameLayout
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:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<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>
</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>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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"
app:cardCornerRadius="2dp"
android:id="@+id/dialog_card_view_style">
<LinearLayout
android:layout_width="match_parent"
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"/>
<!--PREVIEW CARD STYLE-->
<LinearLayout
android:id="@+id/ll_preview_album_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/medium_spacing">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:padding="@dimen/medium_spacing"
>
<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>
</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>
<!--RADIO BUTTONS-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioGroup
android:padding="@dimen/medium_spacing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/radio_group_card_view_style"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/medium_text"
android:id="@+id/radio_card_material"
android:text="@string/card_type_material"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/medium_text"
android:id="@+id/radio_card_flat"
android:text="@string/card_type_flat"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/medium_text"
android:id="@+id/radio_card_compact"
android:text="@string/card_type_compact" />
</RadioGroup>
</ScrollView>
</LinearLayout>
</android.support.v7.widget.CardView>
......@@ -19,7 +19,7 @@
android:textSize="18sp"
android:textStyle="bold"/>
<android.support.v4.view.ViewPager
<org.horaapps.leafpic.util.CustomViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -31,9 +31,6 @@
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