Fixed bugs with icon themes on tablet, updated crittercism library

pull/14/head
Sam Bosley 14 years ago
parent cc80afcfef
commit 4e3ebbde05

@ -737,14 +737,28 @@ public class AndroidUtilities {
}
}
/**
* Array of device names that should be considered tablets
*/
private static final String[] THREE_PANE_DEVICES = new String[] {
"kindle", //$NON-NLS-1$
};
/**
* Returns true if the screen is large or xtra large
* @param context
* @return
*/
public static boolean isTabletSized(Context context) {
int screenSize = context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
return (screenSize >= Configuration.SCREENLAYOUT_SIZE_LARGE);
int size = context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK;
if (size == Configuration.SCREENLAYOUT_SIZE_XLARGE) return true;
String model = android.os.Build.MODEL.toLowerCase();
for (String s : THREE_PANE_DEVICES) {
if (model.contains(s)) return true;
}
return false;
}
}

@ -29,6 +29,6 @@
<classpathentry exported="true" kind="lib" path="libs/google-oauth-client-1.6.0-beta.jar"/>
<classpathentry exported="true" kind="lib" path="libs/google-oauth-client-extensions-1.6.0-beta.jar"/>
<classpathentry exported="true" kind="lib" path="libs/gson-1.7.1.jar"/>
<classpathentry kind="lib" path="libs/crittercism_v2_0_1.jar"/>
<classpathentry kind="lib" path="libs/crittercism_v2_1_1.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

@ -54,6 +54,7 @@ import com.todoroo.astrid.helper.AsyncImageView;
import com.todoroo.astrid.helper.ProgressBarSyncResultCallback;
import com.todoroo.astrid.service.SyncV2Service;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.subtasks.SubtasksTagListFragment;
import com.todoroo.astrid.tags.TagFilterExposer;
import com.todoroo.astrid.tags.TagService.Tag;
@ -156,11 +157,12 @@ public class TagViewFragment extends TaskListFragment {
}
@Override
protected void addSyncRefreshMenuItem(Menu menu) {
protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
if(actFmPreferenceService.isLoggedIn()) {
addMenuItem(menu, R.string.actfm_TVA_menu_refresh, R.drawable.icn_menu_refresh, MENU_REFRESH_ID, false);
addMenuItem(menu, R.string.actfm_TVA_menu_refresh,
ThemeService.getDrawable(R.drawable.icn_menu_refresh, themeFlags), MENU_REFRESH_ID, false);
} else {
super.addSyncRefreshMenuItem(menu);
super.addSyncRefreshMenuItem(menu, themeFlags);
}
}

@ -14,6 +14,7 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.activity.FilterListFragment;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.AstridFilterExposer;
@ -67,8 +68,10 @@ public final class CoreFilterExposer extends BroadcastReceiver implements Astrid
Criterion.and(MetadataCriteria.withKey(TagService.KEY),
TagService.TAG.like("x_%", "x"))))))), //$NON-NLS-1$ //$NON-NLS-2$
null);
boolean isTablet = AndroidUtilities.isTabletSized(ContextManager.getContext());
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
inbox.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_inbox))).getBitmap();
ThemeService.getDrawable(R.drawable.filter_inbox, themeFlags))).getBitmap();
return inbox;
}

@ -75,6 +75,9 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
}
private Filter[] buildSavedFilters(Context context, Resources r) {
boolean isTablet = AndroidUtilities.isTabletSized(context);
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
StoreObjectDao dao = PluginServices.getStoreObjectDao();
TodorooCursor<StoreObject> cursor = dao.query(Query.select(StoreObject.PROPERTIES).where(
StoreObject.TYPE.eq(SavedFilter.TYPE)).orderBy(Order.asc(SavedFilter.NAME)));
@ -93,7 +96,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
Task.DUE_DATE.lte(PermaSql.VALUE_EOD))),
todayValues);
list[0].listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_calendar))).getBitmap();
ThemeService.getDrawable(R.drawable.filter_calendar, themeFlags))).getBitmap();
list[1] = new Filter(r.getString(R.string.BFE_Recent),
r.getString(R.string.BFE_Recent),
@ -102,7 +105,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
Order.desc(Task.MODIFICATION_DATE)).limit(15),
null);
list[1].listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_pencil))).getBitmap();
ThemeService.getDrawable(R.drawable.filter_pencil, themeFlags))).getBitmap();
list[2] = getAssignedByMeFilter(r);
@ -118,7 +121,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
list[i].contextMenuLabels = new String[] { context.getString(R.string.BFE_Saved_delete) };
list[i].contextMenuIntents = new Intent[] { deleteIntent };
list[i].listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_sliders))).getBitmap();
ThemeService.getDrawable(R.drawable.filter_sliders, themeFlags))).getBitmap();
}
return list;
@ -128,6 +131,8 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
}
public static Filter getAssignedByMeFilter(Resources r) {
boolean isTablet = AndroidUtilities.isTabletSized(ContextManager.getContext());
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
Filter f = new Filter(r.getString(R.string.BFE_Assigned),
r.getString(R.string.BFE_Assigned),
new QueryTemplate().join(Join.left(Metadata.TABLE, Task.ID.eq(Metadata.TASK)))
@ -137,7 +142,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
Criterion.and(Metadata.KEY.eq(TaskRabbitMetadata.METADATA_KEY), TaskRabbitMetadata.ID.gt(0))))),
null);
f.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_assigned))).getBitmap();
ThemeService.getDrawable(R.drawable.filter_assigned, themeFlags))).getBitmap();
return f;
}

