Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
1.4.3s (#13)
Browse files Browse the repository at this point in the history
\* fully moved to AndroidX
\* moved to AppCompad themes
  • Loading branch information
Guiorgy authored May 15, 2019
1 parent adfd296 commit 2ec80c8
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 91 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.4.3s - 2019-05-15

\* fully moved to AndroidX
\* moved to AppCompad themes

## 1.4.2s - 2019-04-22

\- removed refreshLayout
Expand Down
14 changes: 5 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,17 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':library')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'eu.agno3.jcifs:jcifs-ng:2.1.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha5'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'

/** LeakCanary - https://github.com/square/leakcanary */
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'

// implementation 'com.obsez.android.lib.filechooser:filechooser:1.1.6'
// implementation 'com.github.hedzr:android-file-chooser:master-SNAPSHOT'
// implementation 'com.github.hedzr:android-file-chooser:v1.1.10'
}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.obsez.android.lib.smbfilechooser.demo;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand All @@ -23,6 +22,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import jcifs.smb.SmbException;
import jcifs.smb.SmbFile;
Expand Down Expand Up @@ -88,11 +88,16 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
final Context ctx = getContext();
if (ctx == null) {
buttonView.setChecked(false);
return;
}
AlertDialog.Builder alert;
alert = darkTheme.isChecked() ? new AlertDialog.Builder(getContext(), R.style.FileChooserDialogStyle_Dark) : new AlertDialog.Builder(getContext(), R.style.FileChooserDialogStyle);
alert = darkTheme.isChecked() ? new AlertDialog.Builder(ctx, R.style.FileChooserDialogStyle_Dark) : new AlertDialog.Builder(ctx, R.style.FileChooserDialogStyle);
alert.setTitle("Set server");
alert.setCancelable(false);
final EditText input = new EditText(getContext());
final EditText input = new EditText(ctx);
input.setText(_server);
alert.setView(input);
alert.setPositiveButton("Ok", (dialog, whichButton) -> _server = input.getText().toString());
Expand Down
22 changes: 0 additions & 22 deletions app/src/main/res/values-v21/styles.xml

This file was deleted.

8 changes: 5 additions & 3 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
<item name="fileChooserNewFolderStyle">@style/FileChooserNewFolderStyle_Dark</item>
</style>

<style name="FileChooserDialogStyle_Dark" parent="@android:style/Theme.DeviceDefault">
<item name="android:windowBackground">@android:color/transparent</item>
<style name="FileChooserDialogStyle_Dark" parent="Theme.AppCompat.Dialog.Alert">
<!--<item name="android:windowBackground">@android:color/transparent</item>-->
<item name="android:textColorPrimary">@android:color/holo_blue_light</item>
<item name="colorAccent">@android:color/holo_blue_light</item>
<item name="android:windowTitleStyle">@style/FileChooserTitleStyle_Dark</item>
<item name="android:buttonBarButtonStyle">@style/FileChooserButtonStyle_Dark</item>
<item name="buttonBarButtonStyle">@style/FileChooserButtonStyle_Dark</item>
<item name="android:backgroundDimAmount">0.8</item>
</style>

<style name="FileChooserTitleStyle_Dark" parent="FileChooserTitleStyle">
<item name="android:textAppearance">@android:style/TextAppearance.Holo.DialogWindowTitle</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Title.Inverse</item>
<item name="android:textColor">@android:color/holo_blue_light</item>
</style>

