Merge branch 'fix-ellipsize' into 'master'

Fix ellipsizing on 2.X, other minor updates



See merge request !276
This commit is contained in:
Daniel Martí 2016-05-07 20:44:57 +00:00
commit ee696b4737
8 changed files with 41 additions and 43 deletions

View File

@ -33,6 +33,7 @@ import android.content.pm.PackageManager;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -1112,7 +1113,10 @@ public class AppDetails extends AppCompatActivity {
viewMorePermissions.setText(getString(R.string.less)); viewMorePermissions.setText(getString(R.string.less));
} else { } else {
description.setMaxLines(MAX_LINES); description.setMaxLines(MAX_LINES);
description.setEllipsize(TextUtils.TruncateAt.MARQUEE); if (Build.VERSION.SDK_INT > 10) {
// ellipsizing doesn't work properly here on 2.X
description.setEllipsize(TextUtils.TruncateAt.MARQUEE);
}
viewMorePermissions.setText(R.string.more); viewMorePermissions.setText(R.string.more);
} }
viewAllDescription ^= true; viewAllDescription ^= true;
@ -1133,7 +1137,10 @@ public class AppDetails extends AppCompatActivity {
// If description has more than five lines // If description has more than five lines
if (description.getLineCount() > MAX_LINES) { if (description.getLineCount() > MAX_LINES) {
description.setMaxLines(MAX_LINES); description.setMaxLines(MAX_LINES);
description.setEllipsize(TextUtils.TruncateAt.MARQUEE); if (Build.VERSION.SDK_INT > 10) {
// ellipsizing doesn't work properly here on 2.X
description.setEllipsize(TextUtils.TruncateAt.MARQUEE);
}
description.setOnClickListener(expanderDescription); description.setOnClickListener(expanderDescription);
viewAllDescription = true; viewAllDescription = true;

View File

@ -71,7 +71,6 @@ import java.util.zip.Adler32;
public final class Utils { public final class Utils {
@SuppressWarnings("UnusedDeclaration")
private static final String TAG = "Utils"; private static final String TAG = "Utils";
private static final int BUFFER_SIZE = 4096; private static final int BUFFER_SIZE = 4096;

View File

@ -17,34 +17,33 @@ public abstract class ClipboardCompat {
return new OldClipboard(); return new OldClipboard();
} }
} @TargetApi(11)
private static class HoneycombClipboard extends ClipboardCompat {
@TargetApi(11) private final ClipboardManager manager;
class HoneycombClipboard extends ClipboardCompat {
private final ClipboardManager manager; HoneycombClipboard(Context context) {
this.manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
HoneycombClipboard(Context context) { }
this.manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
} @Override
public String getText() {
@Override CharSequence text = null;
public String getText() { if (manager.hasPrimaryClip()) {
CharSequence text = null; ClipData data = manager.getPrimaryClip();
if (manager.hasPrimaryClip()) { if (data.getItemCount() > 0) {
ClipData data = manager.getPrimaryClip(); text = data.getItemAt(0).getText();
if (data.getItemCount() > 0) { }
text = data.getItemAt(0).getText(); }
} return text != null ? text.toString() : null;
}
}
private static class OldClipboard extends ClipboardCompat {
@Override
public String getText() {
return null;
} }
return text != null ? text.toString() : null;
}
}
class OldClipboard extends ClipboardCompat {
@Override
public String getText() {
return null;
} }
} }

View File

@ -181,15 +181,14 @@ public class DownloaderService extends Service {
* message. * message.
*/ */
private String getNotificationTitle(@Nullable String packageName) { private String getNotificationTitle(@Nullable String packageName) {
String title;
if (packageName != null) { if (packageName != null) {
App app = AppProvider.Helper.findByPackageName( final App app = AppProvider.Helper.findByPackageName(
getContentResolver(), packageName, new String[]{AppProvider.DataColumns.NAME}); getContentResolver(), packageName, new String[]{AppProvider.DataColumns.NAME});
title = getString(R.string.downloading_apk, app.name); if (app != null) {
} else { return getString(R.string.downloading_apk, app.name);
title = getString(R.string.downloading); }
} }
return title; return getString(R.string.downloading);
} }
public static PendingIntent createAppDetailsIntent(@NonNull Context context, int requestCode, @Nullable String packageName) { public static PendingIntent createAppDetailsIntent(@NonNull Context context, int requestCode, @Nullable String packageName) {

View File

@ -227,9 +227,6 @@ public class SwapAppsView extends ListView implements
private class AppListAdapter extends CursorAdapter { private class AppListAdapter extends CursorAdapter {
@SuppressWarnings("UnusedDeclaration")
private static final String TAG = "AppListAdapter";
private class ViewHolder { private class ViewHolder {
private final LocalBroadcastManager localBroadcastManager; private final LocalBroadcastManager localBroadcastManager;

View File

@ -656,9 +656,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
public static final int TYPE_COMPLETE = 1; public static final int TYPE_COMPLETE = 1;
public static final int TYPE_ERROR = 2; public static final int TYPE_ERROR = 2;
@SuppressWarnings("UnusedDeclaration")
private static final String TAG = "UpdateAsyncTask";
@NonNull @NonNull
protected final Set<String> selectedApps; protected final Set<String> selectedApps;

View File

@ -3,7 +3,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.0.0' classpath 'com.android.tools.build:gradle:2.1.0'
classpath files('libs/gradle-witness.jar') classpath files('libs/gradle-witness.jar')
} }
} }

View File

@ -62,7 +62,7 @@
</module> </module>
<module name="NoLineWrap"/> <module name="NoLineWrap"/>
<!--<module name="OneTopLevelClass" />--> <module name="OneTopLevelClass" />
<module name="OneStatementPerLine" /> <module name="OneStatementPerLine" />
<module name="EmptyBlock"> <module name="EmptyBlock">