Improve activity for bookmarks
This commit is contained in:
parent
403992ed38
commit
0767a69af8
|
@ -385,7 +385,8 @@
|
|||
android:name="app.fedilab.android.activities.BookmarkActivity"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name" />
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppThemeDark_NoActionBar"/>
|
||||
<activity
|
||||
android:name="app.fedilab.android.activities.SettingsActivity"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.content.pm.ActivityInfo;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -98,7 +97,6 @@ import app.fedilab.android.client.Entities.Status;
|
|||
import app.fedilab.android.client.Entities.TagTimeline;
|
||||
import app.fedilab.android.client.Entities.Version;
|
||||
import app.fedilab.android.fragments.DisplayAccountsFragment;
|
||||
import app.fedilab.android.fragments.DisplayBookmarksFragment;
|
||||
import app.fedilab.android.fragments.DisplayBookmarksPixelfedFragment;
|
||||
import app.fedilab.android.fragments.DisplayDraftsFragment;
|
||||
import app.fedilab.android.fragments.DisplayFavoritesPeertubeFragment;
|
||||
|
@ -117,7 +115,6 @@ import app.fedilab.android.fragments.WhoToFollowFragment;
|
|||
import app.fedilab.android.helper.CrossActions;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MenuFloating;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
import app.fedilab.android.services.BackupStatusService;
|
||||
import app.fedilab.android.services.LiveNotificationDelayedService;
|
||||
import app.fedilab.android.services.LiveNotificationService;
|
||||
|
@ -1732,7 +1729,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
Intent intent = new Intent(getApplicationContext(), MutedInstanceActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
}else if ( id == R.id.nav_bookmarks && ( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)){
|
||||
}else if ( id == R.id.nav_bookmarks){
|
||||
Intent intent = new Intent(getApplicationContext(), BookmarkActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
|
@ -1759,7 +1756,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
toolbarTitle.setVisibility(View.VISIBLE);
|
||||
delete_instance.setVisibility(View.GONE);
|
||||
appBar.setExpanded(true);
|
||||
if (id != R.id.nav_drafts && id != R.id.nav_pixelfed_drafts && id != R.id.nav_bookmarks && id != R.id.nav_peertube) {
|
||||
if (id != R.id.nav_drafts && id != R.id.nav_pixelfed_drafts && id != R.id.nav_peertube) {
|
||||
delete_all.hide();
|
||||
} else {
|
||||
delete_all.show();
|
||||
|
@ -1867,12 +1864,6 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
fragmentManager.beginTransaction()
|
||||
.replace(R.id.main_app_container, displayDraftsFragment, fragmentTag).commit();
|
||||
toot.hide();
|
||||
} else if (id == R.id.nav_bookmarks ) {
|
||||
DisplayBookmarksFragment displayBookmarksFragment = new DisplayBookmarksFragment();
|
||||
fragmentTag = "BOOKMARKS";
|
||||
fragmentManager.beginTransaction()
|
||||
.replace(R.id.main_app_container, displayBookmarksFragment, fragmentTag).commit();
|
||||
toot.hide();
|
||||
} else if (id == R.id.nav_pixelfed_bookmarks) {
|
||||
DisplayBookmarksPixelfedFragment displayBookmarksPixelfedFragment = new DisplayBookmarksPixelfedFragment();
|
||||
fragmentTag = "BOOKMARKS";
|
||||
|
|
|
@ -33,6 +33,7 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -49,6 +50,7 @@ import app.fedilab.android.R;
|
|||
import app.fedilab.android.asynctasks.PostActionAsyncTask;
|
||||
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import app.fedilab.android.asynctasks.SyncBookmarksAsyncTask;
|
||||
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
||||
import app.fedilab.android.client.API;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
import app.fedilab.android.client.Entities.Account;
|
||||
|
@ -82,20 +84,17 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
switch (theme) {
|
||||
case Helper.THEME_LIGHT:
|
||||
setTheme(R.style.AppTheme_Fedilab);
|
||||
break;
|
||||
case Helper.THEME_DARK:
|
||||
setTheme(R.style.AppThemeDark);
|
||||
setTheme(R.style.AppTheme_NoActionBar_Fedilab);
|
||||
break;
|
||||
case Helper.THEME_BLACK:
|
||||
setTheme(R.style.AppThemeBlack);
|
||||
setTheme(R.style.AppThemeBlack_NoActionBar);
|
||||
break;
|
||||
default:
|
||||
setTheme(R.style.AppThemeDark);
|
||||
setTheme(R.style.AppThemeDark_NoActionBar);
|
||||
}
|
||||
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.activity_bookmark);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(BookmarkActivity.this, R.color.cyanea_primary)));
|
||||
|
@ -119,7 +118,7 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
} else {
|
||||
setTitle(R.string.bookmarks);
|
||||
}
|
||||
setContentView(R.layout.activity_bookmark);
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
|
@ -157,6 +156,10 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bookmarks, menu);
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
|
||||
menu.findItem(R.id.action_export_bookmarks).setVisible(false);
|
||||
menu.findItem(R.id.action_import_bookmarks).setVisible(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,8 +135,6 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
new IntentFilter(Helper.INTENT_BACKUP_FINISH));
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
if (theme == Helper.THEME_BLACK)
|
||||
toolbar.setBackgroundColor(ContextCompat.getColor(OwnerStatusActivity.this, R.color.black));
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
|
|
|
@ -3112,7 +3112,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
break;
|
||||
case R.id.action_schedule_boost:
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
package app.fedilab.android.fragments;
|
||||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Fedilab
|
||||
*
|
||||
* 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 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Fedilab 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 Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.asynctasks.PostActionAsyncTask;
|
||||
import app.fedilab.android.client.API;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.drawers.StatusListAdapter;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 15/02/2018.
|
||||
* Fragment to display bookmarks
|
||||
*/
|
||||
public class DisplayBookmarksFragment extends Fragment implements OnRetrieveFeedsInterface {
|
||||
|
||||
|
||||
private Context context;
|
||||
private List<Status> statuses;
|
||||
private StatusListAdapter statusListAdapter;
|
||||
private RelativeLayout textviewNoAction;
|
||||
private RelativeLayout mainLoader;
|
||||
private RecyclerView lv_status;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
View rootView = inflater.inflate(R.layout.fragment_bookmarks, container, false);
|
||||
context = getContext();
|
||||
|
||||
lv_status = rootView.findViewById(R.id.lv_status);
|
||||
|
||||
mainLoader = rootView.findViewById(R.id.loader);
|
||||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||
mainLoader.setVisibility(View.VISIBLE);
|
||||
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, DisplayBookmarksFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle saveInstance) {
|
||||
super.onCreate(saveInstance);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(@NotNull Context context) {
|
||||
super.onAttach(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRetrieveFeeds(APIResponse apiResponse) {
|
||||
|
||||
mainLoader.setVisibility(View.GONE);
|
||||
FloatingActionButton delete_all = null;
|
||||
try {
|
||||
delete_all = ((MainActivity) context).findViewById(R.id.delete_all);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
final boolean isOnWifi = Helper.isOnWIFI(context);
|
||||
statuses = apiResponse.getStatuses();
|
||||
if (statuses != null && statuses.size() > 0) {
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(context);
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, isOnWifi, this.statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
lv_status.setLayoutManager(mLayoutManager);
|
||||
} else {
|
||||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (delete_all != null)
|
||||
delete_all.setOnClickListener(view -> {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
int style;
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
style = R.style.DialogBlack;
|
||||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context, style);
|
||||
builder.setTitle(R.string.delete_all);
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setPositiveButton(R.string.yes, (dialogConfirm, which) -> {
|
||||
|
||||
statuses = new ArrayList<>();
|
||||
statuses.clear();
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, isOnWifi, statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
new PostActionAsyncTask(context, API.StatusAction.UNBOOKMARK).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
dialogConfirm.dismiss();
|
||||
})
|
||||
.setNegativeButton(R.string.no, (dialogConfirm, which) -> dialogConfirm.dismiss())
|
||||
.show();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -14,46 +14,86 @@
|
|||
You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:paddingLeft="@dimen/fab_margin"
|
||||
android:paddingRight="@dimen/fab_margin"
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<!-- Listview status -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/lv_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none" />
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/no_action"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:padding="10dp"
|
||||
android:gravity="center"
|
||||
android:textSize="25sp"
|
||||
android:layout_gravity="center"
|
||||
android:textStyle="italic|bold"
|
||||
android:typeface="serif"
|
||||
android:text="@string/bookmarks_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
||||
<!-- Main Loader -->
|
||||
<RelativeLayout
|
||||
android:id="@+id/loader"
|
||||
android:visibility="gone"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
tools:context="app.fedilab.android.activities.BookmarkActivity">
|
||||
|
||||
<ProgressBar
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?colorPrimary"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
/>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
<RelativeLayout
|
||||
android:paddingLeft="@dimen/fab_margin"
|
||||
android:paddingRight="@dimen/fab_margin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context="app.fedilab.android.activities.BookmarkActivity">
|
||||
<!-- Listview status -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/lv_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/no_action"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:padding="10dp"
|
||||
android:gravity="center"
|
||||
android:textSize="25sp"
|
||||
android:layout_gravity="center"
|
||||
android:textStyle="italic|bold"
|
||||
android:typeface="serif"
|
||||
android:text="@string/bookmarks_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
||||
<!-- Main Loader -->
|
||||
<RelativeLayout
|
||||
android:id="@+id/loader"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/delete_all"
|
||||
android:contentDescription="@string/delete_all"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin_floating"
|
||||
android:src="@drawable/ic_delete_floating"
|
||||
tools:ignore="VectorDrawableCompat" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
Loading…
Reference in New Issue