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.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
@ -48,6 +49,13 @@ 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;
@ -292,6 +300,17 @@ 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, Intent intent) {

@ -157,7 +157,12 @@ public class FilterListFragment extends ListFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
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;
}

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

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

Loading…
Cancel
Save