[yota] New UI

This commit is contained in:
Dmitry Kunin 2013-09-06 20:00:22 +03:00 committed by Alex Zolotarev
parent b9fd4c6560
commit c10bbe63e4
31 changed files with 364 additions and 144 deletions

View file

@ -15,21 +15,22 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:icon="@drawable/ic_app"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="@string/com.yotadevices.BS_TITLE"
android:value="Sample API" />
android:value="@string/app_name" />
<meta-data
android:name="@string/com.yotadevices.BS_ICON"
android:resource="@drawable/ic_launcher" />
android:resource="@drawable/inc_icon" />
<activity
android:name="com.mapswithme.yopme.YopmeFrontActivity"
android:configChanges="keyboardHidden|screenSize|orientation"
android:label="@string/app_name"
android:launchMode="singleTop" >
android:launchMode="singleTop"
android:screenOrientation="sensorPortrait" >
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
@ -44,6 +45,16 @@
<uses-library
android:name="com.yotadevices.platinum" />
<activity
android:name="com.mapswithme.yopme.ReferenceActivity"
android:label="@string/title_activity_reference"
android:parentActivityName="com.mapswithme.yopme.YopmeFrontActivity"
android:screenOrientation="sensorPortrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapswithme.yopme.YopmeFrontActivity" />
</activity>
</application>
</manifest>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/plashka_pressed" android:state_pressed="true"/>
</selector>

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<color xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#E6FFFFFF" />

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<color xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#E666CCFF" />

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/plashka_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/plashka_background"/>
</selector>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
style="@style/MidText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center_vertical"
android:gravity="center"
android:text="@string/app_name"
android:textSize="@dimen/big_text" />
<ImageView
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:background="@drawable/menu_selector"
android:src="@drawable/ic_menu" />
</FrameLayout>

View file

@ -0,0 +1,14 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0F0F0"
android:gravity="center"
tools:context=".ReferenceActivity" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_help" />
</RelativeLayout>

View file

@ -1,61 +1,79 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".YopmeFrontActivity" >
<Space
android:id="@+id/center"
<FrameLayout
android:id="@+id/me"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_centerInParent="true" />
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/selectPoi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/center"
android:layout_centerHorizontal="true"
android:paddingBottom="@dimen/dimen_4x"
android:paddingLeft="@dimen/dimen_3x"
android:paddingRight="@dimen/dimen_3x"
android:paddingTop="@dimen/dimen_4x"
android:text="@string/select_poi"
android:textSize="@dimen/big_text" />
<RadioGroup
android:id="@+id/mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/center"
android:gravity="center"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/modePoi"
android:layout_width="wrap_content"
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/poi" />
android:layout_gravity="center"
android:src="@drawable/bg_selforiented" />
<RadioButton
android:id="@+id/modeLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/location" />
</RadioGroup>
<LinearLayout
style="@style/Plashka"
android:layout_width="match_parent"
android:layout_height="@dimen/plashka"
android:layout_gravity="bottom|center_horizontal" >
<TextView
<TextView
style="@style/MidText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/self_oriented" />
<TextView
style="@style/SmallText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/your_location_label" />
</LinearLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/poi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/selectPoi"
android:layout_marginTop="@dimen/dimen_4x"
android:gravity="center_horizontal"
android:textSize="@dimen/mid_text" />
android:layout_height="0dp"
android:layout_weight="1" >
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/bg_poioriented" />
<LinearLayout
style="@style/Plashka"
android:layout_width="match_parent"
android:layout_height="@dimen/plashka"
android:layout_gravity="bottom|center_horizontal" >
<TextView
style="@style/MidText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:drawablePadding="@dimen/dimen_3x"
android:drawableRight="@drawable/ic_arrow"
android:text="@string/self_oriented" />
<TextView
android:id="@+id/selectedLocation"
style="@style/SmallText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/take_your_poi" />
</LinearLayout>
</FrameLayout>
</LinearLayout>

View file

@ -1,9 +1,19 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!--
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_menu"
android:orderInCategory="100"
android:showAsAction="always"
android:title="@string/action_settings"/>
android:title="@string/menu_settings"/>
-->
<item
android:id="@+id/menu_help"
android:icon="@drawable/ic_menu"
android:orderInCategory="101"
android:showAsAction="always"
android:title="@string/menu_help"/>
</menu>

View file

