Commit faf2df59 authored by Donald's avatar Donald

theme engine stuff

parent 8591a227
......@@ -82,6 +82,7 @@ dependencies {
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.drewnoakes:metadata-extractor:2.9.1'
compile "com.orhanobut:hawk:2.0.1"
// rxJava
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
......@@ -90,7 +91,7 @@ dependencies {
compile 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
// icons
compile 'com.mikepenz:iconics-core:2.8.1@aar'
compile 'com.mikepenz:iconics-core:2.8.6@aar'
compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
compile 'com.mikepenz:community-material-typeface:1.5.54.2@aar'
compile 'com.mikepenz:fontawesome-typeface:4.6.0.1@aar'
......@@ -104,7 +105,7 @@ dependencies {
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'jp.wasabeef:recyclerview-animators:2.2.6'
compile project(':liz')
// debug Only
//debugCompile project(':inappstoragereader')
......
package org.horaapps.leafpic;
import android.app.Application;
import android.util.Log;
import com.orhanobut.hawk.Hawk;
import org.horaapps.leafpic.data.Album;
import org.horaapps.leafpic.data.HandlingAlbums;
......@@ -8,13 +11,16 @@ import org.horaapps.leafpic.data.HandlingAlbums;
/**
* Created by dnld on 28/04/16.
*/
public class App extends Application {
public class App extends /*horaapps.org.liz.App*/ Application {
private static App mInstance;
@Override
public void onCreate() {
super.onCreate();
Hawk.init(this).build();
Log.wtf("asd", Hawk.get("card_view_style") + "");
mInstance = this;
}
......
package org.horaapps.leafpic.activities.theme;
package org.horaapps.leafpic;
import org.horaapps.leafpic.R;
/**
* Created by Jibo on 20/11/2016.
*/
......
......@@ -36,8 +36,6 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.view.IconicsImageView;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.activities.theme.ThemeHelper;
import org.horaapps.leafpic.data.ContentHelper;
import org.horaapps.leafpic.data.filter.FoldersFileFilter;
import org.horaapps.leafpic.util.AlertDialogsHelper;
......@@ -48,6 +46,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import horaapps.org.liz.ThemeHelper;
import horaapps.org.liz.ThemedActivity;
public class SelectAlbumBuilder extends BottomSheetDialogFragment {
private String title;
......
......@@ -22,13 +22,13 @@ import com.mikepenz.iconics.view.IconicsImageView;
import org.horaapps.leafpic.BuildConfig;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.AlertDialogsHelper;
import org.horaapps.leafpic.util.CustomTabService;
import org.horaapps.leafpic.util.PreferenceUtil;
import org.horaapps.leafpic.util.StringUtils;
import de.hdodenhof.circleimageview.CircleImageView;
import horaapps.org.liz.ThemedActivity;
/**
* Created by Jibo on 02/03/2016.
......
......@@ -438,49 +438,6 @@ public class MainActivity extends SharedMediaActivity {
dialog.show();
return true;
case R.id.exclude_action:
final AlertDialog.Builder excludeDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
final View excludeDialogLayout = getLayoutInflater().inflate(R.layout.dialog_exclude, null);
TextView textViewExcludeTitle = (TextView) excludeDialogLayout.findViewById(R.id.text_dialog_title);
TextView textViewExcludeMessage = (TextView) excludeDialogLayout.findViewById(R.id.text_dialog_message);
final Spinner spinnerParents = (Spinner) excludeDialogLayout.findViewById(R.id.parents_folder);
spinnerParents.getBackground().setColorFilter(getIconColor(), PorterDuff.Mode.SRC_ATOP);
((CardView) excludeDialogLayout.findViewById(R.id.message_card)).setCardBackgroundColor(getCardBackgroundColor());
textViewExcludeTitle.setBackgroundColor(getPrimaryColor());
textViewExcludeTitle.setText(getString(R.string.exclude));
if((albumsMode && albumsAdapter.getSelectedCount() > 1)) {
textViewExcludeMessage.setText(R.string.exclude_albums_message);
spinnerParents.setVisibility(View.GONE);
} else {
textViewExcludeMessage.setText(R.string.exclude_album_message);
spinnerParents.setAdapter(getSpinnerAdapter(albumsMode ? firstSelectedAlbum.getParentsFolders() : getAlbum().getParentsFolders()));
}
textViewExcludeMessage.setTextColor(getTextColor());
excludeDialogBuilder.setView(excludeDialogLayout);
excludeDialogBuilder.setPositiveButton(this.getString(R.string.exclude).toUpperCase(), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if ((albumsMode && albumsAdapter.getSelectedCount() > 1)) {
getAlbums().excludeSelectedAlbums();
albumsAdapter.clearSelected();
//albumsAdapter.notifyDataSetChanged();
supportInvalidateOptionsMenu();
} else {
getAlbums().excludeAlbum(spinnerParents.getSelectedItem().toString());
finishEditMode();
displayAlbums(true);
}
}
});
excludeDialogBuilder.setNegativeButton(this.getString(R.string.cancel).toUpperCase(), null);
excludeDialogBuilder.show();
return true;
case R.id.delete_action:
class DeletePhotos extends AsyncTask<String, Integer, Boolean> {
......
......@@ -2,54 +2,31 @@ package org.horaapps.leafpic.activities;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.media.Image;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AlertDialog;
import android.support.v7.graphics.Palette;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.mikepenz.community_material_typeface_library.CommunityMaterial;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.view.IconicsImageView;
import org.horaapps.leafpic.BuildConfig;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.SelectAlbumBuilder;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.AlertDialogsHelper;
import org.horaapps.leafpic.util.CustomTabService;
import org.horaapps.leafpic.util.PreferenceUtil;
import org.horaapps.leafpic.util.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import de.hdodenhof.circleimageview.CircleImageView;
import static org.horaapps.leafpic.R.string.path;
import horaapps.org.liz.ThemedActivity;
/**
* Created by Jibo on 02/03/2016.
......
......@@ -79,7 +79,6 @@ import com.google.android.exoplayer2.util.Util;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.Measure;
import org.horaapps.leafpic.util.StringUtils;
import org.horaapps.leafpic.views.videoplayer.CustomExoPlayerView;
......@@ -93,6 +92,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import horaapps.org.liz.ThemedActivity;
public class PlayerActivity extends ThemedActivity implements ExoPlayer.EventListener,
TrackSelector.EventListener<MappedTrackInfo>, CustomPlayBackController.VisibilityListener {
......
......@@ -18,11 +18,12 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.view.IconicsImageView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.activities.theme.ThemeHelper;
import org.horaapps.leafpic.util.PreferenceUtil;
import org.horaapps.leafpic.util.Security;
import horaapps.org.liz.ThemeHelper;
import horaapps.org.liz.ThemedActivity;
/**
* Created by dnld on 22/05/16.
*/
......
......@@ -14,8 +14,6 @@ import android.widget.Toast;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.activities.theme.ColorPalette;
import org.horaapps.leafpic.settings.CardViewStyleSetting;
import org.horaapps.leafpic.settings.ColorsSetting;
import org.horaapps.leafpic.settings.GeneralSetting;
......@@ -23,13 +21,15 @@ import org.horaapps.leafpic.settings.MapProviderSetting;
import org.horaapps.leafpic.settings.SinglePhotoSetting;
import org.horaapps.leafpic.util.PreferenceUtil;
import org.horaapps.leafpic.util.Security;
import org.horaapps.leafpic.util.ViewUtil;
import org.horaapps.leafpic.views.SettingWithSwitchView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import horaapps.org.liz.ColorPalette;
import horaapps.org.liz.ThemedActivity;
import horaapps.org.liz.ViewUtil;
public class SettingsActivity extends ThemedActivity {
private PreferenceUtil SP;
......
......@@ -38,7 +38,6 @@ import com.yalantis.ucrop.UCrop;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.SelectAlbumBuilder;
import org.horaapps.leafpic.activities.base.SharedMediaActivity;
import org.horaapps.leafpic.activities.theme.ColorPalette;
import org.horaapps.leafpic.adapters.MediaPagerAdapter;
import org.horaapps.leafpic.animations.DepthPageTransformer;
import org.horaapps.leafpic.data.Album;
......@@ -59,6 +58,8 @@ import org.horaapps.leafpic.views.HackyViewPager;
import java.io.File;
import java.io.InputStream;
import horaapps.org.liz.ColorPalette;
/**
* Created by dnld on 18/02/16.
*/
......
......@@ -21,7 +21,6 @@ import android.widget.Toast;
import org.horaapps.leafpic.LookForMediaJob;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.SharedMediaActivity;
import org.horaapps.leafpic.activities.theme.ColorPalette;
import org.horaapps.leafpic.data.Album;
import org.horaapps.leafpic.data.HandlingAlbums;
import org.horaapps.leafpic.util.PermissionUtils;
......@@ -29,6 +28,8 @@ import org.horaapps.leafpic.util.StringUtils;
import java.io.File;
import horaapps.org.liz.ColorPalette;
/**
* Created by dnld on 01/04/16.
*/
......
......@@ -13,6 +13,8 @@ import org.horaapps.leafpic.data.ContentHelper;
import org.horaapps.leafpic.data.HandlingAlbums;
import org.horaapps.leafpic.util.AlertDialogsHelper;
import horaapps.org.liz.ThemedActivity;
/**
* Created by dnld on 03/08/16.
*/
......
......@@ -14,13 +14,10 @@ import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.orhanobut.hawk.Hawk;
import org.horaapps.leafpic.CardViewStyle;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.theme.ColorPalette;
import org.horaapps.leafpic.activities.theme.Theme;
import org.horaapps.leafpic.activities.theme.ThemeHelper;
import org.horaapps.leafpic.activities.theme.ThemedAdapter;
import org.horaapps.leafpic.activities.theme.ThemedViewHolder;
import org.horaapps.leafpic.data.Album;
import org.horaapps.leafpic.data.Media;
import org.horaapps.leafpic.data.sort.AlbumsComparators;
......@@ -37,6 +34,11 @@ import java.util.stream.Collectors;
import butterknife.BindView;
import butterknife.ButterKnife;
import horaapps.org.liz.ColorPalette;
import horaapps.org.liz.Theme;
import horaapps.org.liz.ThemeHelper;
import horaapps.org.liz.ThemedAdapter;
import horaapps.org.liz.ThemedViewHolder;
import io.reactivex.Observable;
import io.reactivex.subjects.PublishSubject;
......@@ -56,11 +58,13 @@ public class AlbumsAdapter extends ThemedAdapter<AlbumsAdapter.ViewHolder> {
private SortingMode sortingMode;
private Drawable placeholder;
private CardViewStyle cvs;
public AlbumsAdapter(Context context, SortingMode sortingMode, SortingOrder sortingOrder) {
super(context);
albums = new ArrayList<>();
placeholder = getThemeHelper().getPlaceHolder();
cvs = CardViewStyle.fromValue(Hawk.get("card_view_style", 0));
this.sortingMode = sortingMode;
this.sortingOrder = sortingOrder;
}
......@@ -186,13 +190,15 @@ public class AlbumsAdapter extends ThemedAdapter<AlbumsAdapter.ViewHolder> {
@Override
public void refreshTheme(ThemeHelper theme) {
placeholder = theme.getPlaceHolder();
cvs = CardViewStyle.fromValue(Hawk.get("card_view_style", 0));
super.refreshTheme(theme);
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v;
switch (getThemeHelper().getCardViewStyle()) {
switch (cvs) {
default:
case MATERIAL: v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_album_material, parent, false); break;
case FLAT: v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_album_flat, parent, false); break;
......@@ -221,7 +227,7 @@ public class AlbumsAdapter extends ThemedAdapter<AlbumsAdapter.ViewHolder> {
public void onBindViewHolder(final AlbumsAdapter.ViewHolder holder, int position) {
Album a = albums.get(position);
holder.refreshTheme(getThemeHelper(), a.isSelected());
holder.refreshTheme(getThemeHelper(), cvs, a.isSelected());
Media f = a.getCover();
......@@ -329,7 +335,7 @@ public class AlbumsAdapter extends ThemedAdapter<AlbumsAdapter.ViewHolder> {
ButterKnife.bind(this, itemView);
}
public void refreshTheme(ThemeHelper theme, boolean selected) {
public void refreshTheme(ThemeHelper theme, CardViewStyle cvs, boolean selected) {
if (selected) {
footer.setBackgroundColor(theme.getPrimaryColor());
......@@ -338,7 +344,7 @@ public class AlbumsAdapter extends ThemedAdapter<AlbumsAdapter.ViewHolder> {
} else {
picture.clearColorFilter();
selectedIcon.setVisibility(View.GONE);
switch (theme.getCardViewStyle()) {
switch (cvs) {
default: case MATERIAL:
footer.setBackgroundColor(theme.getCardBackgroundColor());
break;
......
package org.horaapps.leafpic.adapters;
import android.content.Context;
import java.util.ArrayList;
import java.util.List;
import horaapps.org.liz.ThemeHelper;
import horaapps.org.liz.Themed;
import horaapps.org.liz.ThemedAdapter;
import horaapps.org.liz.ThemedViewHolder;
/**
* Created by dnld on 01/04/17.
*/
public abstract class BaseAdapter<T, VH extends ThemedViewHolder> extends ThemedAdapter<VH> implements Themed {
private List<T> items;
/* private OnItemClickListener<T> clickListener;
private OnItemLongClickListener<T> longClickListener;*/
private Context context;
public BaseAdapter(Context context) {
super(context);
items = new ArrayList<>();
this.context = context;
}
public BaseAdapter(Context context, List<T> items) {
this(context);
this.items = items;
}
public Context getContext() {
return context;
}
/* public void setClickListener(OnItemClickListener<T> clickListener) {
this.clickListener = clickListener;
}
public void setLongClickListener(OnItemLongClickListener<T> longClickListener) {
this.longClickListener = longClickListener;
}
public void onCLick(T itm, @Nullable View parent, int pos) {
if (clickListener != null)
clickListener.onItemClick(itm, parent, pos);
}
public boolean onLongCLick(T itm, View parent, int pos) {
if (longClickListener != null)
return longClickListener.onItemLongClick(itm, parent, pos);
return false;
}*/
public List<T> getItems() {
return items;
}
public void setItems(List<T> items) {
this.items.clear();
this.items.addAll(items);
notifyDataSetChanged();
}
public void add(T item) {
items.add(item);
notifyDataSetChanged();
}
public void add(int position, T item) {
items.add(position, item);
notifyItemInserted(position);
}
public void removeItem(T item) {
items.remove(item);
notifyDataSetChanged();
}
public void addAll(List<T> items) {
int start = this.items.size();
this.items.addAll(items);
notifyItemRangeInserted(start, items.size());
}
public void clear() {
items.clear();
notifyDataSetChanged();
}
public T getElement(int pos) {
return items.get(pos);
}
@Override
public int getItemCount() {
return items.size();
}
@Override
public void refreshTheme(ThemeHelper theme) {
setThemeHelper(theme);
notifyDataSetChanged();
}
}
......@@ -17,9 +17,6 @@ import com.mikepenz.community_material_typeface_library.CommunityMaterial;
import com.mikepenz.iconics.view.IconicsImageView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.theme.ThemeHelper;
import org.horaapps.leafpic.activities.theme.ThemedAdapter;
import org.horaapps.leafpic.activities.theme.ThemedViewHolder;
import org.horaapps.leafpic.data.Media;
import org.horaapps.leafpic.data.sort.MediaComparators;
import org.horaapps.leafpic.data.sort.SortingMode;
......@@ -33,6 +30,9 @@ import java.util.stream.Collectors;
import butterknife.BindView;
import butterknife.ButterKnife;
import horaapps.org.liz.ThemeHelper;
import horaapps.org.liz.ThemedAdapter;
import horaapps.org.liz.ThemedViewHolder;
import io.reactivex.Observable;
import io.reactivex.subjects.PublishSubject;
......
......@@ -18,12 +18,13 @@ import com.mikepenz.community_material_typeface_library.CommunityMaterial;
import com.mikepenz.iconics.view.IconicsImageView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.theme.ColorPalette;
import org.horaapps.leafpic.activities.theme.ThemeHelper;
import org.horaapps.leafpic.data.Media;
import java.util.ArrayList;
import horaapps.org.liz.ColorPalette;
import horaapps.org.liz.ThemeHelper;
/**
* Created by dnld on 1/7/16.
......
package org.horaapps.leafpic.dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.data.Album;
import java.util.ArrayList;
import horaapps.org.liz.ThemeHelper;
/**
* Created by dnld on 6/29/17.
*/
public class DeleteAlbumsDialog extends DialogFragment {
ThemeHelper t;
TextView dialogTitle;
TextView dialogMessage;
ArrayList<Album> albums;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
t = ThemeHelper.getInstanceLoaded(getActivity());
setCancelable(false);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(org.horaapps.leafpic.R.layout.dialog_text, container, false);
dialogTitle = view.findViewById(R.id.text_dialog_title);
dialogMessage = view.findViewById(R.id.text_dialog_message);
((CardView) view.findViewById(R.id.message_card)).setCardBackgroundColor(t.getCardBackgroundColor());
dialogTitle.setBackgroundColor(t.getPrimaryColor());
//dialogMessage.setText(Message);
dialogMessage.setTextColor(t.getTextColor());
//builder.setView(view);
return view;
}
public void setTitle(String title) {
dialogTitle.setText(title);
}
/*@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
public static AlertDialog getTextDialog(ThemedActivity activity, @StringRes int title, @StringRes int Message){
AlertDialog.Builder builder = new AlertDialog.Builder(activity,activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(R.layout.dialog_text, null);
TextView dialogTitle = (TextView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.text_dialog_title);
TextView dialogMessage = (TextView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.text_dialog_message);
((CardView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.message_card)).setCardBackgroundColor(activity.getCardBackgroundColor());
dialogTitle.setBackgroundColor(activity.getPrimaryColor());
dialogTitle.setText(title);
dialogMessage.setText(Message);
dialogMessage.setTextColor(activity.getTextColor());
builder.setView(dialogLayout);
return builder.create();
}
}*/
}
package org.horaapps.leafpic.dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.mikepenz.iconics.view.IconicsImageView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.adapters.BaseAdapter;
import org.horaapps.leafpic.data.Album;
import butterknife.BindView;
import butterknife.ButterKnife;
import horaapps.org.liz.ThemeHelper;
import horaapps.org.liz.ThemedViewHolder;
/**
* Created by dnld on 6/29/17.
*/
public class FolderAdapter extends BaseAdapter<Album, FolderAdapter.ViewHoldera> {
public FolderAdapter(Context context) {
super(context);
}
@Override
public ViewHoldera onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.select_folder_bottom_sheet_item, parent, false);
//v.setOnClickListener(onClickListener);
return new ViewHoldera(v);
}
@Override
public void onBindViewHolder(ViewHoldera holder, int position) {
}
static class ViewHoldera extends ThemedViewHolder {
@BindView(R.id.name_folder)
TextView folderName;
@BindView(R.id.folder_icon_bottom_sheet_item)
IconicsImageView imgFolder;
@BindView(R.id.ll_album_bottom_sheet_item)
LinearLayout llItemBackground;
ViewHoldera(View view) {
super(view);
ButterKnife.bind(this, view);