commit d632b04553e2b25cec8dd06f93d583b0d9b40037
parent 6f8dfc7e9782ecb92dd5bb9ddcd6b5b484b73183
Author: Jan Dankert <devnull@localhost>
Date: Thu, 17 May 2012 01:59:17 +0200
Verknüpfungen auf dem Homescreen für Foren und Nachrichtenfächer.
Diffstat:
3 files changed, 108 insertions(+), 15 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
@@ -4,6 +4,7 @@
<application android:icon="@drawable/ibc_icon"
android:name=".IBCApplication" android:label="@string/app_name">
+
<activity android:name=".IBCActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -16,9 +17,37 @@
<activity android:name="NewsDetailActivity" android:label="@string/news"></activity>
<activity android:name="PhotoActivity" android:label="@string/photos"></activity>
- <activity android:name="ForumOverviewActivity" android:label="@string/forum"></activity>
- <activity android:name="ForumActivity" android:label="@string/forum"></activity>
- <activity android:name="TopicActivity" android:label="@string/forum"></activity>
+ <activity android:name="ForumOverviewActivity" android:label="@string/forum" >
+ <!-- URL-Filter, damit diese Activity beim Aufruf der Forum-URL gestartet wird. -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:scheme="http" android:host="www.mtb-news.de" android:path="/forum/index.php" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:scheme="http" android:host="www.mtb-news.de" android:path="/forum/" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.CREATE_SHORTCUT"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name="ForumActivity" android:label="@string/forum" android:configChanges="keyboardHidden|orientation">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name="TopicActivity" android:label="@string/forum" android:configChanges="keyboardHidden|orientation">
+ </activity>
<activity android:name=".SearchActivity">
<intent-filter>
@@ -28,8 +57,17 @@
android:resource="@xml/searchable" />
</activity>
- <activity android:name="MailboxActivity" android:label="@string/mailbox"></activity>
- <activity android:name="MailActivity" android:label="@string/mailbox"></activity>
+ <activity android:name="MailboxActivity" android:label="@string/mailbox">
+ <intent-filter>
+ <action android:name="android.intent.action.CREATE_SHORTCUT"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ </activity>
+ <activity android:name="MailActivity" android:label="@string/mailbox">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
<activity android:name="MessageActivity" android:label="@string/mailbox"></activity>
<activity android:name="ReplyMailActivity" android:label="@string/reply"></activity>
<activity android:name="ReplyPostActivity" android:label="@string/reply"></activity>
diff --git a/src/de/mtbnews/android/ForumOverviewActivity.java b/src/de/mtbnews/android/ForumOverviewActivity.java
@@ -12,6 +12,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
@@ -27,7 +28,6 @@ import de.mtbnews.android.adapter.ExpandableForumContentAdapter;
import de.mtbnews.android.tapatalk.TapatalkClient;
import de.mtbnews.android.tapatalk.TapatalkException;
import de.mtbnews.android.tapatalk.wrapper.Forum;
-import de.mtbnews.android.util.IBC;
import de.mtbnews.android.util.ServerAsyncTask;
import de.mtbnews.android.util.Utils;
@@ -137,15 +137,42 @@ public class ForumOverviewActivity extends ExpandableListActivity
}
else if (!TextUtils.isEmpty(forum.url))
{
- startActivity(new Intent(Intent.ACTION_VIEW, Uri
- .parse(forum.url)));
+ if (!Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri
+ .parse(forum.url)));
+ }
}
else
{
- final Intent intent = new Intent(
- ForumOverviewActivity.this, ForumActivity.class);
- intent.putExtra("forum_id", forum.getId());
- startActivity(intent);
+ if (Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) {
+
+ Intent shortcutIntent = new Intent(
+ ForumOverviewActivity.this, ForumActivity.class);
+// Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
+// shortcutIntent.setClassName(ForumActivity.class.getPackage().getName(), "." + ForumActivity.class.getSimpleName());
+// shortcutIntent.setClassName(ForumActivity.class.getPackage().getName(), ForumActivity.class.getName());
+ shortcutIntent.putExtra("forum_id", forum.getId());
+
+ // Then, set up the container intent (the response to the caller)
+
+ Intent intent = new Intent();
+ intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
+ intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, forum.getTitle());
+ Parcelable iconResource = Intent.ShortcutIconResource.fromContext(
+ ForumOverviewActivity.this, R.drawable.ibc_icon);
+ intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
+
+ // Now, return the result to the launcher
+
+ setResult(RESULT_OK, intent);
+ finish();
+
+ } else {
+ final Intent intent = new Intent(
+ ForumOverviewActivity.this, ForumActivity.class);
+ intent.putExtra("forum_id", forum.getId());
+ startActivity(intent);
+ }
}
return true;
}
diff --git a/src/de/mtbnews/android/MailboxActivity.java b/src/de/mtbnews/android/MailboxActivity.java
@@ -7,6 +7,7 @@ import android.app.ListActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
@@ -73,9 +74,36 @@ public class MailboxActivity extends ListActivity
public void onItemClick(AdapterView<?> parent, View view,
int position, long id)
{
- Intent i = new Intent(MailboxActivity.this, MailActivity.class);
- i.putExtra("box_id", mailboxList.get(position).getId());
- startActivity(i);
+ final Mailbox mailbox = mailboxList.get(position);
+
+ if (Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) {
+
+ Intent shortcutIntent = new Intent(
+ MailboxActivity.this, MailActivity.class);
+// Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
+ shortcutIntent.setClassName(MailboxActivity.this, MailActivity.class.getName());
+ shortcutIntent.putExtra("box_id", mailbox.getId());
+
+ // Then, set up the container intent (the response to the caller)
+
+ Intent intent = new Intent();
+ intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
+ intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mailbox.getTitle());
+ Parcelable iconResource = Intent.ShortcutIconResource.fromContext(
+ MailboxActivity.this, R.drawable.ibc_icon);
+ intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
+
+ // Now, return the result to the launcher
+
+ setResult(RESULT_OK, intent);
+ finish();
+
+ } else {
+
+ Intent i = new Intent(MailboxActivity.this, MailActivity.class);
+ i.putExtra("box_id", mailbox.getId());
+ startActivity(i);
+ }
}
});