[android] pre-honeycomb UI improvements.

This commit is contained in:
Dmitry Kunin 2013-05-03 16:11:23 +03:00 committed by Alex Zolotarev
parent 54fcd34b43
commit 5cef11e2de
5 changed files with 116 additions and 7 deletions

View file

@ -16,7 +16,8 @@
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout
android:layout_width="fill_parent"
@ -97,10 +98,10 @@
<include
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/disclosure_image_color"
layout="@layout/color_row"
android:clickable="false"
android:focusable="false"
android:layout_toLeftOf="@+id/disclosure_image_color"/>
android:focusable="false" />
<ImageView
android:id="@+id/disclosure_image_color"
@ -142,8 +143,28 @@
android:layout_margin="5dp"
android:onClick="onDeleteClick"
android:text="@string/remove_pin" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/compat_btns_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0" >
<Button
android:id="@+id/btn_share_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/share_by_email" />
<Button
android:id="@+id/btn_share_any"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/share" />
</LinearLayout>
</LinearLayout>

View file

@ -23,12 +23,14 @@
android:layout_height="wrap_content"
android:text="@string/bookmarks" />
<!-- <Button
<!--
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:onClick="onSendEMail"
android:text="@string/share_by_email" /> -->
android:text="@string/share_by_email" />
-->
<TextView
android:id="@+id/bookmark_usage_hint"
@ -40,7 +42,16 @@
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
<Button
android:id="@+id/btn_share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="@string/share_by_email"
android:drawableLeft="@android:drawable/ic_menu_share"/>
</LinearLayout>

View file

@ -11,7 +11,9 @@ import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
@ -61,6 +63,57 @@ public class BookmarkActivity extends AbstractBookmarkActivity
setTitle(mPin.getName());
setUpViews();
adaptUiForOsVersion();
}
private void adaptUiForOsVersion()
{
ViewGroup compatBtns = (ViewGroup) findViewById(R.id.compat_btns_bar);
if (Utils.apiLowerThan(11))
{
Button shareEmailBtn = (Button) compatBtns.findViewById(R.id.btn_share_email);
if (ShareAction.getEmailShare().isSupported(this))
{
shareEmailBtn.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
assignPinParams();
ShareAction.getEmailShare().shareBookmark(BookmarkActivity.this, mPin);
}
});
}
else
{
shareEmailBtn.setVisibility(View.GONE);
}
Button shareAnyBtn = (Button) compatBtns.findViewById(R.id.btn_share_any);
if (ShareAction.getAnyShare().isSupported(this))
{
shareAnyBtn.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
assignPinParams();
ShareAction.getAnyShare().shareBookmark(BookmarkActivity.this, mPin);
}
});
}
else
{
shareAnyBtn.setVisibility(View.GONE);
}
}
else
{
compatBtns.setVisibility(View.GONE);
}
}
private void updateColorChooser(Icon icon)

View file

@ -13,8 +13,10 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import com.mapswithme.maps.MWMActivity;
@ -66,6 +68,23 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
}
});
registerForContextMenu(getListView());
adaptUiForOsVersion();
}
private void adaptUiForOsVersion()
{
final Button shareButton = (Button) findViewById(R.id.btn_share);
if (Utils.apiLowerThan(11))
{
shareButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) { onSendEMail(shareButton); }
});
}
else
shareButton.setVisibility(View.GONE);
}
private void createListAdapter()

View file

@ -120,6 +120,11 @@ public class Utils
return Build.VERSION.SDK_INT >= api;
}
public static boolean apiLowerThan(int api)
{
return Build.VERSION.SDK_INT < api;
}
public static void checkNotNull(Object object)
{
if (null == object) throw new NullPointerException("Argument here must not be NULL");