mirror of https://github.com/readrops/Readrops.git
Add opml import/export preference in account preferences and open android file dialog
This commit is contained in:
parent
d4eb6d6660
commit
dfb4c82c59
|
@ -2,6 +2,7 @@ package com.readrops.app.fragments.settings;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.observers.DisposableCompletableObserver;
|
import io.reactivex.observers.DisposableCompletableObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
import static android.app.Activity.RESULT_OK;
|
||||||
import static com.readrops.app.utils.ReadropsKeys.ACCOUNT;
|
import static com.readrops.app.utils.ReadropsKeys.ACCOUNT;
|
||||||
import static com.readrops.app.utils.ReadropsKeys.EDIT_ACCOUNT;
|
import static com.readrops.app.utils.ReadropsKeys.EDIT_ACCOUNT;
|
||||||
|
|
||||||
|
@ -31,6 +33,8 @@ import static com.readrops.app.utils.ReadropsKeys.EDIT_ACCOUNT;
|
||||||
*/
|
*/
|
||||||
public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
|
public static final int OPEN_OPML_FILE_REQUEST = 1;
|
||||||
|
|
||||||
private Account account;
|
private Account account;
|
||||||
private AccountViewModel viewModel;
|
private AccountViewModel viewModel;
|
||||||
|
|
||||||
|
@ -57,10 +61,14 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
||||||
Preference feedsFoldersPref = findPreference("feeds_folders_key");
|
Preference feedsFoldersPref = findPreference("feeds_folders_key");
|
||||||
Preference credentialsPref = findPreference("credentials_key");
|
Preference credentialsPref = findPreference("credentials_key");
|
||||||
Preference deleteAccountPref = findPreference("delete_account_key");
|
Preference deleteAccountPref = findPreference("delete_account_key");
|
||||||
|
Preference opmlPref = findPreference("opml_import_export");
|
||||||
|
|
||||||
if (account.is(AccountType.LOCAL))
|
if (account.is(AccountType.LOCAL))
|
||||||
credentialsPref.setVisible(false);
|
credentialsPref.setVisible(false);
|
||||||
|
|
||||||
|
if (!account.is(AccountType.LOCAL))
|
||||||
|
opmlPref.setVisible(false);
|
||||||
|
|
||||||
feedsFoldersPref.setOnPreferenceClickListener(preference -> {
|
feedsFoldersPref.setOnPreferenceClickListener(preference -> {
|
||||||
Intent intent = new Intent(getContext(), ManageFeedsFoldersActivity.class);
|
Intent intent = new Intent(getContext(), ManageFeedsFoldersActivity.class);
|
||||||
intent.putExtra(ACCOUNT, account);
|
intent.putExtra(ACCOUNT, account);
|
||||||
|
@ -83,6 +91,11 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
||||||
deleteAccount();
|
deleteAccount();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
opmlPref.setOnPreferenceClickListener(preference -> {
|
||||||
|
openOPMLFile();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,4 +126,21 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
||||||
})))
|
})))
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openOPMLFile() {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
intent.setType("application/*");
|
||||||
|
|
||||||
|
getActivity().startActivityForResult(intent, OPEN_OPML_FILE_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
if (requestCode == OPEN_OPML_FILE_REQUEST && requestCode == RESULT_OK && data != null) {
|
||||||
|
Uri uri = data.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp" android:tint="#727272"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M9,3L5,6.99h3L8,14h2L10,6.99h3L9,3zM16,17.01L16,10h-2v7.01h-3L15,21l4,-3.99h-3z"/>
|
||||||
|
</vector>
|
|
@ -93,5 +93,6 @@
|
||||||
<string name="external_navigator">Navigateur externe</string>
|
<string name="external_navigator">Navigateur externe</string>
|
||||||
<string name="actualize">Actualiser</string>
|
<string name="actualize">Actualiser</string>
|
||||||
<string name="share_url">Partager le lien</string>
|
<string name="share_url">Partager le lien</string>
|
||||||
|
<string name="opml_import_export">Import/Export OPML</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -101,4 +101,5 @@
|
||||||
<string name="external_navigator">External navigator</string>
|
<string name="external_navigator">External navigator</string>
|
||||||
<string name="actualize">Actualize</string>
|
<string name="actualize">Actualize</string>
|
||||||
<string name="share_url">Share url</string>
|
<string name="share_url">Share url</string>
|
||||||
|
<string name="opml_import_export">OPML Import/Export</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
android:key="credentials_key"
|
android:key="credentials_key"
|
||||||
android:title="@string/credentials" />
|
android:title="@string/credentials" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:icon="@drawable/ic_import_export"
|
||||||
|
android:key="opml_import_export"
|
||||||
|
android:title="@string/opml_import_export" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:icon="@drawable/ic_delete_grey"
|
android:icon="@drawable/ic_delete_grey"
|
||||||
android:key="delete_account_key"
|
android:key="delete_account_key"
|
||||||
|
|
Loading…
Reference in New Issue