Merge remote-tracking branch 'refs/remotes/commons-app/master'
|
|
@ -1,7 +1,9 @@
|
|||
package fr.free.nrw.commons;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||
|
|
@ -306,4 +308,12 @@ public class Utils {
|
|||
public static boolean isNullOrWhiteSpace(String value) {
|
||||
return value == null || value.trim().isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isDarkTheme(Context context) {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("theme",true)) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.nearby;
|
|||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
|
@ -71,6 +72,11 @@ public class NearbyActivity extends BaseActivity {
|
|||
return true;
|
||||
case R.id.action_map:
|
||||
showMapView();
|
||||
if (isMapViewActive) {
|
||||
item.setIcon(R.drawable.ic_list_white_24dp);
|
||||
} else {
|
||||
item.setIcon(R.drawable.ic_map_white_24dp);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
|
@ -83,6 +89,12 @@ public class NearbyActivity extends BaseActivity {
|
|||
if (nearbyAsyncTask.getStatus() == AsyncTask.Status.FINISHED) {
|
||||
setMapFragment();
|
||||
}
|
||||
|
||||
} else {
|
||||
isMapViewActive = false;
|
||||
if (nearbyAsyncTask.getStatus() == AsyncTask.Status.FINISHED) {
|
||||
setListFragment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,22 +172,21 @@ public class NearbyActivity extends BaseActivity {
|
|||
* Calls fragment for map view.
|
||||
*/
|
||||
public void setMapFragment() {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
NearbyMapFragment fragment = new NearbyMapFragment();
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
Fragment fragment = new NearbyMapFragment();
|
||||
fragment.setArguments(bundle);
|
||||
ft.add(R.id.container, fragment);
|
||||
ft.commit();
|
||||
fragmentTransaction.replace(R.id.container, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls fragment for list view.
|
||||
*/
|
||||
public void setListFragment() {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
NearbyListFragment fragment = new NearbyListFragment();
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
Fragment fragment = new NearbyListFragment();
|
||||
fragment.setArguments(bundle);
|
||||
ft.add(R.id.container, fragment);
|
||||
ft.commit();
|
||||
fragmentTransaction.replace(R.id.container, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,4 +107,9 @@ public class NearbyInfoDialog extends OverlayDialog {
|
|||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, articleLink);
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
|
||||
@OnClick(R.id.emptyLayout)
|
||||
void onCloseClicked() {
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,17 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
if (curLatLng != null) {
|
||||
setupMapView(savedInstanceState);
|
||||
}
|
||||
|
||||
setHasOptionsMenu(false);
|
||||
|
||||
return mapView;
|
||||
}
|
||||
|
||||
private void setupMapView(Bundle savedInstanceState) {
|
||||
MapboxMapOptions options = new MapboxMapOptions()
|
||||
.styleUrl(Style.OUTDOORS)
|
||||
.camera(new CameraPosition.Builder()
|
||||
|
|
@ -99,10 +110,6 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
} else {
|
||||
mapView.setStyleUrl(getResources().getString(R.string.map_theme_light));
|
||||
}
|
||||
|
||||
setHasOptionsMenu(false);
|
||||
|
||||
return mapView;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -112,31 +119,41 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
|
||||
@Override
|
||||
public void onStart() {
|
||||
mapView.onStart();
|
||||
if (mapView != null) {
|
||||
mapView.onStart();
|
||||
}
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mapView.onPause();
|
||||
if (mapView != null) {
|
||||
mapView.onPause();
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
mapView.onResume();
|
||||
if (mapView != null) {
|
||||
mapView.onResume();
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mapView.onStop();
|
||||
if (mapView != null) {
|
||||
mapView.onStop();
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
mapView.onDestroy();
|
||||
if (mapView != null) {
|
||||
mapView.onDestroy();
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,16 +6,17 @@ import android.preference.PreferenceManager;
|
|||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
|
||||
public class BaseActivity extends AppCompatActivity {
|
||||
boolean currentTheme;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",true)) {
|
||||
if(Utils.isDarkTheme(this)){
|
||||
currentTheme = true;
|
||||
setTheme(R.style.DarkAppTheme);
|
||||
}else {
|
||||
} else {
|
||||
currentTheme = false;
|
||||
setTheme(R.style.LightAppTheme); // default
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,12 @@ import android.view.View;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
|
||||
public abstract class OverlayDialog extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setStyle(STYLE_NORMAL, R.style.borderless_dialog);
|
||||
setStyle(STYLE_NO_FRAME, android.R.style.Theme_Holo_Light);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
BIN
app/src/main/res/drawable-hdpi/ic_list_white_24dp.png
Normal file
|
After Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 310 B |
BIN
app/src/main/res/drawable-mdpi/ic_list_white_24dp.png
Normal file
|
After Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 222 B |
BIN
app/src/main/res/drawable-xhdpi/ic_list_white_24dp.png
Normal file
|
After Width: | Height: | Size: 95 B |
|
Before Width: | Height: | Size: 363 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_list_white_24dp.png
Normal file
|
After Width: | Height: | Size: 94 B |
|
Before Width: | Height: | Size: 513 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_list_white_24dp.png
Normal file
|
After Width: | Height: | Size: 100 B |
|
Before Width: | Height: | Size: 667 B |
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
|
@ -9,89 +9,107 @@
|
|||
app:behavior_peekHeight="@dimen/bottom_peak_height">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/emptyLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="1" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:minHeight="@dimen/bottom_peak_height"
|
||||
android:background="@android:color/white"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@android:color/white">
|
||||
<LinearLayout
|
||||
android:id="@+id/link_preview_toolbar"
|
||||
android:id="@+id/dialogInfoLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="64dp">
|
||||
android:animateLayoutChanges="true"
|
||||
android:minHeight="@dimen/bottom_peak_height"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/link_preview_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:minHeight="64dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/link_preview_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="serif"
|
||||
android:lineSpacingMultiplier="0.9"
|
||||
android:maxLines="3"
|
||||
android:paddingBottom="4dp"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="20sp"
|
||||
tools:text="Lorem ipsum" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="@android:color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/link_preview_title"
|
||||
android:id="@+id/link_preview_extract"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:lineSpacingMultiplier="1.3"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@android:color/black"
|
||||
tools:text="Lorem ipsum" />
|
||||
|
||||
<View
|
||||
android:id="@+id/link_preview_bottom_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialogButtonsLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/dialogInfoLayout"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/link_preview_directions_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingBottom="4dp"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="serif"
|
||||
android:lineSpacingMultiplier="0.9"
|
||||
android:maxLines="3"
|
||||
android:ellipsize="end"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:textColor="@android:color/black"
|
||||
tools:text="Lorem ipsum" />
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:text="GET DIRECTIONS"
|
||||
android:textColor="@android:color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/link_preview_go_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:text="READ ARTICLE"
|
||||
android:textColor="@android:color/black" />
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="@android:color/black"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/link_preview_extract"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:textSize="16sp"
|
||||
android:lineSpacingMultiplier="1.3"
|
||||
android:textIsSelectable="true"
|
||||
android:textColor="@android:color/black"
|
||||
tools:text="Lorem ipsum"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/link_preview_bottom_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/link_preview_directions_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:textColor="@android:color/black"
|
||||
android:text="GET DIRECTIONS"/>
|
||||
<TextView
|
||||
android:id="@+id/link_preview_go_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:textColor="@android:color/black"
|
||||
android:text="READ ARTICLE"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
||||