fixes the menus for appcompat library
This commit is contained in:
parent
cc8d3e1eab
commit
e25dc08fe5
|
@ -17,26 +17,27 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:yourapp="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:id="@+id/menu_start"
|
||||
android:title="@string/menu_start"
|
||||
android:icon="@drawable/ic_action_start"
|
||||
android:showAsAction="ifRoom"
|
||||
|
||||
yourapp:showAsAction="ifRoom"
|
||||
yourapp:actionProviderClass="android.support.v7.widget.ShareActionProvider"
|
||||
/>
|
||||
|
||||
<item android:id="@+id/menu_settings"
|
||||
android:title="@string/menu_settings"
|
||||
android:icon="@drawable/ic_action_settings"
|
||||
android:showAsAction="always"
|
||||
yourapp:showAsAction="always"
|
||||
/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_verify_list"
|
||||
android:title="@string/menu_verify"
|
||||
android:icon="@drawable/ic_action_browse"
|
||||
android:showAsAction="always"
|
||||
yourapp:showAsAction="always"
|
||||
>
|
||||
<menu>
|
||||
<item android:id="@+id/menu_verify"
|
||||
|
@ -54,21 +55,21 @@
|
|||
<item android:id="@+id/menu_about"
|
||||
android:title="@string/menu_about"
|
||||
android:icon="@drawable/ic_menu_about"
|
||||
android:showAsAction="ifRoom"
|
||||
yourapp:showAsAction="ifRoom"
|
||||
|
||||
/>
|
||||
|
||||
<item android:id="@+id/menu_wizard"
|
||||
android:title="@string/menu_wizard"
|
||||
android:icon="@drawable/ic_menu_goto"
|
||||
android:showAsAction="ifRoom"
|
||||
yourapp:showAsAction="ifRoom"
|
||||
|
||||
/>
|
||||
|
||||
<item android:id="@+id/menu_exit"
|
||||
android:title="@string/menu_exit"
|
||||
android:icon="@drawable/ic_menu_exit"
|
||||
android:showAsAction="ifRoom"
|
||||
yourapp:showAsAction="ifRoom"
|
||||
|
||||
/>
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
package org.torproject.android;
|
||||
|
||||
import static org.torproject.android.TorConstants.TAG;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.torproject.android.service.ITorService;
|
||||
|
@ -34,6 +36,7 @@ import android.os.IBinder;
|
|||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.view.ActionMode;
|
||||
import android.text.ClipboardManager;
|
||||
import android.text.Layout;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
|
@ -188,9 +191,87 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
|
||||
mItemOnOff = menu.getItem(0);
|
||||
|
||||
/*
|
||||
startSupportActionMode(new ActionMode.Callback() {
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
|
||||
// Inflate our menu from a resource file
|
||||
// actionMode.getMenuInflater().inflate(R.menu.action_mode_main, menu);
|
||||
|
||||
// Return true so that the action mode is shown
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
|
||||
// As we do not need to modify the menu before displayed, we return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
|
||||
// Similar to menu handling in Activity.onOptionsItemSelected()
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.menu_start:
|
||||
try
|
||||
{
|
||||
|
||||
if (mService == null)
|
||||
{
|
||||
|
||||
}
|
||||
else if (mService.getStatus() == TorServiceConstants.STATUS_OFF)
|
||||
{
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_stop);
|
||||
startTor();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_start);
|
||||
stopTor();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (RemoteException re)
|
||||
{
|
||||
Log.w(TAG, "Unable to start/top Tor from menu UI", re);
|
||||
}
|
||||
return true;
|
||||
case R.id.menu_settings:
|
||||
showSettings();
|
||||
return true;
|
||||
case R.id.menu_wizard:
|
||||
startWizard();
|
||||
return true;
|
||||
case R.id.menu_verify:
|
||||
doTorCheck();
|
||||
return true;
|
||||
case R.id.menu_exit:
|
||||
doExit();
|
||||
return true;
|
||||
case R.id.menu_about:
|
||||
showAbout();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode actionMode) {
|
||||
// Allows you to be notified when the action mode is dismissed
|
||||
}
|
||||
});*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void showAbout ()
|
||||
{
|
||||
|
@ -214,10 +295,11 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
.setView(view)
|
||||
.show();
|
||||
}
|
||||
/**
|
||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||
|
||||
super.onMenuItemSelected(featureId, item);
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
super.onOptionsItemSelected(item);
|
||||
|
||||
if (item.getItemId() == R.id.menu_start)
|
||||
{
|
||||
|
@ -278,7 +360,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is our attempt to REALLY exit Orbot, and stop the background service
|
||||
|
|
Loading…
Reference in New Issue