diff --git a/res/drawable-hdpi/about_chat_default.png b/res/drawable-hdpi/about_chat_default.png
new file mode 100644
index 000000000..c5f697093
Binary files /dev/null and b/res/drawable-hdpi/about_chat_default.png differ
diff --git a/res/drawable-hdpi/about_chat_over.png b/res/drawable-hdpi/about_chat_over.png
new file mode 100644
index 000000000..c05e4b14e
Binary files /dev/null and b/res/drawable-hdpi/about_chat_over.png differ
diff --git a/res/drawable-hdpi/about_chat_selected.png b/res/drawable-hdpi/about_chat_selected.png
new file mode 100644
index 000000000..fb523a4bd
Binary files /dev/null and b/res/drawable-hdpi/about_chat_selected.png differ
diff --git a/res/drawable-hdpi/about_settings_default.png b/res/drawable-hdpi/about_settings_default.png
new file mode 100644
index 000000000..bf1a4c81d
Binary files /dev/null and b/res/drawable-hdpi/about_settings_default.png differ
diff --git a/res/drawable-hdpi/about_settings_over.png b/res/drawable-hdpi/about_settings_over.png
new file mode 100644
index 000000000..6a265b3e3
Binary files /dev/null and b/res/drawable-hdpi/about_settings_over.png differ
diff --git a/res/drawable-hdpi/about_settings_selected.png b/res/drawable-hdpi/about_settings_selected.png
new file mode 100644
index 000000000..66fcdb232
Binary files /dev/null and b/res/drawable-hdpi/about_settings_selected.png differ
diff --git a/res/drawable/about_chat.xml b/res/drawable/about_chat.xml
new file mode 100644
index 000000000..ae54de5a7
--- /dev/null
+++ b/res/drawable/about_chat.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/res/drawable/about_chat.xml~ b/res/drawable/about_chat.xml~
new file mode 100644
index 000000000..a7a0da6b3
--- /dev/null
+++ b/res/drawable/about_chat.xml~
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/res/drawable/about_settings.xml b/res/drawable/about_settings.xml
new file mode 100644
index 000000000..b98f2f8e8
--- /dev/null
+++ b/res/drawable/about_settings.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/res/drawable/about_settings.xml~ b/res/drawable/about_settings.xml~
new file mode 100644
index 000000000..365633495
--- /dev/null
+++ b/res/drawable/about_settings.xml~
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/res/layout/about.xml b/res/layout/about.xml
new file mode 100644
index 000000000..5bea75752
--- /dev/null
+++ b/res/layout/about.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/main.xml b/res/layout/main.xml
index dd80d88f2..3fb1fdb37 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -144,8 +144,31 @@
android:contentDescription="@string/content_description_settings"
android:scaleType="fitXY"
android:src="@drawable/settings" />
+
+
+
+
diff --git a/res/layout/settings.xml b/res/layout/settings.xml
index 770a0f09d..df48eb090 100644
--- a/res/layout/settings.xml
+++ b/res/layout/settings.xml
@@ -128,8 +128,31 @@
android:contentDescription="@string/content_description_settings"
android:scaleType="fitXY"
android:src="@drawable/settings" />
+
+
+
+
diff --git a/res/values/non_localizable_custom.xml b/res/values/non_localizable_custom.xml
index d8866ed55..1f39d0017 100644
--- a/res/values/non_localizable_custom.xml
+++ b/res/values/non_localizable_custom.xml
@@ -6,22 +6,28 @@
https://www.linphone.org/wizard.php
- false
+ true
+ false
+ false
+
false
false
false
false
+
false
false
true
true
true
false
+
true
true
true
true
false
+
linphone-android@belledonne-communications.com
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6b154441c..d270a6ca4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -266,6 +266,7 @@
Add to contacts button
+
diff --git a/src/org/linphone/AboutFragment.java b/src/org/linphone/AboutFragment.java
new file mode 100644
index 000000000..7b6bbdee5
--- /dev/null
+++ b/src/org/linphone/AboutFragment.java
@@ -0,0 +1,190 @@
+package org.linphone;
+/*
+AboutFragment.java
+Copyright (C) 2012 Belledonne Communications, Grenoble, France
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.linphone.core.Log;
+
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.preference.PreferenceManager;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * @author Sylvain Berfini
+ */
+public class AboutFragment extends Fragment implements OnClickListener {
+ private Handler mHandler = new Handler();
+ private FragmentsAvailable about = FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ if (getArguments() != null && getArguments().getSerializable("About") != null) {
+ about = (FragmentsAvailable) getArguments().getSerializable("About");
+ }
+
+ View view = inflater.inflate(R.layout.about, container, false);
+
+ TextView aboutText = (TextView) view.findViewById(R.id.AboutText);
+ try {
+ aboutText.setText(String.format(getString(R.string.about_text), getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName));
+ } catch (NameNotFoundException e) {
+ Log.e(e, "cannot get version name");
+ }
+
+ SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ if (pref.getBoolean(getString(R.string.pref_debug_key), false)) {
+ View issue = view.findViewById(R.id.about_report_issue);
+ issue.setOnClickListener(this);
+ issue.setVisibility(View.VISIBLE);
+ }
+ return view;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ if (LinphoneActivity.isInstanciated()) {
+ LinphoneActivity.instance().selectMenu(about);
+ }
+ }
+
+ private Thread thread;
+ @Override
+ public void onClick(View v) {
+ if (thread != null) return;
+ Toast.makeText(getActivity(), getString(R.string.about_reading_logs), Toast.LENGTH_LONG).show();
+ thread = new ReadLogThread();
+ thread.start();
+ }
+
+ private File writeLogs(String logs, File directory) {
+ File tempFile = null;
+ try {
+ tempFile = File.createTempFile("bugreport", ".txt", directory);
+ tempFile.deleteOnExit();
+ FileWriter writer = new FileWriter(tempFile);
+ writer.append(logs);
+ writer.close();
+ return tempFile;
+ } catch (IOException e) {
+ Toast.makeText(getActivity(), getString(R.string.about_error_generating_bugreport_attachement), Toast.LENGTH_LONG).show();
+ Log.e(e, "couldn't write to temporary file");
+ return null;
+ }
+ }
+
+ private void onLogsRead(String logs) {
+ if (logs == null) {
+ Toast.makeText(getActivity(), getString(R.string.about_logs_not_found), Toast.LENGTH_SHORT).show();
+ } else {
+ File tempFile = writeLogs(logs, null);
+ if (tempFile == null) {
+ // If writing to temporary file to default location failed
+ // Write one to our storage place
+ tempFile = writeLogs(logs, getActivity().getFilesDir());
+ }
+
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setType("plain/text");
+ intent.putExtra(Intent.EXTRA_EMAIL, new String[]{getString(R.string.about_bugreport_email)});
+ intent.putExtra(Intent.EXTRA_SUBJECT,"Bug report " + getString(R.string.app_name) + "-android");
+ intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.about_bugreport_email_text));
+ intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tempFile));
+ intent = Intent.createChooser(intent,getString(R.string.about_mailer_chooser_text));
+ startActivityForResult(intent, 0);
+ }
+ }
+
+
+ private class ReadLogThread extends Thread {
+ @Override
+ public void run() {
+ final String logs = readLogs();
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ onLogsRead(logs);
+ thread=null;
+ }
+ });
+ super.run();
+ }
+ }
+
+ private String readLogs() {
+ StringBuilder sb1 = null;
+ StringBuilder sb2 = null;
+ BufferedReader br = null;
+ Process p = null;
+
+ try {
+ p = Runtime.getRuntime().exec(new String[] {"logcat", "-d"});
+ br = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
+
+ String line;
+ while ((line = br.readLine()) != null) {
+ if (line.contains(LinphoneService.START_LINPHONE_LOGS)) {
+ if (sb1 != null) {
+ sb2 = sb1;
+ }
+ sb1 = new StringBuilder();
+ }
+ if (sb1 != null) {
+ sb1.append(line).append('\n');
+ }
+ }
+
+ if (sb1 == null) return null;
+ if (sb2 != null) {
+ sb1.append(sb2);
+ }
+ return sb1.toString();
+ } catch (IOException e) {
+ Log.e(e, "Error while reading logs");
+ return null;
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {}
+ }
+ if (p != null) {
+ p.destroy();
+ }
+ }
+ }
+}
diff --git a/src/org/linphone/FragmentsAvailable.java b/src/org/linphone/FragmentsAvailable.java
index b77ba49b4..90bfd6d7c 100644
--- a/src/org/linphone/FragmentsAvailable.java
+++ b/src/org/linphone/FragmentsAvailable.java
@@ -27,6 +27,8 @@ public enum FragmentsAvailable {
HISTORY_DETAIL,
CONTACTS,
CONTACT,
+ ABOUT_INSTEAD_OF_SETTINGS,
+ ABOUT_INSTEAD_OF_CHAT,
SETTINGS,
CHATLIST,
CHAT;
@@ -56,11 +58,13 @@ public enum FragmentsAvailable {
case DIALER:
return CONTACTS.isRightOf(fragment) || fragment == CONTACT || fragment == CONTACTS;
+ case ABOUT_INSTEAD_OF_SETTINGS:
case SETTINGS:
return DIALER.isRightOf(fragment) || fragment == DIALER;
+ case ABOUT_INSTEAD_OF_CHAT:
case CHATLIST:
- return SETTINGS.isRightOf(fragment) || fragment == SETTINGS;
+ return SETTINGS.isRightOf(fragment) || fragment == SETTINGS || fragment == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS;
case CHAT:
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;
diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java
index e22170bc9..25efffaf1 100644
--- a/src/org/linphone/LinphoneActivity.java
+++ b/src/org/linphone/LinphoneActivity.java
@@ -85,7 +85,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
private StatusFragment statusFragment;
private TextView missedCalls, missedChats;
- private ImageView history, contacts, dialer, settings, chat;
+ private ImageView history, contacts, dialer, settings, chat, aboutChat, aboutSettings;
private FragmentsAvailable currentFragment;
private Fragment dialerFragment, messageListenerFragment;
private SavedState dialerSavedState;
@@ -134,6 +134,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
dialerFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, dialerFragment).commit();
+ selectMenu(FragmentsAvailable.DIALER);
}
}
@@ -158,11 +159,27 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
contacts.setOnClickListener(this);
dialer = (ImageView) findViewById(R.id.dialer);
dialer.setOnClickListener(this);
- dialer.setSelected(true);
settings = (ImageView) findViewById(R.id.settings);
settings.setOnClickListener(this);
chat = (ImageView) findViewById(R.id.chat);
chat.setOnClickListener(this);
+ aboutChat = (ImageView) findViewById(R.id.about_chat);
+ aboutSettings = (ImageView) findViewById(R.id.about_settings);
+
+ if (getResources().getBoolean(R.bool.replace_chat_by_about)) {
+ chat.setVisibility(View.GONE);
+ chat.setOnClickListener(null);
+ findViewById(R.id.completeChat).setVisibility(View.GONE);
+ aboutChat.setVisibility(View.VISIBLE);
+ aboutChat.setOnClickListener(this);
+ }
+ if (getResources().getBoolean(R.bool.replace_settings_by_about)) {
+ settings.setVisibility(View.GONE);
+ settings.setOnClickListener(null);
+ aboutSettings.setVisibility(View.VISIBLE);
+ aboutSettings.setOnClickListener(this);
+ }
+
missedCalls = (TextView) findViewById(R.id.missedCalls);
missedChats = (TextView) findViewById(R.id.missedChats);
}
@@ -209,6 +226,10 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
break;
case SETTINGS:
break;
+ case ABOUT_INSTEAD_OF_CHAT:
+ case ABOUT_INSTEAD_OF_SETTINGS:
+ newFragment = new AboutFragment();
+ break;
case CHAT:
newFragment = new ChatFragment();
messageListenerFragment = newFragment;
@@ -418,19 +439,26 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
dialer.setSelected(true);
}
else if (id == R.id.settings) {
-// if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
-// changeCurrentFragment(FragmentsAvailable.SETTINGS, null);
-// settings.setSelected(true);
-// } else {
- Intent intent = new Intent(ACTION_MAIN);
- intent.setClass(this, PreferencesActivity.class);
- startActivityForResult(intent, SETTINGS_ACTIVITY);
- if (FragmentsAvailable.SETTINGS.isRightOf(currentFragment)) {
- Compatibility.overridePendingTransition(this, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left);
- } else {
- Compatibility.overridePendingTransition(this, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right);
- }
-// }
+ Intent intent = new Intent(ACTION_MAIN);
+ intent.setClass(this, PreferencesActivity.class);
+ startActivityForResult(intent, SETTINGS_ACTIVITY);
+ if (FragmentsAvailable.SETTINGS.isRightOf(currentFragment)) {
+ Compatibility.overridePendingTransition(this, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left);
+ } else {
+ Compatibility.overridePendingTransition(this, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right);
+ }
+ }
+ else if (id == R.id.about_chat) {
+ Bundle b = new Bundle();
+ b.putSerializable("About", FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT);
+ changeCurrentFragment(FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT, b);
+ aboutChat.setSelected(true);
+ }
+ else if (id == R.id.about_settings) {
+ Bundle b = new Bundle();
+ b.putSerializable("About", FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS);
+ changeCurrentFragment(FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS, b);
+ aboutSettings.setSelected(true);
}
else if (id == R.id.chat) {
changeCurrentFragment(FragmentsAvailable.CHATLIST, null);
@@ -444,6 +472,8 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
dialer.setSelected(false);
settings.setSelected(false);
chat.setSelected(false);
+ aboutChat.setSelected(false);
+ aboutSettings.setSelected(false);
}
@SuppressWarnings("incomplete-switch")
@@ -466,6 +496,12 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
case SETTINGS:
settings.setSelected(true);
break;
+ case ABOUT_INSTEAD_OF_CHAT:
+ aboutChat.setSelected(true);
+ break;
+ case ABOUT_INSTEAD_OF_SETTINGS:
+ aboutSettings.setSelected(true);
+ break;
case CHAT:
case CHATLIST:
chat.setSelected(true);
diff --git a/src/org/linphone/LinphonePreferencesActivity.java b/src/org/linphone/LinphonePreferencesActivity.java
index b2e4b2345..4d07ef089 100644
--- a/src/org/linphone/LinphonePreferencesActivity.java
+++ b/src/org/linphone/LinphonePreferencesActivity.java
@@ -32,7 +32,7 @@ import android.widget.TextView;
* @author Sylvain Berfini
*/
public class LinphonePreferencesActivity extends PreferenceActivity implements OnClickListener {
- private ImageView history, contacts, dialer, settings, chat;
+ private ImageView history, contacts, dialer, settings, chat, aboutChat, aboutSettings;
private TextView missedCalls;
@Override
@@ -61,12 +61,28 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements O
chat = (ImageView) findViewById(R.id.chat);
chat.setOnClickListener(this);
missedCalls = (TextView) findViewById(R.id.missedCalls);
+ aboutChat = (ImageView) findViewById(R.id.about_chat);
+ aboutChat.setOnClickListener(this);
+ aboutSettings = (ImageView) findViewById(R.id.about_settings);
+ aboutSettings.setOnClickListener(this);
+
+ if (getResources().getBoolean(R.bool.replace_chat_by_about)) {
+ chat.setVisibility(View.GONE);
+ findViewById(R.id.completeChat).setVisibility(View.GONE);
+ aboutChat.setVisibility(View.VISIBLE);
+ }
+ if (getResources().getBoolean(R.bool.replace_settings_by_about)) {
+ settings.setVisibility(View.GONE);
+ aboutSettings.setVisibility(View.VISIBLE);
+ }
history.setSelected(false);
contacts.setSelected(false);
dialer.setSelected(false);
settings.setSelected(true);
chat.setSelected(false);
+ aboutChat.setSelected(false);
+ aboutSettings.setSelected(false);
}
@Override
@@ -86,6 +102,12 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements O
else if (id == R.id.chat) {
newFragment = FragmentsAvailable.CHATLIST;
}
+ else if (id == R.id.about_chat) {
+ newFragment = FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
+ }
+ else if (id == R.id.about_settings) {
+ newFragment = FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS;
+ }
if (newFragment != FragmentsAvailable.SETTINGS) {
Intent intent = new Intent();