@ -17,6 +17,7 @@ import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.SyncV2Service;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.subtasks.OrderedListFragmentHelper;
import com.todoroo.astrid.subtasks.SubtasksListFragment;
@ -144,11 +145,12 @@ public class GtasksListFragment extends SubtasksListFragment {
}
@Override
protected void addSyncRefreshMenuItem(Menu menu) {
protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
if(gtasksPreferenceService.isLoggedIn()) {
addMenuItem(menu, R.string.actfm_TVA_menu_refresh, R.drawable.icn_menu_refresh, MENU_REFRESH_ID, false);
addMenuItem(menu, R.string.actfm_TVA_menu_refresh,
ThemeService.getDrawable(R.drawable.icn_menu_refresh, themeFlags), MENU_REFRESH_ID, false);
} else {
super.addSyncRefreshMenuItem(menu);
super.addSyncRefreshMenuItem(menu, themeFlags);
}
}

@ -26,6 +26,7 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.actfm.TagViewFragment;
@ -169,6 +170,9 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
Context context = ContextManager.getContext();
Resources r = context.getResources();
boolean isTablet = AndroidUtilities.isTabletSized(context);
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_LIGHT : 0;
// --- untagged
int untaggedLabel = gtasksPreferenceService.isLoggedIn() ?
R.string.tag_FEx_untagged_w_astrid : R.string.tag_FEx_untagged;
@ -177,7 +181,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
TagService.untaggedTemplate(),
null);
untagged.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.gl_lists))).getBitmap();
ThemeService.getDrawable(R.drawable.gl_lists, themeFlags))).getBitmap();
filters[0] = untagged;
for(int i = 0; i < tags.length; i++)

