1 <?xml version="1.0" encoding="utf-8"?> 2 <merge xmlns:android="http://schemas.android.com/apk/res/android"> 3 4 <org.ligi.androidhelper.views.SquareImageView 5 android:layout_width="match_parent" 6 android:layout_height="wrap_content"src/main/res/layout/last_hash_inner.xml:4:
1 <?xml version="1.0" encoding="utf-8"?> 2 <merge xmlns:android="http://schemas.android.com/apk/res/android"> 3 4 <org.ligi.androidhelper.views.SquareImageView 5 android:layout_width="match_parent" 6 android:layout_height="wrap_content"src/main/res/layout/last_hash_inner.xml:4:
1 <?xml version="1.0" encoding="utf-8"?> 2 <merge xmlns:android="http://schemas.android.com/apk/res/android"> 3 4 <org.ligi.androidhelper.views.SquareImageView 5 android:layout_width="match_parent" 6 android:layout_height="wrap_content"
70 progressDialog.dismiss(); 71 AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); 72 alertBuilder.setPositiveButton("OK",new DialogDiscardingOnClickListener()); 73 if (s.toLowerCase().startsWith("never seen")) { 74 alertBuilder.setMessage("The existence of this is not proven yet."); 75 alertBuilder.setNeutralButton("Add Proof",new DialogInterface.OnClickListener() {src/main/java/org/ligi/satoshiproof/ProofAsyncTask.java:73:
70 progressDialog.dismiss(); 71 AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); 72 alertBuilder.setPositiveButton("OK",new DialogDiscardingOnClickListener()); 73 if (s.toLowerCase().startsWith("never seen")) { 74 alertBuilder.setMessage("The existence of this is not proven yet."); 75 alertBuilder.setNeutralButton("Add Proof",new DialogInterface.OnClickListener() {src/main/java/org/ligi/satoshiproof/ProofAsyncTask.java:73:
70 progressDialog.dismiss(); 71 AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); 72 alertBuilder.setPositiveButton("OK",new DialogDiscardingOnClickListener()); 73 if (s.toLowerCase().startsWith("never seen")) { 74 alertBuilder.setMessage("The existence of this is not proven yet."); 75 alertBuilder.setNeutralButton("Add Proof",new DialogInterface.OnClickListener() {
String
manipulation methods.String#toLowerCase()
or #toUpperCase()
without specifying an explicit locale is a common source of bugs. The reason for that is that those methods will use the current locale on the user's device, and even though the code appears to work correctly when you are developing the app, it will fail in some locales. For example, in the Turkish locale, the uppercase replacement for i
is not I
.String#toUpperCase(Locale.US)
instead. If you really want to use the current locale, call String#toUpperCase(Locale.getDefault())
instead.
25 aQuery = new AQuery(this); 26 new FetchLastHashAsyncTask().execute(); 27 if (Build.VERSION.SDK_INT>=11) { 28 getActionBar().setDisplayHomeAsUpEnabled(true); 29 } 30 }src/main/java/org/ligi/satoshiproof/LastHashActivity.java:28:
25 aQuery = new AQuery(this); 26 new FetchLastHashAsyncTask().execute(); 27 if (Build.VERSION.SDK_INT>=11) { 28 getActionBar().setDisplayHomeAsUpEnabled(true); 29 } 30 }src/main/java/org/ligi/satoshiproof/LastHashActivity.java:28:
25 aQuery = new AQuery(this); 26 new FetchLastHashAsyncTask().execute(); 27 if (Build.VERSION.SDK_INT>=11) { 28 getActionBar().setDisplayHomeAsUpEnabled(true); 29 } 30 }src/main/java/org/ligi/satoshiproof/LastHashActivity.java:28:
25 aQuery = new AQuery(this); 26 new FetchLastHashAsyncTask().execute(); 27 if (Build.VERSION.SDK_INT>=11) { 28 getActionBar().setDisplayHomeAsUpEnabled(true); 29 } 30 }src/main/java/org/ligi/satoshiproof/LastHashActivity.java:28:
25 aQuery = new AQuery(this); 26 new FetchLastHashAsyncTask().execute(); 27 if (Build.VERSION.SDK_INT>=11) { 28 getActionBar().setDisplayHomeAsUpEnabled(true); 29 } 30 }src/main/java/org/ligi/satoshiproof/LastHashActivity.java:28:
25 aQuery = new AQuery(this); 26 new FetchLastHashAsyncTask().execute(); 27 if (Build.VERSION.SDK_INT>=11) { 28 getActionBar().setDisplayHomeAsUpEnabled(true); 29 } 30 }
minSdkVersion
in your AndroidManifest.xml
file.@TargetApi
annotation specifying the local minimum SDK to apply, such as @TargetApi(11)
, such that this check considers 11 rather than your manifest file's minimum SDK as the required API level.android:
attributes in style definitions, make sure you place this in a values-v11
folder in order to avoid running into runtime conflicts on certain devices where manufacturers have added custom attributes whose ids conflict with the new ones on later platforms.4 android:versionCode="4" 5 android:versionName="0.4"> 6 7 <uses-sdk 8 android:minSdkVersion="7" 9 android:targetSdkVersion="16"/>
targetSdkVersion
specifies that it has been tested with, various compatibility modes kick in. This ensures that your application continues to work, but it may look out of place. For example, if the targetSdkVersion
is less than 14, your app may get an option button in the UI.targetSdkVersion
to the highest available value. Then test your app to make sure everything works correctly. You may want to consult the compatibility notes to see what changes apply to each version you are adding support for: http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
80 }); 81 82 } else { 83 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 84 Date date=null; 85 try {src/main/java/org/ligi/satoshiproof/ProofAsyncTask.java:83:
80 }); 81 82 } else { 83 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 84 Date date=null; 85 try {src/main/java/org/ligi/satoshiproof/ProofAsyncTask.java:83:
80 }); 81 82 } else { 83 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 84 Date date=null; 85 try {
SimpleDateFormat
directly without an explicit locale.getDateInstance()
, getDateTimeInstance()
, or getTimeInstance()
to get a ready-made instance of SimpleDateFormat suitable for the user's locale. The main reason you'd create an instance this class directly is because you need to format/parse a specific machine-readable format, in which case you almost certainly want to explicitly ask for US to ensure that you get ASCII digits (rather than, say, Arabic digits).8 android:paddingTop="@dimen/activity_vertical_margin" 9 android:paddingBottom="@dimen/activity_vertical_margin" 10 tools:context=".MainActivity" 11 android:background="@android:color/white" 12 android:orientation="vertical"> 13src/main/res/layout-land/last_hash.xml:11:
8 android:paddingTop="@dimen/activity_vertical_margin" 9 android:paddingBottom="@dimen/activity_vertical_margin" 10 tools:context=".MainActivity" 11 android:background="@android:color/white" 12 android:orientation="horizontal"> 13src/main/res/layout/last_hash.xml:11:
8 android:paddingTop="@dimen/activity_vertical_margin" 9 android:paddingBottom="@dimen/activity_vertical_margin" 10 tools:context=".MainActivity" 11 android:background="@android:color/white" 12 android:orientation="vertical"> 13src/main/res/layout-land/last_hash.xml:11:
8 android:paddingTop="@dimen/activity_vertical_margin" 9 android:paddingBottom="@dimen/activity_vertical_margin" 10 tools:context=".MainActivity" 11 android:background="@android:color/white" 12 android:orientation="horizontal"> 13src/main/res/layout/last_hash.xml:11:
8 android:paddingTop="@dimen/activity_vertical_margin" 9 android:paddingBottom="@dimen/activity_vertical_margin" 10 tools:context=".MainActivity" 11 android:background="@android:color/white" 12 android:orientation="vertical"> 13src/main/res/layout-land/last_hash.xml:11:
8 android:paddingTop="@dimen/activity_vertical_margin" 9 android:paddingBottom="@dimen/activity_vertical_margin" 10 tools:context=".MainActivity" 11 android:background="@android:color/white" 12 android:orientation="horizontal"> 13
30 android:layout_height="wrap_content" 31 android:layout_marginTop="20dp" 32 /> 33 <EditText 34 android:layout_width="match_parent" 35 android:layout_height="wrap_content"src/main/res/layout/activity_main.xml:33:
30 android:layout_height="wrap_content" 31 android:layout_marginTop="20dp" 32 /> 33 <EditText 34 android:layout_width="match_parent" 35 android:layout_height="wrap_content"src/main/res/layout/activity_main.xml:33:
30 android:layout_height="wrap_content" 31 android:layout_marginTop="20dp" 32 /> 33 <EditText 34 android:layout_width="match_parent" 35 android:layout_height="wrap_content"
inputType
or hint
settings.inputType
attribute on a text field improves usability because depending on the data to be input, optimized keyboards can be shown to the user (such as just digits and parentheses for a phone number). Similarly,a hint attribute displays a hint to the user for what is expected in the text field.id
of the view, and if the id offers a hint of the purpose of the field (for example, the id
contains the phrase phone
or email
), then lint will also ensure that the inputType
contains the corresponding type attributes.inputType="text"
.
11 android:orientation="vertical"> 12 13 <TextView 14 android:text="Proof existence of picture:" 15 android:layout_width="wrap_content" 16 android:layout_height="wrap_content"src/main/res/layout/activity_main.xml:14:
11 android:orientation="vertical"> 12 13 <TextView 14 android:text="Proof existence of picture:" 15 android:layout_width="wrap_content" 16 android:layout_height="wrap_content"src/main/res/layout/activity_main.xml:14:
11 android:orientation="vertical"> 12 13 <TextView 14 android:text="Proof existence of picture:" 15 android:layout_width="wrap_content" 16 android:layout_height="wrap_content"src/main/res/layout/activity_main.xml:23:
20 <Button 21 android:layout_width="wrap_content" 22 android:layout_height="wrap_content" 23 android:text="select picture" 24 android:id="@+id/pickPictureButton" 25 />src/main/res/layout/activity_main.xml:23:
20 <Button 21 android:layout_width="wrap_content" 22 android:layout_height="wrap_content" 23 android:text="select picture" 24 android:id="@+id/pickPictureButton" 25 />+ 13 More Occurrences...
textAlignment
attribute to specify text alignment. However, if you are supporting older versions than API 17, you must also specify a gravity or layout_gravity attribute, since older platforms will ignore the textAlignment
attribute.
android:supportsRtl
attribute in the manifest <application>
element.Gravity#LEFT
and Gravity#RIGHT
can lead to problems when a layout is rendered in locales where text flows from right to left. Use Gravity#START
and Gravity#END
instead. Similarly, in XML gravity
and layout_gravity
attributes, use start
rather than left
.layout_marginLeft
, use paddingStart
and layout_marginStart
. NOTE: If your minSdkVersion
is less than 17, you should add both the older left/right attributes as well as the new start/right attributes. On older platforms, where RTL is not supported and the start/right attributes are unknown and therefore ignored, you need the older left/right attributes. There is a separate lint check which catches that type of error.Gravity#LEFT
and Gravity#START
, you can use these constants even when targeting older platforms, because the start
bitmask is a superset of the left
bitmask. Therefore, you can use gravity="start"
rather than gravity="left|start"
.)
<TextView>
is used to display data, the user might want to copy that data and paste it elsewhere. To allow this, the <TextView>
should specify android:textIsSelectable="true"
.minSdkVersion
.
//STOPSHIP
which indicates that code should not be released yet.// STOPSHIP
can be used to flag code that is incomplete but checked in. This comment marker can be used to indicate that the code should not be shipped until the issue is addressed, and lint will look for these.