Browse Source

Added about navigation menu, moved debug info

Closes #12
main
M66B 6 years ago
parent
commit
b0179b2b13
5 changed files with 184 additions and 51 deletions
  1. +7
    -46
      app/src/main/java/eu/faircode/email/ActivityView.java
  2. +105
    -0
      app/src/main/java/eu/faircode/email/FragmentAbout.java
  3. +63
    -0
      app/src/main/res/layout/fragment_about.xml
  4. +1
    -1
      app/src/main/res/layout/fragment_eula.xml
  5. +8
    -4
      app/src/main/res/values/strings.xml

+ 7
- 46
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -49,20 +49,13 @@ import android.widget.CheckBox;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.mail.Address;
import javax.mail.internet.InternetAddress;
public class ActivityView extends ActivityBase implements FragmentManager.OnBackStackChangedListener, SharedPreferences.OnSharedPreferenceChangeListener { public class ActivityView extends ActivityBase implements FragmentManager.OnBackStackChangedListener, SharedPreferences.OnSharedPreferenceChangeListener {
private boolean newIntent = false; private boolean newIntent = false;
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
private ListView drawerList; private ListView drawerList;
private ActionBarDrawerToggle drawerToggle; private ActionBarDrawerToggle drawerToggle;
private ExecutorService executor = Executors.newCachedThreadPool();
static final int LOADER_ACCOUNT_PUT = 1; static final int LOADER_ACCOUNT_PUT = 1;
static final int LOADER_IDENTITY_PUT = 2; static final int LOADER_IDENTITY_PUT = 2;
@ -114,8 +107,8 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
case R.string.menu_setup: case R.string.menu_setup:
onMenuSetup(); onMenuSetup();
break; break;
case R.string.menu_debug:
onMenuDebug();
case R.string.menu_about:
onMenuAbout();
break; break;
} }
@ -286,7 +279,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
public void updateDrawer() { public void updateDrawer() {
ArrayAdapterDrawer drawerArray = new ArrayAdapterDrawer(this, R.layout.item_drawer); ArrayAdapterDrawer drawerArray = new ArrayAdapterDrawer(this, R.layout.item_drawer);
drawerArray.add(new DrawerItem(ActivityView.this, R.string.menu_setup)); drawerArray.add(new DrawerItem(ActivityView.this, R.string.menu_setup));
drawerArray.add(new DrawerItem(ActivityView.this, R.string.menu_debug));
drawerArray.add(new DrawerItem(ActivityView.this, R.string.menu_about));
drawerList.setAdapter(drawerArray); drawerList.setAdapter(drawerArray);
} }
@ -302,42 +295,10 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
startActivity(new Intent(ActivityView.this, ActivitySetup.class)); startActivity(new Intent(ActivityView.this, ActivitySetup.class));
} }
private void onMenuDebug() {
executor.submit(new Runnable() {
@Override
public void run() {
try {
DB db = DB.getInstance(ActivityView.this);
EntityFolder drafts = db.folder().getPrimaryFolder(EntityFolder.TYPE_DRAFTS);
if (drafts != null) {
StringBuilder info = Helper.getDebugInfo();
info.insert(0, getString(R.string.title_debug_info) + "\n\n\n\n");
Address to = new InternetAddress("marcel+email@faircode.eu", "FairCode");
EntityMessage draft = new EntityMessage();
draft.account = drafts.account;
draft.folder = drafts.id;
draft.to = MessageHelper.encodeAddresses(new Address[]{to});
draft.subject = BuildConfig.APPLICATION_ID + " debug info";
draft.body = "<pre>" + info.toString().replaceAll("\\r?\\n", "<br />") + "</pre>";
draft.received = new Date().getTime();
draft.seen = false;
draft.ui_seen = false;
draft.ui_hide = false;
draft.id = db.message().insertMessage(draft);
EntityOperation.queue(ActivityView.this, draft, EntityOperation.ADD);
EntityOperation.process(ActivityView.this);
startActivity(new Intent(ActivityView.this, ActivityCompose.class)
.putExtra("id", draft.id));
}
} catch (Throwable ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
}
});
private void onMenuAbout() {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentAbout()).addToBackStack("about");
fragmentTransaction.commit();
} }
private class DrawerItem { private class DrawerItem {


+ 105
- 0
app/src/main/java/eu/faircode/email/FragmentAbout.java View File

@ -0,0 +1,105 @@
package eu.faircode.email;
/*
This file is part of Safe email.
Safe email 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.
NetGuard 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 NetGuard. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018 by Marcel Bokhorst (M66B)
*/
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.mail.Address;
import javax.mail.internet.InternetAddress;
public class FragmentAbout extends FragmentEx {
private ExecutorService executor = Executors.newCachedThreadPool();
@Override
@Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
setSubtitle(R.string.menu_about);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_about, container, false);
TextView tvVersion = view.findViewById(R.id.tvVersion);
Button btnDebugInfo = view.findViewById(R.id.btnDebugInfo);
tvVersion.setText(getString(R.string.title_version, BuildConfig.VERSION_NAME));
btnDebugInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
executor.submit(new Runnable() {
@Override
public void run() {
try {
DB db = DB.getInstance(getContext());
EntityFolder drafts = db.folder().getPrimaryFolder(EntityFolder.TYPE_DRAFTS);
if (drafts != null) {
StringBuilder info = Helper.getDebugInfo();
info.insert(0, getString(R.string.title_debug_info_remark) + "\n\n\n\n");
Address to = new InternetAddress("marcel+email@faircode.eu", "FairCode");
EntityMessage draft = new EntityMessage();
draft.account = drafts.account;
draft.folder = drafts.id;
draft.to = MessageHelper.encodeAddresses(new Address[]{to});
draft.subject = BuildConfig.APPLICATION_ID + " debug info";
draft.body = "<pre>" + info.toString().replaceAll("\\r?\\n", "<br />") + "</pre>";
draft.received = new Date().getTime();
draft.seen = false;
draft.ui_seen = false;
draft.ui_hide = false;
draft.id = db.message().insertMessage(draft);
EntityOperation.queue(getContext(), draft, EntityOperation.ADD);
EntityOperation.process(getContext());
startActivity(new Intent(getContext(), ActivityCompose.class)
.putExtra("id", draft.id));
}
} catch (Throwable ex) {
Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
}
});
}
});
return view;
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
menu.clear();
}
}

