Merge pull request #576 from neslihanturan/switchMapIcon

Switch map icon
This commit is contained in:
Josephine Lim 2017-05-14 15:23:57 +02:00 committed by GitHub
commit 5ed7755a2c
13 changed files with 33 additions and 11 deletions

View file

@ -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;
}
}
}

View file

@ -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();
}
}

View file

@ -6,13 +6,14 @@ 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 {

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B