Skip to content

Commit b5d9b24

Browse files
committed
fix actionbar
1 parent 13a5825 commit b5d9b24

File tree

5 files changed

+70
-26
lines changed

5 files changed

+70
-26
lines changed

PowerFileExplorer/src/main/AndroidManifest.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666

6767
<!--uses-feature android:name="android.software.leanback" android:required="false"/>
6868
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/
69-
|orientation|screenSize-->
69+
|orientation|screenSize
70+
android:launchMode="singleTop"
71+
-->
7072

7173

7274
<application
@@ -83,8 +85,7 @@
8385
<activity android:name="net.gnu.explorer.ExplorerActivity"
8486
android:label="@string/app_name"
8587
android:theme="@style/appCompatLight"
86-
android:launchMode="singleTop"
87-
android:windowSoftInputMode="adjustPan"
88+
android:windowSoftInputMode="adjustPan"
8889
>
8990
<!--
9091
android:resizableActivity="true"

PowerFileExplorer/src/main/java/net/gnu/explorer/ExplorerActivity.java

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ public void onCreate(final Bundle savedInstanceState) {
423423
window.requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
424424

425425
resources = getResources();
426-
final ActionBar actionBar = getSupportActionBar();
427426
intent = getIntent();
428427
final String action = intent.getAction();
429428

@@ -432,14 +431,18 @@ public void onCreate(final Bundle savedInstanceState) {
432431

433432
dataUtils.registerOnDataChangedListener(this);
434433

434+
if (!Intent.ACTION_MAIN.equals(action)) {
435+
setTheme(R.style.Theme_AppCompat_DayNight);
436+
}
435437
setContentView(R.layout.activity_folder_chooser);
438+
final ActionBar actionBar = getSupportActionBar();
436439

437440
if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
438441
//setContentView(R.layout.activity_folder_chooser_vertical);
439-
Log.d(TAG, "ORIENTATION_PORTRAIT " + action);
442+
Log.d(TAG, "ORIENTATION_PORTRAIT ");// + action + ", " + getTheme() + ", " + actionBar);
440443
} else {
441444
//setContentView(R.layout.activity_folder_chooser);
442-
Log.d(TAG, "ORIENTATION_LANDSCAPE " + action);
445+
Log.d(TAG, "ORIENTATION_LANDSCAPE ");// + action + ", " + getTheme() + ", " + actionBar);
443446
}
444447

445448
final FragmentManager supportFragmentManager = getSupportFragmentManager();
@@ -501,20 +504,22 @@ public void onCreate(final Bundle savedInstanceState) {
501504
imageView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
502505
mDrawerList.addHeaderView(imageView);
503506

504-
if (Intent.ACTION_MAIN.equals(action) || Intent.ACTION_VIEW.equals(action)) {
505-
findViewById(R.id.buttons).setVisibility(View.GONE);
506-
}
507+
// if (Intent.ACTION_MAIN.equals(action) || Intent.ACTION_VIEW.equals(action)) {
508+
// //findViewById(R.id.buttons).setVisibility(View.GONE);
509+
// }
507510

508511
if (actionBar != null) {
509512
if (Intent.ACTION_MAIN.equals(action)) {
510513
actionBar.hide();
511514
} else {
512-
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
513-
actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
514-
actionBar.setDisplayShowTitleEnabled(false);
515+
//actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
516+
//actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
517+
actionBar.setDisplayShowTitleEnabled(true);
515518
actionBar.setDisplayHomeAsUpEnabled(true);
516-
actionBar.setHomeButtonEnabled(true);
517-
setTitle("File/Folder chooser");
519+
//actionBar.setHomeButtonEnabled(true);
520+
final View customView = getLayoutInflater().inflate(R.layout.filechoosertoolbar, null);
521+
actionBar.setCustomView(customView);
522+
actionBar.setDisplayShowCustomEnabled(true);
518523
actionBar.show();
519524
}
520525
}
@@ -549,13 +554,17 @@ public void onCreate(final Bundle savedInstanceState) {
549554
if (suffix.length() == 0) {
550555
suffix = ".*";
551556
}
552-
} else if (Intent.ACTION_GET_CONTENT.equals(action) && !intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)) {
553-
multiFiles = false;
554-
if (suffix.length() == 0) {
557+
} else if (Intent.ACTION_GET_CONTENT.equals(action)) {
558+
if (!intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)) {
559+
multiFiles = false;
560+
if (suffix.length() == 0) {
561+
suffix = ".*";
562+
}
563+
} else {
555564
suffix = ".*";
556565
}
557566
} else {
558-
suffix = ".*";
567+
suffix = "*";
559568
}
560569
previousSelectedStr = intent.getStringArrayExtra(Constants.PREVIOUS_SELECTED_FILES);
561570
Log.d(TAG, "previousSelectedStr " + Util.arrayToString(previousSelectedStr, true, "\n"));
@@ -2448,7 +2457,7 @@ private void updateColor() {
24482457

24492458
setTheme(mCurTheme);
24502459
window.getDecorView().setBackgroundColor(Constants.BASE_BACKGROUND);
2451-
findViewById(R.id.buttons).setBackgroundColor(Constants.BASE_BACKGROUND);
2460+
//findViewById(R.id.buttons).setBackgroundColor(Constants.BASE_BACKGROUND);
24522461

24532462
if (configurationChanged) {
24542463
configurationChanged = false;
@@ -2896,9 +2905,7 @@ public void ok(View view) {
28962905
intent.putStringArrayListExtra(Constants.PREVIOUS_SELECTED_FILES, fileArr);
28972906
intent.putExtra(Constants.EXTRA_MULTI_SELECT, multiFiles);
28982907
final int size = fileArr.size();
2899-
if (size == 1) {
2900-
intent.setData(FileProvider.getUriForFile(this, "net.gnu.explorer.fileprovider", new File(fileArr.get(0))));
2901-
} else if (size > 1) {
2908+
if (size > 1) {
29022909
final ClipData clipData = ClipData.newRawUri(
29032910
"", FileProvider.getUriForFile(this, "net.gnu.explorer.fileprovider", new File(fileArr.get(0))));
29042911
for (int i = 1; i < size; i ++) {

PowerFileExplorer/src/main/res/layout-land/activity_folder_chooser.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
</FrameLayout>
6060
</LinearLayout>
61-
<LinearLayout
61+
<!--<LinearLayout
6262
android:id="@+id/buttons"
6363
android:layout_width="match_parent"
6464
android:layout_height="wrap_content"
@@ -87,7 +87,7 @@
8787
android:src="@drawable/install"
8888
android:textSize="14sp"
8989
android:layout_margin="0dp" />
90-
</LinearLayout>
90+
</LinearLayout>-->
9191

9292
</RelativeLayout>
9393
<!-- The navigation drawer -->

PowerFileExplorer/src/main/res/layout-port/activity_folder_chooser.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
</FrameLayout>
6060
</LinearLayout>
6161

62-
<LinearLayout
62+
<!--<LinearLayout
6363
android:id="@+id/buttons"
6464
android:layout_width="match_parent"
6565
android:layout_height="wrap_content"
@@ -88,7 +88,7 @@
8888
android:src="@drawable/install"
8989
android:textSize="14sp"
9090
android:layout_margin="0dp" />
91-
</LinearLayout>
91+
</LinearLayout>-->
9292

9393
</RelativeLayout>
9494

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:id="@+id/buttons"
5+
android:layout_width="wrap_content"
6+
android:layout_height="wrap_content"
7+
android:layout_gravity="right"
8+
android:gravity="right"
9+
android:orientation="horizontal"
10+
android:layout_margin="0dp" >
11+
12+
<ImageButton
13+
android:id="@+id/cancelDir"
14+
android:layout_width="64dp"
15+
android:layout_height="48dp"
16+
android:layout_toLeftOf="@+id/okDir"
17+
android:layout_weight="1"
18+
android:onClick="cancel"
19+
android:text="Cancel"
20+
android:src="@drawable/delete"
21+
android:textSize="14sp"
22+
android:layout_margin="0dp" />
23+
24+
<ImageButton
25+
android:id="@+id/okDir"
26+
android:layout_width="64dp"
27+
android:layout_height="48dp"
28+
android:layout_alignParentRight="true"
29+
android:layout_weight="1"
30+
android:onClick="ok"
31+
android:text="OK"
32+
android:src="@drawable/install"
33+
android:textSize="14sp"
34+
android:layout_margin="0dp" />
35+
</LinearLayout>
36+

0 commit comments

Comments
 (0)