Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated UI for Pref and Frag to newer androidx #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ dependencies {
implementation 'com.twofortyfouram:android-plugin-client-sdk-for-locale:4.0.3'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'org.jetbrains:annotations:23.0.0'
implementation 'androidx.work:work-runtime:2.9.0'
implementation 'androidx.work:work-runtime:2.9.1'
implementation 'androidx.preference:preference:1.2.1'
}

android {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ along with SwiFTP. If not, see <http://www.gnu.org/licenses/>.

<activity
android:name="be.ppareit.swiftp.gui.MainActivity"
android:configChanges="screenSize|orientation"
android:theme="@style/AppThemeDark"
android:exported="true">
<intent-filter>
Expand All @@ -72,6 +73,7 @@ along with SwiFTP. If not, see <http://www.gnu.org/licenses/>.

<activity
android:name=".gui.ManageUsersActivity"
android:configChanges="screenSize|orientation"
android:parentActivityName=".gui.MainActivity"
android:theme="@style/AppThemeDark" />

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/be/ppareit/swiftp/gui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public void onCreate(Bundle savedInstanceState) {
ad.show();
}

getFragmentManager().beginTransaction()
.replace(android.R.id.content, new PreferenceFragment())
getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, new PreferenceFragment(), null)
.commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ManageUsersActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
setTheme(FsSettings.getTheme());
super.onCreate(savedInstanceState);
getFragmentManager().beginTransaction()
getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, UserListFragment.newInstance())
.commit();
}
Expand Down
423 changes: 254 additions & 169 deletions app/src/main/java/be/ppareit/swiftp/gui/PreferenceFragment.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package be.ppareit.swiftp.gui;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/java/be/ppareit/swiftp/gui/UserListFragment.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package be.ppareit.swiftp.gui;

import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -68,7 +70,7 @@ private void showEditItemFragment(FtpUser item) {
}
refreshUserList();
});
getActivity().getFragmentManager().beginTransaction()
getActivity().getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, editFragment)
.addToBackStack("default")
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
Expand Down
64 changes: 43 additions & 21 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,78 @@ along with SwiFTP. If not, see <http://www.gnu.org/licenses/>.
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="preference_screen">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:key="preference_screen"
app:iconSpaceReserved="false">

<SwitchPreference
android:defaultValue="false"
android:key="running_switch"
android:summary="@string/running_summary_stopped"
android:title="@string/running_label" />
android:title="@string/running_label"
app:iconSpaceReserved="false" />
<Preference
android:key="market_version"
android:summary="@string/market_version_summary"
android:title="@string/market_version_label" />
android:title="@string/market_version_label"
app:iconSpaceReserved="false" />

<PreferenceCategory
android:key="settings"
android:title="@string/settings_label">
android:title="@string/settings_label"
app:iconSpaceReserved="false">

<Preference
android:key="manage_users"
android:title="@string/manage_users_label" />
android:title="@string/manage_users_label"
app:iconSpaceReserved="false" />

<Preference
android:key="manage_anon"
android:title="@string/manage_anon_label" />
android:title="@string/manage_anon_label"
app:iconSpaceReserved="false"/>

<PreferenceScreen
android:key="appearance_screen"
android:title="@string/gui_settings_label">
android:title="@string/gui_settings_label"
app:iconSpaceReserved="false">
<ListPreference
android:defaultValue="0"
android:entries="@array/pref_list_themes"
android:entryValues="@array/pref_list_themes_values"
android:key="theme"
android:title="@string/app_theme" />
android:title="@string/app_theme"
app:iconSpaceReserved="false" />
<CheckBoxPreference
android:defaultValue="true"
android:key="show_notification_icon_preference"
android:summary="@string/show_notification_icon_summary"
android:title="@string/show_notification_icon" />
android:title="@string/show_notification_icon"
app:iconSpaceReserved="false" />
</PreferenceScreen>


<PreferenceScreen
android:title="@string/advanced_settings_label">
android:key="preference_screen_advanced"
android:title="@string/advanced_settings_label"
app:iconSpaceReserved="false" >
<EditTextPreference
android:defaultValue="@string/portnumber_default"
android:key="portNum"
android:title="@string/port_number_label" />
android:title="@string/port_number_label"
app:iconSpaceReserved="false" />

<CheckBoxPreference
android:defaultValue="@string/wakelock_default"
android:key="stayAwake"
android:title="@string/wakelock_label" />
android:title="@string/wakelock_label"
app:iconSpaceReserved="false" />

<CheckBoxPreference
android:defaultValue="@string/writeExternalStorage_default"
android:key="writeExternalStorage"
android:title="@string/writeExternalStorage_label" />
android:title="@string/writeExternalStorage_label"
app:iconSpaceReserved="false" />

<CheckBoxPreference
android:defaultValue="@string/useScopedStorage_default"
Expand All @@ -83,7 +98,7 @@ along with SwiFTP. If not, see <http://www.gnu.org/licenses/>.
android:drawableStart="@drawable/ic_shared_dir"
android:title="@string/use_scoped_storage_label"
android:summary="@string/use_scope_storage_summary"
/>
app:iconSpaceReserved="false" />

<ListPreference
android:defaultValue="0"
Expand All @@ -92,19 +107,23 @@ along with SwiFTP. If not, see <http://www.gnu.org/licenses/>.
android:key="battery_saver"
android:dialogTitle="@string/battery_saver_setting_title"
android:title="@string/battery_saver_setting_title"
android:summary="@string/battery_saver_desc"/>
android:summary="@string/battery_saver_desc"
app:iconSpaceReserved="false" />

<PreferenceCategory
android:key="settings"
android:title="@string/logging">
android:title="@string/logging"
app:iconSpaceReserved="false" >
<CheckBoxPreference
android:defaultValue="@string/enableLogging_default"
android:key="enable_logging"
android:title="@string/enable_logging" />
android:title="@string/enable_logging"
app:iconSpaceReserved="false" />

<Preference
android:key="logs"
android:title="@string/manage_log_label" />
android:title="@string/manage_log_label"
app:iconSpaceReserved="false" />

</PreferenceCategory>
</PreferenceScreen>
Expand All @@ -113,13 +132,16 @@ along with SwiFTP. If not, see <http://www.gnu.org/licenses/>.

<PreferenceCategory
android:key="extra_category"
android:title="@string/extra_label">
android:title="@string/extra_label"
app:iconSpaceReserved="false" >
<Preference
android:key="help"
android:title="@string/help_label" />
android:title="@string/help_label"
app:iconSpaceReserved="false" />
<Preference
android:key="about"
android:title="@string/about_label" />
android:title="@string/about_label"
app:iconSpaceReserved="false"/>
</PreferenceCategory>

</PreferenceScreen>