Skip to content

Commit 3a434df

Browse files
author
Arnav Gupta
committed
UI/UX Improvements
* handle color/size changes in code instead of hardcode on xml * Make summary smaller text size * Make Title smaller text size
1 parent e81c7b6 commit 3a434df

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

App/src/main/java/in/ac/dtu/subtlenews/MainFragment.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package in.ac.dtu.subtlenews;
22

3+
import android.annotation.TargetApi;
34
import android.app.Activity;
45
import android.app.AlertDialog;
56
import android.content.Context;
67
import android.content.DialogInterface;
78
import android.content.Intent;
9+
import android.graphics.Color;
810
import android.net.Uri;
911
import android.os.AsyncTask;
1012
import android.os.Bundle;
1113
import android.support.v4.app.Fragment;
1214
import android.util.Log;
15+
import android.view.Gravity;
1316
import android.view.LayoutInflater;
1417
import android.view.View;
1518
import android.view.ViewGroup;
@@ -27,6 +30,7 @@
2730
import java.io.BufferedReader;
2831
import java.io.File;
2932
import java.io.FileReader;
33+
import java.lang.annotation.Target;
3034
import java.util.ArrayList;
3135
import 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));

App/src/main/res/layout/row_list.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
android:id="@+id/source_news"
1515
android:layout_width="wrap_content"
1616
android:layout_height="wrap_content"
17-
android:layout_gravity="right"
18-
android:textSize="10sp"
19-
android:textColor="#BFBFBF"/>
17+
android:layout_gravity="right"/>
2018

2119
</LinearLayout>

0 commit comments

Comments
 (0)