Commit 9ab0cd21 authored by Donald's avatar Donald

albumfragment progress

menu albums related options removed from mainact
parent 7d2dc263
......@@ -6,6 +6,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.GravityCompat;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
......@@ -17,12 +18,16 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import org.horaapps.leafpic.App;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.MainActivity;
import org.horaapps.leafpic.adapters.AlbumsAdapter;
import org.horaapps.leafpic.model.Album;
import org.horaapps.leafpic.model.HandlingAlbums;
import org.horaapps.leafpic.model.base.SortingMode;
import org.horaapps.leafpic.model.base.SortingOrder;
import org.horaapps.leafpic.new_way.CPHelper;
import org.horaapps.leafpic.new_way.DataManager;
import org.horaapps.leafpic.util.Measure;
......@@ -40,20 +45,26 @@ import io.reactivex.schedulers.Schedulers;
public class AlbumsFragment extends Fragment implements IFragment, Themeable {
private static final String TAG = "asd";
RecyclerView rvAlbums;
private AlbumsAdapter albumsAdapter;
private GridSpacingItemDecoration rvAlbumsDecoration;
MainActivity act;
SortingOrder sortingOrder;
SortingMode sortingMode;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
albumsAdapter = new AlbumsAdapter(getContext());
sortingMode = SortingMode.NUMERIC;
sortingOrder = SortingOrder.ASCENDING;
}
MainActivity act;
@Override
public void onAttach(Context context) {
super.onAttach(context);
......@@ -119,7 +130,15 @@ public class AlbumsFragment extends Fragment implements IFragment, Themeable {
}
private void updateToolbar() {
act.updateToolbar();
if (editMode()) act.updateToolbar(
String.format("%d/%d", albumsAdapter.getSelectedCount(), albumsAdapter.getItemCount()),
GoogleMaterial.Icon.gmd_check, v -> albumsAdapter.clearSelectedAlbums());
else
act.updateToolbar(
getString(R.string.app_name),
GoogleMaterial.Icon.gmd_menu, v -> act.mDrawerLayout.openDrawer(GravityCompat.START));
}
@Nullable
......@@ -136,6 +155,8 @@ public class AlbumsFragment extends Fragment implements IFragment, Themeable {
rvAlbums.setHasFixedSize(true);
rvAlbums.setItemAnimator(new DefaultItemAnimator());
albumsAdapter = new AlbumsAdapter(getContext());
albumsAdapter.getAlbumsClicks()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
......@@ -146,6 +167,8 @@ public class AlbumsFragment extends Fragment implements IFragment, Themeable {
.observeOn(AndroidSchedulers.mainThread())
.subscribe((album) -> updateToolbar());
//displayAlbums(false);
rvAlbums.setAdapter(albumsAdapter);
return rvAlbums;
......@@ -154,6 +177,47 @@ public class AlbumsFragment extends Fragment implements IFragment, Themeable {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
menu.findItem(R.id.select_all).setTitle(
getString(getSelectedCount() == getCount()
? R.string.clear_selected
: R.string.select_all));
menu.findItem(R.id.ascending_sort_action).setChecked(sortingOrder == SortingOrder.ASCENDING);
switch (sortingMode) {
case NAME: menu.findItem(R.id.name_sort_action).setChecked(true); break;
case SIZE: menu.findItem(R.id.size_sort_action).setChecked(true); break;
case DATE: default:
menu.findItem(R.id.date_taken_sort_action).setChecked(true); break;
case NUMERIC: menu.findItem(R.id.numeric_sort_action).setChecked(true); break;
}
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
boolean editMode = editMode();
boolean oneSelected = getSelectedCount() == 1;
menu.setGroupVisible(R.id.album_options_menu, true);
menu.setGroupVisible(R.id.photos_option_men, false);
menu.findItem(R.id.type_sort_action).setVisible(false);
menu.findItem(R.id.filter_menu).setVisible(false);
menu.findItem(R.id.search_action).setVisible(true);
menu.findItem(R.id.renameAlbum).setVisible(oneSelected);
menu.findItem(R.id.set_pin_album).setVisible(oneSelected);
menu.findItem(R.id.clear_album_preview).setVisible(oneSelected);
menu.findItem(R.id.clear_album_preview).setVisible(oneSelected);
if (oneSelected)
menu.findItem(R.id.set_pin_album).setTitle(albumsAdapter.getFirstSelectedAlbum().isPinned() ? getString(R.string.un_pin) : getString(R.string.pin));
menu.findItem(R.id.delete_action).setVisible(editMode);
menu.findItem(R.id.shortcut).setVisible(editMode);
}
@Override
......@@ -162,10 +226,11 @@ public class AlbumsFragment extends Fragment implements IFragment, Themeable {
switch (item.getItemId()) {
case R.id.select_all:
if (albumsAdapter.getSelectedCount() == albumsAdapter.getItemCount()) {
if (albumsAdapter.getSelectedCount() == albumsAdapter.getItemCount())
albumsAdapter.clearSelectedAlbums();
} else albumsAdapter.selectAllAlbums();
else albumsAdapter.selectAllAlbums();
return true;
case R.id.set_pin_album:
Album selectedAlbum = albumsAdapter.getFirstSelectedAlbum();
if (selectedAlbum != null) {
......@@ -176,6 +241,11 @@ public class AlbumsFragment extends Fragment implements IFragment, Themeable {
// TODO: 3/24/17 notify
return true;
case R.id.shortcut:
HandlingAlbums.installShortcutForSelectedAlbums(getContext(), albumsAdapter.getSelectedAlbums());
albumsAdapter.clearSelectedAlbums();
return true;
}
return super.onOptionsItemSelected(item);
......@@ -190,7 +260,7 @@ public class AlbumsFragment extends Fragment implements IFragment, Themeable {
}
@Override
public boolean selecting() {
public boolean editMode() {
return albumsAdapter.selecting();
}
......
......@@ -5,6 +5,6 @@ package org.horaapps.leafpic.fragments;
*/
public interface IFragment {
boolean selecting();
boolean editMode();
void clearSelected();
}
......@@ -35,6 +35,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
/**
* Created by dnld on 27/04/16.
......@@ -409,8 +410,8 @@ public class HandlingAlbums extends SQLiteOpenHelper {
selectedAlbums.clear();
}
public void installShortcutForSelectedAlbums(Context context) {
for (Album selectedAlbum : selectedAlbums) {
public static void installShortcutForSelectedAlbums(Context context, List<Album> albums) {
for (Album selectedAlbum : albums) {
Intent shortcutIntent;
shortcutIntent = new Intent(context, SplashScreen.class);
......@@ -443,7 +444,7 @@ public class HandlingAlbums extends SQLiteOpenHelper {
}
}
private Bitmap addWhiteBorder(Bitmap bmp, int borderSize) {
private static Bitmap addWhiteBorder(Bitmap bmp, int borderSize) {
Bitmap bmpWithBorder = Bitmap.createBitmap(bmp.getWidth() + borderSize * 2, bmp.getHeight() + borderSize * 2, bmp.getConfig());
Canvas canvas = new Canvas(bmpWithBorder);
canvas.drawColor(Color.WHITE);
......@@ -451,7 +452,7 @@ public class HandlingAlbums extends SQLiteOpenHelper {
return bmpWithBorder;
}
private Bitmap getCroppedBitmap(Bitmap srcBmp){
private static Bitmap getCroppedBitmap(Bitmap srcBmp){
Bitmap dstBmp;
if (srcBmp.getWidth() >= srcBmp.getHeight()){
dstBmp = Bitmap.createBitmap(srcBmp,
......
......@@ -22,9 +22,17 @@
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content"
/>
<RelativeLayout
android:id="@+id/rl_main_content"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/grid_albums"
......
......@@ -3,82 +3,80 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.horaapps.leafpic.activities.MainActivity">
<group android:id="@+id/general_action">
<item
android:id="@+id/search_action"
android:title="@string/search_menu"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="ifRoom|collapseActionView" />
<item
android:id="@+id/search_action"
android:title="@string/search_menu"
android:visible="false"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="ifRoom|collapseActionView" />
<item
android:id="@+id/filter_menu"
android:title="@string/filter_menu_title"
app:showAsAction="ifRoom">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="org.horaapps.leafpic.activities.MainActivity">
<group android:checkableBehavior="single">
<item
android:id="@+id/all_media_filter"
android:checked="true"
android:title="@string/all"
app:showAsAction="never" />
<item
android:id="@+id/video_media_filter"
android:title="@string/videos"
app:showAsAction="never" />
<item
android:id="@+id/image_media_filter"
android:title="@string/images"
app:showAsAction="never" />
<item
android:id="@+id/gifs_media_filter"
android:title="@string/gifs"
app:showAsAction="never" />
</group>
</menu>
</item>
<item
android:id="@+id/filter_menu"
android:title="@string/filter_menu_title"
app:showAsAction="ifRoom">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="org.horaapps.leafpic.activities.MainActivity">
<group android:checkableBehavior="single">
<item
android:id="@+id/all_media_filter"
android:checked="true"
android:title="@string/all"
app:showAsAction="never" />
<item
android:id="@+id/video_media_filter"
android:title="@string/videos"
app:showAsAction="never" />
<item
android:id="@+id/image_media_filter"
android:title="@string/images"
app:showAsAction="never" />
<item
android:id="@+id/gifs_media_filter"
android:title="@string/gifs"
app:showAsAction="never" />
</group>
</menu>
</item>
<item
android:id="@+id/sort_action"
android:title="@string/sort_menu_title"
app:showAsAction="ifRoom">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".PhotosActivity">
<group android:checkableBehavior="single">
<item
android:id="@+id/name_sort_action"
android:title="@string/name"
app:showAsAction="never" />
<item
android:id="@+id/date_taken_sort_action"
android:checked="true"
android:title="@string/date"
app:showAsAction="never" />
<item
android:id="@+id/size_sort_action"
android:title="@string/size"
app:showAsAction="never" />
<item
android:id="@+id/type_sort_action"
android:title="@string/type"
app:showAsAction="never" />
<item
android:id="@+id/numeric_sort_action"
android:title="@string/numeric"
app:showAsAction="never" />
</group>
<group android:checkableBehavior="all">
<item
android:id="@+id/ascending_sort_action"
android:title="@string/ascending"
app:showAsAction="never" />
</group>
</menu>
</item>
</group>
<item
android:id="@+id/sort_action"
android:title="@string/sort_menu_title"
app:showAsAction="ifRoom">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".PhotosActivity">
<group android:checkableBehavior="single">
<item
android:id="@+id/name_sort_action"
android:title="@string/name"
app:showAsAction="never" />
<item
android:id="@+id/date_taken_sort_action"
android:checked="true"
android:title="@string/date"
app:showAsAction="never" />
<item
android:id="@+id/size_sort_action"
android:title="@string/size"
app:showAsAction="never" />
<item
android:id="@+id/type_sort_action"
android:title="@string/type"
app:showAsAction="never" />
<item
android:id="@+id/numeric_sort_action"
android:title="@string/numeric"
app:showAsAction="never" />
</group>
<group android:checkableBehavior="all">
<item
android:id="@+id/ascending_sort_action"
android:title="@string/ascending"
app:showAsAction="never" />
</group>
</menu>
</item>
<group android:id="@+id/photos_option_men">
<item
......@@ -95,6 +93,18 @@
android:title="@string/move_to"
app:showAsAction="never" />
<item
android:id="@+id/set_as_cover"
android:title="@string/set_preview"
android:visible="false"
app:showAsAction="never" />
<item
android:id="@+id/affix"
android:title="@string/affix"
android:visible="false"
app:showAsAction="never" />
</group>
<group android:id="@+id/album_options_menu">
......@@ -106,44 +116,35 @@
android:id="@+id/exclude_action"
android:title="@string/exclude"
app:showAsAction="never" />
<item
android:id="@+id/set_pin_album"
android:title="@string/pin"
app:showAsAction="never" />
<item
android:id="@+id/shortcut"
android:title="@string/install_shortcut"
app:showAsAction="never" />
</group>
<item
android:id="@+id/renameAlbum"
android:title="@string/rename"
app:showAsAction="never" />
<item
android:id="@+id/select_all"
android:title="@string/select_all"
app:showAsAction="never" />
<item
android:id="@+id/delete_action"
android:title="@string/delete"
app:showAsAction="ifRoom" />
<item
android:id="@+id/clear_album_preview"
android:title="@string/clear_preview"
android:visible="false"
app:showAsAction="never" />
<item
android:id="@+id/set_pin_album"
android:title="@string/pin"
android:id="@+id/select_all"
android:title="@string/select_all"
app:showAsAction="never" />
<item
android:id="@+id/setAsAlbumPreview"
android:title="@string/set_preview"
android:visible="false"
app:showAsAction="never" />
<item
android:id="@+id/installShortcut"
android:title="@string/install_shortcut"
app:showAsAction="never" />
<item
android:id="@+id/affixPhoto"
android:title="@string/affix"
android:id="@+id/clear_album_preview"
android:title="@string/clear_preview"
android:visible="false"
app:showAsAction="never" />
......
......@@ -7,7 +7,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha3'
classpath 'com.android.tools.build:gradle:2.4.0-alpha1'
classpath 'me.tatarka:gradle-retrolambda:3.6.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Mar 25 09:54:58 CET 2017
systemProp.https.proxyPort=3128
systemProp.http.proxyHost=10.0.5.1
org.gradle.daemon=true
systemProp.https.proxyHost=10.0.5.1
org.gradle.configureondemand=true
org.gradle.daemon=true
\ No newline at end of file
systemProp.http.proxyPort=3128
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