Merge pull request #710 from AnotherDaniel/aboutRework
704 - move about dialog info to settings menu
This commit is contained in:
commit
b4cd2b2586
8 changed files with 117 additions and 35 deletions
|
@ -822,11 +822,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
.show();
|
||||
break;
|
||||
|
||||
case R.id.menu_About_Changelog:
|
||||
DialogFragment dialog = new VersionInfoDialogFragment();
|
||||
dialog.show(getSupportFragmentManager(), "VersionChangelogDialogFragment");
|
||||
return true;
|
||||
|
||||
case R.id.menu_markAllAsRead:
|
||||
NewsReaderDetailFragment ndf = getNewsReaderDetailFragment();
|
||||
if(ndf != null) {
|
||||
|
|
|
@ -23,6 +23,7 @@ package de.luhmer.owncloudnewsreader;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -123,16 +124,19 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
public static final String SP_DISPLAY_BROWSER = "sp_display_browser";
|
||||
public static final String SP_SEARCH_IN = "sp_search_in";
|
||||
|
||||
public static final String CB_VERSION = "cb_version";
|
||||
|
||||
//public static final String PREF_SIGN_IN_DIALOG = "sPref_signInDialog";
|
||||
//public static final String SP_MAX_ITEMS_SYNC = "sync_max_items";
|
||||
|
||||
private static EditTextPreference clearCachePref;
|
||||
private static Activity _mActivity;
|
||||
private static String version = "<loading>";
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
version = VersionInfoDialogFragment.getVersionString(this);
|
||||
ThemeChooser.getInstance(this).chooseTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
ThemeChooser.getInstance(this).afterOnCreate(this);
|
||||
|
@ -204,6 +208,19 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
getPreferenceScreen().addPreference(header);
|
||||
addPreferencesFromResource(R.xml.pref_notification);
|
||||
|
||||
header = new PreferenceCategory(this);
|
||||
header.setTitle(R.string.pref_header_about);
|
||||
getPreferenceScreen().addPreference(header);
|
||||
addPreferencesFromResource(R.xml.pref_about);
|
||||
Preference dialogPreference = getPreferenceScreen().findPreference(CB_VERSION);
|
||||
dialogPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
DialogFragment dialog = new VersionInfoDialogFragment();
|
||||
dialog.show(SettingsActivity.this.getFragmentManager(), "VersionChangelogDialogFragment");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
header = new PreferenceCategory(this);
|
||||
header.setTitle(R.string.pref_header_podcast);
|
||||
|
@ -215,6 +232,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
bindDisplayPreferences(null, this);
|
||||
bindDataSyncPreferences(null, this);
|
||||
bindNotificationPreferences(null, this);
|
||||
bindAboutPreferences(null, this);
|
||||
//bindPodcastPreferences(null, this);
|
||||
}
|
||||
|
||||
|
@ -477,6 +495,21 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* This fragment shows about preferences only. It is used when the
|
||||
* activity is showing a two-pane settings UI.
|
||||
*/
|
||||
public static class AboutPreferenceFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.pref_about);
|
||||
|
||||
bindAboutPreferences(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void bindDisplayPreferences(PreferenceFragment prefFrag, PreferenceActivity prefAct)
|
||||
|
@ -587,6 +620,16 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static void bindAboutPreferences(PreferenceFragment prefFrag, PreferenceActivity prefAct) {
|
||||
if(prefFrag != null) {
|
||||
prefFrag.findPreference(CB_VERSION).setSummary(version);
|
||||
} else {
|
||||
prefAct.findPreference(CB_VERSION).setSummary(version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void bindPodcastPreferences(PreferenceFragment prefFrag)
|
||||
{
|
||||
if(prefFrag != null)
|
||||
|
|
|
@ -21,12 +21,14 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
|
@ -50,17 +52,24 @@ public class VersionInfoDialogFragment extends DialogFragment {
|
|||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.dialog_version_info, null);
|
||||
|
||||
ChangeLogFileListView clListView = (ChangeLogFileListView) view.findViewById(R.id.changelog_listview);
|
||||
final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.changeLogLoadingProgressBar);
|
||||
TextView versionTextView = (TextView) view.findViewById(R.id.tv_androidAppVersion);
|
||||
ChangeLogFileListView clListView = view.findViewById(R.id.changelog_listview);
|
||||
final ProgressBar progressBar = view.findViewById(R.id.changeLogLoadingProgressBar);
|
||||
TextView versionTextView = view.findViewById(R.id.tv_androidAppVersion);
|
||||
|
||||
// build dialog
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
.setView(view)
|
||||
.setTitle(getString(R.string.menu_About_Changelog));
|
||||
.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.setCancelable(true) // React to click outside of version info
|
||||
.setTitle("Changelog"); // changelog content is in english only anyways..
|
||||
|
||||
// set current version
|
||||
versionTextView.setText(getVersionString());
|
||||
versionTextView.setText(getVersionString(getActivity()));
|
||||
|
||||
// load changelog into view
|
||||
loadChangeLog(clListView, progressBar);
|
||||
|
@ -82,18 +91,18 @@ public class VersionInfoDialogFragment extends DialogFragment {
|
|||
super.onStart();
|
||||
}
|
||||
|
||||
private String getVersionString() {
|
||||
public static String getVersionString(Activity activity) {
|
||||
String version = "?";
|
||||
|
||||
try {
|
||||
PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
|
||||
PackageInfo pInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
|
||||
version = pInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Formatter formatter = new Formatter();
|
||||
String versionString = getString(R.string.current_version);
|
||||
String versionString = activity.getString(R.string.current_version);
|
||||
return formatter.format(versionString, version).toString();
|
||||
}
|
||||
|
||||
|
@ -101,7 +110,7 @@ public class VersionInfoDialogFragment extends DialogFragment {
|
|||
* Loads changelog into the given view and hides progress bar when done.
|
||||
*/
|
||||
private void loadChangeLog(ChangeLogFileListView clListView, final ProgressBar progressBar) {
|
||||
new DownloadChangelogTask(getContext(), clListView, new DownloadChangelogTask.Listener() {
|
||||
new DownloadChangelogTask(getActivity(), clListView, new DownloadChangelogTask.Listener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical">
|
||||
|
||||
<de.luhmer.owncloudnewsreader.helper.AutoResizeTextView
|
||||
android:id="@+id/tv_androidAppVersion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="30dp"
|
||||
android:gravity="center_horizontal|center_vertical" />
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="24dp"/>
|
||||
|
||||
<!-- android:paddingStart="?dialogPreferredPadding" -->
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/changeLogLoadingProgressBar"
|
||||
|
@ -22,6 +25,8 @@
|
|||
android:id="@+id/changelog_listview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical" />
|
||||
android:scrollbars="vertical"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -60,17 +60,10 @@
|
|||
app:showAsAction="never"
|
||||
android:title="@string/action_add_new_feed"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_About_Changelog"
|
||||
app:showAsAction="never"
|
||||
android:orderInCategory="102"
|
||||
android:title="@string/menu_About_Changelog"/>
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_CreateDatabaseDump"
|
||||
app:showAsAction="never"
|
||||
android:orderInCategory="103"
|
||||
android:orderInCategory="102"
|
||||
android:title="Create Database Dump"
|
||||
android:visible="false"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
<string name="title_activity_new_feed">Add new feed</string>
|
||||
|
||||
<string name="menu_update">Refresh</string>
|
||||
<string name="menu_About_Changelog">About / Changelog</string>
|
||||
<string name="menu_markAllAsRead">Mark all as read</string>
|
||||
<string name="menu_StartImageCaching">Download images</string>
|
||||
<string name="menu_downloadMoreItems">Download more items</string>
|
||||
|
@ -176,6 +175,16 @@
|
|||
<string name="notification_downloading_podcast_title">Downloading podcast</string>
|
||||
|
||||
|
||||
<!-- Settings for About -->
|
||||
<string name="pref_header_about">About</string>
|
||||
<string name="pref_license">License</string>
|
||||
<string name="pref_license_summary">GNU Affero General Public License (AGPL) version 3</string>
|
||||
<string name="pref_contribute">Contribute!</string>
|
||||
<string name="pref_contribute_summary">Get source code</string>
|
||||
<string name="pref_version">Nextcloud News Android app</string>
|
||||
|
||||
|
||||
|
||||
<!-- Settings for Display -->
|
||||
<string name="pref_header_display">Display</string>
|
||||
<string name="pref_title_app_theme">Theme</string>
|
||||
|
@ -185,7 +194,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<string name="pref_display_news_detail_actionbar_icons_title">Action icons (Detail View)</string>
|
||||
|
||||
<string-array name="pref_display_news_detail_actionbar_icons" translatable="false">
|
||||
|
@ -341,9 +349,6 @@
|
|||
<string name="pref_title_CacheImagesOffline">Cache images offline</string>
|
||||
<string name="pref_title_Max_Cache_Size">Max Cache Size</string>
|
||||
|
||||
|
||||
|
||||
|
||||
<string name="pref_data_sync_image_cache_never">Never</string>
|
||||
<string name="pref_data_sync_image_cache_wifi_only">Over WiFi only</string>
|
||||
<string name="pref_data_sync_image_cache_wifi_and_mobile">Over WiFi & Mobile</string>
|
||||
|
@ -385,8 +390,6 @@
|
|||
</string-array>
|
||||
|
||||
|
||||
|
||||
|
||||
<string name="array_sync_interval_min_5">5 Minutes</string>
|
||||
<string name="array_sync_interval_min_15">15 Minutes</string>
|
||||
<string name="array_sync_interval_min_30">30 Minutes</string>
|
||||
|
|
30
News-Android-App/src/main/res/xml/pref_about.xml
Normal file
30
News-Android-App/src/main/res/xml/pref_about.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<Preference
|
||||
android:key="cb_license"
|
||||
android:title="@string/pref_license"
|
||||
android:summary="@string/pref_license_summary">
|
||||
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://www.gnu.org/licenses/license-list.html#AGPLv3.0" />
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:key="cb_contribute"
|
||||
android:title="@string/pref_contribute"
|
||||
android:summary="@string/pref_contribute_summary">
|
||||
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://github.com/nextcloud/news-android" />
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:key="cb_version"
|
||||
android:title="@string/pref_version"
|
||||
android:summary="@string/current_version">
|
||||
</Preference>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
|
@ -18,6 +18,10 @@
|
|||
android:fragment="de.luhmer.owncloudnewsreader.SettingsActivity$DataSyncPreferenceFragment"
|
||||
android:title="@string/pref_header_data_sync" />
|
||||
|
||||
<header
|
||||
android:fragment="de.luhmer.owncloudnewsreader.SettingsActivity$AboutPreferenceFragment"
|
||||
android:title="@string/pref_header_about" />
|
||||
|
||||
|
||||
<!--
|
||||
<header
|
||||
|
|
Loading…
Reference in a new issue