various layout tweaks

fix logout action
This commit is contained in:
Andrew Dolgov 2011-11-24 17:57:44 +03:00
parent 7ad712cb41
commit 3cc0cb8410
16 changed files with 78 additions and 62 deletions

View File

@ -7,10 +7,10 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_height="match_parent" android:orientation="vertical"> android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:background="?articleHeader" android:layout_gravity="center_vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/article_header" android:padding="10dip"> <LinearLayout android:background="?articleHeader" android:layout_gravity="center_vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/article_header" android:padding="10dip">
<TextView android:singleLine="true" android:layout_weight="1" android:text="TextView" android:layout_height="wrap_content" android:ellipsize="end" android:layout_width="match_parent" android:id="@+id/title" android:textSize="15dip"></TextView> <TextView android:singleLine="true" android:layout_weight="1" android:text="" android:layout_height="wrap_content" android:ellipsize="end" android:layout_width="match_parent" android:id="@+id/title" android:textSize="18dip"></TextView>
<Button android:text="Close" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/close_button"></Button>
</LinearLayout> </LinearLayout>
<ImageView android:background="?articleDivider" android:paddingTop="2dip" android:layout_weight="0" android:layout_height="wrap_content" android:layout_width="match_parent"></ImageView> <ImageView android:background="?feedlistDivider" android:paddingTop="2dip" android:layout_weight="0" android:layout_height="wrap_content" android:layout_width="match_parent"></ImageView>
<WebView android:layout_weight="0" android:layout_width="match_parent" android:padding="3dip" android:layout_height="match_parent" android:id="@+id/content"></WebView> <WebView android:layout_weight="0" android:layout_width="match_parent" android:padding="3dip" android:layout_height="match_parent" android:id="@+id/content"></WebView>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -6,6 +6,6 @@
<ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:id="@+id/loading_progress" android:layout_height="wrap_content"></ProgressBar> <ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:id="@+id/loading_progress" android:layout_height="wrap_content"></ProgressBar>
<TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView> <TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView>
</LinearLayout> </LinearLayout>
<ListView android:divider="#00000000" android:id="@+id/feeds" android:layout_height="match_parent" android:layout_width="match_parent"></ListView> <ListView android:id="@+id/feeds" android:layout_height="match_parent" android:layout_width="match_parent"></ListView>
</FrameLayout> </FrameLayout>

View File

@ -10,7 +10,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:paddingLeft="6dip" android:paddingLeft="6dip"
android:text="{FEED}" android:layout_width="wrap_content" android:textSize="21dp"/> android:text="{FEED}" android:layout_width="wrap_content" android:textSize="18dip"/>
<TextView <TextView
android:id="@+id/unread_counter" android:id="@+id/unread_counter"
android:gravity="right" android:gravity="right"
@ -20,6 +20,6 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="{123}" android:textSize="16dp"/> android:text="{123}" android:textSize="13dip"/>
</LinearLayout> </LinearLayout>

View File

@ -11,7 +11,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:paddingLeft="6dip" android:paddingLeft="6dip"
android:text="{FEED}" android:layout_width="wrap_content" android:textSize="21dp"/> android:text="{FEED}" android:layout_width="wrap_content" android:textSize="18dip"/>
<TextView <TextView
android:id="@+id/unread_counter" android:id="@+id/unread_counter"
android:gravity="right" android:gravity="right"
@ -21,6 +21,6 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="{123}" android:textSize="16dp"/> android:text="{123}" android:textSize="13dip"/>
</LinearLayout> </LinearLayout>

View File

@ -12,10 +12,10 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/linerLayout3" android:id="@+id/linerLayout3"
android:layout_width="wrap_content" android:gravity="center" android:layout_width="wrap_content" android:gravity="center" android:padding="3dip"
android:layout_height="wrap_content" android:orientation="vertical"> android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/date" android:text="Jan 01"></TextView> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#909090" android:textSize="13sp" android:id="@+id/date" android:text="Jan 01"></TextView>
<ImageView android:clickable="true" android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView> <ImageView android:clickable="true" android:id="@+id/marked" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -14,11 +14,11 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/linerLayout3" android:id="@+id/linerLayout3" android:padding="3dip"
android:layout_width="wrap_content" android:gravity="center" android:layout_width="wrap_content" android:gravity="center"
android:layout_height="wrap_content" android:orientation="vertical"> android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/date" android:text="Jan 01"></TextView> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#909090" android:textSize="13sp" android:id="@+id/date" android:text="Jan 01"></TextView>
<ImageView android:clickable="true" android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView> <ImageView android:clickable="true" android:id="@+id/marked" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -15,10 +15,10 @@
<LinearLayout <LinearLayout
android:id="@+id/linerLayout3" android:id="@+id/linerLayout3"
android:layout_width="wrap_content" android:gravity="center" android:layout_width="wrap_content" android:gravity="center" android:padding="3dip"
android:layout_height="wrap_content" android:orientation="vertical"> android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/date" android:text="Jan 01"></TextView> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#909090" android:textSize="13sp" android:id="@+id/date" android:text="Jan 01"></TextView>
<ImageView android:clickable="true" android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView> <ImageView android:clickable="true" android:id="@+id/marked" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -1,15 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/preferences"
android:icon="@android:drawable/ic_menu_preferences"
android:title="@string/preferences"
android:showAsAction="ifRoom|withText"
/>
<item android:id="@+id/login"
android:icon="@android:drawable/ic_menu_rotate"
android:title="@string/login_login"
android:showAsAction="ifRoom|withText"
/>
</menu>

