11package in .ac .dtu .subtlenews ;
22
3+ import android .annotation .TargetApi ;
34import android .app .Activity ;
45import android .app .AlertDialog ;
56import android .content .Context ;
67import android .content .DialogInterface ;
78import android .content .Intent ;
9+ import android .graphics .Color ;
810import android .net .Uri ;
911import android .os .AsyncTask ;
1012import android .os .Bundle ;
1113import android .support .v4 .app .Fragment ;
1214import android .util .Log ;
15+ import android .view .Gravity ;
1316import android .view .LayoutInflater ;
1417import android .view .View ;
1518import android .view .ViewGroup ;
2730import java .io .BufferedReader ;
2831import java .io .File ;
2932import java .io .FileReader ;
33+ import java .lang .annotation .Target ;
3034import java .util .ArrayList ;
3135import java .util .List ;
3236
@@ -152,8 +156,14 @@ protected void onPostExecute(ArrayList<JSONObject> mArrayList){
152156 @ Override
153157 public void onItemClick (AdapterView <?> adapterView , View view , final int i , long l ) {
154158 try {
155- new AlertDialog .Builder (getActivity ())
156- .setTitle (fArrayList .get (i ).getString (TAG_TITLE ))
159+ TextView summaryTitle = new TextView (getActivity ());
160+ summaryTitle .setText (fArrayList .get (i ).getString (TAG_TITLE ));
161+ summaryTitle .setTextSize (16 );
162+ summaryTitle .setPadding (8 , 8 , 8 , 8 );
163+ summaryTitle .setGravity (Gravity .CENTER );
164+ summaryTitle .setTextColor (Color .GRAY );
165+ AlertDialog summaryBox = new AlertDialog .Builder (getActivity ())
166+ .setCustomTitle (summaryTitle )
157167 .setMessage (fArrayList .get (i ).getString (TAG_SUMMARY ))
158168 .setPositiveButton ("Source" , new DialogInterface .OnClickListener () {
159169 public void onClick (DialogInterface dialog , int id ) {
@@ -173,6 +183,12 @@ public void onClick(DialogInterface dialog, int id) {
173183 }
174184 })
175185 .show ();
186+ TextView summaryText = (TextView ) summaryBox .findViewById (android .R .id .message );
187+ summaryText .setTextSize (12 );
188+ if (android .os .Build .VERSION .SDK_INT > 11 ) {
189+ // Let Android 3.0 above users select the news text
190+ summaryText .setTextIsSelectable (true );
191+ }
176192 } catch (JSONException e ) {
177193 e .printStackTrace ();
178194 }
@@ -224,6 +240,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
224240 // set value into textview
225241 TextView newsTitle = (TextView ) rowView .findViewById (R .id .title_news );
226242 TextView sourceName = (TextView ) rowView .findViewById (R .id .source_news );
243+ sourceName .setTextColor (Color .GRAY );
244+ sourceName .setTextSize (10 );
227245 try {
228246 newsTitle .setText (selectedCategoryList .get (position ).getString (TAG_TITLE ));
229247 sourceName .setText (selectedCategoryList .get (position ).getString (TAG_SOURCE ));
0 commit comments