Skip to content

Commit

Permalink
Fixed a bug with the options menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Viddi committed Apr 19, 2014
1 parent a72a2a7 commit 66598f8
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 22 deletions.
1 change: 1 addition & 0 deletions main/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT"/>

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class DetailsActivity extends Activity {
public static final String TAG = DetailsActivity.class.getSimpleName();

public static final String KEY_INTENT_EXTRA_PATH = "filePath";
public static final int INTENT_DETAILS = 400;

private TextView mTxtTitle, mTxtTime, mTxtSize, mTxtPath;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
protected void onResume() {
super.onResume();
openOptionsMenu();
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
openOptionsMenu();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand Down Expand Up @@ -67,6 +67,7 @@ public void onOptionsMenuClosed(Menu menu) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
openOptionsMenu();
if (resultCode == RESULT_OK && requestCode == INTENT_PICTURES) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ protected void onCreate(Bundle savedInstanceState) {

}

@Override
protected void onResume() {
super.onResume();
openOptionsMenu();
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
openOptionsMenu();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class PictureMenuActivity extends Activity {

public static final String TAG = PictureMenuActivity.class.getSimpleName();

public static final String KEY_INTENT_EXTRA_PICTURE = "pictureItem";

private FileItem mFileItem;
Expand All @@ -39,8 +39,8 @@ else if(bundle.getParcelable(VideoItem.KEY_FOR_INTENT_EXTRA) != null) {
}

@Override
protected void onResume() {
super.onResume();
public void onAttachedToWindow() {
super.onAttachedToWindow();
openOptionsMenu();
}

Expand All @@ -63,7 +63,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.details:
Intent detailsIntent = new Intent(this, DetailsActivity.class);
detailsIntent.putExtra(DetailsActivity.KEY_INTENT_EXTRA_PATH, mFileItem.getPath());
startActivity(detailsIntent);
startActivityForResult(detailsIntent, DetailsActivity.INTENT_DETAILS);
isWaiting = true;
return true;
case R.id.delete:
Expand All @@ -88,6 +88,8 @@ public void onOptionsMenuClosed(Menu menu) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
openOptionsMenu();

if(requestCode == DeleteActivity.INTENT_DELETE && resultCode == RESULT_OK) {
setResult(DeleteActivity.RESULT_DELETED);
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

@Override
protected void onResume() {
super.onResume();
openOptionsMenu();
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
openOptionsMenu();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand All @@ -53,7 +53,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.details:
Intent detailsIntent = new Intent(this, DetailsActivity.class);
detailsIntent.putExtra(DetailsActivity.KEY_INTENT_EXTRA_PATH, mVideo.getPath());
startActivity(detailsIntent);
startActivityForResult(detailsIntent, DetailsActivity.INTENT_DETAILS);
mIsWaiting = true;
return true;
case R.id.delete:
Expand All @@ -78,6 +78,8 @@ public void onOptionsMenuClosed(Menu menu) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
openOptionsMenu();

if (requestCode == DeleteActivity.INTENT_DELETE && resultCode == RESULT_OK) {
setResult(DeleteActivity.RESULT_DELETED);
finish();
Expand Down
1 change: 0 additions & 1 deletion main/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<string name="app_name">Gallery</string>
<string name="gallery_pictures">Pictures</string>
<string name="gallery_videos">Videos</string>
<string name="trigger_gallery">gallery</string>
<string name="error_picture">Failed to load image</string>
<string name="share">Share with..</string>
<string name="details">Details</string>
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/res/xml/gallery_trigger.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>

<trigger keyword="@string/trigger_gallery"/>
<trigger command="CHECK_ME_IN"/>

0 comments on commit 66598f8

Please sign in to comment.