From: Reimar Döffinger Date: Thu, 27 Oct 2016 00:51:29 +0000 (+0200) Subject: Add floating button to switch language. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=7d31142fbfb0ace1d668e9b8b6e723a1dc4ffe0b Add floating button to switch language. --- 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 0000000..7a8e6cd Binary files /dev/null and b/res/drawable-hdpi/ic_swap_horiz_black_24dp.png differ 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 0000000..15020da Binary files /dev/null and b/res/drawable-mdpi/ic_swap_horiz_black_24dp.png differ 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 0000000..4ab679b Binary files /dev/null and b/res/drawable-xhdpi/ic_swap_horiz_black_24dp.png differ 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 0000000..13fde18 Binary files /dev/null and b/res/drawable-xxhdpi/ic_swap_horiz_black_24dp.png differ 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 0000000..c3a2007 Binary files /dev/null and b/res/drawable-xxxhdpi/ic_swap_horiz_black_24dp.png differ 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) {