Skip to content

Commit

Permalink
update dump view UI
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Dec 17, 2021
1 parent 9782261 commit 2cad012
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dependencies {
implementation 'com.tencent:mmkv-static:1.2.8'
implementation 'de.psdev.licensesdialog:licensesdialog:2.2.0'
implementation 'io.noties.markwon:core:4.6.2'
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:2.0'
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:3.0'
implementation "com.github.topjohnwu.libsu:core:3.1.2"
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected boolean doOnCreate(Bundle savedInstanceState) {
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_main_home, R.id.nav_main_dump, R.id.nav_main_cards)
R.id.nav_main_home, R.id.nav_main_dump_live, R.id.nav_main_cards)
.setDrawerLayout(drawer)
.build();
mNavController = Navigation.findNavController(this, R.id.nav_host_fragment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
Bundle args = getArguments();
final String uriPath = args == null ? null : args.getString(EXTRA_CONTENT);
if (uriPath == null) {
requireActivity().finish();
popSelf();
return null;
}
Uri uri = Uri.parse(uriPath);
Expand All @@ -101,7 +101,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
.setTitle(R.string.ui_dialog_error_title)
.setMessage(e.toString())
.setCancelable(false)
.setPositiveButton(android.R.string.ok, (dialog1, which) -> requireActivity().finish())
.setPositiveButton(android.R.string.ok, (dialog1, which) -> popSelf())
.show());
}
} catch (IOException e) {
Expand All @@ -110,7 +110,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
.setMessage(context.getString(R.string.ui_dialog_unable_to_open_file_v0s, uri.toString())
+ "\n" + e)
.setCancelable(false)
.setPositiveButton(android.R.string.ok, (dialog1, which) -> requireActivity().finish())
.setPositiveButton(android.R.string.ok, (dialog1, which) -> popSelf())
.show());
}
});
Expand All @@ -127,4 +127,9 @@ public void onResume() {
}

}

private void popSelf() {
requireActivity().onBackPressed();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
}
case R.id.action_view_dump_file: {
SafUtils.requestOpenFile(requireActivity()).setMimeType("application/*").onResult(uri -> {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setComponent(new ComponentName(requireContext(), SidebandHostActivity.class));
intent.setData(uri);
startActivity(intent);
Bundle args = new Bundle();
args.putString(HalDumpFileViewFragment.EXTRA_CONTENT, uri.toString());
((MainUiFragmentActivity) requireActivity()).getNavController().navigate(R.id.nav_main_dump_file, args);
}).commit();
return true;
}
default:
return super.onContextItemSelected(item);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:icon="@drawable/ic_baseline_home_24"
android:title="@string/menu_fragment_home" />
<item
android:id="@+id/nav_main_dump"
android:id="@+id/nav_main_dump_live"
android:icon="@drawable/ic_baseline_swap_vert_24"
android:title="@string/menu_fragment_dump" />
<item
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/res/navigation/mobile_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
tools:layout="@layout/fragment_main_home" />

<fragment
android:id="@+id/nav_main_dump"
android:id="@+id/nav_main_dump_live"
android:name="cc.ioctl.nfcdevicehost.activity.ui.dump.NciLiveDumpFragment"
android:label="@string/menu_fragment_dump"
tools:layout="@layout/fragment_main_dump" />
Expand All @@ -22,4 +22,10 @@
android:name="cc.ioctl.nfcdevicehost.activity.ui.cards.CardListFragment"
android:label="@string/menu_fragment_cards"
tools:layout="@layout/fragment_main_card_list" />

<fragment
android:id="@+id/nav_main_dump_file"
android:name="cc.ioctl.nfcdevicehost.activity.ui.dump.HalDumpFileViewFragment"
android:label="@string/label_nav_main_dump_file" />

</navigation>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ NCI Host 的开发人员不对使用此应用程序造成的任何损失负责
<string name="action_view_dump_file">浏览转储文件</string>
<string name="ui_dialog_title_requesting_root">请求 root 权限</string>
<string name="ui_dialog_msg_body_requesting_root">正在请求 root 权限,请授予本应用 root 权限</string>
<string name="label_nav_main_dump_file">HAL Dump File</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ By using this application, you accept all responsibility using it and agree that
<string name="action_view_dump_file">View dump file</string>
<string name="ui_dialog_title_requesting_root">Requesting root</string>
<string name="ui_dialog_msg_body_requesting_root">Please grant root permission</string>
<string name="label_nav_main_dump_file">HAL Dump File</string>
</resources>

0 comments on commit 2cad012

Please sign in to comment.