View File

@ -7,10 +7,6 @@
android:title="@string/login" android:title="@string/login"
android:showAsAction="ifRoom|withText"/> android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/logout"
android:visible="false"
android:title="@string/logout"
android:showAsAction=""/>
<item android:id="@+id/show_feeds" <item android:id="@+id/show_feeds"
android:visible="false" android:visible="false"
@ -18,6 +14,13 @@
android:title="@string/menu_all_feeds" android:title="@string/menu_all_feeds"
android:showAsAction=""/> android:showAsAction=""/>
<item android:id="@+id/close_article"
android:visible="false"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:title="@string/close_article"
android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/update" <item android:id="@+id/update"
android:visible="false" android:visible="false"
android:icon="@android:drawable/ic_menu_rotate" android:icon="@android:drawable/ic_menu_rotate"
@ -28,4 +31,10 @@
android:icon="@android:drawable/ic_menu_preferences" android:icon="@android:drawable/ic_menu_preferences"
android:title="@string/preferences" android:title="@string/preferences"
android:showAsAction="ifRoom|withText"/> android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/logout"
android:visible="false"
android:title="@string/logout"
android:showAsAction=""/>
</menu> </menu>

View File

@ -29,5 +29,5 @@
<string name="menu_unread_feeds">Show unread feeds</string> <string name="menu_unread_feeds">Show unread feeds</string>
<string name="menu_all_feeds">Show all feeds</string> <string name="menu_all_feeds">Show all feeds</string>
<string name="update">Update</string> <string name="update">Update</string>
<string name="close_article">Close article</string>
</resources> </resources>

View File

@ -5,7 +5,7 @@
<item name="unreadCounterColor">#0000ff</item> <item name="unreadCounterColor">#0000ff</item>
<item name="headlinesBackground">#ffffff</item> <item name="headlinesBackground">#ffffff</item>
<item name="articleDivider">#96c5ff</item> <item name="articleDivider">#96c5ff</item>
<item name="articleHeader">#ffffff</item> <item name="articleHeader">@android:color/transparent</item>
<item name="headlineSelectedBackground">#fff7d5</item> <item name="headlineSelectedBackground">#fff7d5</item>
<item name="headlineUnreadBackground">#ffffff</item> <item name="headlineUnreadBackground">#ffffff</item>
<item name="feedsSelectedBackground">#96C5FF</item> <item name="feedsSelectedBackground">#96C5FF</item>
@ -20,7 +20,7 @@
<item name="unreadCounterColor">#0000ff</item> <item name="unreadCounterColor">#0000ff</item>
<item name="headlinesBackground">#000000</item> <item name="headlinesBackground">#000000</item>
<item name="articleDivider">#303030</item> <item name="articleDivider">#303030</item>
<item name="articleHeader">#101010</item> <item name="articleHeader">@android:color/transparent</item>
<item name="headlineSelectedBackground">#303060</item> <item name="headlineSelectedBackground">#303060</item>
<item name="headlineUnreadBackground">#303030</item> <item name="headlineUnreadBackground">#303030</item>
<item name="feedsSelectedBackground">#303060</item> <item name="feedsSelectedBackground">#303060</item>

View File