<style name="FileChooserButtonStyle_Dark" parent="FileChooserButtonStyle">
Expand Down
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.30'
ext.kotlin_version = '1.3.31'
repositories {
google()
maven { url "https://maven.google.com" }
maven { url "https://maven.google.com" }
maven { url "https://dl.bintray.com/kotlin/kotlinx/" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools:r8:1.3.52'
classpath 'com.android.tools:r8:1.4.93'

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android.enableJetifier=true
android.useAndroidX=true

# Global variables
VERSION_NAME=1.4.2s
VERSION_CODE=104020
VERSION_NAME=1.4.3s
VERSION_CODE=104030
GROUP=com.obsez.android.lib.smbfilechooser

POM_GROUP_ID=com.github.Guiorgy
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'eu.agno3.jcifs:jcifs-ng:2.1.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

task createPom {
Expand Down
8 changes: 4 additions & 4 deletions library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.Guiorgy</groupId>
<artifactId>android-smbfile-chooser</artifactId>
<version>1.4.2s</version>
<version>1.4.3s</version>
<inceptionYear>2018</inceptionYear>
<licenses>
<license>
Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>androidx.appcompat</groupId>
<artifactId>appcompat</artifactId>
<version>1.1.0-alpha04</version>
<version>1.1.0-alpha05</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand All @@ -28,8 +28,8 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk7</artifactId>
<version>1.3.30</version>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.3.31</version>
<scope>runtime</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.obsez.android.lib.smbfilechooser;

import android.Manifest;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
Expand Down Expand Up @@ -56,6 +55,7 @@
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;

Expand Down Expand Up @@ -670,10 +670,15 @@ public void onClick(final View v) {
if (FileChooserDialog.this._options == null) {
// region Draw options view. (this only happens the first time one clicks on options)
// Root view (FrameLayout) of the ListView in the AlertDialog.
final int rootId = getResources().getIdentifier("contentPanel", "id", "android");
final ViewGroup root = ((AlertDialog) dialog).findViewById(rootId);
// In case the id was changed or not found.
if (root == null) return;
int rootId = getResources().getIdentifier("contentPanel", "id", getPackageName());
ViewGroup tmpRoot = ((AlertDialog) dialog).findViewById(rootId);
// In case the root id was changed or not found.
if (tmpRoot == null) {
rootId = getResources().getIdentifier("contentPanel", "id", "android");
tmpRoot = ((AlertDialog) dialog).findViewById(rootId);
if (tmpRoot == null) return;
}
final ViewGroup root = tmpRoot;

// Create options view.
final FrameLayout options = new FrameLayout(getBaseContext());
Expand Down Expand Up @@ -1113,10 +1118,14 @@ public void onShouldShowRequestPermissionRationale(final String[] permissions) {

private void displayPath(@Nullable String path) {
if (_pathView == null) {
final int rootId = getResources().getIdentifier("contentPanel", "id", "android");
final ViewGroup root = ((AlertDialog) _alertDialog).findViewById(rootId);
// In case the id was changed or not found.
if (root == null) return;
int rootId = getResources().getIdentifier("contentPanel", "id", getPackageName());
ViewGroup root = ((AlertDialog) _alertDialog).findViewById(rootId);
// In case the root id was changed or not found.
if (root == null) {
rootId = getResources().getIdentifier("contentPanel", "id", "android");
root = ((AlertDialog) _alertDialog).findViewById(rootId);
if (root == null) return;
}

ViewGroup.MarginLayoutParams params;
if (root instanceof LinearLayout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
Expand Down Expand Up @@ -39,6 +38,7 @@
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;

Expand Down Expand Up @@ -800,10 +800,15 @@ public void onShow(final DialogInterface dialog) {
final PorterDuffColorFilter filter = new PorterDuffColorFilter(buttonColor, PorterDuff.Mode.SRC_IN);

// Root view (FrameLayout) of the ListView in the AlertDialog.
final int rootId = getResources().getIdentifier("contentPanel", "id", "android");
final ViewGroup root = ((AlertDialog) dialog).findViewById(rootId);
// In case the id was changed or not found.
if (root == null) return;
int rootId = getResources().getIdentifier("contentPanel", "id", getPackageName());
ViewGroup tmpRoot = ((AlertDialog) dialog).findViewById(rootId);
// In case the root id was changed or not found.
if (tmpRoot == null) {
rootId = getResources().getIdentifier("contentPanel", "id", "android");
tmpRoot = ((AlertDialog) dialog).findViewById(rootId);
if (tmpRoot == null) return;
}
final ViewGroup root = tmpRoot;

ViewGroup.MarginLayoutParams params;
ProgressBar progressBar;
Expand Down Expand Up @@ -1406,10 +1411,14 @@ public void onShouldShowRequestPermissionRationale(final String[] permissions) {

private void displayPath(@Nullable String path) {
if (_pathView == null) {
final int rootId = getResources().getIdentifier("contentPanel", "id", "android");
final ViewGroup root = ((AlertDialog) _alertDialog).findViewById(rootId);
// In case the id was changed or not found.
if (root == null) return;
int rootId = getResources().getIdentifier("contentPanel", "id", getPackageName());
ViewGroup root = ((AlertDialog) _alertDialog).findViewById(rootId);
// In case the root id was changed or not found.
if (root == null) {
rootId = getResources().getIdentifier("contentPanel", "id", "android");
root = ((AlertDialog) _alertDialog).findViewById(rootId);
if (root == null) return;
}

ViewGroup.MarginLayoutParams params;
if (root instanceof LinearLayout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public static abstract class LightContextWrapper {

public LightContextWrapper(@NonNull final Context context) {
this.context = context;
if (context instanceof AppCompatActivity || context instanceof Activity) {
if (context instanceof Activity) {
this.activity = (Activity) context;
}
}
Expand All @@ -253,6 +253,11 @@ public Activity getActivity() {
return activity;
}

@NonNull
public String getPackageName() {
return context.getPackageName();
}

@NonNull
public Resources getResources() {
return context.getResources();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ Context getContext() {
@SuppressLint("SimpleDateFormat")
private void init(String dateFormat) {
_formatter = new SimpleDateFormat(dateFormat != null && !"".equals(dateFormat.trim()) ? dateFormat.trim() : "yyyy/MM/dd HH:mm:ss");
_defaultFolderIcon = ContextCompat.getDrawable(getContext(), R.drawable.ic_folder);
_defaultFileIcon = ContextCompat.getDrawable(getContext(), R.drawable.ic_file);
if (_defaultFolderIcon == null) _defaultFolderIcon = ContextCompat.getDrawable(getContext(), R.drawable.ic_folder);
if (_defaultFileIcon == null) _defaultFileIcon = ContextCompat.getDrawable(getContext(), R.drawable.ic_file);

TypedArray ta = getContext().obtainStyledAttributes(R.styleable.FileChooser);
int colorFilter = ta.getColor(R.styleable.FileChooser_fileListItemSelectedTint, getContext().getResources().getColor(R.color.li_row_background_tint));
Expand Down
18 changes: 0 additions & 18 deletions library/src/main/res/values-v21/styles.xml

This file was deleted.

12 changes: 8 additions & 4 deletions library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:ignore="ResourceName,PrivateResource">

<!-- PermissionActivity style -->
<style name="Theme.Transparent" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
Expand Down Expand Up @@ -44,7 +45,7 @@
<!-- Dialog -->
<public name="FileChooserDialogStyle" type="style" />
<style name="FileChooserDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowBackground">@android:color/transparent</item>
<!--<item name="android:windowBackground">@android:color/transparent</item>-->
<item name="android:windowTitleStyle">@style/FileChooserTitleStyle</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
Expand All @@ -53,20 +54,23 @@
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:windowIsFloating">true</item>
<item name="android:buttonBarStyle">@android:style/Holo.Light.ButtonBar.AlertDialog</item>
<item name="android:buttonBarStyle">@style/Widget.AppCompat.ButtonBar.AlertDialog</item>
<item name="buttonBarStyle">@style/Widget.AppCompat.ButtonBar.AlertDialog</item>
<item name="android:buttonBarButtonStyle">@style/FileChooserButtonStyle</item>
<item name="buttonBarButtonStyle">@style/FileChooserButtonStyle</item>
</style>

<public name="FileChooserTitleStyle" type="style" />
<style name="FileChooserTitleStyle">
<item name="android:maxLines">1</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:textAppearance">@android:style/TextAppearance.DialogWindowTitle</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
<item name="android:textColor">#f000</item>
</style>

<public name="FileChooserButtonStyle" type="style" />
<style name="FileChooserButtonStyle" parent="@android:style/Holo.Light.ButtonBar.AlertDialog">
<style name="FileChooserButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textAppearanceButton">@style/TextAppearance.AppCompat.Button</item>
<item name="android:textColor">@color/material_deep_teal_500</item>
</style>

Expand Down
Loading

0 comments on commit 2ec80c8

Please sign in to comment.