mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Move theme checkbox to settings activity
This commit is contained in:
parent
c7909b4f66
commit
7e256175dc
23 changed files with 118 additions and 121 deletions
|
|
@ -125,7 +125,6 @@ public class ContributionsActivity
|
|||
if (mediaDetails != null && savedInstanceState.getBoolean("mediaDetailsVisible")) {
|
||||
// Feels awful that we have to reset this manually!
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowCustomEnabled(true);
|
||||
}
|
||||
}
|
||||
requestAuthToken();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.IntentCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
|
@ -166,27 +167,6 @@ public class ContributionsListFragment extends Fragment {
|
|||
startActivity(nearbyIntent);
|
||||
return true;
|
||||
}
|
||||
case R.id.menu_theme_toggle:
|
||||
final SharedPreferences prefs = getActivity().getSharedPreferences("prefs", Context.MODE_PRIVATE);
|
||||
prefs.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
|
||||
if(s.equals("theme")){
|
||||
//http://stackoverflow.com/questions/5659742/onsharedpreferencechanged-called-multiple-times-why
|
||||
prefs.unregisterOnSharedPreferenceChangeListener(this);
|
||||
//Finish current activity and tart new one with selected theme
|
||||
Intent intent = getActivity().getIntent();
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
getActivity().finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
//put inverse of selected boolean
|
||||
editor.putBoolean("theme", !prefs.getBoolean("theme", false));
|
||||
editor.commit();
|
||||
return true;
|
||||
case R.id.menu_refresh:
|
||||
((SourceRefresher)getActivity()).refreshSource();
|
||||
return true;
|
||||
|
|
@ -229,7 +209,6 @@ public class ContributionsListFragment extends Fragment {
|
|||
}
|
||||
|
||||
menu.findItem(R.id.menu_refresh).setVisible(false);
|
||||
menu.findItem(R.id.menu_theme_toggle).setActionView(R.layout.theme_toggle_layout);
|
||||
}
|
||||
|
||||
/*http://stackoverflow.com/questions/30076392/how-does-this-strange-condition-happens-when-show-menu-item-icon-in-toolbar-over/30337653#30337653
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue