Adds handling of formatted descriptions

This commit is contained in:
Ciaran Gultnieks 2012-09-17 21:46:32 +01:00
parent a06d18b029
commit 0d0c65fb0e
4 changed files with 187 additions and 80 deletions

View File

@ -1,52 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fdroid.fdroid" android:versionCode="26"
android:versionName="0.35-test" android:installLocation="auto">
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="15" />
package="org.fdroid.fdroid"
android:installLocation="auto"
android:versionCode="26"
android:versionName="0.35-test" >
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="15" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:smallScreens="true" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<application android:name="FDroidApp" android:label="@string/app_name"
android:icon="@drawable/ic_launcher">
android:smallScreens="true"
android:xlargeScreens="true" />
<activity android:name="FDroid" android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.default_searchable"
android:value=".SearchResults" />
</activity>
<activity android:name="ManageRepo" />
<activity android:name="Settings" />
<activity android:name="AppDetails" />
<activity android:name="Preferences" />
<activity android:name="SearchResults" android:launchMode="singleTop" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<receiver android:name="StartupReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<service android:name="UpdateService" />
</application>
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name="FDroidApp"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="FDroid"
android:configChanges="keyboardHidden|orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchResults" />
</activity>
<activity android:name="ManageRepo" />
<activity android:name="Settings" />
<activity
android:name="AppDetails"
android:exported="true" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="fdroid.app" />
</intent-filter>
</activity>
<activity android:name="Preferences" />
<activity
android:name="SearchResults"
android:exported="true"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<receiver android:name="StartupReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<service android:name="UpdateService" />
</application>
</manifest>

View File

@ -1,45 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout android:id="@+id/header"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView android:id="@+id/icon" android:cropToPadding="true"
android:padding="4px" android:scaleType="centerInside"
android:layout_height="50px" android:layout_width="50px" />
<ImageView
android:id="@+id/icon"
android:layout_width="50px"
android:layout_height="50px"
android:cropToPadding="true"
android:padding="4px"
android:scaleType="centerInside" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView android:id="@+id/title" android:textStyle="bold"
android:singleLine="true" android:ellipsize="marquee"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textSize="18sp" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:textSize="18sp"
android:textStyle="bold" />
<TextView android:id="@+id/license" android:textSize="12sp"
android:layout_below="@id/title" android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:layout_width="wrap_content" />
<TextView
android:id="@+id/license"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/title"
android:textSize="12sp" />
<TextView android:id="@+id/status" android:layout_toLeftOf="@id/license"
android:layout_below="@id/title" android:layout_alignParentLeft="true"
android:textSize="12sp" android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView android:id="@+id/signature" android:layout_below="@id/status"
android:layout_alignParentLeft="true" android:textSize="12sp"
android:layout_height="wrap_content" android:layout_width="fill_parent" />
<TextView
android:id="@+id/status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/title"
android:layout_toLeftOf="@id/license"
android:textSize="12sp" />
<TextView
android:id="@+id/signature"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/status"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
<TextView android:id="@+id/description" android:singleLine="false"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<TextView
android:id="@+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="false" />
<ListView android:id="@android:id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>

View File

@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import org.xml.sax.XMLReader;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
@ -45,7 +47,11 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.text.Editable;
import android.text.Html;
import android.text.Html.TagHandler;
import android.text.format.DateFormat;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@ -171,7 +177,11 @@ public class AppDetails extends ListActivity {
Intent i = getIntent();
appid = "";
if (!i.hasExtra("appid")) {
Uri data = getIntent().getData();
if(data != null) {
appid = data.getEncodedSchemeSpecificPart();
Log.d("FDroid", "AppDetails launched from link, for '" + appid + "'");
} else if (!i.hasExtra("appid")) {
Log.d("FDroid", "No application ID in AppDetails!?");
} else {
appid = i.getStringExtra("appid");
@ -343,7 +353,36 @@ public class AppDetails extends ListActivity {
tv.setText(String.format(getString(R.string.details_installed),
app.installedVersion));
tv = (TextView) findViewById(R.id.description);
tv.setText(app.detail_description);
tv.setMovementMethod(LinkMovementMethod.getInstance());
// Need this to add the unimplemented support for ordered and unordered
// lists to Html.fromHtml().
class HtmlTagHandler implements TagHandler {
int listNum;
@Override
public void handleTag(boolean opening, String tag, Editable output,
XMLReader reader) {
if (opening && tag.equals("ul")) {
listNum = -1;
} else if (opening && tag.equals("ol")) {
listNum = 1;
} else if (tag.equals("li")) {
if (opening) {
if (listNum == -1) {
output.append("\t•");
} else {
output.append("\t" + Integer.toString(listNum)
+ ". ");
listNum++;
}
} else {
output.append('\n');
}
}
}
}
tv.setText(Html.fromHtml(app.detail_description, null, new HtmlTagHandler()));
if (pref_expert && mInstalledSignature != null) {
tv = (TextView) findViewById(R.id.signature);
tv.setText("Signed: " + mInstalledSigID);
@ -367,6 +406,8 @@ public class AppDetails extends ListActivity {
super.onCreateOptionsMenu(menu);
menu.clear();
if(app == null)
return true;
DB.Apk curver = app.getCurrentVersion();
if (app.installedVersion != null && curver != null
&& !app.installedVersion.equals(curver.version)) {
@ -419,7 +460,8 @@ public class AppDetails extends ListActivity {
return true;
case WEBSITE:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(app.detail_webURL)));
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(app.detail_webURL)));
return true;
case ISSUES:

View File

@ -170,6 +170,12 @@ public class RepoXMLHandler extends DefaultHandler {
} else if (curel.equals("icon")) {
curapp.icon = str;
} else if (curel.equals("description")) {
// This is the old-style description. We'll read it
// if present, to support old repos, but in newer
// repos it will get overwritten straight away!
curapp.detail_description = "<p>" + str + "</p>";
} else if (curel.equals("desc")) {
// New-style description.
curapp.detail_description = str;
} else if (curel.equals("summary")) {
curapp.summary = str;