diff --git a/app/build.gradle b/app/build.gradle index 0593f4f9..9b496e16 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.keylesspalace.tusky" minSdkVersion 15 targetSdkVersion 25 - versionCode 4 - versionName "1.0.0-alpha.4" + versionCode 5 + versionName "1.0.0-alpha.5" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary true } diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index c25ef5ec..822f765d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -57,7 +57,7 @@ public class AccountActivity extends BaseActivity { private String accountId; private boolean following = false; private boolean blocking = false; - private boolean isSelf = false; + private boolean isSelf; private String openInWebUrl; private TabLayout tabLayout; @@ -86,6 +86,7 @@ public class AccountActivity extends BaseActivity { obtainAccount(); if (!accountId.equals(loggedInAccountId)) { + isSelf = false; obtainRelationships(); } else { /* Cause the options menu to update and instead show an options menu for when the diff --git a/app/src/main/java/com/keylesspalace/tusky/FooterViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/FooterViewHolder.java index 247e4e5a..cd47c139 100644 --- a/app/src/main/java/com/keylesspalace/tusky/FooterViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/FooterViewHolder.java @@ -18,12 +18,11 @@ package com.keylesspalace.tusky; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.Button; -import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; public class FooterViewHolder extends RecyclerView.ViewHolder { - private LinearLayout retryBar; + private View retryBar; private TextView retryMessage; private Button retry; private ProgressBar progressBar; @@ -37,7 +36,7 @@ public class FooterViewHolder extends RecyclerView.ViewHolder { public FooterViewHolder(View itemView) { super(itemView); - retryBar = (LinearLayout) itemView.findViewById(R.id.footer_retry_bar); + retryBar = itemView.findViewById(R.id.footer_retry_bar); retryMessage = (TextView) itemView.findViewById(R.id.footer_retry_message); retry = (Button) itemView.findViewById(R.id.footer_retry_button); progressBar = (ProgressBar) itemView.findViewById(R.id.footer_progress_bar); diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index 7da68a30..aa320796 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -115,9 +115,11 @@ public class LoginActivity extends BaseActivity { * (such as in the case that the domain has never been accessed before) * authenticate with the server and store the received credentials to use next * time. */ - clientId = preferences.getString(domain + "/client_id", null); - clientSecret = preferences.getString(domain + "/client_secret", null); - if (clientId != null && clientSecret != null) { + String prefClientId = preferences.getString(domain + "/client_id", null); + String prefClientSecret = preferences.getString(domain + "/client_secret", null); + if (prefClientId != null && prefClientSecret != null) { + clientId = prefClientId; + clientSecret = prefClientSecret; redirectUserToAuthorizeAndLogin(); } else { String endpoint = getString(R.string.endpoint_apps); @@ -137,13 +139,17 @@ public class LoginActivity extends BaseActivity { new Response.Listener() { @Override public void onResponse(JSONObject response) { + String obtainedClientId; + String obtainedClientSecret; try { - clientId = response.getString("client_id"); - clientSecret = response.getString("client_secret"); + obtainedClientId = response.getString("client_id"); + obtainedClientSecret = response.getString("client_secret"); } catch (JSONException e) { Log.e(TAG, "Couldn't get data from the authentication response."); return; } + clientId = obtainedClientId; + clientSecret = obtainedClientSecret; SharedPreferences.Editor editor = preferences.edit(); editor.putString(domain + "/client_id", clientId); editor.putString(domain + "/client_secret", clientSecret); @@ -167,6 +173,11 @@ public class LoginActivity extends BaseActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); + if (savedInstanceState != null) { + domain = savedInstanceState.getString("domain"); + clientId = savedInstanceState.getString("clientId"); + clientSecret = savedInstanceState.getString("clientSecret"); + } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); preferences = getSharedPreferences( @@ -198,6 +209,14 @@ public class LoginActivity extends BaseActivity { }); } + @Override + protected void onSaveInstanceState(Bundle outState) { + outState.putString("domain", domain); + outState.putString("clientId", clientId); + outState.putString("clientSecret", clientSecret); + super.onSaveInstanceState(outState); + } + @Override protected void onPause() { super.onPause(); diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index f40f1ded..23426aa0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -79,12 +79,6 @@ public class MainActivity extends BaseActivity { viewPager.setAdapter(adapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); tabLayout.setupWithViewPager(viewPager); - for (int i = 0; i < tabLayout.getTabCount(); i++) { - TabLayout.Tab tab = tabLayout.getTabAt(i); - if (tab != null) { - tab.setCustomView(adapter.getTabView(i)); - } - } // Retrieve notification update preference. SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); diff --git a/app/src/main/java/com/keylesspalace/tusky/TimelinePagerAdapter.java b/app/src/main/java/com/keylesspalace/tusky/TimelinePagerAdapter.java index 3ce1b4bd..fdea632b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TimelinePagerAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/TimelinePagerAdapter.java @@ -63,11 +63,4 @@ public class TimelinePagerAdapter extends FragmentPagerAdapter { public CharSequence getPageTitle(int position) { return pageTitles[position]; } - - public View getTabView(int position) { - View view = LayoutInflater.from(context).inflate(R.layout.tab_main, null); - TextView title = (TextView) view.findViewById(R.id.title); - title.setText(pageTitles[position]); - return view; - } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 72f921ca..2da08be8 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,7 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content" + app:tabTextAppearance="@style/TabLayoutTextStyle" + app:tabPaddingStart="1dp" + app:tabPaddingEnd="1dp"> - - + + android:textStyle="normal|bold" /> \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 2c8b7246..86cc48ff 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -4,6 +4,10 @@ @drawable/splash_background + +