Merge pull request #48 from deathbaba/android-titles-fix
Android fixes from todo
This commit is contained in:
commit
56f2bd91aa
14 changed files with 132 additions and 70 deletions
|
@ -53,7 +53,7 @@
|
|||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.guidewithme.ArticleInfoListActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:hardwareAccelerated="true"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="adjustResize" >
|
||||
|
|
|
@ -103,13 +103,17 @@ jobject NativeArticle2JavaArticle(JNIEnv * env, ArticleInfo const * p)
|
|||
jclass ArtInfoClass = env->FindClass("com/guidewithme/article/ArticleInfo");
|
||||
jmethodID initId = env->GetMethodID(ArtInfoClass, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;DD)V");
|
||||
|
||||
double lat = -1000;
|
||||
double lon = -1000;
|
||||
p->GetLatLon(lat, lon);
|
||||
|
||||
return env->NewObject(ArtInfoClass, initId,
|
||||
StdString2JString(env, p->GetUrl()),
|
||||
StdString2JString(env, p->GetThumbnailUrl()),
|
||||
StdString2JString(env, p->GetTitle()),
|
||||
StdString2JString(env, STORAGE.GetParentName(*p)),
|
||||
p->m_lat,
|
||||
p->m_lon);
|
||||
lat,
|
||||
lon);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -7,17 +7,6 @@
|
|||
android:showDividers="middle"
|
||||
tools:context=".ArticleInfoListActivity" >
|
||||
|
||||
<!--
|
||||
This layout is a two-pane layout for the ArticleInfos
|
||||
master/detail flow. See res/values-large/refs.xml and
|
||||
res/values-sw600dp/refs.xml for an example of layout aliases
|
||||
that replace the single-pane version of the layout with
|
||||
this two-pane version.
|
||||
|
||||
For more on layout aliases, see:
|
||||
http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
|
||||
-->
|
||||
|
||||
<fragment
|
||||
android:id="@+id/articleinfo_list"
|
||||
android:name="com.guidewithme.ArticleInfoListFragment"
|
29
android/res/layout-port/activity_articleinfo_twopane.xml
Normal file
29
android/res/layout-port/activity_articleinfo_twopane.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<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:baselineAligned="false"
|
||||
android:orientation="horizontal"
|
||||
android:showDividers="middle"
|
||||
tools:context=".ArticleInfoListActivity" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/articleinfo_detail_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#c0000000" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/articleinfo_list"
|
||||
android:name="com.guidewithme.ArticleInfoListFragment"
|
||||
android:layout_width="@dimen/searchPanelWidth"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
tools:layout="@android:layout/list_content" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -12,9 +12,14 @@
|
|||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@android:style/TextAppearance.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginLeft="60dp"
|
||||
android:layout_marginRight="60dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/yellow"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
@ -34,6 +39,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<com.guidewithme.webkit.TgWebView
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<dimen name="searchPanelWidth">400dp</dimen>
|
||||
|
||||
<dimen name="listitem_size">94dp</dimen>
|
||||
<dimen name="thumb_size">84dp</dimen>
|
||||
<dimen name="search_bar">70dp</dimen>
|
||||
<dimen name="search_text">50dp</dimen>
|
||||
<dimen name="pad_mid">12dp</dimen>
|
||||
<dimen name="pad_small">6dp</dimen>
|
||||
<dimen name="thumb_sep">5dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -1,12 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Layout alias to replace the single-pane version of the layout with a
|
||||
two-pane version on Large screens.
|
||||
|
||||
For more on layout aliases, see:
|
||||
http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
|
||||
-->
|
||||
<item name="activity_articleinfo_list" type="layout">@layout/activity_articleinfo_twopane</item>
|
||||
|
||||
</resources>
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
|
||||
<dimen name="searchPanelWidth">400dp</dimen>
|
||||
|
||||
<dimen name="listitem_size">94dp</dimen>
|
||||
<dimen name="thumb_size">84dp</dimen>
|
||||
<dimen name="search_bar">70dp</dimen>
|
||||
<dimen name="search_text">50dp</dimen>
|
||||
<dimen name="pad_mid">12dp</dimen>
|
||||
<dimen name="pad_small">6dp</dimen>
|
||||
<dimen name="thumb_sep">5dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
||||
</resources>
|
|
@ -1,9 +1,5 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
|
||||
-->
|
||||
<dimen name="activity_horizontal_margin">128dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<dimen name="pad_mid">8dp</dimen>
|
||||
<dimen name="pad_small">4dp</dimen>
|
||||
<dimen name="thumb_sep">3dp</dimen>
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="activity_horizontal_margin">0dp</dimen>
|
||||
<dimen name="activity_vertical_margin">0dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -8,6 +8,7 @@ import android.graphics.Bitmap;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -39,7 +40,7 @@ public class ArticleInfoDetailFragment extends Fragment
|
|||
|
||||
public static final String ARTICLE_INFO = "article_info";
|
||||
|
||||
private ArticleInfo mItem;
|
||||
private static ArticleInfo mItem;
|
||||
|
||||
private View mRootView;
|
||||
private WebView mWebView;
|
||||
|
@ -65,12 +66,22 @@ public class ArticleInfoDetailFragment extends Fragment
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Bundle args = getArguments();
|
||||
|
||||
if (args != null && args.containsKey(ARTICLE_INFO))
|
||||
mItem = (ArticleInfo) args.getSerializable(ARTICLE_INFO);
|
||||
else if (savedInstanceState != null && savedInstanceState.containsKey(ARTICLE_INFO))
|
||||
mItem = (ArticleInfo) savedInstanceState.getSerializable(ARTICLE_INFO);
|
||||
|
||||
mFinder = new ObbPathFinder(getActivity().getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState)
|
||||
{
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putSerializable(ARTICLE_INFO, mItem);
|
||||
}
|
||||
|
||||
public void setArticleInfo(ArticleInfo info)
|
||||
{
|
||||
mItem = info;
|
||||
|
|
|
@ -6,12 +6,14 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import com.guidewithme.article.ArticleInfo;
|
||||
import com.guidewithme.cpp.Storage;
|
||||
import com.guidewithme.util.Utils;
|
||||
import com.mapswithme.maps.api.MWMPoint;
|
||||
import com.mapswithme.maps.api.MWMResponse;
|
||||
import com.guidewithme.R;
|
||||
|
||||
/**
|
||||
* An activity representing a list of ArticleInfos. This activity has different
|
||||
|
@ -45,6 +47,8 @@ public class ArticleInfoListActivity extends FragmentActivity
|
|||
private ArticleInfoListFragment mArtInfoListFragment;
|
||||
private ArticleInfoDetailFragment mArtInfoDetailFragment;
|
||||
|
||||
private View mShadow;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
|
@ -59,6 +63,17 @@ public class ArticleInfoListActivity extends FragmentActivity
|
|||
{
|
||||
mTwoPane = true;
|
||||
|
||||
mShadow = findViewById(R.id.shadow);
|
||||
if (mShadow != null)
|
||||
mShadow.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
toogleListVisible();
|
||||
}
|
||||
});
|
||||
|
||||
mArtInfoListFragment.setActivateOnItemClick(true);
|
||||
mArtInfoListFragment.setOnFirstLoadListener(this);
|
||||
mArtInfoListFragment.setHeaderVisible(false);
|
||||
|
@ -70,11 +85,26 @@ public class ArticleInfoListActivity extends FragmentActivity
|
|||
.beginTransaction()
|
||||
.add(R.id.articleinfo_detail_container, mArtInfoDetailFragment)
|
||||
.commit();
|
||||
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey(LIST_VISIBLE))
|
||||
if (savedInstanceState.getBoolean(LIST_VISIBLE, true))
|
||||
showList();
|
||||
else
|
||||
hideList();
|
||||
|
||||
}
|
||||
|
||||
handleIntent(getIntent());
|
||||
}
|
||||
|
||||
private static final String LIST_VISIBLE = ".list_visible";
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState)
|
||||
{
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(LIST_VISIBLE, mArtInfoListFragment.isVisible());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent)
|
||||
{
|
||||
|
@ -94,22 +124,18 @@ public class ArticleInfoListActivity extends FragmentActivity
|
|||
{
|
||||
final String id = point.getId();
|
||||
Log.d(TAG, id);
|
||||
// final Storage storage = new Storage(getAssets());
|
||||
// storage.create();
|
||||
onItemSelected(Storage.get(this).getArticleInfoByUrl(id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback method from {@link ArticleInfoListFragment.Callbacks} indicating
|
||||
* that the item with the given ID was selected.
|
||||
*/
|
||||
@Override
|
||||
public void onItemSelected(ArticleInfo info)
|
||||
{
|
||||
if (mTwoPane)
|
||||
{
|
||||
mArtInfoDetailFragment.setArticleInfo(info);
|
||||
if (mShadow != null)
|
||||
hideList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -128,16 +154,32 @@ public class ArticleInfoListActivity extends FragmentActivity
|
|||
public void toogleListVisible()
|
||||
{
|
||||
if (mArtInfoListFragment.isVisible())
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.hide(mArtInfoListFragment)
|
||||
.commit();
|
||||
hideList();
|
||||
else
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right)
|
||||
.show(mArtInfoListFragment)
|
||||
.commit();
|
||||
showList();
|
||||
}
|
||||
|
||||
private void hideList()
|
||||
{
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.hide(mArtInfoListFragment)
|
||||
.commit();
|
||||
|
||||
if (mShadow != null)
|
||||
Utils.fadeOut(this, mShadow);
|
||||
}
|
||||
|
||||
private void showList()
|
||||
{
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right)
|
||||
.show(mArtInfoListFragment)
|
||||
.commit();
|
||||
|
||||
if (mShadow != null)
|
||||
Utils.fadeIn(this, mShadow);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ArticleInfoListFragment extends ListFragment
|
|||
}
|
||||
|
||||
private OnFirstLoadListener mOnFirstLoad;
|
||||
private boolean mFirstLoad = true;
|
||||
private static boolean mFirstLoad = true;
|
||||
|
||||
public void setOnFirstLoadListener(OnFirstLoadListener listener)
|
||||
{
|
||||
|
@ -217,7 +217,6 @@ public class ArticleInfoListFragment extends ListFragment
|
|||
{
|
||||
getListView().setItemChecked(position, true);
|
||||
}
|
||||
|
||||
mActivatedPosition = position;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,17 @@ public:
|
|||
void Write(wr::Writer & w) const;
|
||||
void Read(rd::Reader & r);
|
||||
|
||||
bool GetLatLon(double & lat, double & lon) const
|
||||
{
|
||||
if (IsValidCoordinates())
|
||||
{
|
||||
lat = m_lat;
|
||||
lon = m_lon;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Calculate score for info. Less is better.
|
||||
double Score(double currLat, double currLon) const;
|
||||
|
||||
|
|
Reference in a new issue