mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Merge pull request #576 from neslihanturan/switchMapIcon
Switch map icon
This commit is contained in:
commit
5ed7755a2c
13 changed files with 33 additions and 11 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue