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.

pull/14/head
Tim Su 17 years ago
parent c1db49dddb
commit 569a0fc9a3

@ -4,5 +4,6 @@
<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>

@ -4,6 +4,10 @@
android:versionCode="101"
android:versionName="2.7.3">
<!-- ##############################################################
Metadata
############################################################## -->
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
@ -14,6 +18,10 @@
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!-- ##############################################################
Activities
############################################################## -->
<!-- Activity that displays the task list -->
<activity android:name=".activities.TaskList">
<intent-filter>
@ -47,13 +55,26 @@
<!-- Activity that lets users edit app preferences -->
<activity android:name=".activities.EditPreferences"/>
<!-- Activity that les users edit synchronization preferences -->
<!-- Activity that lets users edit synchronization preferences -->
<activity android:name=".activities.SyncPreferences"/>
<!-- Receivers -->
<!-- activity that Locale displays to edit tag notification settings -->
<activity
android:name=".activities.LocaleEditAlerts"
android:label="@string/locale_edit_alerts_title"
android:icon="@drawable/icon_32"
android:exported="true" >
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name=".utilities.Notifications">
</receiver>
<!-- ##############################################################
Receivers
############################################################## -->
<receiver android:name=".utilities.Notifications" />
<receiver android:name=".utilities.StartupReceiver">
<intent-filter>
@ -62,7 +83,9 @@
</intent-filter>
</receiver>
<!-- Services -->
<!-- ##############################################################
Services
############################################################## -->
<service android:name=".sync.SynchronizationService"/>

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>

@ -197,7 +197,7 @@
<string name="flag_before">As Deadlines Approach</string>
<string name="flag_during">At Deadlines</string>
<string name="flag_after">After Absolute Deadline Passes</string>
<string name="flag_nonstop">Nonstop Until I View the Task</string>
<string name="flag_nonstop">Alarm Clock Mode</string>
<string name="alerts_label">Fixed Reminders</string>
<string name="add_alert">Add New Reminder</string>
@ -334,6 +334,13 @@ Some things you may not know about Astrid:\n
Thanks for using Astrid!\n
</string>
<!-- Locale Plugin -->
<skip />
<string name="locale_edit_alerts_title">Astrid Tag Alert</string>
<string name="locale_edit_intro">Astrid will send you a reminder
when you have uncompleted tasks with the following criteria:</string>
<string name="locale_pick_tag">Tagged with:</string>
<!-- Notification -->
<skip />

@ -28,6 +28,11 @@
<style name="TextAppearance" parent="android:TextAppearance">
</style>
<style name="TextAppearance.Locale_Label">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@android:color/black</item>
</style>
<style name="TextAppearance.TaskList_Task">
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>

@ -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…
Cancel
Save