Add author/email/license display capabilities to app. (Closes: #532)

This commit is contained in:
Dominik George 2016-01-04 23:53:28 +01:00
parent 87fb293348
commit 0df829034c
No known key found for this signature in database
GPG Key ID: B79A3C16A0C4F296
14 changed files with 76 additions and 4 deletions

View File

@ -18,6 +18,8 @@
* Translation updates
* Display license and author information in app details where appropriate
### 0.97 (2015-11-07)
* Add option to prompt for unstable updates globally

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -73,6 +73,19 @@
android:baselineAligned="false"
android:orientation="vertical">
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:gravity="start"
android:singleLine="true"
android:textAlignment="viewStart"
android:textSize="13sp"
android:visibility="gone"
tools:text="F-Droid Authors" />
<TextView
android:id="@+id/current_version"
android:layout_width="wrap_content"

View File

@ -169,6 +169,13 @@ Changelog" />
android:drawableStart="@drawable/ic_website"
android:text="@string/menu_website" />
<TextView
android:id="@+id/email"
style="@style/AppDetailsLink"
android:drawableLeft="@drawable/ic_email"
android:drawableStart="@drawable/ic_email"
android:text="@string/menu_email" />
<TextView
android:id="@+id/donate"
style="@style/AppDetailsLink"

View File

@ -10,6 +10,7 @@
<string name="installIncompatible">It seems like this package is not compatible with your device. Do you want to try and install it anyway?</string>
<string name="installDowngrade">You are trying to downgrade this application. Doing so might get it to malfunction and even lose your data. Do you want to try and downgrade it anyway?</string>
<string name="version">Version</string>
<string name="by_author">by</string>
<string name="delete">Delete</string>
<string name="enable_nfc_send">Enable NFC Send…</string>
<string name="cache_downloaded">Cache packages</string>
@ -115,6 +116,7 @@
<string name="menu_ignore_all">Ignore All Updates</string>
<string name="menu_ignore_this">Ignore This Update</string>
<string name="menu_website">Website</string>
<string name="menu_email">E-Mail Author</string>
<string name="menu_issues">Issues</string>
<string name="menu_changelog">Changelog</string>
<string name="menu_source">Source Code</string>

View File

@ -1135,6 +1135,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
case R.id.website:
url = app.webURL;
break;
case R.id.email:
url = "mailto:" + app.email;
break;
case R.id.source:
url = app.sourceURL;
break;
@ -1231,6 +1234,13 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
else
tv.setVisibility(View.GONE);
// Email button
tv = view.findViewById(R.id.email);
if (!TextUtils.isEmpty(app.email))
tv.setOnClickListener(mOnClickListener);
else
tv.setVisibility(View.GONE);
// Source button
tv = view.findViewById(R.id.source);
if (!TextUtils.isEmpty(app.sourceURL))
@ -1586,9 +1596,14 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
btMain.setOnClickListener(mOnClickListener);
btMain.setEnabled(true);
}
TextView author = (TextView) view.findViewById(R.id.author);
if (!TextUtils.isEmpty(app.author)) {
author.setText(getString(R.string.by_author) + " " + app.author);
author.setVisibility(View.VISIBLE);
}
TextView currentVersion = (TextView) view.findViewById(R.id.current_version);
if (!getApks().isEmpty()) {
currentVersion.setText(getApks().getItem(0).version);
currentVersion.setText(getApks().getItem(0).version + " (" + app.license + ")");
} else {
currentVersion.setVisibility(View.GONE);
btMain.setVisibility(View.GONE);

View File

@ -167,6 +167,12 @@ public class RepoXMLHandler extends DefaultHandler {
case "license":
curapp.license = str;
break;
case "author":
curapp.author = str;
break;
case "email":
curapp.email = str;
break;
case "source":
curapp.sourceURL = str;
break;

View File

@ -40,6 +40,9 @@ public class App extends ValueObject implements Comparable<App> {
public String license = "Unknown";
public String author;
public String email;
public String webURL;
public String trackerURL;
@ -139,6 +142,12 @@ public class App extends ValueObject implements Comparable<App> {
case AppProvider.DataColumns.LICENSE:
license = cursor.getString(i);
break;
case AppProvider.DataColumns.AUTHOR:
author = cursor.getString(i);
break;
case AppProvider.DataColumns.EMAIL:
email = cursor.getString(i);
break;
case AppProvider.DataColumns.WEB_URL:
webURL = cursor.getString(i);
break;
@ -374,6 +383,8 @@ public class App extends ValueObject implements Comparable<App> {
values.put(AppProvider.DataColumns.ICON_URL_LARGE, iconUrlLarge);
values.put(AppProvider.DataColumns.DESCRIPTION, description);
values.put(AppProvider.DataColumns.LICENSE, license);
values.put(AppProvider.DataColumns.AUTHOR, author);
values.put(AppProvider.DataColumns.EMAIL, email);
values.put(AppProvider.DataColumns.WEB_URL, webURL);
values.put(AppProvider.DataColumns.TRACKER_URL, trackerURL);
values.put(AppProvider.DataColumns.SOURCE_URL, sourceURL);

View File

@ -179,6 +179,8 @@ public class AppProvider extends FDroidProvider {
String ICON = "icon";
String DESCRIPTION = "description";
String LICENSE = "license";
String AUTHOR = "author";
String EMAIL = "email";
String WEB_URL = "webURL";
String TRACKER_URL = "trackerURL";
String SOURCE_URL = "sourceURL";
@ -212,8 +214,8 @@ public class AppProvider extends FDroidProvider {
String[] ALL = {
_ID, IS_COMPATIBLE, PACKAGE_NAME, NAME, SUMMARY, ICON, DESCRIPTION,
LICENSE, WEB_URL, TRACKER_URL, SOURCE_URL, CHANGELOG_URL, DONATE_URL,
BITCOIN_ADDR, LITECOIN_ADDR, FLATTR_ID,
LICENSE, AUTHOR, EMAIL, WEB_URL, TRACKER_URL, SOURCE_URL,
CHANGELOG_URL, DONATE_URL, BITCOIN_ADDR, LITECOIN_ADDR, FLATTR_ID,
UPSTREAM_VERSION, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED,
CATEGORIES, ANTI_FEATURES, REQUIREMENTS, IGNORE_ALLUPDATES,
IGNORE_THISUPDATE, ICON_URL, ICON_URL_LARGE,

View File

@ -70,6 +70,8 @@ public class DBHelper extends SQLiteOpenHelper {
+ "icon text, "
+ "description text not null, "
+ "license text not null, "
+ "author text, "
+ "email text, "
+ "webURL text, "
+ "trackerURL text, "
+ "sourceURL text, "
@ -104,7 +106,7 @@ public class DBHelper extends SQLiteOpenHelper {
+ " );";
private static final String DROP_TABLE_INSTALLED_APP = "DROP TABLE " + TABLE_INSTALLED_APP + ";";
private static final int DB_VERSION = 52;
private static final int DB_VERSION = 53;
private final Context context;
@ -288,6 +290,7 @@ public class DBHelper extends SQLiteOpenHelper {
updateIconUrlLarge(db, oldVersion);
recreateInstalledCache(db, oldVersion);
addCredentialsToRepo(db, oldVersion);
addAuthorToApp(db, oldVersion);
}
/**
@ -458,6 +461,17 @@ public class DBHelper extends SQLiteOpenHelper {
}
}
private void addAuthorToApp(SQLiteDatabase db, int oldVersion) {
if (oldVersion < 53 && !columnExists(db, TABLE_APP, "author")) {
Utils.debugLog(TAG, "Adding author column to " + TABLE_APP);
db.execSQL("alter table " + TABLE_APP + " add column author text");
}
if (oldVersion < 53 && !columnExists(db, TABLE_APP, "email")) {
Utils.debugLog(TAG, "Adding email column to " + TABLE_APP);
db.execSQL("alter table " + TABLE_APP + " add column email text");
}
}
/**
* By clearing the etags stored in the repo table, it means that next time the user updates
* their repos (either manually or on a scheduled task), they will update regardless of whether