mirror of https://github.com/tasks/tasks
Added a new activity that is exported to Locale for picking a tag. Next step is to wire Astrid up to receive triggering events and respodn appropriately.
parent
c1db49dddb
commit
569a0fc9a3
@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry excluding="javax/xml/validation/|javax/xml/transform/dom/|javax/xml/parsers/|org/jaxp/transform/dom/|org/jaxp/transform/sax/|org/jaxp/transform/stax/|org/jaxp/transform/stream/|org/jaxp/stream/events/|org/jaxp/stream/util/|org/jaxp/parsers/|org/jaxp/stream/|org/jaxp/validation/" kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry excluding="javax/xml/validation/|javax/xml/transform/dom/|javax/xml/parsers/|org/jaxp/transform/dom/|org/jaxp/transform/sax/|org/jaxp/transform/stax/|org/jaxp/transform/stream/|org/jaxp/stream/events/|org/jaxp/stream/util/|org/jaxp/parsers/|org/jaxp/stream/|org/jaxp/validation/" kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="lib" path="lib/locale_platform.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/locale_edit_intro" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/locale_border"
|
||||
android:layout_margin="10px">
|
||||
|
||||
<TextView
|
||||
android:paddingTop="5px"
|
||||
android:paddingBottom="10px"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/locale_pick_tag"
|
||||
style="@style/TextAppearance.Locale_Label" />
|
||||
|
||||
<Spinner
|
||||
android:paddingBottom="10px"
|
||||
android:id="@+id/spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/locale_ellipsizing_title_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:ellipsize="start"
|
||||
android:singleLine="true" />
|
||||
</RelativeLayout>
|
||||
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
<item
|
||||
android:title="Help"
|
||||
android:icon="@drawable/icon_help_color_40"
|
||||
android:id="@+id/menu_help" />
|
||||
<item
|
||||
android:title="Don't Save"
|
||||
android:icon="@drawable/icon_dontsave_color_40"
|
||||
android:id="@+id/menu_dontsave" />
|
||||
<item
|
||||
android:title="Save"
|
||||
android:icon="@drawable/icon_save_color_40"
|
||||
android:id="@+id/menu_save" />
|
||||
</menu>
|
||||
@ -0,0 +1,163 @@
|
||||
package com.timsu.astrid.activities;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.timsu.astrid.data.tag.TagController;
|
||||
import com.timsu.astrid.data.tag.TagModelForView;
|
||||
|
||||
/**
|
||||
* Activity to edit alerts from Locale
|
||||
*
|
||||
* @author timsu
|
||||
*
|
||||
*/
|
||||
public final class LocaleEditAlerts extends Activity {
|
||||
|
||||
/** value for action type for tag alert */
|
||||
public static final String ACTION_TAG_ALERT = "com.timsu.astrid.action.TAG_ALERT";
|
||||
|
||||
/** key name for tag name in bundle */
|
||||
public static final String KEY_TAG_NAME = "tag";
|
||||
|
||||
private String[] tagNames = null;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
|
||||
setContentView(R.layout.locale_edit_alerts);
|
||||
|
||||
// Set up the breadcrumbs in the title bar
|
||||
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.locale_ellipsizing_title);
|
||||
|
||||
String breadcrumbString = getIntent().getStringExtra(com.twofortyfouram.Intent.EXTRA_STRING_BREADCRUMB);
|
||||
if (breadcrumbString == null)
|
||||
breadcrumbString = getString(R.string.locale_edit_alerts_title);
|
||||
else
|
||||
breadcrumbString = breadcrumbString + com.twofortyfouram.Intent.BREADCRUMB_SEPARATOR + getString(R.string.locale_edit_alerts_title);
|
||||
|
||||
((TextView) findViewById(R.id.locale_ellipsizing_title_text)).setText(breadcrumbString);
|
||||
setTitle(breadcrumbString);
|
||||
|
||||
final Spinner tagSpinner = (Spinner) findViewById(R.id.spinner);
|
||||
|
||||
TagController tagController = new TagController(this);
|
||||
tagController.open();
|
||||
LinkedList<TagModelForView> tags = tagController.getAllTags();
|
||||
tagController.close();
|
||||
|
||||
tagNames = new String[tags.size()];
|
||||
for(int i = 0; i < tags.size(); i++)
|
||||
tagNames[i] = tags.get(i).getName();
|
||||
|
||||
ArrayAdapter<String> tagAdapter = new ArrayAdapter<String>(
|
||||
this, android.R.layout.simple_spinner_item, tagNames);
|
||||
tagAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
tagSpinner.setAdapter(tagAdapter);
|
||||
|
||||
// Save the state into the return Intent whenever the field
|
||||
tagSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1,
|
||||
int arg2, long arg3) {
|
||||
updateResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Private helper method to persist the Toast message in the return {@code Intent}.
|
||||
*/
|
||||
private void updateResult() {
|
||||
final String tagName = (String)((Spinner) findViewById(R.id.spinner)).getSelectedItem();
|
||||
|
||||
/*
|
||||
* If the message is of 0 length, then there isn't a setting to save
|
||||
*/
|
||||
if (tagName == null) {
|
||||
setResult(com.twofortyfouram.Intent.RESULT_REMOVE);
|
||||
} else {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(com.twofortyfouram.Intent.EXTRA_STRING_ACTION_FIRE,
|
||||
ACTION_TAG_ALERT);
|
||||
intent.putExtra(KEY_TAG_NAME, tagName);
|
||||
intent.putExtra(com.twofortyfouram.Intent.EXTRA_STRING_BLURB, tagName);
|
||||
setResult(RESULT_OK, intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
getMenuInflater().inflate(R.menu.locale_edit_alerts, menu);
|
||||
|
||||
menu.findItem(R.id.menu_save).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener()
|
||||
{
|
||||
public boolean onMenuItemClick(final MenuItem item)
|
||||
{
|
||||
updateResult();
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
menu.findItem(R.id.menu_dontsave).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener()
|
||||
{
|
||||
public boolean onMenuItemClick(final MenuItem item)
|
||||
{
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
menu.findItem(R.id.menu_help).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener()
|
||||
{
|
||||
public boolean onMenuItemClick(final MenuItem item)
|
||||
{
|
||||
|
||||
final Intent helpIntent = new Intent(com.twofortyfouram.Intent.ACTION_HELP);
|
||||
helpIntent.putExtra("com.twofortyfouram.locale.intent.extra.HELP_URL", "http://www.androidlocale.com/app_data/toast/1.0/help_toast.htm"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// Set up the breadcrumbs in the title bar
|
||||
String breadcrumbString = getIntent().getStringExtra(com.twofortyfouram.Intent.EXTRA_STRING_BREADCRUMB);
|
||||
if (breadcrumbString == null)
|
||||
helpIntent.putExtra(com.twofortyfouram.Intent.EXTRA_STRING_BREADCRUMB, getString(R.string.locale_edit_alerts_title));
|
||||
else
|
||||
helpIntent.putExtra(com.twofortyfouram.Intent.EXTRA_STRING_BREADCRUMB, breadcrumbString + com.twofortyfouram.Intent.BREADCRUMB_SEPARATOR
|
||||
+ getString(R.string.locale_edit_alerts_title));
|
||||
|
||||
startActivity(helpIntent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue