mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
Fix long click selection of WebView
The read aloud feature was crashing the app when long clicking the WebView, ultimativly making it impossible to copy text.
This commit is contained in:
parent
ece6217f7b
commit
eab0b39c08
@ -20,7 +20,6 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/menu_speak_text"
|
android:id="@+id/menu_speak_text"
|
||||||
android:icon="@drawable/action_voice"
|
android:icon="@drawable/action_voice"
|
||||||
android:onClick="onContextMenuClicked"
|
|
||||||
android:title="@string/menu_read_aloud"
|
android:title="@string/menu_read_aloud"
|
||||||
app:showAsAction="always"/>
|
app:showAsAction="always"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -164,6 +164,7 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
Menu menu = mode.getMenu();
|
Menu menu = mode.getMenu();
|
||||||
// Inflate custom menu icon.
|
// Inflate custom menu icon.
|
||||||
getMenuInflater().inflate(R.menu.menu_webview_action, menu);
|
getMenuInflater().inflate(R.menu.menu_webview_action, menu);
|
||||||
|
readAloudSelection(menu);
|
||||||
}
|
}
|
||||||
super.onActionModeStarted(mode);
|
super.onActionModeStarted(mode);
|
||||||
}
|
}
|
||||||
@ -174,19 +175,20 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
super.onActionModeFinished(mode);
|
super.onActionModeFinished(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onContextMenuClicked(MenuItem item) {
|
private void readAloudSelection(Menu menu) {
|
||||||
switch (item.getItemId()) {
|
if (menu != null) {
|
||||||
case R.id.menu_speak_text:
|
menu.findItem(R.id.menu_speak_text).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
Log.i(TAG_KIWIX, "Speaking selection.");
|
Log.i(TAG_KIWIX, "Speaking selection.");
|
||||||
tts.readSelection();
|
tts.readSelection();
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Log.e(TAG_KIWIX, "Unexpected context menu click.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mActionMode != null) {
|
if (mActionMode != null) {
|
||||||
mActionMode.finish();
|
mActionMode.finish();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user