mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Prepare xml files
This commit is contained in:
parent
5147769405
commit
23aa691275
15 changed files with 117 additions and 15 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package fr.free.nrw.commons;
|
package fr.free.nrw.commons;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -21,6 +22,13 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
getDelegate().installViewFactory();
|
getDelegate().installViewFactory();
|
||||||
getDelegate().onCreate(savedInstanceState);
|
getDelegate().onCreate(savedInstanceState);
|
||||||
|
//Check prefs on every activity starts
|
||||||
|
if (getSharedPreferences("prefs", Context.MODE_PRIVATE).getBoolean("theme", false)) {
|
||||||
|
setTheme(R.style.LightAppTheme);
|
||||||
|
}else {
|
||||||
|
setTheme(R.style.DarkAppTheme); //default
|
||||||
|
}
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
ListPreference licensePreference = (ListPreference) findPreference(Prefs.DEFAULT_LICENSE);
|
ListPreference licensePreference = (ListPreference) findPreference(Prefs.DEFAULT_LICENSE);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v4.content.IntentCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
|
@ -23,6 +24,8 @@ import android.widget.ListAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import fr.free.nrw.commons.AboutActivity;
|
import fr.free.nrw.commons.AboutActivity;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
|
@ -163,6 +166,27 @@ public class ContributionsListFragment extends Fragment {
|
||||||
startActivity(nearbyIntent);
|
startActivity(nearbyIntent);
|
||||||
return true;
|
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:
|
case R.id.menu_refresh:
|
||||||
((SourceRefresher)getActivity()).refreshSource();
|
((SourceRefresher)getActivity()).refreshSource();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -207,6 +231,31 @@ public class ContributionsListFragment extends Fragment {
|
||||||
menu.findItem(R.id.menu_refresh).setVisible(false);
|
menu.findItem(R.id.menu_refresh).setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*http://stackoverflow.com/questions/30076392/how-does-this-strange-condition-happens-when-show-menu-item-icon-in-toolbar-over/30337653#30337653
|
||||||
|
Overriden to show toggle_layout button on overlay menu
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
|
if(menu != null){
|
||||||
|
if(menu.getClass().getSimpleName().equals("MenuBuilder")){
|
||||||
|
try{
|
||||||
|
Method m = menu.getClass().getDeclaredMethod(
|
||||||
|
"setOptionalIconsVisible", Boolean.TYPE);
|
||||||
|
m.setAccessible(true);
|
||||||
|
m.invoke(menu, true);
|
||||||
|
}
|
||||||
|
catch(NoSuchMethodException e){
|
||||||
|
Log.e(TAG, "onMenuOpened", e);
|
||||||
|
}
|
||||||
|
catch(Exception e){
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onPrepareOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
|
||||||
BIN
app/src/main/res/drawable/toggle.png
Normal file
BIN
app/src/main/res/drawable/toggle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
BIN
app/src/main/res/drawable/toggle_inverse.png
Normal file
BIN
app/src/main/res/drawable/toggle_inverse.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
9
app/src/main/res/drawable/toggle_selector.xml
Normal file
9
app/src/main/res/drawable/toggle_selector.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:drawable="@drawable/toggle"
|
||||||
|
android:state_checked="true"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:drawable="@drawable/toggle_inverse"
|
||||||
|
android:state_checked="false"/>
|
||||||
|
</selector>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#000"
|
android:background="?attr/mainBackground"
|
||||||
>
|
>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#0c609c"
|
android:background="?attr/commonsAppBlue"
|
||||||
>
|
>
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<android.support.v4.view.ViewPager
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
android:id="@+id/mediaDetailCategoryItemText"
|
android:id="@+id/mediaDetailCategoryItemText"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:background="#20ffffff"
|
android:background="?attr/subBackground"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<fr.free.nrw.commons.media.MediaDetailSpacer
|
<fr.free.nrw.commons.media.MediaDetailSpacer
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#AA000000"
|
android:background="?attr/fragmentCategorisationBackground"
|
||||||
android:paddingBottom="8dip"
|
android:paddingBottom="8dip"
|
||||||
android:paddingLeft="16dip"
|
android:paddingLeft="16dip"
|
||||||
android:paddingStart="16dip"
|
android:paddingStart="16dip"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#000000"
|
android:background="?attr/mainBackground"
|
||||||
>
|
>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#AA000000"
|
android:background="?attr/fragmentCategorisationBackground"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#20ffffff"
|
android:background="?attr/subBackground"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
>
|
>
|
||||||
<TextView
|
<TextView
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
android:id="@+id/mediaDetailTitle"
|
android:id="@+id/mediaDetailTitle"
|
||||||
android:layout_gravity="left|start"
|
android:layout_gravity="left|start"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:background="#20ffffff"
|
android:background="?attr/subBackground"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
/>
|
/>
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#20ffffff"
|
android:background="?attr/subBackground"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
>
|
>
|
||||||
<TextView
|
<TextView
|
||||||
|
|
@ -116,7 +116,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/media_detail_description_explanation"
|
android:text="@string/media_detail_description_explanation"
|
||||||
android:background="#20ffffff"
|
android:background="?attr/subBackground"
|
||||||
android:id="@+id/mediaDetailDesc"
|
android:id="@+id/mediaDetailDesc"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:layout_gravity="left|start"
|
android:layout_gravity="left|start"
|
||||||
|
|
@ -134,7 +134,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#20ffffff"
|
android:background="?attr/subBackground"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
>
|
>
|
||||||
<TextView
|
<TextView
|
||||||
|
|
@ -152,7 +152,7 @@
|
||||||
android:text="License link"
|
android:text="License link"
|
||||||
android:id="@+id/mediaDetailLicense"
|
android:id="@+id/mediaDetailLicense"
|
||||||
android:layout_gravity="left|start"
|
android:layout_gravity="left|start"
|
||||||
android:background="#20ffffff"
|
android:background="?attr/subBackground"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
|
|
@ -168,7 +168,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#20ffffff"
|
android:background="?attr/subBackground"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@
|
||||||
android:title="@string/menu_nearby"
|
android:title="@string/menu_nearby"
|
||||||
app:showAsAction="never"
|
app:showAsAction="never"
|
||||||
/>
|
/>
|
||||||
|
<item android:id="@+id/menu_theme_toggle"
|
||||||
|
android:title="Night mode"
|
||||||
|
android:icon="?attr/toggleButtonIcon"
|
||||||
|
app:showAsAction="never"
|
||||||
|
/>
|
||||||
<item android:id="@+id/menu_refresh"
|
<item android:id="@+id/menu_refresh"
|
||||||
android:title="@string/menu_refresh"
|
android:title="@string/menu_refresh"
|
||||||
app:showAsAction="never"
|
app:showAsAction="never"
|
||||||
|
|
|
||||||
11
app/src/main/res/values/attrs.xml
Normal file
11
app/src/main/res/values/attrs.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<attr name="mainBackground" format="reference"/>
|
||||||
|
<attr name="semitransparentText" format="reference"/>
|
||||||
|
<attr name="commonsAppBlue" format="reference"/>
|
||||||
|
<attr name="subBackground" format="reference"/>
|
||||||
|
<attr name="fragmentCategorisationBackground" format="reference"/>
|
||||||
|
<attr name="buttonBackground" format="reference"/>
|
||||||
|
<attr name="uploadOverlayBackground" format="reference"/>
|
||||||
|
<attr name="toggleButtonIcon" format="reference"/>
|
||||||
|
</resources>
|
||||||
|
|
@ -1,6 +1,23 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<!-- Some colours are same for dark/light themes. They are written two times in case
|
||||||
|
we want to change light ones later.
|
||||||
|
-->
|
||||||
<color name="text_background">#90000000</color>
|
<color name="text_background">#90000000</color>
|
||||||
|
<color name="item_white_background">#ffffffff</color>
|
||||||
|
<color name="main_background_dark">#000000</color>
|
||||||
|
<color name="main_background_light">#bdbdbd</color>
|
||||||
|
<color name="commons_app_blue_dark">#33FFFFFF</color>
|
||||||
|
<color name="commons_app_blue_light">#33FFFFFF</color>
|
||||||
|
<color name="activity_welcome_background_dark">#0c609c</color>
|
||||||
|
<color name="activity_welcome_background_light">#0c609c</color>
|
||||||
|
<color name="sub_background_dark">#20ffffff</color>
|
||||||
|
<color name="sub_background_light">#20ffffff</color>
|
||||||
|
<color name="fragment_categorisation_background_dark">#AA000000</color>
|
||||||
|
<color name="fragment_categorisation_background_light">#44ffffff</color>
|
||||||
|
<color name="button_background_dark">#90000000</color>
|
||||||
|
<color name="button_background_light">#60000000</color>
|
||||||
|
<color name="upload_overlay_background_dark">#77000000</color>
|
||||||
|
<color name="upload_overlay_background_light">#44000000</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
<string name="menu_from_camera">Take photo</string>
|
<string name="menu_from_camera">Take photo</string>
|
||||||
<string name="menu_nearby">Nearby</string>
|
<string name="menu_nearby">Nearby</string>
|
||||||
<string name="provider_contributions">My uploads</string>
|
<string name="provider_contributions">My uploads</string>
|
||||||
|
<string name="menu_theme_toggle">Night mode</string>
|
||||||
<string name="menu_share">Share</string>
|
<string name="menu_share">Share</string>
|
||||||
<string name="menu_open_in_browser">View in Browser</string>
|
<string name="menu_open_in_browser">View in Browser</string>
|
||||||
<string name="share_title_hint">Title</string>
|
<string name="share_title_hint">Title</string>
|
||||||
|
|
@ -90,6 +91,8 @@ Tap this message (or hit back) to skip this step.</string>
|
||||||
<string name="use_previous">Use previous title/description</string>
|
<string name="use_previous">Use previous title/description</string>
|
||||||
<string name="allow_gps">Automatically get current location</string>
|
<string name="allow_gps">Automatically get current location</string>
|
||||||
<string name="allow_gps_summary">Retrieve current location to offer category suggestions if image is not geotagged</string>
|
<string name="allow_gps_summary">Retrieve current location to offer category suggestions if image is not geotagged</string>
|
||||||
|
<string name="preference_theme">Select theme</string>
|
||||||
|
<string name="preference_theme_summary">Select application theme as light/dark</string>
|
||||||
<string name="license_name_cc_by_sa_four"> Attribution-ShareAlike 4.0</string>
|
<string name="license_name_cc_by_sa_four"> Attribution-ShareAlike 4.0</string>
|
||||||
<string name="license_name_cc_by_four"> Attribution 4.0</string>
|
<string name="license_name_cc_by_four"> Attribution 4.0</string>
|
||||||
<string name="license_name_cc_by_sa"> Attribution-ShareAlike 3.0</string>
|
<string name="license_name_cc_by_sa"> Attribution-ShareAlike 3.0</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue