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" applicationId "org.mariotaku.twidere"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 22 targetSdkVersion 22
versionCode 110 versionCode 111
versionName "0.3.0" versionName "0.3.0"
multiDexEnabled true multiDexEnabled true
} }

View File

@ -25,7 +25,7 @@
android:name=".activity.support.OpenStreetMapViewerActivity" android:name=".activity.support.OpenStreetMapViewerActivity"
android:exported="false" android:exported="false"
android:label="@string/view_map" android:label="@string/view_map"
android:theme="@style/Theme.Blank"> android:theme="@style/Theme.Twidere.Dark.DialogWhenLarge">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW"/> <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.Constants;
import org.mariotaku.twidere.R; import org.mariotaku.twidere.R;
import org.mariotaku.twidere.util.ParseUtils; import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.ThemeUtils;
import org.osmdroid.ResourceProxy; import org.osmdroid.ResourceProxy;
import org.osmdroid.api.IMapController; import org.osmdroid.api.IMapController;
import org.osmdroid.api.IMapView; import org.osmdroid.api.IMapView;
@ -44,21 +43,11 @@ import org.osmdroid.views.overlay.OverlayItem;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class OpenStreetMapViewerActivity extends ThemedAppCompatActivity implements Constants { public class OpenStreetMapViewerActivity extends BaseDialogWhenLargeActivity implements Constants {
private MapView mMapView; private MapView mMapView;
private double mLatitude, mLongitude; private double mLatitude, mLongitude;
@Override
public int getThemeColor() {
return ThemeUtils.getUserAccentColor(this);
}
@Override
public int getThemeResourceId() {
return ThemeUtils.getViewerThemeResource(this);
}
@Override @Override
public boolean onCreateOptionsMenu(final Menu menu) { public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_osm_viewer, menu); getMenuInflater().inflate(R.menu.menu_osm_viewer, menu);
@ -95,6 +84,7 @@ public class OpenStreetMapViewerActivity extends ThemedAppCompatActivity impleme
@Override @Override
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_osm_viewer);
final Uri uri = getIntent().getData(); final Uri uri = getIntent().getData();
if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) { if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) {
finish(); finish();
@ -112,7 +102,6 @@ public class OpenStreetMapViewerActivity extends ThemedAppCompatActivity impleme
if (actionBar != null) { if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
} }
setContentView(R.layout.activity_osm_viewer);
mMapView.setMultiTouchControls(true); mMapView.setMultiTouchControls(true);
mMapView.setBuiltInZoomControls(true); mMapView.setBuiltInZoomControls(true);
mMapView.setTilesScaledToDpi(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 ~ Twidere - Twitter client for Android
~ ~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com> ~ 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/>. ~ along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<merge xmlns:android="http://schemas.android.com/apk/res/android" <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" android:layout_width="match_parent"
app:setPadding="true"
android:layout_height="match_parent"> android:layout_height="match_parent">
<org.osmdroid.views.MapView <org.osmdroid.views.MapView
android:id="@+id/map_view" android:id="@+id/map_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tilesource="Mapnik"/> tilesource="Mapnik" />
</merge> </org.mariotaku.twidere.view.TintedStatusFrameLayout>

View File

@ -16,7 +16,7 @@
android:name=".activity.support.GoogleMapViewerActivity" android:name=".activity.support.GoogleMapViewerActivity"
android:exported="false" android:exported="false"
android:label="@string/view_map" android:label="@string/view_map"
android:theme="@style/Theme.Blank"> android:theme="@style/Theme.Twidere.Dark.DialogWhenLarge">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW"/> <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.GoogleMapFragment;
import org.mariotaku.twidere.fragment.support.WebMapFragment; import org.mariotaku.twidere.fragment.support.WebMapFragment;
import org.mariotaku.twidere.util.ParseUtils; import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.ThemeUtils;
public class GoogleMapViewerActivity extends ThemedAppCompatActivity implements Constants { public class GoogleMapViewerActivity extends BaseDialogWhenLargeActivity implements Constants {
@Override
public int getThemeColor() {
return ThemeUtils.getUserAccentColor(this);
}
@Override
public int getThemeResourceId() {
return ThemeUtils.getViewerThemeResource(this);
}
@Override @Override
public boolean onCreateOptionsMenu(final Menu menu) { public boolean onCreateOptionsMenu(final Menu menu) {
@ -64,11 +53,10 @@ public class GoogleMapViewerActivity extends ThemedAppCompatActivity implements
break; break;
} }
case MENU_CENTER: { case MENU_CENTER: {
final Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content); final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.main_content);
if (!(fragment instanceof IMapFragment)) { if ((fragment instanceof IMapFragment)) {
break;
}
((IMapFragment) fragment).center(); ((IMapFragment) fragment).center();
}
break; break;
} }
} }
@ -78,6 +66,8 @@ public class GoogleMapViewerActivity extends ThemedAppCompatActivity implements
@Override @Override
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content_fragment);
getMainContent().setSetPaddingEnabled(true);
final Uri uri = getIntent().getData(); final Uri uri = getIntent().getData();
if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) { if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) {
finish(); finish();
@ -104,7 +94,7 @@ public class GoogleMapViewerActivity extends ThemedAppCompatActivity implements
final Fragment fragment = isNativeMapSupported() ? new GoogleMapFragment() : new WebMapFragment(); final Fragment fragment = isNativeMapSupported() ? new GoogleMapFragment() : new WebMapFragment();
fragment.setArguments(bundle); fragment.setArguments(bundle);
final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(android.R.id.content, fragment).commit(); ft.replace(R.id.main_content, fragment).commit();
} }
private boolean isNativeMapSupported() { private boolean isNativeMapSupported() {

View File

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