@ -15,7 +15,6 @@ import android.util.Log;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonElement> { public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonElement> {

View File

@ -4,22 +4,21 @@ import java.net.URLEncoder;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
public class ArticleFragment extends Fragment implements View.OnClickListener { public class ArticleFragment extends Fragment {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
protected SharedPreferences m_prefs; protected SharedPreferences m_prefs;
//private int m_articleId;
private String m_sessionId; private String m_sessionId;
private Article m_article; private Article m_article;
@ -38,7 +37,8 @@ public class ArticleFragment extends Fragment implements View.OnClickListener {
TextView title = (TextView)view.findViewById(R.id.title); TextView title = (TextView)view.findViewById(R.id.title);
if (title != null) { if (title != null) {
title.setText(m_article.title); title.setText(Html.fromHtml("<a href=\""+URLEncoder.encode(m_article.link)+"\">" + m_article.title + "</a>"));
title.setMovementMethod(LinkMovementMethod.getInstance());
} }
WebView web = (WebView)view.findViewById(R.id.content); WebView web = (WebView)view.findViewById(R.id.content);
@ -46,6 +46,7 @@ public class ArticleFragment extends Fragment implements View.OnClickListener {
if (web != null) { if (web != null) {
// this is ridiculous // this is ridiculous
// TODO white on black style for dark theme
String content = URLEncoder.encode("<html>" + String content = URLEncoder.encode("<html>" +
"<head><style type=\"text/css\">img { max-width : 90%; }</style></head>" + "<head><style type=\"text/css\">img { max-width : 90%; }</style></head>" +
"<body>" + m_article.content + "</body></html>").replace('+', ' '); "<body>" + m_article.content + "</body></html>").replace('+', ' ');
@ -53,11 +54,6 @@ public class ArticleFragment extends Fragment implements View.OnClickListener {
web.loadData(content, "text/html", "utf-8"); web.loadData(content, "text/html", "utf-8");
} }
Button btn = (Button)view.findViewById(R.id.close_button);
if (btn != null) {
btn.setOnClickListener(this);
}
} }
return view; return view;
@ -86,11 +82,4 @@ public class ArticleFragment extends Fragment implements View.OnClickListener {
//m_prefs = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()); //m_prefs = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext());
} }
@Override
public void onClick(View v) {
getActivity().findViewById(R.id.article_fragment).setVisibility(View.GONE);
getActivity().findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
}
} }

View File

@ -12,11 +12,9 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;

View File

@ -19,6 +19,7 @@ import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
@ -26,6 +27,7 @@ import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
@ -285,6 +287,22 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
tt.setText(article.title); tt.setText(article.title);
} }
ImageView marked = (ImageView)v.findViewById(R.id.marked);
if (marked != null) {
marked.setImageResource(article.marked ? android.R.drawable.star_on : android.R.drawable.star_off);
marked.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "Marked image clicked " + v + " / " + article.id + "/" + article.marked);
article.marked = !article.marked;
m_adapter.notifyDataSetChanged();
}
});
}
TextView te = (TextView)v.findViewById(R.id.excerpt); TextView te = (TextView)v.findViewById(R.id.excerpt);
if (te != null) { if (te != null) {

View File

@ -191,6 +191,9 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
case R.id.login: case R.id.login:
login(); login();
return true; return true;
case R.id.close_article:
closeArticle();
return true;
case R.id.show_feeds: case R.id.show_feeds:
if (getUnreadOnly()) { if (getUnreadOnly()) {
item.setTitle(R.string.menu_unread_feeds); item.setTitle(R.string.menu_unread_feeds);
@ -205,6 +208,16 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
} }
} }
public void closeArticle() {
findViewById(R.id.article_fragment).setVisibility(View.GONE);
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
if (m_menu != null)
m_menu.findItem(R.id.close_article).setVisible(false);
m_selectedArticle = null;
}
private class LoginRequest extends ApiRequest { private class LoginRequest extends ApiRequest {
protected void onPostExecute(JsonElement result) { protected void onPostExecute(JsonElement result) {
@ -316,6 +329,9 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
if (m_menu != null)
m_menu.findItem(R.id.close_article).setVisible(true);
} }
public Feed getActiveFeed() { public Feed getActiveFeed() {
@ -327,9 +343,11 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
findViewById(R.id.main).setVisibility(View.INVISIBLE); findViewById(R.id.main).setVisibility(View.INVISIBLE);
if (m_menu != null) { if (m_menu != null) {
m_menu.findItem(R.id.login).setVisible(true);
m_menu.findItem(R.id.logout).setVisible(false); m_menu.findItem(R.id.logout).setVisible(false);
m_menu.findItem(R.id.update).setVisible(false); m_menu.findItem(R.id.update).setVisible(false);
m_menu.findItem(R.id.show_feeds).setVisible(false); m_menu.findItem(R.id.show_feeds).setVisible(false);
m_menu.findItem(R.id.close_article).setVisible(false);
} }
if (m_refreshTask != null) { if (m_refreshTask != null) {