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