Add Utils.getVersionName(Context)
This commit is contained in:
parent
7f23cc9d51
commit
6c81216bc2
@ -279,15 +279,12 @@ public class FDroid extends ActionBarActivity {
|
|||||||
|
|
||||||
case R.id.action_about:
|
case R.id.action_about:
|
||||||
View view = LayoutInflater.from(this).inflate(R.layout.about, null);
|
View view = LayoutInflater.from(this).inflate(R.layout.about, null);
|
||||||
// Fill in the version...
|
|
||||||
try {
|
String versionName = Utils.getVersionName(this);
|
||||||
PackageInfo pi = getPackageManager()
|
if (versionName == null) {
|
||||||
.getPackageInfo(getApplicationContext()
|
versionName = getString(R.string.unknown);
|
||||||
.getPackageName(), 0);
|
|
||||||
((TextView) view.findViewById(R.id.version))
|
|
||||||
.setText(pi.versionName);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
}
|
||||||
|
((TextView) view.findViewById(R.id.version)).setText(versionName);
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this).setView(view);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this).setView(view);
|
||||||
final AlertDialog alrt = builder.create();
|
final AlertDialog alrt = builder.create();
|
||||||
|
@ -72,11 +72,9 @@ public class RepoUpdater {
|
|||||||
|
|
||||||
private URL getIndexAddress() throws MalformedURLException {
|
private URL getIndexAddress() throws MalformedURLException {
|
||||||
String urlString = repo.address + "/index.jar";
|
String urlString = repo.address + "/index.jar";
|
||||||
try {
|
String versionName = Utils.getVersionName(context);
|
||||||
String versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
|
if (versionName != null) {
|
||||||
urlString += "?client_version=" + versionName;
|
urlString += "?client_version=" + versionName;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
Log.e(TAG, "Could not get client version name", e);
|
|
||||||
}
|
}
|
||||||
return new URL(urlString);
|
return new URL(urlString);
|
||||||
}
|
}
|
||||||
|
@ -675,4 +675,16 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to get the version name of the client. Return null on failure.
|
||||||
|
public static String getVersionName(Context context) {
|
||||||
|
String versionName = null;
|
||||||
|
try {
|
||||||
|
versionName = context.getPackageManager()
|
||||||
|
.getPackageInfo(context.getPackageName(), 0).versionName;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Log.e(TAG, "Could not get client version name", e);
|
||||||
|
}
|
||||||
|
return versionName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user