@ -5,7 +5,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
@ -55,13 +54,6 @@ public class AstridActivity extends FragmentActivity
TaskListFragment.OnTaskListItemClickedListener,
TaskEditFragment.OnTaskEditDetailsClickedListener {
/**
* Array of device names that we want to override the layout for
*/
private static final String[] THREE_PANE_DEVICES = new String[] {
"kindle", //$NON-NLS-1$
};
public static final int LAYOUT_SINGLE = 0;
public static final int LAYOUT_DOUBLE = 1;
public static final int LAYOUT_TRIPLE = 2;
@ -337,17 +329,6 @@ public class AstridActivity extends FragmentActivity
return fragmentLayout;
}
public static boolean shouldUseThreePane(Context context) {
int size = context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK;
if (size == Configuration.SCREENLAYOUT_SIZE_XLARGE) return true;
String model = android.os.Build.MODEL.toLowerCase();
for (String s : THREE_PANE_DEVICES) {
if (model.contains(s)) return true;
}
return false;
}
private class ReminderReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, final Intent intent) {

@ -136,7 +136,7 @@ public class FilterListFragment extends ListFragment {
Bundle savedInstanceState) {
Activity activity = getActivity();
int layout;
if (AstridActivity.shouldUseThreePane(activity))
if (AndroidUtilities.isTabletSized(activity))
layout = R.layout.filter_list_activity_3pane;
else
layout = R.layout.filter_list_activity;

@ -18,7 +18,7 @@ public class TaskEditActivity extends AstridActivity {
protected void onCreate(Bundle savedInstanceState) {
ThemeService.applyTheme(this);
super.onCreate(savedInstanceState);
if (shouldUseThreePane(this))
if (AndroidUtilities.isTabletSized(this))
setContentView(R.layout.task_edit_wrapper_activity_3pane);
else
setContentView(R.layout.task_edit_wrapper_activity);

@ -121,7 +121,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
ThemeService.applyTheme(this);
super.onCreate(savedInstanceState);
if (shouldUseThreePane(this))
if (AndroidUtilities.isTabletSized(this))
setContentView(R.layout.task_list_wrapper_activity_3pane);
else
setContentView(R.layout.task_list_wrapper_activity);
@ -227,7 +227,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
private void createMainMenuPopover() {
int layout;
if (shouldUseThreePane(this))
if (AndroidUtilities.isTabletSized(this))
layout = R.layout.main_menu_popover_tablet;
else
layout = R.layout.main_menu_popover;

@ -363,9 +363,9 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
contextMenuExtensionLoader.loadInNewThread(getActivity());
}
protected void addSyncRefreshMenuItem(Menu menu) {
protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
addMenuItem(menu, R.string.TLA_menu_sync,
ThemeService.getDrawable(R.drawable.icn_menu_refresh), MENU_SYNC_ID, true);
ThemeService.getDrawable(R.drawable.icn_menu_refresh, themeFlags), MENU_SYNC_ID, true);
}
protected void addMenuItem(Menu menu, int title, int imageRes, int id, boolean showAsAction) {
@ -395,26 +395,26 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
if (activity == null)
return;
boolean isTablet = AndroidUtilities.isTabletSized(activity);
activity.getMainMenuPopover().clear();
// --- sort
if (allowResorting()) {
addMenuItem(menu, R.string.TLA_menu_sort,
ThemeService.getDrawable(R.drawable.icn_menu_sort_by_size), MENU_SORT_ID, true);
ThemeService.getDrawable(R.drawable.icn_menu_sort_by_size, isTablet ? ThemeService.FLAG_INVERT : 0), MENU_SORT_ID, true);
}
// --- sync
addSyncRefreshMenuItem(menu);
addSyncRefreshMenuItem(menu, isTablet ? ThemeService.FLAG_INVERT : 0);
// --- new filter
addMenuItem(menu, R.string.FLA_new_filter,
ThemeService.getDrawable(R.drawable.icn_menu_filters), MENU_NEW_FILTER_ID, true);
ThemeService.getDrawable(R.drawable.icn_menu_filters, isTablet ? ThemeService.FLAG_INVERT : 0), MENU_NEW_FILTER_ID, true);
// --- addons
if (!Constants.MARKET_DISABLED) {
addMenuItem(menu, R.string.TLA_menu_addons,
ThemeService.getDrawable(R.drawable.icn_menu_plugins), MENU_ADDONS_ID, false);
ThemeService.getDrawable(R.drawable.icn_menu_plugins, isTablet ? ThemeService.FLAG_FORCE_DARK : 0), MENU_ADDONS_ID, false);
}
// ask about plug-ins

@ -18,6 +18,10 @@ public class ThemeService {
public static final String THEME_TRANSPARENT = "transparent";
public static final String THEME_TRANSPARENT_WHITE = "transparent-white";
public static final int FLAG_FORCE_DARK = 1;
public static final int FLAG_FORCE_LIGHT = 2;
public static final int FLAG_INVERT = 3;
private static int currentTheme;
public static void applyTheme(Activity activity) {
@ -69,7 +73,25 @@ public class ThemeService {
}
public static int getDrawable(int lightDrawable) {
return getDrawable(lightDrawable, 0);
}
public static int getDrawable(int lightDrawable, int alter) {
boolean darkTheme = currentTheme == R.style.Theme || currentTheme == R.style.Theme_Transparent;
switch(alter) {
case FLAG_FORCE_DARK:
darkTheme = true;
break;
case FLAG_FORCE_LIGHT:
darkTheme = false;
break;
case FLAG_INVERT:
darkTheme = !darkTheme;
break;
default:
break;
}
if(!darkTheme)
return lightDrawable;

@ -13,7 +13,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.astrid.activity.AstridActivity;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.ui.TouchInterceptingFrameLayout.InterceptTouchListener;
@ -48,7 +48,7 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi
TouchInterceptingFrameLayout rootLayout = (TouchInterceptingFrameLayout) getContentView();
rootLayout.setInterceptTouchListener(this);
if (AstridActivity.shouldUseThreePane(context))
if (AndroidUtilities.isTabletSized(context))
rowLayout = R.layout.main_menu_row_tablet;
else
rowLayout = R.layout.main_menu_row;
@ -85,18 +85,19 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi
}
private void addFixedItems(boolean isTablet) {
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_DARK : 0;
if (!isTablet)
addMenuItem(R.string.TLA_menu_lists,
ThemeService.getDrawable(R.drawable.icn_menu_lists),
ThemeService.getDrawable(R.drawable.icn_menu_lists, themeFlags),
MAIN_MENU_ITEM_LISTS, null, topFixed); // Lists item
addMenuItem(R.string.TLA_menu_tutorial,
ThemeService.getDrawable(R.drawable.icn_menu_tutorial),
ThemeService.getDrawable(R.drawable.icn_menu_tutorial, themeFlags),
MAIN_MENU_ITEM_TUTORIAL, null, bottomFixed); // Tutorial item
addMenuItem(R.string.TLA_menu_settings,
ThemeService.getDrawable(R.drawable.icn_menu_settings),
ThemeService.getDrawable(R.drawable.icn_menu_settings, themeFlags),
MAIN_MENU_ITEM_SETTINGS, null, bottomFixed); // Settings item
addMenuItem(R.string.TLA_menu_support,
ThemeService.getDrawable(R.drawable.icn_menu_support),
ThemeService.getDrawable(R.drawable.icn_menu_support, themeFlags),
MAIN_MENU_ITEM_SUPPORT, null, bottomFixed); // Support item
}

Loading…
Cancel
Save