Commit 292a517c authored by DNLDsht's avatar DNLDsht

improved ui & ux select albums/photos

clean
parent 8bb59e25
......@@ -25,7 +25,6 @@
</activity>
<activity android:name=".AlbumsActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
......
......@@ -37,6 +37,9 @@ import com.leafpic.app.Base.Album;
import com.leafpic.app.Base.HandlingAlbums;
import com.leafpic.app.utils.StringUtils;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.Iconics;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.context.IconicsContextWrapper;
import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
......@@ -266,15 +269,34 @@ public class AlbumsActivity extends AppCompatActivity /*implements FolderChooser
MenuItem opt;
if (editmode) {
opt = menu.findItem(R.id.endEditAlbumMode);
opt.setEnabled(true).setVisible(true);
setOptionsAlbmuMenusItemsVisible(menu,true);
opt = menu.findItem(R.id.action_camera);
opt.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
opt = menu.findItem(R.id.sort_action);
opt.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
opt = menu.findItem(R.id.deleteAction);
opt.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
opt = menu.findItem(R.id.hideAlbumButton);
opt.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
} else {
opt = menu.findItem(R.id.endEditAlbumMode);
opt.setEnabled(false).setVisible(false);
setOptionsAlbmuMenusItemsVisible(menu,false);
opt = menu.findItem(R.id.action_camera);
opt.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
opt = menu.findItem(R.id.sort_action);
opt.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
opt = menu.findItem(R.id.deleteAction);
opt.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
opt = menu.findItem(R.id.hideAlbumButton);
opt.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}
if (hidden) {
opt = menu.findItem(R.id.refreshhiddenAlbumsButton);
opt.setEnabled(true).setVisible(true);
......@@ -287,42 +309,76 @@ public class AlbumsActivity extends AppCompatActivity /*implements FolderChooser
opt.setTitle(getString(R.string.hide_album_action));
}
if (albums.getSelectedCount()==0) {
editmode = false;
opt = menu.findItem(R.id.endEditAlbumMode);
setOptionsAlbmuMenusItemsVisible(menu,false);
opt.setEnabled(false).setVisible(false);
invalidateOptionsMenu();
}
updateSelectedStuff();
return super.onPrepareOptionsMenu(menu);
}
void updateSelectedStuff() {
int c;
try {
if ((c = albums.getSelectedCount()) != 0)
setTitle(c + "/" + albums.dispAlbums.size());
else setTitle(getString(R.string.app_name));
} catch (NullPointerException ex){ex.printStackTrace();}
Log.wtf("sadas",albums.getSelectedCount()+"");
}
private void setOptionsAlbmuMenusItemsVisible(final Menu m, boolean val) {
MenuItem option = m.findItem(R.id.hideAlbumButton);
option.setEnabled(val).setVisible(val);
option = m.findItem(R.id.deleteAction);
option.setEnabled(val).setVisible(val);
option = m.findItem(R.id.excludeAlbumButton);
option.setEnabled(val).setVisible(val);
if ((c = albums.getSelectedCount()) != 0) {
getSupportActionBar().setTitle(c + "/" + albums.dispAlbums.size());
toolbar.setNavigationIcon(new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_check)
.color(Color.WHITE)
.sizeDp(20));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
editmode = false;
invalidateOptionsMenu();
albums.clearSelectedAlbums();
adapt.notifyDataSetChanged();
}
});
toolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
albums.selectAllAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
});
} else {
getSupportActionBar().setTitle(getString(R.string.app_name));
toolbar.setNavigationIcon(new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_menu)
.color(Color.WHITE)
.sizeDp(20));
toolbar.setOnClickListener(null);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {drawer.openDrawer();
}
});
}
}catch (NullPointerException e){e.printStackTrace();}
}
private void setOptionsAlbmuMenusItemsVisible(final Menu menu, boolean val) {
MenuItem opt = menu.findItem(R.id.hideAlbumButton);
opt.setEnabled(val).setVisible(val);
opt = menu.findItem(R.id.deleteAction);
opt.setEnabled(val).setVisible(val);
opt = menu.findItem(R.id.excludeAlbumButton);
opt.setEnabled(val).setVisible(val);
opt = menu.findItem(R.id.select_all_albums_action);
opt.setEnabled(val).setVisible(val);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
StringUtils.showToast(getApplicationContext(), "asdasd");
return true;
case R.id.sort_action:
View sort_btn = findViewById(R.id.sort_action);
......@@ -350,11 +406,11 @@ public class AlbumsActivity extends AppCompatActivity /*implements FolderChooser
albums.loadPreviewHiddenAlbums();
adapt.notifyDataSetChanged();
break;
case R.id.endEditAlbumMode:
editmode = false;
invalidateOptionsMenu();
albums.clearSelectedAlbums();
case R.id.select_all_albums_action:
albums.selectAllAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
break;
case R.id.excludeAlbumButton:
......
......@@ -54,6 +54,15 @@ public class HandlingAlbums {
return last_position_selecte;
}
public void selectAllAlbums(){
for (Album dispAlbum : dispAlbums) {
if(!dispAlbum.isSelected()) {
dispAlbum.setSelcted(true);
selectedAlbums.add(dispAlbum);
}
}
}
public int getSelectedCount() {
return selectedAlbums.size();
}
......
......@@ -246,6 +246,17 @@ public class HandlingPhotos implements Parcelable {
return last_position_selecte;
}
public void selectAllPhotos(){
for (int i = 0; i < photos.size(); i++) {
if(!photos.get(i).isSelected()) {
photos.get(i).setSelected(true);
selectedPhotos.add(photos.get(i));
selectedPhotosIndexs.add(i);
}
}
}
public int toggleSelectPhoto(String path) {
Photo x = getPhoto(path);
if (x != null) {
......@@ -318,6 +329,10 @@ public class HandlingPhotos implements Parcelable {
e.printStackTrace();
}
}
public void removePhoto(int index) {
if (index > -1 && index < photos.size())
photos.remove(index);
}
private int removePhoto(String path) {
for (int i = 0; i < photos.size(); i++)
......
......@@ -22,6 +22,7 @@ import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.transition.Slide;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
......@@ -39,6 +40,8 @@ import com.leafpic.app.Base.HandlingAlbums;
import com.leafpic.app.Base.HandlingPhotos;
import com.leafpic.app.Base.Photo;
import com.leafpic.app.utils.StringUtils;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import java.io.File;
import java.util.ArrayList;
......@@ -54,6 +57,7 @@ public class PhotosActivity extends AppCompatActivity {
CollapsingToolbarLayout collapsingToolbarLayout;
Toolbar toolbar;
ImageView headerImage;
SharedPreferences SP;
......@@ -160,24 +164,16 @@ public class PhotosActivity extends AppCompatActivity {
public boolean onPrepareOptionsMenu(final Menu menu) {
MenuItem opt;
if (editmode) {
opt = menu.findItem(R.id.endEditAlbumMode);
opt.setEnabled(true).setVisible(true);
if (editmode)
setOptionsAlbmuMenusItemsVisible(menu, false);
} else {
opt = menu.findItem(R.id.endEditAlbumMode);
opt.setEnabled(false).setVisible(false);
else
setOptionsAlbmuMenusItemsVisible(menu, true);
}
if (photos.hidden) {
opt = menu.findItem(R.id.hideAlbumButton);
opt.setTitle(getString(R.string.unhide_album_action));
} else {
opt = menu.findItem(R.id.hideAlbumButton);
opt.setTitle(getString(R.string.hide_album_action));
}
if (photos.hidden)
menu.findItem(R.id.hideAlbumButton).setTitle(getString(R.string.unhide_album_action));
else
menu.findItem(R.id.hideAlbumButton).setTitle(getString(R.string.hide_album_action));
if (photos.getSelectedCount() == 0) {
editmode = false;
......@@ -191,7 +187,8 @@ public class PhotosActivity extends AppCompatActivity {
}
togglePrimaryToolbarOptions(menu);
updateSort(menu);
updateSort(menu);
updateSelectedStuff();
return super.onPrepareOptionsMenu(menu);
}
......@@ -223,6 +220,8 @@ public class PhotosActivity extends AppCompatActivity {
option.setEnabled(val).setVisible(val);
option = m.findItem(R.id.renameAlbum);
option.setEnabled(val).setVisible(val);
option = m.findItem(R.id.select_all_albums_action);
option.setEnabled(!val).setVisible(!val);
option = m.findItem(R.id.sharePhotos);
option.setEnabled(!val).setVisible(!val);
......@@ -230,12 +229,52 @@ public class PhotosActivity extends AppCompatActivity {
option.setEnabled(!val).setVisible(!val);
option = m.findItem(R.id.copyAction);
option.setEnabled(!val).setVisible(!val);
option = m.findItem(R.id.endEditAlbumMode);
option.setEnabled(!val).setVisible(!val);
option = m.findItem(R.id.setAsAlbumPreview);
option.setEnabled(!val).setVisible(!val);
}
void updateSelectedStuff() {
int c;
try {
if ((c = photos.getSelectedCount()) != 0) {
toolbar.setCollapsible(false);
collapsingToolbarLayout.setTitle(c + "/" + photos.photos.size());
toolbar.setNavigationIcon(new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_check)
.color(Color.WHITE)
.sizeDp(20));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { finishEditMode(); }});
toolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
photos.selectAllPhotos();
adapter.notifyDataSetChanged();
invalidateOptionsMenu();
}
});
} else {
collapsingToolbarLayout.setTitle(photos.DisplayName);
toolbar.setNavigationIcon(new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_arrow_back)
.color(Color.WHITE)
.sizeDp(20));
toolbar.setOnClickListener(null);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {onBackPressed();}
});
}
}catch (NullPointerException e){e.printStackTrace();}
}
private void finishEditMode() {
editmode = false;
invalidateOptionsMenu();
......@@ -261,16 +300,20 @@ public class PhotosActivity extends AppCompatActivity {
String ind = b.getString("photos_indexes");
if (ind != null) {
for (String asd : ind.split("ç")) {
// TODO remove photo moved from older album
// Log.wtf("asdasdasdas",asd);
//Log.wtf("asdasdasdas", photos.photos.size() + "");
//photos.removePhoto(Integer.valueOf(asd));
// TODO remove photo moved from older album [porco dio]
//Log.wtf("asdasdasdas", photos.photos.size() + "");
//adapter.removeItemAt(Integer.valueOf(asd));
//mRecyclerView.removeViewAt(Integer.parseInt(asd));
//photos.photos.remove(Integer.parseInt(asd));
//mRecyclerView.removeViewAt(Integer.valueOf(asd));
//adapter.notifyDataSetChanged();
//adapter.notifyItemRemoved(Integer.parseInt(asd));
}
}
StringUtils.showToast(getApplicationContext(), "moved ok");
//adapter.notifyDataSetChanged();
invalidateOptionsMenu();
}
break;
default:
......@@ -282,6 +325,7 @@ public class PhotosActivity extends AppCompatActivity {
}
public void updateSort(final Menu menu){
menu.findItem(R.id.ascending_sort_action).setChecked(photos.settings.ascending);
if (photos.settings.columnSortingMode == null || photos.settings.columnSortingMode.equals(MediaStore.Images.ImageColumns.DATE_TAKEN))
......@@ -309,10 +353,14 @@ public class PhotosActivity extends AppCompatActivity {
int2.putExtra("request_code", SelectAlbumActivity.COPY_TO_ACTION);
startActivityForResult(int2, SelectAlbumActivity.COPY_TO_ACTION);
break;
case R.id.endEditAlbumMode:
finishEditMode();
case R.id.select_all_albums_action:
photos.selectAllPhotos();
adapter.notifyDataSetChanged();
invalidateOptionsMenu();
break;
case R.id.setAsAlbumPreview:
photos.setSelectedPhotoAsPreview();
finishEditMode();
......@@ -481,7 +529,7 @@ public class PhotosActivity extends AppCompatActivity {
/**** ToolBar*/
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar = (Toolbar) findViewById(R.id.toolbar);
//String SColor = SP.getString("PrimaryPrefColor", "#009688");
//toolbar.setBackgroundColor(Color.parseColor(SColor));
setSupportActionBar(toolbar);
......
......@@ -3,12 +3,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item
android:id="@+id/endEditAlbumMode"
android:icon="@mipmap/ic_done_white_24dp"
android:title="DONE"
app:showAsAction="ifRoom"
/>
<item android:id="@+id/sort_action"
android:title="Sort"
android:icon="@mipmap/ic_sort_white_24dp"
app:showAsAction="ifRoom"
/>
<item
android:id="@+id/action_camera"
android:icon="@mipmap/ic_photo_camera_white_24dp"
......@@ -16,28 +17,35 @@
app:showAsAction="ifRoom"
/>
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/sort_action"
android:title="Sort"
android:orderInCategory="1"
android:icon="@mipmap/ic_sort_white_24dp"
app:showAsAction="ifRoom"
<item android:id="@+id/select_all_albums_action"
android:title="Select all"
app:showAsAction="never"
/>
<item android:id="@+id/filter_albums_action"
android:title="Filter"
app:showAsAction="never"
/>
<item
android:id="@+id/deleteAction"
android:icon="@mipmap/ic_delete_white_24dp"
android:title="@string/delete_album_action"
app:showAsAction="never"
app:showAsAction="ifRoom"
/>
<item
android:id="@+id/excludeAlbumButton"
android:title="@string/exclude_album_action"
app:showAsAction="never"
/>
<item
android:id="@+id/hideAlbumButton"
android:title="@string/hide_album_action"
app:showAsAction="never"
android:icon="@mipmap/ic_visibility_off_white_24dp"
app:showAsAction="ifRoom"
/>
<item
android:id="@+id/refreshhiddenAlbumsButton"
android:title="@string/refresh_hidde_folders_action"
......
......@@ -4,12 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context=".PhotosActivity"
>
<item
android:id="@+id/endEditAlbumMode"
android:icon="@mipmap/ic_done_white_24dp"
android:title="DONE"
app:showAsAction="ifRoom"
/>
<item android:id="@+id/sortPhotos"
android:title="Sort"
android:orderInCategory="1"
......@@ -17,12 +12,12 @@
app:showAsAction="ifRoom"
>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".PhotosActivity">
<group android:enabled="true" android:checkableBehavior="single">
<group android:checkableBehavior="single">
<item
android:id="@+id/name_sort_action"
android:checked="false"
android:title="by Name"
app:showAsAction="ifRoom"
/>
......@@ -31,11 +26,11 @@
android:id="@+id/date_taken_sort_action"
android:title="by Date Taken"
app:showAsAction="ifRoom"
/>
<item
android:id="@+id/size_sort_action"
android:title="by Size"
android:checked="false"
app:showAsAction="ifRoom"
/>
</group>
......@@ -43,7 +38,6 @@
<item
android:id="@+id/ascending_sort_action"
android:title="Ascending"
android:checked="false"
app:showAsAction="ifRoom"
/>
</group>
......@@ -91,4 +85,8 @@
android:title="Set as Preview"
app:showAsAction="never"
/>
<item android:id="@+id/select_all_albums_action"
android:title="Select all"
app:showAsAction="never"
/>
</menu>
\ No newline at end of file
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