Browse Source

Move the buttons to the options menu UI accessible via the menu button.

master
Reece H. Dunn 12 years ago
parent
commit
d92abbe342

+ 0
- 60
android/res/layout/main.xml View File

android:layout_height="wrap_content" > android:layout_height="wrap_content" >


</ListView> </ListView>

<LinearLayout
android:id="@+id/updateVoicesLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<Button
android:id="@+id/updateVoices"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/update_voices" />

<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>

<LinearLayout
android:id="@+id/engineSettingsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<Button
android:id="@+id/engineSettings"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/engine_settings" />

<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

<LinearLayout
android:id="@+id/ttsSettingsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<Button
android:id="@+id/ttsSettings"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/tts_settings" />

<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout> </LinearLayout>


<LinearLayout <LinearLayout

+ 8
- 0
android/res/menu/options.xml View File

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/updateVoices" android:title="@string/update_voices"></item>
<item android:id="@+id/espeakSettings" android:title="@string/engine_settings"></item>
<item android:id="@+id/ttsSettings" android:title="@string/tts_settings"></item>

</menu>

+ 33
- 35
android/src/com/reecedunn/espeak/eSpeakActivity.java View File

import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;


import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
((ListView)findViewById(R.id.properties)).setAdapter(mInformationView); ((ListView)findViewById(R.id.properties)).setAdapter(mInformationView);


setState(State.LOADING); setState(State.LOADING);
manageSettingVisibility();
checkVoiceData(); checkVoiceData();
} }


} }
} }


@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options, menu);
if (Build.VERSION.SDK_INT < 14) {
// Hide the eSpeak setting menu item on pre-ICS.
menu.getItem(R.id.espeakSettings).setVisible(false);
}
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.espeakSettings:
startActivityForResult(new Intent(eSpeakActivity.this, TtsSettingsActivity.class), REQUEST_DEFAULT);
return true;
case R.id.ttsSettings:
launchGeneralTtsSettings();
return true;
case R.id.updateVoices:
downloadVoiceData();
return true;
}
return super.onOptionsItemSelected(item);
}

/** /**
* Sets the UI state. * Sets the UI state.
* *
mTts = new TextToSpeech(this, mInitListener); mTts = new TextToSpeech(this, mInitListener);
} }


/**
* Hides preferences according to SDK level.
*/
private void manageSettingVisibility() {
if (Build.VERSION.SDK_INT < 14) {
// Hide the eSpeak setting button on pre-ICS.
findViewById(R.id.engineSettingsLayout).setVisibility(View.GONE);
}
}

private void populateInformationView() { private void populateInformationView() {
mInformation.clear(); mInformation.clear();


return; return;
} }


findViewById(R.id.updateVoices).setOnClickListener(mOnClickListener);
findViewById(R.id.ttsSettings).setOnClickListener(mOnClickListener);
findViewById(R.id.engineSettings).setOnClickListener(mOnClickListener);

populateInformationView(); populateInformationView();
setState(State.SUCCESS); setState(State.SUCCESS);
} }
} }
private final Handler mHandler = new EspeakHandler(this); private final Handler mHandler = new EspeakHandler(this);


private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.updateVoices:
downloadVoiceData();
break;
case R.id.engineSettings:
startActivityForResult(
new Intent(eSpeakActivity.this, TtsSettingsActivity.class),
REQUEST_DEFAULT);
break;
case R.id.ttsSettings:
launchGeneralTtsSettings();
break;
}
}
};

private void launchGeneralTtsSettings() private void launchGeneralTtsSettings()
{ {
Intent intent; Intent intent;

Loading…
Cancel
Save