copy release notes
This commit is contained in:
parent
05dbcc7609
commit
0fd8ecbb92
|
@ -0,0 +1,237 @@
|
||||||
|
/* Copyright 2019 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>. */
|
||||||
|
package app.fedilab.android.activities;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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.client.API;
|
||||||
|
import app.fedilab.android.client.APIResponse;
|
||||||
|
import app.fedilab.android.client.Entities.Account;
|
||||||
|
import app.fedilab.android.client.Entities.Status;
|
||||||
|
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||||
|
import app.fedilab.android.drawers.StatusListAdapter;
|
||||||
|
import app.fedilab.android.helper.Helper;
|
||||||
|
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
|
||||||
|
import app.fedilab.android.interfaces.OnSyncBookmarksInterface;
|
||||||
|
import app.fedilab.android.sqlite.AccountDAO;
|
||||||
|
import app.fedilab.android.sqlite.Sqlite;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Thomas on 15/11/2019.
|
||||||
|
* Bookmark activity
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInterface, OnSyncBookmarksInterface {
|
||||||
|
|
||||||
|
private List<Status> statuses;
|
||||||
|
private StatusListAdapter statusListAdapter;
|
||||||
|
private RelativeLayout textviewNoAction;
|
||||||
|
private RelativeLayout mainLoader;
|
||||||
|
private RecyclerView lv_status;
|
||||||
|
private ImageView pp_actionBar;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
|
switch (theme) {
|
||||||
|
case Helper.THEME_LIGHT:
|
||||||
|
setTheme(R.style.AppTheme_NoActionBar_Fedilab);
|
||||||
|
break;
|
||||||
|
case Helper.THEME_BLACK:
|
||||||
|
setTheme(R.style.AppThemeBlack_NoActionBar);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setTheme(R.style.AppThemeDark_NoActionBar);
|
||||||
|
}
|
||||||
|
setContentView(R.layout.activity_bookmark);
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
if (actionBar != null) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||||
|
assert inflater != null;
|
||||||
|
View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(BookmarkActivity.this), false);
|
||||||
|
toolbar.setBackgroundColor(ContextCompat.getColor(BookmarkActivity.this, R.color.cyanea_primary));
|
||||||
|
view.setBackground(new ColorDrawable(ContextCompat.getColor(BookmarkActivity.this, R.color.cyanea_primary)));
|
||||||
|
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||||
|
TextView title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||||
|
pp_actionBar = actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||||
|
title.setText(R.string.bookmarks);
|
||||||
|
ImageView close_conversation = actionBar.getCustomView().findViewById(R.id.close_conversation);
|
||||||
|
if (close_conversation != null) {
|
||||||
|
close_conversation.setOnClickListener(v -> finish());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setTitle(R.string.bookmarks);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
Account account = new AccountDAO(BookmarkActivity.this, db).getUniqAccount(userId, instance);
|
||||||
|
|
||||||
|
Helper.loadGiF(BookmarkActivity.this, account, pp_actionBar);
|
||||||
|
|
||||||
|
lv_status = findViewById(R.id.lv_status);
|
||||||
|
|
||||||
|
mainLoader = findViewById(R.id.loader);
|
||||||
|
textviewNoAction = findViewById(R.id.no_action);
|
||||||
|
mainLoader.setVisibility(View.VISIBLE);
|
||||||
|
new RetrieveFeedsAsyncTask(BookmarkActivity.this, RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, BookmarkActivity.this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
int itemId = item.getItemId();
|
||||||
|
if (itemId == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
} else if (itemId == R.id.action_import_bookmarks) {
|
||||||
|
new SyncBookmarksAsyncTask(BookmarkActivity.this, SyncBookmarksAsyncTask.sync.IMPORT, BookmarkActivity.this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.bookmarks, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRetrieveFeeds(APIResponse apiResponse) {
|
||||||
|
mainLoader.setVisibility(View.GONE);
|
||||||
|
FloatingActionButton delete_all = null;
|
||||||
|
try {
|
||||||
|
delete_all = findViewById(R.id.delete_all);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
final boolean isOnWifi = Helper.isOnWIFI(BookmarkActivity.this);
|
||||||
|
statuses = apiResponse.getStatuses();
|
||||||
|
if (statuses != null && statuses.size() > 0) {
|
||||||
|
LinearLayoutManager mLayoutManager = new LinearLayoutManager(BookmarkActivity.this);
|
||||||
|
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||||
|
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS);
|
||||||
|
statusDrawerParams.setTargetedId(null);
|
||||||
|
statusDrawerParams.setOnWifi(isOnWifi);
|
||||||
|
statusDrawerParams.setStatuses(this.statuses);
|
||||||
|
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||||
|
lv_status.setAdapter(statusListAdapter);
|
||||||
|
lv_status.setLayoutManager(mLayoutManager);
|
||||||
|
} else {
|
||||||
|
textviewNoAction.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delete_all != null)
|
||||||
|
delete_all.setOnClickListener(view -> {
|
||||||
|
final SharedPreferences sharedpreferences = 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(BookmarkActivity.this, 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();
|
||||||
|
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||||
|
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS);
|
||||||
|
statusDrawerParams.setTargetedId(null);
|
||||||
|
statusDrawerParams.setOnWifi(isOnWifi);
|
||||||
|
statusDrawerParams.setStatuses(this.statuses);
|
||||||
|
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||||
|
lv_status.setAdapter(statusListAdapter);
|
||||||
|
statusListAdapter.notifyDataSetChanged();
|
||||||
|
textviewNoAction.setVisibility(View.VISIBLE);
|
||||||
|
new PostActionAsyncTask(BookmarkActivity.this, API.StatusAction.UNBOOKMARK);
|
||||||
|
dialogConfirm.dismiss();
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.no, (dialogConfirm, which) -> dialogConfirm.dismiss())
|
||||||
|
.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRetrieveBookmarks(List<Status> bookmarks) {
|
||||||
|
if (bookmarks != null) {
|
||||||
|
statuses = new ArrayList<>();
|
||||||
|
statuses.clear();
|
||||||
|
statuses.addAll(bookmarks);
|
||||||
|
final boolean isOnWifi = Helper.isOnWIFI(BookmarkActivity.this);
|
||||||
|
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||||
|
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS);
|
||||||
|
statusDrawerParams.setTargetedId(null);
|
||||||
|
statusDrawerParams.setOnWifi(isOnWifi);
|
||||||
|
statusDrawerParams.setStatuses(this.statuses);
|
||||||
|
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||||
|
lv_status.setAdapter(statusListAdapter);
|
||||||
|
statusListAdapter.notifyDataSetChanged();
|
||||||
|
if (statuses.size() == 0) {
|
||||||
|
textviewNoAction.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
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>.
|
||||||
|
-->
|
||||||
|
<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"
|
||||||
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="app.fedilab.android.activities.BookmarkActivity">
|
||||||
|
|
||||||
|
<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:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="@dimen/fab_margin"
|
||||||
|
android:paddingRight="@dimen/fab_margin"
|
||||||
|
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:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/bookmarks_empty"
|
||||||
|
android:textSize="25sp"
|
||||||
|
android:textStyle="italic|bold"
|
||||||
|
android:typeface="serif" />
|
||||||
|
</RelativeLayout>
|
||||||
|
<!-- Main Loader -->
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/loader"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<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:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin_floating"
|
||||||
|
android:contentDescription="@string/delete_all"
|
||||||
|
android:src="@drawable/ic_delete_floating"
|
||||||
|
app:backgroundTint="?colorAccent"
|
||||||
|
app:tint="?iconColorMenu" />
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
</androidx.drawerlayout.widget.DrawerLayout>
|
Loading…
Reference in New Issue