Merge branch 'master' into 'master'

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

![Screenshot_2016-01-06-20-10-18](/uploads/c15a5e59624113e9e83914914cd9c6a9/Screenshot_2016-01-06-20-10-18.png)
![Screenshot_2016-01-06-20-18-31](/uploads/0f6c15b6c0646a3336460a91a2a04e42/Screenshot_2016-01-06-20-18-31.png)


See merge request !189
This commit is contained in:
Daniel Martí 2016-01-09 13:45:13 +00:00
commit bb1c551cb8
14 changed files with 76 additions and 4 deletions

View File

@ -18,6 +18,8 @@
* Translation updates * Translation updates
* Display license and author information in app details where appropriate
### 0.97 (2015-11-07) ### 0.97 (2015-11-07)
* Add option to prompt for unstable updates globally * 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:baselineAligned="false"
android:orientation="vertical"> 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 <TextView
android:id="@+id/current_version" android:id="@+id/current_version"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -169,6 +169,13 @@ Changelog" />
android:drawableStart="@drawable/ic_website" android:drawableStart="@drawable/ic_website"
android:text="@string/menu_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 <TextView
android:id="@+id/donate" android:id="@+id/donate"
style="@style/AppDetailsLink" 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="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="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="version">Version</string>
<string name="by_author">by</string>
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="enable_nfc_send">Enable NFC Send…</string> <string name="enable_nfc_send">Enable NFC Send…</string>
<string name="cache_downloaded">Cache packages</string> <string name="cache_downloaded">Cache packages</string>
@ -114,6 +115,7 @@
<string name="menu_ignore_all">Ignore All Updates</string> <string name="menu_ignore_all">Ignore All Updates</string>
<string name="menu_ignore_this">Ignore This Update</string> <string name="menu_ignore_this">Ignore This Update</string>
<string name="menu_website">Website</string> <string name="menu_website">Website</string>
<string name="menu_email">E-Mail Author</string>
<string name="menu_issues">Issues</string> <string name="menu_issues">Issues</string>
<string name="menu_changelog">Changelog</string> <string name="menu_changelog">Changelog</string>
<string name="menu_source">Source Code</string> <string name="menu_source">Source Code</string>

View File

@ -1132,6 +1132,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
case R.id.website: case R.id.website:
url = app.webURL; url = app.webURL;
break; break;
case R.id.email:
url = "mailto:" + app.email;
break;
case R.id.source: case R.id.source:
url = app.sourceURL; url = app.sourceURL;
break; break;
@ -1228,6 +1231,13 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
else else
tv.setVisibility(View.GONE); 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 // Source button
tv = view.findViewById(R.id.source); tv = view.findViewById(R.id.source);
if (!TextUtils.isEmpty(app.sourceURL)) if (!TextUtils.isEmpty(app.sourceURL))
@ -1583,9 +1593,14 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
btMain.setOnClickListener(mOnClickListener); btMain.setOnClickListener(mOnClickListener);
btMain.setEnabled(true); 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); TextView currentVersion = (TextView) view.findViewById(R.id.current_version);
if (!getApks().isEmpty()) { if (!getApks().isEmpty()) {
currentVersion.setText(getApks().getItem(0).version); currentVersion.setText(getApks().getItem(0).version + " (" + app.license + ")");
} else { } else {
currentVersion.setVisibility(View.GONE); currentVersion.setVisibility(View.GONE);
btMain.setVisibility(View.GONE); btMain.setVisibility(View.GONE);

View File

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

View File

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

View File

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

View File

@ -70,6 +70,8 @@ public class DBHelper extends SQLiteOpenHelper {
+ "icon text, " + "icon text, "
+ "description text not null, " + "description text not null, "
+ "license text not null, " + "license text not null, "
+ "author text, "
+ "email text, "
+ "webURL text, " + "webURL text, "
+ "trackerURL text, " + "trackerURL text, "
+ "sourceURL 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 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; private final Context context;
@ -288,6 +290,7 @@ public class DBHelper extends SQLiteOpenHelper {
updateIconUrlLarge(db, oldVersion); updateIconUrlLarge(db, oldVersion);
recreateInstalledCache(db, oldVersion); recreateInstalledCache(db, oldVersion);
addCredentialsToRepo(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 * 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 * their repos (either manually or on a scheduled task), they will update regardless of whether