mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Merge pull request #452 from neslihanturan/spinnerThemeIssue
Spinner theme issue
This commit is contained in:
commit
af91a3fe8c
2 changed files with 28 additions and 1 deletions
|
|
@ -92,6 +92,7 @@ public class SingleUploadFragment extends Fragment {
|
||||||
View rootView = inflater.inflate(R.layout.fragment_single_upload, null);
|
View rootView = inflater.inflate(R.layout.fragment_single_upload, null);
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
|
|
||||||
ArrayList<String> licenseItems = new ArrayList<>();
|
ArrayList<String> licenseItems = new ArrayList<>();
|
||||||
licenseItems.add(getString(R.string.license_name_cc0));
|
licenseItems.add(getString(R.string.license_name_cc0));
|
||||||
licenseItems.add(getString(R.string.license_name_cc_by));
|
licenseItems.add(getString(R.string.license_name_cc_by));
|
||||||
|
|
@ -104,7 +105,15 @@ public class SingleUploadFragment extends Fragment {
|
||||||
|
|
||||||
Log.d("Single Upload fragment", license);
|
Log.d("Single Upload fragment", license);
|
||||||
|
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, licenseItems);
|
ArrayAdapter<String> adapter;
|
||||||
|
if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("theme",true)) {
|
||||||
|
// dark theme
|
||||||
|
adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, licenseItems);
|
||||||
|
}else {
|
||||||
|
// light theme
|
||||||
|
adapter = new ArrayAdapter<>(getActivity(), R.layout.light_simple_spinner_dropdown_item, licenseItems);
|
||||||
|
}
|
||||||
|
|
||||||
licenseSpinner.setAdapter(adapter);
|
licenseSpinner.setAdapter(adapter);
|
||||||
|
|
||||||
int position = licenseItems.indexOf(getString(Utils.licenseNameFor(license)));
|
int position = licenseItems.indexOf(getString(Utils.licenseNameFor(license)));
|
||||||
|
|
@ -136,6 +145,13 @@ public class SingleUploadFragment extends Fragment {
|
||||||
@OnItemSelected(R.id.licenseSpinner) void onLicenseSelected(AdapterView<?> parent, View view, int position, long id) {
|
@OnItemSelected(R.id.licenseSpinner) void onLicenseSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
String licenseName = parent.getItemAtPosition(position).toString();
|
String licenseName = parent.getItemAtPosition(position).toString();
|
||||||
|
|
||||||
|
// Set selected color to white because it should be readable on random images.
|
||||||
|
TextView selectedText = (TextView) licenseSpinner.getChildAt(0);
|
||||||
|
if (selectedText != null ) {
|
||||||
|
selectedText.setTextColor(Color.WHITE);
|
||||||
|
selectedText.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
String license = Prefs.Licenses.CC_BY_SA_3; // default value
|
String license = Prefs.Licenses.CC_BY_SA_3; // default value
|
||||||
if(getString(R.string.license_name_cc0).equals(licenseName)) {
|
if(getString(R.string.license_name_cc0).equals(licenseName)) {
|
||||||
license = Prefs.Licenses.CC0;
|
license = Prefs.Licenses.CC0;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@android:id/text1"
|
||||||
|
style="?android:attr/spinnerDropDownItemStyle"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
/>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue