Added dialog in the main app to advise users about the workaround app

This commit is contained in:
David A. Velasco 2013-01-30 13:46:15 +01:00
parent 0ad4898ccf
commit 5da9c095a4
8 changed files with 243 additions and 1 deletions

View file

@ -8,5 +8,5 @@
# project structure.
# Project target.
target=android-14
target=android-17
android.library.reference.1=actionbarsherlock/library

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
ownCloud Android client application
Copyright (C) 2013 ownCloud Inc
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/owncloud_white"
android:id="@+id/explanation"
android:orientation="vertical">
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:padding="10dip"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:text="@string/text_placeholder"
android:autoLink="all"
/>
<!-- LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/common_ok" />
<Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/common_cancel" />
</LinearLayout -->
</LinearLayout>

13
res/raw-de/changelog.html Normal file
View file

@ -0,0 +1,13 @@
<html>
<body>
<p>
Dieses Gerät läuft mit Android 4.1.x.
</p>
<p>
In dieser Version von Android existiert ein Bug, der nach jedem Neustart eine erneute Eingabe der ownCloud Login-Informationen nötig macht. Um das zu umgehen installieren Sie bitte diese kostenlose Hilfs-App:
</p>
<p style="text-align:center">
<a href="http://play.google.com/store/apps/details?id=com.owncloud.android.workaround.accounts">ownCloud Jelly Bean Workaround</a>
</p>
</body>
</html>

13
res/raw-es/changelog.html Normal file
View file

@ -0,0 +1,13 @@
<html>
<body>
<p>
Su dispositivo ejecuta Android 4.1.x.
</p>
<p>
Para prevenir la pérdida de las credenciales de sus cuentas ownCloud en cada reinicio, por favor, instale esta app gratuita que evita el problema en Jelly Bean:
</p>
<p style="text-align:center">
<a href="http://play.google.com/store/apps/details?id=com.owncloud.android.workaround.accounts">ownCloud Jelly Bean Workaround</a>
</p>
</body>
</html>

13
res/raw/changelog.html Normal file
View file

@ -0,0 +1,13 @@
<html>
<body>
<p>
Your device runs Android 4.1.x.
</p>
<p>
To prevent losing your ownCloud account credentials on every reboot, please, install this free helper app to work around the bug in Jelly Bean:
</p>
<p style="text-align:center">
<a href="http://play.google.com/store/apps/details?id=com.owncloud.android.workaround.accounts">ownCloud Jelly Bean Workaround</a>
</p>
</body>
</html>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ownCloud</string>
<string name="whats_new">What\'s new</string>
<string name="main_password">Password:</string>
<string name="main_login">Username:</string>
<string name="main_button_login">Login</string>

View file

@ -35,6 +35,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources.NotFoundException;
@ -82,6 +83,7 @@ import com.owncloud.android.operations.RenameFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.syncadapter.FileSyncService;
import com.owncloud.android.ui.dialog.ChangelogDialog;
import com.owncloud.android.ui.dialog.SslValidatorDialog;
import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;
import com.owncloud.android.ui.fragment.FileDetailFragment;
@ -124,6 +126,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 4;
private static final int DIALOG_SSL_VALIDATOR = 5;
private static final int DIALOG_CERT_NOT_SAVED = 6;
private static final String DIALOG_CHANGELOG_TAG = "DIALOG_CHANGELOG";
private static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;
@ -206,10 +209,40 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
actionBar.setListNavigationCallbacks(mDirectories, this);
setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to workaround bug in its implementation
// show changelog, if needed
showChangeLog();
Log.d(getClass().toString(), "onCreate() end");
}
/**
* Shows a dialog with the change log of the current version after each app update
*
* TODO make it permanent; by now, only to advice the workaround app for 4.1.x
*/
private void showChangeLog() {
if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.JELLY_BEAN) {
final String KEY_VERSION = "version";
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
int currentVersionNumber = 0;
int savedVersionNumber = sharedPref.getInt(KEY_VERSION, 0);
try {
PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
currentVersionNumber = pi.versionCode;
} catch (Exception e) {}
if (currentVersionNumber > savedVersionNumber) {
ChangelogDialog.newInstance(true).show(getSupportFragmentManager(), DIALOG_CHANGELOG_TAG);
Editor editor = sharedPref.edit();
editor.putInt(KEY_VERSION, currentVersionNumber);
editor.commit();
}
}
}
/**
* Launches the account creation activity. To use when no ownCloud account is available
*/

View file

@ -0,0 +1,109 @@
/* ownCloud Android client application
* Copyright (C) 2013 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.owncloud.android.ui.dialog;
import java.io.InputStream;
import java.util.Scanner;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockDialogFragment;
import com.owncloud.android.R;
/**
* Dialog to show the contents of res/raw/CHANGELOG.txt
*/
public class ChangelogDialog extends SherlockDialogFragment {
private static final String ARG_CANCELABLE = ChangelogDialog.class.getCanonicalName() + ".ARG_CANCELABLE";
/**
* Public factory method to get dialog instances.
*
* @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...)
* @return New dialog instance, ready to show.
*/
public static ChangelogDialog newInstance(boolean cancelable) {
ChangelogDialog fragment = new ChangelogDialog();
Bundle args = new Bundle();
args.putBoolean(ARG_CANCELABLE, cancelable);
fragment.setArguments(args);
return fragment;
}
/**
* {@inheritDoc}
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
/// load the custom view to insert in the dialog, between title and
WebView webview = new WebView(getActivity());
webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");
/// build the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
Dialog dialog = builder.setView(webview)
.setIcon(R.drawable.icon)
.setTitle(R.string.whats_new)
.setPositiveButton(R.string.common_ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create();
dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
return dialog;
}
/**
* {@inheritDoc}
*-/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
/// load the custom layout
View view = inflater.inflate(R.layout.fragment_changelog, container);
mEditText = (EditText) view.findViewById(R.id.txt_your_name);
getDialog().setTitle(R.string.whats_new);
/// read full contents of the change log file (don't make it too big)
InputStream changeLogStream = getResources().openRawResource(R.raw.changelog);
Scanner scanner = new java.util.Scanner(changeLogStream).useDelimiter("\\A");
String text = scanner.hasNext() ? scanner.next() : "";
/// make clickable the links in the change log file
SpannableString sText = new SpannableString(text);
Linkify.addLinks(sText, Linkify.ALL);
return view;
}
*/
}