fixed crashes when opening maps

updated version code
This commit is contained in:
Mariotaku Lee 2015-04-27 01:22:06 +08:00
parent c40835b7c9
commit f99df87959
7 changed files with 28 additions and 44 deletions

View File

@ -11,7 +11,7 @@ android {
applicationId "org.mariotaku.twidere"
minSdkVersion 14
targetSdkVersion 22
versionCode 110
versionCode 111
versionName "0.3.0"
multiDexEnabled true
}

View File

@ -25,7 +25,7 @@
android:name=".activity.support.OpenStreetMapViewerActivity"
android:exported="false"
android:label="@string/view_map"
android:theme="@style/Theme.Blank">
android:theme="@style/Theme.Twidere.Dark.DialogWhenLarge">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

View File

@ -31,7 +31,6 @@ import android.view.MenuItem;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.ThemeUtils;
import org.osmdroid.ResourceProxy;
import org.osmdroid.api.IMapController;
import org.osmdroid.api.IMapView;
@ -44,21 +43,11 @@ import org.osmdroid.views.overlay.OverlayItem;
import java.util.ArrayList;
import java.util.List;
public class OpenStreetMapViewerActivity extends ThemedAppCompatActivity implements Constants {
public class OpenStreetMapViewerActivity extends BaseDialogWhenLargeActivity implements Constants {
private MapView mMapView;
private double mLatitude, mLongitude;
@Override
public int getThemeColor() {
return ThemeUtils.getUserAccentColor(this);
}
@Override
public int getThemeResourceId() {
return ThemeUtils.getViewerThemeResource(this);
}
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_osm_viewer, menu);
@ -95,6 +84,7 @@ public class OpenStreetMapViewerActivity extends ThemedAppCompatActivity impleme
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_osm_viewer);
final Uri uri = getIntent().getData();
if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) {
finish();
@ -112,7 +102,6 @@ public class OpenStreetMapViewerActivity extends ThemedAppCompatActivity impleme
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
setContentView(R.layout.activity_osm_viewer);
mMapView.setMultiTouchControls(true);
mMapView.setBuiltInZoomControls(true);
mMapView.setTilesScaledToDpi(true);

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
@ -18,13 +17,15 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.mariotaku.twidere.view.TintedStatusFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
app:setPadding="true"
android:layout_height="match_parent">
<org.osmdroid.views.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tilesource="Mapnik"/>
</merge>
tilesource="Mapnik" />
</org.mariotaku.twidere.view.TintedStatusFrameLayout>

View File

@ -16,7 +16,7 @@
android:name=".activity.support.GoogleMapViewerActivity"
android:exported="false"
android:label="@string/view_map"
android:theme="@style/Theme.Blank">
android:theme="@style/Theme.Twidere.Dark.DialogWhenLarge">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

View File

@ -36,19 +36,8 @@ import org.mariotaku.twidere.fragment.iface.IMapFragment;
import org.mariotaku.twidere.fragment.support.GoogleMapFragment;
import org.mariotaku.twidere.fragment.support.WebMapFragment;
import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.ThemeUtils;
public class GoogleMapViewerActivity extends ThemedAppCompatActivity implements Constants {
@Override
public int getThemeColor() {
return ThemeUtils.getUserAccentColor(this);
}
@Override
public int getThemeResourceId() {
return ThemeUtils.getViewerThemeResource(this);
}
public class GoogleMapViewerActivity extends BaseDialogWhenLargeActivity implements Constants {
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
@ -64,11 +53,10 @@ public class GoogleMapViewerActivity extends ThemedAppCompatActivity implements
break;
}
case MENU_CENTER: {
final Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
if (!(fragment instanceof IMapFragment)) {
break;
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.main_content);
if ((fragment instanceof IMapFragment)) {
((IMapFragment) fragment).center();
}
((IMapFragment) fragment).center();
break;
}
}
@ -78,6 +66,8 @@ public class GoogleMapViewerActivity extends ThemedAppCompatActivity implements
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content_fragment);
getMainContent().setSetPaddingEnabled(true);
final Uri uri = getIntent().getData();
if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) {
finish();
@ -104,7 +94,7 @@ public class GoogleMapViewerActivity extends ThemedAppCompatActivity implements
final Fragment fragment = isNativeMapSupported() ? new GoogleMapFragment() : new WebMapFragment();
fragment.setArguments(bundle);
final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(android.R.id.content, fragment).commit();
ft.replace(R.id.main_content, fragment).commit();
}
private boolean isNativeMapSupported() {

View File

@ -38,7 +38,7 @@ import org.mariotaku.twidere.util.Utils;
public class TintedStatusFrameLayout extends ExtendedFrameLayout {
private final Paint mBlackPaint, mShadowPaint, mColorPaint;
private final boolean mSetPadding;
private boolean mSetPadding;
private int mStatusBarHeight;
private float mFactor;
@ -55,13 +55,13 @@ public class TintedStatusFrameLayout extends ExtendedFrameLayout {
public TintedStatusFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TintedStatusLayout);
mSetPadding = a.getBoolean(R.styleable.TintedStatusLayout_setPadding, false);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TintedStatusLayout);
setSetPaddingEnabled(a.getBoolean(R.styleable.TintedStatusLayout_setPadding, false));
a.recycle();
mBlackPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBlackPaint.setColor(Color.BLACK);
mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
a.recycle();
setWillNotDraw(false);
setFactor(1);
}
@ -129,4 +129,8 @@ public class TintedStatusFrameLayout extends ExtendedFrameLayout {
mColorPaint.setAlpha(Math.round(0xFF * MathUtils.clamp(f, 0, 1)));
invalidate();
}
public void setSetPaddingEnabled(boolean enabled) {
mSetPadding = enabled;
}
}