Renamed and reorganized resources to be able to manually control whether or not 3 column layouts are used

pull/14/head
Sam Bosley 13 years ago
parent 61448124bc
commit 7b33e45c76

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- See the file "LICENSE" for the full license governing this code. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/list_popover_bg">
<!-- Footer -->
<LinearLayout
android:id="@+id/lists_footer"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<include layout="@layout/fla_separator"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical">
<ImageView
android:layout_width="39dip"
android:layout_height="39dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="8dip"
android:src="?attr/asAddButtonImg"
android:scaleType="fitCenter"/>
<TextView
android:id="@+id/new_list_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="10dip"
android:gravity="left|center_vertical"
android:text="@string/FLA_new_list"
style="@style/TextAppearance.FLA_Button"/>
</LinearLayout>
</LinearLayout>
<!-- List -->
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="100"
android:layout_alignParentTop="true"
android:layout_above="@id/lists_footer"
android:scrollbars="vertical"
android:divider="@android:color/transparent"
android:cacheColorHint="#00000000"/>
</RelativeLayout>

@ -4,6 +4,7 @@ import android.app.PendingIntent.CanceledException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
@ -48,6 +49,13 @@ public class AstridActivity extends FragmentActivity
TaskListFragment.OnTaskListItemClickedListener, TaskListFragment.OnTaskListItemClickedListener,
TaskEditFragment.OnTaskEditDetailsClickedListener { 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_SINGLE = 0;
public static final int LAYOUT_DOUBLE = 1; public static final int LAYOUT_DOUBLE = 1;
public static final int LAYOUT_TRIPLE = 2; public static final int LAYOUT_TRIPLE = 2;
@ -292,6 +300,17 @@ public class AstridActivity extends FragmentActivity
return fragmentLayout; 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 { private class ReminderReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {

@ -157,7 +157,12 @@ public class FilterListFragment extends ListFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
Activity activity = getActivity(); Activity activity = getActivity();
ViewGroup parent = (ViewGroup) activity.getLayoutInflater().inflate(R.layout.filter_list_activity, container, false); int layout;
if (AstridActivity.shouldUseThreePane(activity))
layout = R.layout.filter_list_activity_3pane;
else
layout = R.layout.filter_list_activity;
ViewGroup parent = (ViewGroup) activity.getLayoutInflater().inflate(layout, container, false);
return parent; return parent;
} }

@ -18,6 +18,9 @@ public class TaskEditActivity extends AstridActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
ThemeService.applyTheme(this); ThemeService.applyTheme(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (shouldUseThreePane(this))
setContentView(R.layout.task_edit_wrapper_activity_3pane);
else
setContentView(R.layout.task_edit_wrapper_activity); setContentView(R.layout.task_edit_wrapper_activity);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();

@ -42,6 +42,7 @@ import com.todoroo.astrid.welcome.tutorial.WelcomeWalkthrough;
public class TaskListActivity extends AstridActivity implements MainMenuListener { public class TaskListActivity extends AstridActivity implements MainMenuListener {
public static final String TOKEN_SELECTED_FILTER = "selectedFilter"; //$NON-NLS-1$ public static final String TOKEN_SELECTED_FILTER = "selectedFilter"; //$NON-NLS-1$
private View listsNav; private View listsNav;
private ImageView listsNavDisclosure; private ImageView listsNavDisclosure;
private TextView lists; private TextView lists;
@ -111,6 +112,10 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
ThemeService.applyTheme(this); ThemeService.applyTheme(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (shouldUseThreePane(this))
setContentView(R.layout.task_list_wrapper_activity_3pane);
else
setContentView(R.layout.task_list_wrapper_activity); setContentView(R.layout.task_list_wrapper_activity);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();

Loading…
Cancel
Save