Commit 01584d24 authored by Donald's avatar Donald

Merge branch 'fr-280-force-english' into 'dev'

Feature Request  force english language

Closes #280

See merge request !595
parents 30fb4e4d 56d5bed7
......@@ -19,7 +19,6 @@ android {
versionName "v0.7-alpha-2"
versionCode 16
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
......
......@@ -119,7 +119,6 @@
<activity
android:name=".activities.SettingsActivity"
android:configChanges="orientation|screenSize"
android:label="@string/settings"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.SETTING" />
......@@ -135,7 +134,6 @@
<activity
android:name=".about.AboutActivity"
android:configChanges="orientation|screenSize"
android:label="@string/about"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.ABOUT" />
......@@ -146,7 +144,6 @@
<activity
android:name=".activities.SecurityActivity"
android:configChanges="orientation|screenSize"
android:label="@string/security"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.SECURITY" />
......@@ -156,7 +153,6 @@
</activity>
<activity
android:name=".activities.DonateActivity"
android:label="@string/donate"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.DONATE" />
......@@ -166,7 +162,6 @@
</activity>
<activity
android:name=".activities.BlackWhiteListActivity"
android:label="@string/chose_folders"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.ExcludedAlbums" />
......@@ -176,7 +171,6 @@
</activity>
<activity
android:name=".activities.PaletteActivity"
android:label="@string/palette"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.PALETTE" />
......
......@@ -18,7 +18,6 @@ import org.horaapps.leafpic.util.preferences.Prefs;
public class App extends MultiDexApplication {
private static App mInstance;
@Override
public void onCreate() {
super.onCreate();
......@@ -28,6 +27,8 @@ public class App extends MultiDexApplication {
/** This process is dedicated to LeakCanary for heap analysis.
* You should not init your app in this process. */
if (LeakCanary.isInAnalyzerProcess(this)) {
return;
}
......@@ -51,4 +52,4 @@ public class App extends MultiDexApplication {
Prefs.init(this);
Hawk.init(this).build();
}
}
\ No newline at end of file
}
......@@ -22,11 +22,11 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import org.horaapps.leafpic.BuildConfig;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.DonateActivity;
import org.horaapps.leafpic.activities.base.BaseActivity;
import org.horaapps.leafpic.util.AlertDialogsHelper;
import org.horaapps.leafpic.util.ApplicationUtils;
import org.horaapps.leafpic.util.ChromeCustomTabs;
import org.horaapps.leafpic.util.preferences.Prefs;
import org.horaapps.liz.ThemedActivity;
import org.horaapps.liz.ui.ThemedTextView;
import java.util.ArrayList;
......@@ -57,7 +57,7 @@ import static org.horaapps.leafpic.util.ServerConstants.TWITTER_ABOUT_GILBERT;
* - Translators
* - Relevant app links
*/
public class AboutActivity extends ThemedActivity implements ContactListener {
public class AboutActivity extends BaseActivity implements ContactListener {
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.about_version_item_sub) ThemedTextView appVersion;
......@@ -83,6 +83,7 @@ public class AboutActivity extends ThemedActivity implements ContactListener {
chromeTabs = new ChromeCustomTabs(AboutActivity.this);
initUi();
setTitle(R.string.about);
}
@Override
......
......@@ -22,8 +22,8 @@ import android.widget.TextView;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.BaseActivity;
import org.horaapps.leafpic.util.StringUtils;
import org.horaapps.liz.ThemedActivity;
import java.util.List;
......@@ -32,7 +32,7 @@ import java.util.List;
* The Palette Activity used to analyze the colors in the picture.
*/
public class PaletteActivity extends ThemedActivity {
public class PaletteActivity extends BaseActivity {
private Toolbar toolbar;
private ImageView paletteImg;
......@@ -48,7 +48,7 @@ public class PaletteActivity extends ThemedActivity {
setContentView(R.layout.activity_palette);
toolbar = (Toolbar) findViewById(R.id.toolbar);
paletteImg = (ImageView) findViewById(R.id.palette_image);
setTitle(R.string.palette);
setSupportActionBar(toolbar);
uri = getIntent().getData();
paletteImg.setImageURI(null);
......
......@@ -78,19 +78,19 @@ import com.google.android.exoplayer2.util.Util;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.BaseActivity;
import org.horaapps.leafpic.util.Measure;
import org.horaapps.leafpic.util.StringUtils;
import org.horaapps.leafpic.views.videoplayer.CustomExoPlayerView;
import org.horaapps.leafpic.views.videoplayer.CustomPlayBackController;
import org.horaapps.leafpic.views.videoplayer.TrackSelectionHelper;
import org.horaapps.liz.ThemedActivity;
import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.CookiePolicy;
import java.util.UUID;
public class PlayerActivity extends ThemedActivity implements CustomPlayBackController.VisibilityListener {
public class PlayerActivity extends BaseActivity implements CustomPlayBackController.VisibilityListener {
public static final String DRM_SCHEME_UUID_EXTRA = "drm_scheme_uuid";
public static final String DRM_LICENSE_URL = "drm_license_url";
......
......@@ -19,17 +19,17 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.orhanobut.hawk.Hawk;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.BaseActivity;
import org.horaapps.leafpic.util.FingerprintHandler;
import org.horaapps.leafpic.util.Security;
import org.horaapps.liz.ThemeHelper;
import org.horaapps.liz.ThemedActivity;
import org.horaapps.liz.ui.ThemedIcon;
/**
* Created by dnld on 22/05/16.
* The Security Activity used to select the locking method.
*/
public class SecurityActivity extends ThemedActivity {
public class SecurityActivity extends BaseActivity {
private Toolbar toolbar;
......@@ -54,6 +54,7 @@ public class SecurityActivity extends ThemedActivity {
llFingerprint = (LinearLayout) findViewById(R.id.ll_active_security_fingerprint);
initUi();
setTitle(R.string.security);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
fingerprintHandler = new FingerprintHandler(this, null);
if(fingerprintHandler.isFingerprintSupported()){
......
......@@ -17,6 +17,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.orhanobut.hawk.Hawk;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.BaseActivity;
import org.horaapps.leafpic.settings.CardViewStyleSetting;
import org.horaapps.leafpic.settings.ColorsSetting;
import org.horaapps.leafpic.settings.GeneralSetting;
......@@ -25,7 +26,6 @@ import org.horaapps.leafpic.settings.SinglePhotoSetting;
import org.horaapps.leafpic.util.Security;
import org.horaapps.leafpic.views.SettingWithSwitchView;
import org.horaapps.liz.ColorPalette;
import org.horaapps.liz.ThemedActivity;
import org.horaapps.liz.ViewUtil;
import butterknife.BindView;
......@@ -36,7 +36,7 @@ import butterknife.Unbinder;
/**
* The Settings Activity used to select settings.
*/
public class SettingsActivity extends ThemedActivity {
public class SettingsActivity extends BaseActivity {
private Toolbar toolbar;
@BindView(R.id.option_max_brightness) SettingWithSwitchView optionMaxBrightness;
......@@ -99,6 +99,7 @@ public class SettingsActivity extends ThemedActivity {
}
ScrollView scrollView = findViewById(R.id.settingAct_scrollView);
setScrollViewColor(scrollView);
setTitle(R.string.settings);
}
@Override
......@@ -215,6 +216,11 @@ public class SettingsActivity extends ThemedActivity {
}, getAccentColor());
}
@OnClick(R.id.option_language)
public void forceEnglishChanged() {
Toast.makeText(getApplicationContext(), R.string.restart_app, Toast.LENGTH_SHORT).show();
}
@OnClick(R.id.ll_custom_icon_color)
public void onChangedCustomIconClicked(View view) {
updateTheme();
......
package org.horaapps.leafpic.activities.base;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import org.horaapps.leafpic.util.preferences.Prefs;
import org.horaapps.liz.ThemedActivity;
import java.util.Locale;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
......@@ -15,6 +21,30 @@ public abstract class BaseActivity extends ThemedActivity {
disposables.add(disposable);
}
@Override
public void onCreate(Bundle savedInstanceState) {
if(Prefs.forceEnglish()) forceEnglish();
super.onCreate(savedInstanceState);
}
public void forceEnglish() {
changeLocale(new Locale("en"));
}
private void changeLocale(Locale locale) {
Configuration configuration = getResources().getConfiguration();
Locale currentLocale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
currentLocale = configuration.getLocales().get(0);
else currentLocale = configuration.locale;
if(!currentLocale.getLanguage().equals(locale.getLanguage())) {
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, null);
}
}
@CallSuper
@Override
protected void onDestroy() {
......
......@@ -155,7 +155,7 @@ public class CardViewStyleSetting extends ThemedSetting {
Prefs.setCardStyle(cardViewStyle);
Prefs.setShowMediaCount(chkShowMediaCount.isChecked());
Prefs.setShowAlbumPath(chkShowAlbumPath.isChecked());
Toast.makeText(getActivity(), getActivity().getString(R.string.card_style_alert), Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getActivity().getString(R.string.restart_app), Toast.LENGTH_SHORT).show();
}
});
builder.setView(dialogLayout);
......
......@@ -30,6 +30,7 @@ public final class Defaults {
public static final boolean SHOW_ALBUM_PATH = false;
public static final int LAST_VERSION_CODE = 0;
public static final boolean FORCE_ENGLISH = false;
public static final boolean SHOW_EASTER_EGG = false;
public static final boolean ANIMATIONS_DISABLED = false;
......
......@@ -27,6 +27,7 @@ public final class Keys {
public static final String SHOW_EASTER_EGG = "show_easter_egg";
public static final String ANIMATIONS_DISABLED = "disable_animations";
public static final String FORCE_ENGLISH = "force_english_locale";
// Feature flags
public static final String TIMELINE_ENABLED = "enable_timeline";
......
......@@ -132,6 +132,10 @@ public class Prefs {
return getPrefs().get(Keys.LAST_VERSION_CODE, Defaults.LAST_VERSION_CODE);
}
public static boolean forceEnglish() {
return getPrefs().get(Keys.FORCE_ENGLISH, Defaults.FORCE_ENGLISH);
}
/********** SETTERS **********/
/**
......
......@@ -99,6 +99,15 @@
app:settingPreferenceKey="@string/preference_show_tips"
app:settingTitle="@string/option_show_tips"/>
<!-- CHANGE LANGUAGE -->
<org.horaapps.leafpic.views.SettingWithSwitchView
android:id="@+id/option_language"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:settingCaption="@string/option_change_language_sub"
app:settingIcon="gmd-translate"
app:settingPreferenceKey="@string/preference_force_english"
app:settingTitle="@string/option_change_language" />
</LinearLayout>
</org.horaapps.leafpic.views.themeable.ThemedCardView>
......
......@@ -16,6 +16,7 @@
<string name="preference_transparency">set_alpha</string>
<string name="preference_map_provider">map_provider</string>
<string name="preference_show_tips">show_tips</string>
<string name="preference_force_english">force_english_locale</string>
<string name="preference_custom_icon_color">custom_icon_color</string>
<string name="preference_internal_uri_extsdcard_photos">uri_extsdcard_photos</string>
......
......@@ -103,7 +103,7 @@
<string name="unhide_album_message">Unhiding this album will also make the media available for other apps.</string>
<string name="new_folder_message">The new folder will be created in the current path, and the media will then be copied or moved in the new folder.</string>
<string name="card_style_alert">NOTE: Restart the app for the changes to take effect.</string>
<string name="restart_app">NOTE: Restart the app for the changes to take effect.</string>
<string name="show_album_path">Show album path</string>
<string name="show_preview_image_name">Show preview image name</string>
<string name="show_media_count">Show media count</string>
......@@ -190,6 +190,8 @@
<string name="disable_animations_sub">Disable animations if there are performance issues.</string>
<string name="enable_timeline_title">Enable Timeline</string>
<string name="enable_timeline_desc">Enable the Timeline view for media. Experimental.</string>
<string name="option_change_language_sub">Change language to English</string>
<string name="option_change_language">Language</string>
<string name="media_viewer">Media Viewer</string>
<string name="media_viewer_theme">Media Viewer Theme</string>
......
......@@ -17,15 +17,15 @@ import android.widget.TextView;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.BaseActivity;
import org.horaapps.leafpic.util.ChromeCustomTabs;
import org.horaapps.leafpic.util.StringUtils;
import org.horaapps.liz.ThemedActivity;
import org.horaapps.liz.ui.ThemedIcon;
/**
* Created by Jibo on 02/03/2016.
*/
public class DonateActivity extends ThemedActivity {
public class DonateActivity extends BaseActivity {
private Toolbar toolbar;
private ChromeCustomTabs cts;
......@@ -45,6 +45,7 @@ public class DonateActivity extends ThemedActivity {
btnDonatePP = findViewById(R.id.button_donate_paypal);
iniUi();
setTitle(R.string.donate);
cts = new ChromeCustomTabs(DonateActivity.this);
}
......
......@@ -27,13 +27,13 @@ import org.horaapps.leafpic.util.StringUtils;
import org.horaapps.leafpic.util.inapppurchase.IabHelper;
import org.horaapps.leafpic.util.inapppurchase.IabResult;
import org.horaapps.leafpic.util.inapppurchase.Purchase;
import org.horaapps.liz.ThemedActivity;
import org.horaapps.leafpic.activities.base.BaseActivity;
import org.horaapps.liz.ui.ThemedIcon;
/**
* Created by Jibo on 02/03/2016.
*/
public class DonateActivity extends ThemedActivity {
public class DonateActivity extends BaseActivity {
private Toolbar toolbar;
private ChromeCustomTabs cts;
......@@ -64,7 +64,7 @@ public class DonateActivity extends ThemedActivity {
setContentView(org.horaapps.leafpic.R.layout.activity_donate);
toolbar = (Toolbar) findViewById(org.horaapps.leafpic.R.id.toolbar);
bar = (SeekBar) findViewById(R.id.seek_bar_donations);
setTitle(R.string.donate);
setNavBarColor();
cts = new ChromeCustomTabs(this);
scr = (ScrollView)findViewById(org.horaapps.leafpic.R.id.donateAct_scrollView);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment