Adds a splash screen replacement.
|
@ -16,10 +16,11 @@
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:name=".TuskyApplication">
|
android:name=".TuskyApplication">
|
||||||
|
|
||||||
<activity android:name=".SplashActivity">
|
<activity
|
||||||
|
android:name=".SplashActivity"
|
||||||
|
android:theme="@style/SplashTheme">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
|
@ -19,28 +19,13 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
public class SplashActivity extends AppCompatActivity {
|
public class SplashActivity extends AppCompatActivity {
|
||||||
private static final int SPLASH_TIME_OUT = 2000;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false)) {
|
|
||||||
setTheme(R.style.AppTheme_Light);
|
|
||||||
}
|
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_splash);
|
|
||||||
|
|
||||||
/* Determine whether the user is currently logged in, and if so go ahead and load the
|
/* Determine whether the user is currently logged in, and if so go ahead and load the
|
||||||
* timeline. Otherwise, start the activity_login screen. */
|
* timeline. Otherwise, start the activity_login screen. */
|
||||||
SharedPreferences preferences = getSharedPreferences(
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
|
@ -48,20 +33,13 @@ public class SplashActivity extends AppCompatActivity {
|
||||||
String domain = preferences.getString("domain", null);
|
String domain = preferences.getString("domain", null);
|
||||||
String accessToken = preferences.getString("accessToken", null);
|
String accessToken = preferences.getString("accessToken", null);
|
||||||
|
|
||||||
final Intent intent;
|
Intent intent;
|
||||||
|
|
||||||
if (domain != null && accessToken != null) {
|
if (domain != null && accessToken != null) {
|
||||||
intent = new Intent(this, MainActivity.class);
|
intent = new Intent(this, MainActivity.class);
|
||||||
} else {
|
} else {
|
||||||
intent = new Intent(this, LoginActivity.class);
|
intent = new Intent(this, LoginActivity.class);
|
||||||
}
|
}
|
||||||
|
startActivity(intent);
|
||||||
new Handler().postDelayed(new Runnable() {
|
finish();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}, SPLASH_TIME_OUT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,16 +128,22 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi
|
||||||
}
|
}
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
BaseActivity activity = (BaseActivity) getActivity();
|
||||||
|
|
||||||
if (jumpToTopAllowed()) {
|
if (jumpToTopAllowed()) {
|
||||||
TabLayout layout = (TabLayout) getActivity().findViewById(R.id.tab_layout);
|
TabLayout layout = (TabLayout) activity.findViewById(R.id.tab_layout);
|
||||||
onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
|
onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
public void onTabSelected(TabLayout.Tab tab) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabUnselected(TabLayout.Tab tab) {
|
public void onTabUnselected(TabLayout.Tab tab) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabReselected(TabLayout.Tab tab) {
|
public void onTabReselected(TabLayout.Tab tab) {
|
||||||
|
@ -147,16 +153,10 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi
|
||||||
layout.addOnTabSelectedListener(onTabSelectedListener);
|
layout.addOnTabSelectedListener(onTabSelectedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rootView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
/* MastodonAPI on the base activity is only guaranteed to be initialised after the parent
|
/* MastodonAPI on the base activity is only guaranteed to be initialised after the parent
|
||||||
* activity is created, so everything needing to access the api object has to be delayed
|
* activity is created, so everything needing to access the api object has to be delayed
|
||||||
* until here. */
|
* until here. */
|
||||||
api = ((BaseActivity) getActivity()).mastodonAPI;
|
api = activity.mastodonAPI;
|
||||||
scrollListener = new EndlessOnScrollListener(layoutManager) {
|
scrollListener = new EndlessOnScrollListener(layoutManager) {
|
||||||
@Override
|
@Override
|
||||||
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
|
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
|
||||||
|
|
|
@ -45,6 +45,7 @@ import java.util.List;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
public class TimelineFragment extends SFragment implements
|
public class TimelineFragment extends SFragment implements
|
||||||
SwipeRefreshLayout.OnRefreshListener,
|
SwipeRefreshLayout.OnRefreshListener,
|
||||||
|
@ -53,8 +54,6 @@ public class TimelineFragment extends SFragment implements
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private static final String TAG = "Timeline"; // logging tag
|
private static final String TAG = "Timeline"; // logging tag
|
||||||
|
|
||||||
private Call<List<Status>> listCall;
|
|
||||||
|
|
||||||
public enum Kind {
|
public enum Kind {
|
||||||
HOME,
|
HOME,
|
||||||
PUBLIC_LOCAL,
|
PUBLIC_LOCAL,
|
||||||
|
@ -121,6 +120,23 @@ public class TimelineFragment extends SFragment implements
|
||||||
adapter = new TimelineAdapter(this);
|
adapter = new TimelineAdapter(this);
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onLoadMore(RecyclerView view) {
|
||||||
|
TimelineAdapter adapter = (TimelineAdapter) view.getAdapter();
|
||||||
|
Status status = adapter.getItem(adapter.getItemCount() - 2);
|
||||||
|
if (status != null) {
|
||||||
|
sendFetchTimelineRequest(status.id, null);
|
||||||
|
} else {
|
||||||
|
sendFetchTimelineRequest(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
if (jumpToTopAllowed()) {
|
if (jumpToTopAllowed()) {
|
||||||
TabLayout layout = (TabLayout) getActivity().findViewById(R.id.tab_layout);
|
TabLayout layout = (TabLayout) getActivity().findViewById(R.id.tab_layout);
|
||||||
onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
|
onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
|
||||||
|
@ -138,23 +154,6 @@ public class TimelineFragment extends SFragment implements
|
||||||
layout.addOnTabSelectedListener(onTabSelectedListener);
|
layout.addOnTabSelectedListener(onTabSelectedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rootView;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onLoadMore(RecyclerView view) {
|
|
||||||
TimelineAdapter adapter = (TimelineAdapter) view.getAdapter();
|
|
||||||
Status status = adapter.getItem(adapter.getItemCount() - 2);
|
|
||||||
if (status != null) {
|
|
||||||
sendFetchTimelineRequest(status.id, null);
|
|
||||||
} else {
|
|
||||||
sendFetchTimelineRequest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
|
|
||||||
/* This is delayed until onActivityCreated solely because MainActivity.composeButton isn't
|
/* This is delayed until onActivityCreated solely because MainActivity.composeButton isn't
|
||||||
* guaranteed to be set until then. */
|
* guaranteed to be set until then. */
|
||||||
if (composeButtonPresent()) {
|
if (composeButtonPresent()) {
|
||||||
|
@ -199,12 +198,6 @@ public class TimelineFragment extends SFragment implements
|
||||||
recyclerView.addOnScrollListener(scrollListener);
|
recyclerView.addOnScrollListener(scrollListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (listCall != null) listCall.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
if (jumpToTopAllowed()) {
|
if (jumpToTopAllowed()) {
|
||||||
|
@ -232,9 +225,9 @@ public class TimelineFragment extends SFragment implements
|
||||||
adapter.setFooterState(TimelineAdapter.FooterState.LOADING);
|
adapter.setFooterState(TimelineAdapter.FooterState.LOADING);
|
||||||
}
|
}
|
||||||
|
|
||||||
Callback<List<Status>> cb = new Callback<List<Status>>() {
|
Callback<List<Status>> callback = new Callback<List<Status>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<List<Status>> call, retrofit2.Response<List<Status>> response) {
|
public void onResponse(Call<List<Status>> call, Response<List<Status>> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
onFetchTimelineSuccess(response.body(), fromId);
|
onFetchTimelineSuccess(response.body(), fromId);
|
||||||
} else {
|
} else {
|
||||||
|
@ -248,6 +241,7 @@ public class TimelineFragment extends SFragment implements
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Call<List<Status>> listCall;
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
default:
|
default:
|
||||||
case HOME: {
|
case HOME: {
|
||||||
|
@ -276,11 +270,7 @@ public class TimelineFragment extends SFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callList.add(listCall);
|
callList.add(listCall);
|
||||||
listCall.enqueue(cb);
|
listCall.enqueue(callback);
|
||||||
}
|
|
||||||
|
|
||||||
private void sendFetchTimelineRequest() {
|
|
||||||
sendFetchTimelineRequest(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePostsByUser(String accountId) {
|
public void removePostsByUser(String accountId) {
|
||||||
|
@ -322,7 +312,7 @@ public class TimelineFragment extends SFragment implements
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
sendFetchTimelineRequest(null, status.id);
|
sendFetchTimelineRequest(null, status.id);
|
||||||
} else {
|
} else {
|
||||||
sendFetchTimelineRequest();
|
sendFetchTimelineRequest(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<bitmap
|
||||||
|
android:src="@drawable/splash_pattern"
|
||||||
|
android:tileMode="repeat" />
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<bitmap
|
||||||
|
android:src="@mipmap/ic_logo"
|
||||||
|
android:gravity="center"
|
||||||
|
android:tileMode="disabled" />
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
After Width: | Height: | Size: 2.6 KiB |
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="?attr/splash_background_color"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<com.mikhaellopez.circularfillableloaders.CircularFillableLoaders
|
|
||||||
android:id="@+id/circularFillableLoaders"
|
|
||||||
android:layout_width="200dp"
|
|
||||||
android:layout_height="200dp"
|
|
||||||
android:src="@mipmap/ic_logo"
|
|
||||||
app:cfl_border="true"
|
|
||||||
app:cfl_border_width="4dp"
|
|
||||||
app:cfl_progress="80"
|
|
||||||
app:cfl_wave_amplitude="0.08"
|
|
||||||
app:cfl_wave_color="?attr/splash_wave_color" />
|
|
||||||
</LinearLayout>
|
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 74 KiB |
|
@ -14,6 +14,11 @@
|
||||||
<item name="android:padding">0dp</item>
|
<item name="android:padding">0dp</item>
|
||||||
<item name="android:windowBackground">@android:color/black</item>
|
<item name="android:windowBackground">@android:color/black</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
|
||||||
|
<item name="android:windowBackground">@drawable/background_splash</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!--Base Application Theme Styles (Dark)-->
|
<!--Base Application Theme Styles (Dark)-->
|
||||||
|
|
||||||
|
|