@ -1,11 +0,0 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View file

@ -1,12 +0,0 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View file

@ -5,6 +5,7 @@
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="yota_height">640px</dimen>
<dimen name="yota_width">360px</dimen>
<dimen name="plashka">60dp</dimen>
<dimen name="big_text">30sp</dimen>
<dimen name="mid_text">24sp</dimen>
<dimen name="dimen_1x">4dp</dimen>

View file

@ -2,9 +2,12 @@
<resources>
<string name="app_name">YoPme</string>
<string name="action_settings">Settings</string>
<string name="select_poi">Select POI</string>
<string name="poi">POI</string>
<string name="location">Location</string>
<string name="menu_settings">Настройки</string>
<string name="menu_help">Справка</string>
<string name="self_oriented">Ориентация по местоположению</string>
<string name="your_location_label">В центре экрана будет показано ваше местоположение</string>
<string name="take_your_poi">Выберите любое место</string>
<string name="title_activity_reference">YoPme</string>
<string name="action_settings">Настройки</string>
</resources>

View file

@ -1,20 +1,32 @@
<resources>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">@style/Ink.ActionBar</item>
<item name="android:icon">@null</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<style name="Ink.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid"></style>
<style name="Plashka">
<item name="android:background">@drawable/plashka_selector</item>
<item name="android:duplicateParentState">true</item>
<item name="android:gravity">center_vertical|left</item>
<item name="android:orientation">vertical</item>
<item name="android:paddingLeft">@dimen/dimen_4x</item>
<item name="android:paddingRight">@dimen/dimen_4x</item>
</style>
</resources>
<style name="SmallText">
<item name="android:textSize">12sp</item>
<item name="android:textColor">#666666</item>
<item name="android:fontFamily">"sans-serif"</item>
</style>
<style name="MidText" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#333333</item>
<item name="android:fontFamily">"sans-serif-light"</item>
<item name="android:textStyle">normal</item>
</style>
</resources>

View file

@ -0,0 +1,82 @@
package com.mapswithme.location;
import android.app.PendingIntent;
import android.content.Context;
import android.location.LocationManager;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
public class LocationRequester implements Handler.Callback
{
private final static String TAG = LocationRequester.class.getSimpleName();
protected Context mContext;
protected LocationManager mLocationManager;
protected Handler mDelayedEventsHandler;
protected String[] mEnabledProviders = {
LocationManager.GPS_PROVIDER,
LocationManager.NETWORK_PROVIDER,
LocationManager.PASSIVE_PROVIDER,
}; // all of them are enabled by default
private final static int WHAT_LOCATION_REQUEST_CANCELATION = 0x01;
public LocationRequester(Context context)
{
mContext = context.getApplicationContext();
mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
mDelayedEventsHandler = new Handler(this);
}
public boolean requestSingleUpdate(PendingIntent pi)
{
return false;
}
public boolean requestSingleUpdate(PendingIntent pi, long maxTimeToDeliver)
{
if (mEnabledProviders.length > 0)
{
for (final String provider : mEnabledProviders)
{
if (mLocationManager.isProviderEnabled(provider))
mLocationManager.requestSingleUpdate(provider, pi);
}
if (maxTimeToDeliver > 0)
postRequestCancelation(pi, maxTimeToDeliver);
return true;
}
return false;
}
public void removeUpdates(PendingIntent pi)
{
mLocationManager.removeUpdates(pi);
}
private void postRequestCancelation(PendingIntent pi, long maxTimeToDeliver)
{
final Message msg =
mDelayedEventsHandler.obtainMessage(WHAT_LOCATION_REQUEST_CANCELATION);
msg.obj = pi;
mDelayedEventsHandler.sendMessageDelayed(msg, maxTimeToDeliver);
Log.d(TAG, "Posted request cancelation for " + pi + "in " + maxTimeToDeliver + "ms");
}
@Override
public boolean handleMessage(Message msg)
{
if (msg.what == WHAT_LOCATION_REQUEST_CANCELATION)
{
final PendingIntent pi = (PendingIntent) msg.obj;
removeUpdates(pi);
return true;
}
return false;
}
}

View file

@ -0,0 +1,16 @@
package com.mapswithme.yopme;
import android.os.Bundle;
import android.app.Activity;
public class ReferenceActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reference);
}
}

View file

