Skip to content

Commit fe089cf

Browse files
authored
Merge pull request #394 from tejavojjala/iss314
Fixes #314
2 parents b932e1b + b844eb0 commit fe089cf

File tree

13 files changed

+31
-16
lines changed

13 files changed

+31
-16
lines changed
Binary file not shown.
Binary file not shown.
-805 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
466 Bytes
Binary file not shown.
Binary file not shown.

source-code/app/src/main/java/org/buildmlearn/toolkit/dictationtemplate/fragment/DetailActivityFragment.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.database.Cursor;
99
import android.os.Build;
1010
import android.os.Bundle;
11+
import android.support.annotation.Nullable;
1112
import android.speech.tts.TextToSpeech;
1213
import android.speech.tts.UtteranceProgressListener;
1314
import android.support.v4.app.Fragment;
@@ -17,6 +18,7 @@
1718
import android.support.v7.app.AlertDialog;
1819
import android.support.v7.widget.Toolbar;
1920
import android.text.method.LinkMovementMethod;
21+
import android.view.KeyEvent;
2022
import android.view.LayoutInflater;
2123
import android.view.MenuItem;
2224
import android.view.View;
@@ -119,6 +121,25 @@ public void onActivityCreated(Bundle savedInstanceState) {
119121
super.onActivityCreated(savedInstanceState);
120122
}
121123

124+
@Override
125+
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
126+
super.onViewCreated(view, savedInstanceState);
127+
getView().setFocusableInTouchMode(true);
128+
getView().requestFocus();
129+
getView().setOnKeyListener(new View.OnKeyListener() {
130+
@Override
131+
public boolean onKey(View v, int keyCode, KeyEvent event) {
132+
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
133+
getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
134+
getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), org.buildmlearn.toolkit.dictationtemplate.fragment.MainActivityFragment.newInstance()).addToBackStack(null).commit();
135+
return true;
136+
}
137+
return false;
138+
}
139+
});
140+
141+
}
142+
122143
@Override
123144
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
124145
if (null != dictId) {

source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/MainFragment.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.buildmlearn.toolkit.flashcardtemplate.fragment;
22

3-
import android.app.FragmentManager;
43
import android.content.Context;
54
import android.content.Intent;
65
import android.database.Cursor;
@@ -132,7 +131,6 @@ public boolean onMenuItemClick(MenuItem item) {
132131

133132
Fragment frag = MainFragment.newInstance();
134133
frag.setArguments(arguments);
135-
getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
136134
getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), frag).addToBackStack(null).commit();
137135

138136
return false;
@@ -194,7 +192,6 @@ public void onClick(View v) {
194192

195193
Fragment frag = MainFragment.newInstance();
196194
frag.setArguments(arguments);
197-
getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
198195
getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), frag).addToBackStack(null).commit();
199196

200197
}
@@ -214,7 +211,6 @@ public void onClick(View v) {
214211

215212
Fragment frag = MainFragment.newInstance();
216213
frag.setArguments(arguments);
217-
getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
218214
getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), frag).addToBackStack(null).commit();
219215

220216

@@ -223,7 +219,6 @@ public void onClick(View v) {
223219
Bundle arguments = new Bundle();
224220
Fragment frag = LastFragment.newInstance();
225221
frag.setArguments(arguments);
226-
getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
227222
getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), frag).addToBackStack(null).commit();
228223

229224
}

0 commit comments

Comments
 (0)