From 7d31142fbfb0ace1d668e9b8b6e723a1dc4ffe0b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Reimar=20D=C3=B6ffinger?= Date: Thu, 27 Oct 2016 02:51:29 +0200 Subject: [PATCH] Add floating button to switch language. --- build.gradle | 1 + res/drawable-hdpi/ic_swap_horiz_black_24dp.png | Bin 0 -> 160 bytes res/drawable-mdpi/ic_swap_horiz_black_24dp.png | Bin 0 -> 120 bytes res/drawable-xhdpi/ic_swap_horiz_black_24dp.png | Bin 0 -> 180 bytes .../ic_swap_horiz_black_24dp.png | Bin 0 -> 231 bytes .../ic_swap_horiz_black_24dp.png | Bin 0 -> 291 bytes res/layout/dictionary_activity.xml | 12 ++++++++++-- .../android/dictionary/DictionaryActivity.java | 16 ++++++++++++++++ 8 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 res/drawable-hdpi/ic_swap_horiz_black_24dp.png create mode 100644 res/drawable-mdpi/ic_swap_horiz_black_24dp.png create mode 100644 res/drawable-xhdpi/ic_swap_horiz_black_24dp.png create mode 100644 res/drawable-xxhdpi/ic_swap_horiz_black_24dp.png create mode 100644 res/drawable-xxxhdpi/ic_swap_horiz_black_24dp.png diff --git a/build.gradle b/build.gradle index 918d904..bd8ae53 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ configurations { } dependencies { compile 'com.android.support:appcompat-v7:25.0.0' + compile 'com.android.support:design:25.0.0' // Note: you can just replace "smallicu" by compile // and remove the "compile files" part if you do not // care about the size of the apk diff --git a/res/drawable-hdpi/ic_swap_horiz_black_24dp.png b/res/drawable-hdpi/ic_swap_horiz_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7a8e6cd2499d12b6f4e0dcf54438138c344be399 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8x~Gd{NCo5DOB;EQ81Og;<|Xw% zI=C)j(!rU$PMiwsE|vdJ@Hk}h^%jS#0V}7EBa?E#{7cW1xrF@K9^FsdViaBd!TZid z-pCavEHVz4Im&&ysI&V<j1Qp!PC{x JWt~$(69C|0JKq2R literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/ic_swap_horiz_black_24dp.png b/res/drawable-mdpi/ic_swap_horiz_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..15020da34950f098d183316cad9fdcf581f88248 GIT binary patch literal 120 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1drud~kP61+1AK0d%qyk-O)P8@s|$ORNvX<5$6eCVJR7lWm(_0bE3 SkEZ~QV(@hJb6Mw<&;$Tk{VAyc literal 0 HcmV?d00001 diff --git a/res/drawable-xhdpi/ic_swap_horiz_black_24dp.png b/res/drawable-xhdpi/ic_swap_horiz_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..4ab679beb14550278a2efce0f4bab16ab3fd8855 GIT binary patch literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DYEKu(kP61PR|2^XD~PyUyjdBS z^LEx>4WIgZOfEYn9Fh?)P&^jc-LZq^ch&{Q>|IKIKy={yWLKLBdFK$J4XLOP-{&{qR2$Z}fk*6aU*gOPFoT f*2K-|=#c;N_}%-W_h+U7ox$Mg>gTe~DWM4fbB9V} literal 0 HcmV?d00001 diff --git a/res/drawable-xxhdpi/ic_swap_horiz_black_24dp.png b/res/drawable-xxhdpi/ic_swap_horiz_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..13fde1813112aee8cfbfbe02f87d48f63b33f4db GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw)_J-(hEy=Vy%x*WVj#fsa9?Fz z*j?@48!r5Q!D!Uzw5zC*-(==RYj4e^Q-ZRZzFuC^xWr#H;< z`gOu}K@lH=NvcrB32ydd8@pZ?IsEYt^S)L7_Ok(#+wn&QtREFzcawRXnlm5;GbUA~ktDnm{r-UW|DhyxR literal 0 HcmV?d00001 diff --git a/res/drawable-xxxhdpi/ic_swap_horiz_black_24dp.png b/res/drawable-xxxhdpi/ic_swap_horiz_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..c3a200720eaac4acfe7b176f599f904cd9711945 GIT binary patch literal 291 zcmV+;0o?wHP)l4s<$gHY1H#cB5cc+f zu(t<K|k@U}w}984Z|!{Lz4eQFk&La4_m1qX8F2?c_b6$xfOB zHqsn$Bh3LT`S2-!{BWX$GzVOX0lq>7m$)y%582cx;V|bo{l|r-z`Z=+eW~wGcv0)o p9stj>fPo)({gb35Ns=T<`USrZyY$5~*)aeB002ovPDHLkV1ms;eE9$X literal 0 HcmV?d00001 diff --git a/res/layout/dictionary_activity.xml b/res/layout/dictionary_activity.xml index 76f3a01..e92915d 100644 --- a/res/layout/dictionary_activity.xml +++ b/res/layout/dictionary_activity.xml @@ -1,5 +1,5 @@ - @@ -49,10 +49,18 @@ android:focusable="true" android:focusableInTouchMode="true" /> + + - + diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index c79faf3..356e957 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -367,6 +367,7 @@ public class DictionaryActivity extends ActionBarActivity { } Log.d(LOG, "Loading index " + indexIndex); index = dictionary.indices.get(indexIndex); + getListView().setEmptyView(findViewById(android.R.id.empty)); setListAdapter(new IndexAdapter(index)); // Pre-load the collators. @@ -448,6 +449,21 @@ public class DictionaryActivity extends ActionBarActivity { onCreateSetupActionBarAndSearchView(); + View floatSwapButton = findViewById(R.id.floatSwapButton); + floatSwapButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View arg0) { + onLanguageButtonClick(); + } + }); + floatSwapButton.setOnLongClickListener(new OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + onLanguageButtonLongClick(v.getContext()); + return true; + } + }); + // Set the search text from the intent, then the saved state. String text = getIntent().getStringExtra(C.SEARCH_TOKEN); if (savedInstanceState != null) { -- 2.43.0