@ -6,24 +6,24 @@ import com.mapswithme.maps.api.MapsWithMeApi;
import com.mapswithme.yopme.BackscreenActivity.Mode;
import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TextView;
public class YopmeFrontActivity extends Activity
implements OnClickListener, OnCheckedChangeListener
implements OnClickListener
{
private RadioGroup mModeGroup;
private Button mSelectPoi;
private TextView mPoiText;
private TextView mSelectedLocation;
private View mMenu;
private Mode mMode;
private final static String KEY_MODE = "key.mode";
@ -45,6 +45,13 @@ public class YopmeFrontActivity extends Activity
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_yopme_main);
final ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.action_bar_view);
setUpView();
//restore
@ -56,13 +63,13 @@ public class YopmeFrontActivity extends Activity
if (Mode.LOCATION == mMode)
setLocationView();
else if (Mode.POI == mMode)
{
setPoiView();
mPoiText.setText(mPoint.getName());
}
mSelectedLocation.setText(mPoint.getName());
}
setUpListeners();
if (isIntroNeeded())
showIntro();
}
@Override
@ -76,7 +83,7 @@ public class YopmeFrontActivity extends Activity
if (response.hasPoint())
{
mPoint = response.getPoint();
mPoiText.setText(mPoint.getName());
mSelectedLocation.setText(mPoint.getName());
BackscreenActivity.startInMode(this, Mode.POI, mPoint);
}
@ -85,28 +92,46 @@ public class YopmeFrontActivity extends Activity
private void setUpView()
{
mModeGroup = (RadioGroup) findViewById(R.id.mode);
mSelectPoi = (Button) findViewById(R.id.selectPoi);
mPoiText = (TextView) findViewById(R.id.poi);
mSelectedLocation = (TextView) findViewById(R.id.selectedLocation);
mMenu = findViewById(R.id.menu);
}
private void setUpListeners()
{
mModeGroup.setOnCheckedChangeListener(this);
mSelectPoi.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.yopme_main, menu);
return true;
findViewById(R.id.poi).setOnClickListener(this);
findViewById(R.id.me).setOnClickListener(this);
mMenu.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
MapsWithMeApi.pickPoint(this, "Pick point", getPickPointPendingIntent());
if (R.id.me == v.getId())
{
BackscreenActivity.startInMode(getApplicationContext(), Mode.LOCATION, null);
setLocationView();
}
else if (R.id.poi == v.getId())
MapsWithMeApi.pickPoint(this, "Pick point", getPickPointPendingIntent());
else if (R.id.menu == v.getId())
{
final PopupMenu popupMenu = new PopupMenu(this, mMenu);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener()
{
@Override
public boolean onMenuItemClick(MenuItem item)
{
if (item.getItemId() == R.id.menu_help)
{
startActivity(new Intent(getApplicationContext(), ReferenceActivity.class));
return true;
}
return false;
}
});
popupMenu.inflate(R.menu.yopme_main);
popupMenu.show();
}
}
private final static String EXTRA_PICK = ".pick_point";
@ -117,29 +142,38 @@ public class YopmeFrontActivity extends Activity
return PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId)
{
if (checkedId == R.id.modeLocation)
{
BackscreenActivity.startInMode(getApplicationContext(), Mode.LOCATION, null);
setLocationView();
}
else if (checkedId == R.id.modePoi)
setPoiView();
}
private void setPoiView()
{
mPoiText.setVisibility(View.VISIBLE);
mPoiText.setText(null);
mSelectPoi.setEnabled(true);
}
private void setLocationView()
{
mPoiText.setVisibility(View.GONE);
mPoiText.setText(null);
mSelectPoi.setEnabled(false);
mSelectedLocation.setText(getString(R.string.take_your_poi));
}
ImageView mIntro;
private void showIntro()
{
mIntro = new ImageView(this);
mIntro.setImageResource(R.drawable.introduction);
((ViewGroup)getWindow().getDecorView()).addView(mIntro);
mIntro.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
mIntro.setVisibility(View.GONE);
markIntroShown();
}
});
}
private final static String PREFS = "prefs.xml";
private final static String KEY_INTRO = "intro";
private boolean isIntroNeeded()
{
return getSharedPreferences(PREFS, 0).getBoolean(KEY_INTRO, true);
}
private void markIntroShown()
{
getSharedPreferences(PREFS, 0).edit().putBoolean(KEY_INTRO, false).apply();
}
}