diff --git a/app/.gitignore b/app/.gitignore index 796b96d1..e493cfc4 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,2 @@ /build +app-release.apk \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 0202e99b..d8a06d48 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ android { minSdkVersion 15 targetSdkVersion 25 versionCode 1 - versionName "1.0" + versionName "1.0.0-alpha.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary true } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7de530cf..480c07b6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100644 index 00000000..6b0126e9 Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index cbc4b213..e7937bcf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -28,7 +28,6 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.method.LinkMovementMethod; -import android.util.Log; import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java b/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java index 08d6ec0b..af619231 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java @@ -45,6 +45,8 @@ import java.util.Map; public class AccountFragment extends Fragment implements AccountActionListener, FooterActionListener { + private static final String TAG = "Account"; + public enum Type { FOLLOWS, FOLLOWERS, @@ -166,7 +168,7 @@ public class AccountFragment extends Fragment implements AccountActionListener, try { accounts = Account.parse(response); } catch (JSONException e) { - onFetchAccountsFailure(); + onFetchAccountsFailure(e); return; } onFetchAccountsSuccess(accounts, fromId != null); @@ -175,7 +177,7 @@ public class AccountFragment extends Fragment implements AccountActionListener, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { - onFetchAccountsFailure(); + onFetchAccountsFailure(error); } }) { @Override @@ -201,8 +203,9 @@ public class AccountFragment extends Fragment implements AccountActionListener, showFetchAccountsRetry(false); } - private void onFetchAccountsFailure() { + private void onFetchAccountsFailure(Exception exception) { showFetchAccountsRetry(true); + Log.e(TAG, "Fetch failure: " + exception.getMessage()); } private void showFetchAccountsRetry(boolean show) { diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index e3278a1c..82e4ab4d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -404,8 +404,9 @@ public class ComposeActivity extends AppCompatActivity { private void readyStatus(final String content, final String visibility, final boolean sensitive, final String spoilerText) { - final ProgressDialog dialog = ProgressDialog.show(this, "Finishing Media Upload", - "Uploading...", true, true); + final ProgressDialog dialog = ProgressDialog.show( + this, getString(R.string.dialog_title_finishing_media_upload), + getString(R.string.dialog_message_uploading_media), true, true); final AsyncTask waitForMediaTask = new AsyncTask() { @Override @@ -734,6 +735,10 @@ public class ComposeActivity extends AppCompatActivity { Uri uri = data.getData(); ContentResolver contentResolver = getContentResolver(); Cursor cursor = getContentResolver().query(uri, null, null, null, null); + if (cursor == null) { + displayTransientError(R.string.error_media_upload_opening); + return; + } int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE); cursor.moveToFirst(); long mediaSize = cursor.getLong(sizeIndex); diff --git a/app/src/main/java/com/keylesspalace/tusky/Log.java b/app/src/main/java/com/keylesspalace/tusky/Log.java new file mode 100644 index 00000000..5a55af78 --- /dev/null +++ b/app/src/main/java/com/keylesspalace/tusky/Log.java @@ -0,0 +1,51 @@ +/* Copyright 2017 Andrew Dawson + * + * This file is part of Tusky. + * + * Tusky 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. + * + * Tusky 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 Tusky. If not, see + * . */ + +package com.keylesspalace.tusky; + +/**A wrapper for android.util.Log that allows for disabling logging, such as for release builds.*/ +public class Log { + private static final boolean LOGGING_ENABLED = BuildConfig.DEBUG; + + public static void i(String tag, String string) { + if (LOGGING_ENABLED) { + android.util.Log.i(tag, string); + } + } + + public static void e(String tag, String string) { + if (LOGGING_ENABLED) { + android.util.Log.e(tag, string); + } + } + + public static void d(String tag, String string) { + if (LOGGING_ENABLED) { + android.util.Log.d(tag, string); + } + } + + public static void v(String tag, String string) { + if (LOGGING_ENABLED) { + android.util.Log.v(tag, string); + } + } + + public static void w(String tag, String string) { + if (LOGGING_ENABLED) { + android.util.Log.w(tag, string); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index 39352fe3..4f80550b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -24,7 +24,6 @@ import android.net.Uri; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; -import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; @@ -129,6 +128,7 @@ public class LoginActivity extends AppCompatActivity { parameters.put("client_name", getString(R.string.app_name)); parameters.put("redirect_uris", getOauthRedirectUri()); parameters.put("scopes", OAUTH_SCOPES); + parameters.put("website", getString(R.string.app_website)); } catch (JSONException e) { Log.e(TAG, "Unable to build the form data for the authentication request."); return; diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 82b921dc..5ef86cbf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -27,7 +27,6 @@ import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.Toolbar; -import android.util.Log; import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; @@ -137,7 +136,7 @@ public class MainActivity extends AppCompatActivity { id = response.getString("id"); username = response.getString("acct"); } catch (JSONException e) { - onFetchUserInfoFailure(); + onFetchUserInfoFailure(e); return; } onFetchUserInfoSuccess(id, username); @@ -146,7 +145,7 @@ public class MainActivity extends AppCompatActivity { new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { - onFetchUserInfoFailure(); + onFetchUserInfoFailure(error); } }) { @Override @@ -171,9 +170,9 @@ public class MainActivity extends AppCompatActivity { editor.apply(); } - private void onFetchUserInfoFailure() { + private void onFetchUserInfoFailure(Exception exception) { //TODO: help - Log.e(TAG, "Failed to fetch the logged-in user's info."); + Log.e(TAG, "Failed to fetch user info. " + exception.getMessage()); } /* @Unused: For Firebase push notifications, useless for now. diff --git a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java index 7cf6b25b..9209b1eb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java @@ -42,6 +42,8 @@ import java.util.Map; public class NotificationsFragment extends SFragment implements SwipeRefreshLayout.OnRefreshListener, StatusActionListener, FooterActionListener { + private static final String TAG = "Notifications"; // logging tag + private SwipeRefreshLayout swipeRefreshLayout; private RecyclerView recyclerView; private NotificationsAdapter adapter; @@ -108,13 +110,13 @@ public class NotificationsFragment extends SFragment implements List notifications = Notification.parse(response); onFetchNotificationsSuccess(notifications, fromId != null); } catch (JSONException e) { - onFetchNotificationsFailure(); + onFetchNotificationsFailure(e); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { - onFetchNotificationsFailure(); + onFetchNotificationsFailure(error); } }) { @Override @@ -141,9 +143,10 @@ public class NotificationsFragment extends SFragment implements swipeRefreshLayout.setRefreshing(false); } - private void onFetchNotificationsFailure() { + private void onFetchNotificationsFailure(Exception exception) { showFetchTimelineRetry(true); swipeRefreshLayout.setRefreshing(false); + Log.e(TAG, "Fetch failure: " + exception.getMessage()); } private void showFetchTimelineRetry(boolean show) { diff --git a/app/src/main/java/com/keylesspalace/tusky/PullNotificationService.java b/app/src/main/java/com/keylesspalace/tusky/PullNotificationService.java index a32bc993..d69189c5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/PullNotificationService.java +++ b/app/src/main/java/com/keylesspalace/tusky/PullNotificationService.java @@ -26,7 +26,6 @@ import android.provider.Settings; import android.support.annotation.Nullable; import android.support.v4.app.NotificationCompat; import android.support.v4.app.TaskStackBuilder; -import android.util.Log; import com.android.volley.AuthFailureError; import com.android.volley.Response; @@ -44,7 +43,8 @@ import java.util.List; import java.util.Map; public class PullNotificationService extends IntentService { - private final int NOTIFY_ID = 6; // This is an arbitrary number. + private static final int NOTIFY_ID = 6; // This is an arbitrary number. + private static final String TAG = "PullNotifications"; public PullNotificationService() { super("Tusky Pull Notification Service"); @@ -76,7 +76,7 @@ public class PullNotificationService extends IntentService { try { notifications = Notification.parse(response); } catch (JSONException e) { - onCheckNotificationsFailure(); + onCheckNotificationsFailure(e); return; } onCheckNotificationsSuccess(notifications, lastUpdate); @@ -84,7 +84,7 @@ public class PullNotificationService extends IntentService { }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { - onCheckNotificationsFailure(); + onCheckNotificationsFailure(error); } }) { @Override @@ -134,9 +134,9 @@ public class PullNotificationService extends IntentService { } } - private void onCheckNotificationsFailure() { + private void onCheckNotificationsFailure(Exception exception) { //TODO: not sure if just logging here is enough? - Log.e("Error", "Could not check notifications in the service."); + Log.e(TAG, "Failed to check notifications. " + exception.getMessage()); } private static class MentionResult { @@ -193,7 +193,7 @@ public class PullNotificationService extends IntentService { if (preferences.getBoolean("notificationStyleVibrate", false)) { builder.setVibrate(new long[] { 500, 500 }); } - if (preferences.getBoolean("notificationStyleLight", true)) { + if (preferences.getBoolean("notificationStyleLight", false)) { builder.setLights(0xFF00FF8F, 300, 1000); } for (int i = 0; i < mentions.size(); i++) { diff --git a/app/src/main/java/com/keylesspalace/tusky/SFragment.java b/app/src/main/java/com/keylesspalace/tusky/SFragment.java index 515b838c..a4652ec7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/SFragment.java @@ -24,7 +24,6 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; -import android.util.Log; import android.view.MenuItem; import android.view.View; diff --git a/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java index 208a05f9..5cebce5e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java @@ -24,7 +24,6 @@ import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index cde69bcc..8bdc4459 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index c133a0cb..52603b69 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index bfa42f0e..88090fec 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 324e72cd..3b5fa2c8 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index aee44e13..94bd03d7 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cf188b6b..31f4c4b3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,6 @@ Tusky + http://tusky.keylesspalace.com com.keylesspalace.tusky oauth2redirect @@ -112,6 +113,8 @@ websites.\n\nSo, find the address of one you\'d like to join and enter it here. This will direct you there to either make an account or log in. + Finishing Media Upload + Uploading… Show on public timeline Do not display on public timeline