+ 63
- 0
app/src/main/res/layout/fragment_about.xml View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="12dp">
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Version 1.0"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvName" />
<TextView
android:id="@+id/tvCopyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/app_copyright"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvVersion" />
<TextView
android:id="@+id/tvEula"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/app_eula"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCopyright" />
<Button
android:id="@+id/btnDebugInfo"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:text="@string/title_debug_info"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvEula" />
</android.support.constraint.ConstraintLayout>
</ScrollView>

+ 1
- 1
app/src/main/res/layout/fragment_eula.xml View File

@ -13,7 +13,7 @@
android:id="@+id/tvEula" android:id="@+id/tvEula"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/title_eula"
android:text="@string/app_eula"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />


+ 8
- 4
app/src/main/res/values/strings.xml View File

@ -1,5 +1,7 @@
<resources> <resources>
<string name="app_name">Safe email</string>
<string name="app_name" translatable="false">Safe email</string>
<string name="app_copyright">Copyright &#x24B8; 2018 by M. Bokhorst</string>
<string name="app_eula" translatable="false">THIS SOFTWARE IS PROVIDED BY THE AUTHOR \'\'AS IS\'\' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</string>
<string name="channel_service">Service</string> <string name="channel_service">Service</string>
<string name="channel_notification">Notifications</string> <string name="channel_notification">Notifications</string>
@ -12,12 +14,13 @@
<string name="menu_folders">Folders</string> <string name="menu_folders">Folders</string>
<string name="menu_setup">Setup</string> <string name="menu_setup">Setup</string>
<string name="menu_debug">Debug info</string>
<string name="menu_about">About</string>
<string name="title_eula" translatable="false">THIS SOFTWARE IS PROVIDED BY THE AUTHOR \'\'AS IS\'\' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</string>
<string name="title_agree">I agree</string> <string name="title_agree">I agree</string>
<string name="title_disagree">I disagree</string> <string name="title_disagree">I disagree</string>
<string name="title_version">Version %1$s</string>
<string name="title_list_accounts">Accounts</string> <string name="title_list_accounts">Accounts</string>
<string name="title_list_identities">Identities</string> <string name="title_list_identities">Identities</string>
<string name="title_list_folders">Folders</string> <string name="title_list_folders">Folders</string>
@ -118,5 +121,6 @@
<string name="title_item_edit_hint">Long press item to edit properties</string> <string name="title_item_edit_hint">Long press item to edit properties</string>
<string name="title_debug_info">Please describe the problem and indicate the time of the problem:</string>
<string name="title_debug_info">Debug info</string>
<string name="title_debug_info_remark">Please describe the problem and indicate the time of the problem:</string>
</resources> </resources>

Loading…
Cancel
Save