diff --git a/CHANGELOG.md b/CHANGELOG.md
index 638ec4d..890a691 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+### Version 1.0.37 Tag: v1.0.37 (2020-06-19)
+ * Making Selecting a search suggestion fill search field (@dhk2)
+ * Adding configuration setting and supporting code to choose language (@dhk2)
+ * Adding configuration setting and code for configurable back button behavior (@dhk2)
+ * Various translations
+
### Version 1.0.36 Tag: v1.0.36 (2020-06-14)
* fix 'cannot make a new request because the previous response (@lishoujun)
* Various translations
diff --git a/app/build.gradle b/app/build.gradle
index 3844e9c..fdc4ca7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,8 +6,8 @@ android {
applicationId "net.schueller.peertube"
minSdkVersion 21
targetSdkVersion 28
- versionCode 1036
- versionName "1.0.36"
+ versionCode 1037
+ versionName "1.0.37"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ext {
libVersions = [
diff --git a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java
index 60c3589..a733fca 100644
--- a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java
@@ -19,12 +19,15 @@
package net.schueller.peertube.activity;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
+import java.util.Locale;
+
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
@@ -45,6 +48,21 @@ public class CommonActivity extends AppCompatActivity {
"style",
getPackageName())
);
+
+ // Set language
+ String countryCode=sharedPref.getString("pref_language_app","en");
+ Locale locale=new Locale(countryCode);;
+ //Neither Chinese language choice was working, found this fix on stack overflow
+ if(countryCode.equals("zh-rCN"))
+ locale = Locale.SIMPLIFIED_CHINESE;
+ if(countryCode.equals("zh-rTW"))
+ locale = Locale.TRADITIONAL_CHINESE;
+
+ Locale.setDefault(locale);
+ Configuration config = getBaseContext().getResources().getConfiguration();
+ config.locale = locale;
+ getBaseContext().getResources().updateConfiguration(config,
+ getBaseContext().getResources().getDisplayMetrics());
}
}
diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java
index 8a68ce6..54abbc7 100644
--- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java
@@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
+import android.database.Cursor;
import android.preference.PreferenceManager;
import android.provider.SearchRecentSuggestions;
@@ -166,7 +167,27 @@ public class VideoListActivity extends CommonActivity {
Log.d(TAG, "onDismiss: ");
loadVideos(0, count, sort, filter);
});
+ searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
+ @Override
+ public boolean onSuggestionClick(int position) {
+ String suggestion = getSuggestion(position);
+ searchView.setQuery(suggestion, true);
+ return true;
+ }
+ private String getSuggestion(int position) {
+ Cursor cursor = (Cursor) searchView.getSuggestionsAdapter().getItem(
+ position);
+ return cursor.getString(cursor
+ .getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1));
+ }
+
+ @Override
+ public boolean onSuggestionSelect(int position) {
+ /* Required to implement */
+ return true;
+ }
+ });
return true;
}
diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml
index 5936a02..8a7d9f6 100644
--- a/app/src/main/res/values/array.xml
+++ b/app/src/main/res/values/array.xml
@@ -433,6 +433,58 @@
- za
- zu
+
+
+ - ar
+ - bn
+ - cs
+ - de
+ - el
+ - en
+ - es
+ - fa
+ - fi
+ - fr
+ - gd
+ - hi
+ - it
+ - ja
+ - no
+ - nl
+ - pl
+ - ru
+ - sv
+ - tr
+ - zh-rCN
+ - zh-rTW
+
+
+
+ - @string/ar
+ - @string/bn
+ - @string/cs
+ - @string/de
+ - @string/el
+ - @string/en
+ - @string/es
+ - @string/fa
+ - @string/fi
+ - @string/fr
+ - @string/gd
+ - @string/hi
+ - @string/it
+ - @string/ja
+ - @string/no
+ - @string/nl
+ - @string/pl
+ - @string/ru
+ - @string/sv
+ - @string/tr
+ - @string/zh
+ - @string/tw
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ef83c3a..c9cccd5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -63,6 +63,8 @@
Pause on back button
Pause background play when pressing back during video playback.
+ Application Language
+ Select language for application interface. Restart app for change to take effect.
Abkhazian
Afar
diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml
index a6d4e93..e7c3dd8 100644
--- a/app/src/main/res/xml/pref_general.xml
+++ b/app/src/main/res/xml/pref_general.xml
@@ -30,6 +30,15 @@
android:summary="@string/pref_description_back_pause"
android:title="@string/pref_title_back_pause" />
+
+ />
+