]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Add floating button to switch language.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 27 Oct 2016 00:51:29 +0000 (02:51 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 27 Oct 2016 00:51:29 +0000 (02:51 +0200)
build.gradle
res/drawable-hdpi/ic_swap_horiz_black_24dp.png [new file with mode: 0644]
res/drawable-mdpi/ic_swap_horiz_black_24dp.png [new file with mode: 0644]
res/drawable-xhdpi/ic_swap_horiz_black_24dp.png [new file with mode: 0644]
res/drawable-xxhdpi/ic_swap_horiz_black_24dp.png [new file with mode: 0644]
res/drawable-xxxhdpi/ic_swap_horiz_black_24dp.png [new file with mode: 0644]
res/layout/dictionary_activity.xml
src/com/hughes/android/dictionary/DictionaryActivity.java

index 918d904ccf1c64ffad0c200f52d9e41ab3c80dc8..bd8ae53c9c95e0194c92dcc0dd8734e7caa5ba65 100644 (file)
@@ -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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
index 0000000..c3a2007
Binary files /dev/null and b/res/drawable-xxxhdpi/ic_swap_horiz_black_24dp.png differ
index 76f3a01eb74461a00e92638bbba02682c522792f..e92915d42c54eee714c9907fca4cbb7fd6b213db 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical" >
         android:focusable="true"
         android:focusableInTouchMode="true" />
 
+     <android.support.design.widget.FloatingActionButton
+        android:id="@+id/floatSwapButton"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentRight="true"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@drawable/ic_swap_horiz_black_24dp" />
+
     <TextView
         android:id="@android:id/empty"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:text="@string/noSearchResults" />
 
-</LinearLayout>
+</RelativeLayout>
index c79faf32c77e4384867e54a8745839b5e8f28c4b..356e957ebaf8788645e898a1ac3d6b801ba04e7b 100644 (file)
@@ -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) {