mirror of https://github.com/tasks/tasks
Add multi-select copy and delete
parent
1d8411915a
commit
385900cad3
@ -0,0 +1,71 @@
|
|||||||
|
package org.tasks.tasklist;
|
||||||
|
|
||||||
|
import android.support.v7.app.WindowDecorActionBar;
|
||||||
|
import android.support.v7.view.StandaloneActionMode;
|
||||||
|
import android.support.v7.widget.ActionBarContextView;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.tasks.R;
|
||||||
|
import org.tasks.themes.ThemeColor;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class ActionUtils {
|
||||||
|
// cribbed from Twittnuker
|
||||||
|
public static void applySupportActionModeColor(ThemeColor themeColor, final android.support.v7.view.ActionMode modeCompat) {
|
||||||
|
// Very dirty implementation
|
||||||
|
// This call ensures TitleView created
|
||||||
|
modeCompat.setTitle(modeCompat.getTitle());
|
||||||
|
View contextView = null;
|
||||||
|
if (modeCompat instanceof WindowDecorActionBar.ActionModeImpl) {
|
||||||
|
WindowDecorActionBar actionBar = (WindowDecorActionBar) findFieldOfTypes(modeCompat,
|
||||||
|
WindowDecorActionBar.ActionModeImpl.class, WindowDecorActionBar.class);
|
||||||
|
if (actionBar == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
contextView = (View) findFieldOfTypes(actionBar, WindowDecorActionBar.class, ActionBarContextView.class);
|
||||||
|
} else if (modeCompat instanceof StandaloneActionMode) {
|
||||||
|
contextView = (View) findFieldOfTypes(modeCompat, StandaloneActionMode.class, ActionBarContextView.class);
|
||||||
|
}
|
||||||
|
if (!(contextView instanceof ActionBarContextView)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
contextView.setBackgroundColor(themeColor.getPrimaryColor());
|
||||||
|
|
||||||
|
TextView title = (TextView) contextView.findViewById(R.id.action_bar_title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setTextColor(themeColor.getActionBarTint());
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageView closeButton = (ImageView) contextView.findViewById(R.id.action_mode_close_button);
|
||||||
|
if (closeButton != null) {
|
||||||
|
closeButton.setColorFilter(themeColor.getActionBarTint());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> Object findFieldOfTypes(T obj, Class<? extends T> cls, Class<?>... checkTypes) {
|
||||||
|
labelField:
|
||||||
|
for (Field field : cls.getDeclaredFields()) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
final Object fieldObj;
|
||||||
|
try {
|
||||||
|
fieldObj = field.get(obj);
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fieldObj != null) {
|
||||||
|
final Class<?> type = fieldObj.getClass();
|
||||||
|
for (Class<?> checkType : checkTypes) {
|
||||||
|
if (!checkType.isAssignableFrom(type)) {
|
||||||
|
continue labelField;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fieldObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:autoMirrored="true" android:height="24dp"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/copy_tasks"
|
||||||
|
android:title="@string/TAd_contextCopyTask"
|
||||||
|
android:icon="@drawable/ic_content_copy_black_24dp"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/delete"
|
||||||
|
android:title="@string/delete"
|
||||||
|
android:icon="@drawable/ic_delete_24dp"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
|
</menu>
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="TasksOverride" parent="Tasks">
|
<style name="Tasks" parent="TasksBase">
|
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue