mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-18 20:05:53 -04:00
Merge remote-tracking branch 'remotes/upstream/master'
# Conflicts resolved: # android/res/values/strings.xml # android/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java Added snackbar when bookmarks removed
This commit is contained in:
parent
6373074848
commit
cf3d00ad5b
@ -1,45 +1,49 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/bookmarks_activity_layout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
android:orientation="vertical"
|
||||||
android:orientation="vertical">
|
>
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?actionBarSize"
|
||||||
|
android:background="?colorPrimaryDark"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||||
|
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/bookmarks_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?actionBarSize"
|
android:layout_height="match_parent"
|
||||||
android:background="?colorPrimaryDark"
|
/>
|
||||||
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
|
||||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
|
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/bookmarks_list_nobookmarks"
|
||||||
android:layout_height="match_parent">
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
<ListView
|
android:paddingBottom="15dp"
|
||||||
android:id="@+id/bookmarks_list"
|
android:paddingLeft="10dp"
|
||||||
android:layout_width="match_parent"
|
android:paddingRight="10dp"
|
||||||
android:layout_height="match_parent"
|
android:paddingTop="15dp"
|
||||||
/>
|
android:text="@string/no_bookmarks"
|
||||||
|
android:visibility="gone"
|
||||||
|
style="@android:style/TextAppearance.Large"
|
||||||
<TextView
|
/>
|
||||||
android:id="@+id/bookmarks_list_nobookmarks"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
style="@android:style/TextAppearance.Large"
|
|
||||||
android:paddingBottom="15dp"
|
|
||||||
android:paddingTop="15dp"
|
|
||||||
android:paddingLeft="10dp"
|
|
||||||
android:paddingRight="10dp"
|
|
||||||
android:text="@string/no_bookmarks"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_margin="15dp"
|
android:layout_margin="15dp"
|
||||||
android:textColor="@color/material_blue_grey_900"
|
android:textColor="@color/material_blue_grey_900"
|
||||||
android:textSize="20sp"
|
android:textSize="15sp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.kiwix.kiwixmobile.views;
|
package org.kiwix.kiwixmobile.views;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
@ -13,7 +14,9 @@ import android.view.View;
|
|||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.Toast;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.kiwix.kiwixmobile.R;
|
import org.kiwix.kiwixmobile.R;
|
||||||
|
|
||||||
@ -21,16 +24,19 @@ public class BookmarksActivity extends AppCompatActivity
|
|||||||
implements AdapterView.OnItemClickListener {
|
implements AdapterView.OnItemClickListener {
|
||||||
|
|
||||||
private ArrayList<String> contents;
|
private ArrayList<String> contents;
|
||||||
|
private ArrayList<String> tempContents;
|
||||||
private ListView bookmarksList;
|
private ListView bookmarksList;
|
||||||
private ArrayAdapter adapter;
|
private ArrayAdapter adapter;
|
||||||
private ArrayList<String> selected;
|
private ArrayList<String> selected;
|
||||||
private int numOfSelected;
|
private int numOfSelected;
|
||||||
SparseBooleanArray sparseBooleanArray;
|
SparseBooleanArray sparseBooleanArray;
|
||||||
|
private LinearLayout snackbarLayout;
|
||||||
|
|
||||||
@Override protected void onCreate(Bundle savedInstanceState) {
|
@Override protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_bookmarks);
|
setContentView(R.layout.activity_bookmarks);
|
||||||
setUpToolbar();
|
setUpToolbar();
|
||||||
|
snackbarLayout = (LinearLayout) findViewById(R.id.bookmarks_activity_layout);
|
||||||
contents = getIntent().getStringArrayListExtra("bookmark_contents");
|
contents = getIntent().getStringArrayListExtra("bookmark_contents");
|
||||||
selected = new ArrayList<>();
|
selected = new ArrayList<>();
|
||||||
bookmarksList = (ListView) findViewById(R.id.bookmarks_list);
|
bookmarksList = (ListView) findViewById(R.id.bookmarks_list);
|
||||||
@ -51,10 +57,6 @@ public class BookmarksActivity extends AppCompatActivity
|
|||||||
numOfSelected--;
|
numOfSelected--;
|
||||||
mode.setTitle(numOfSelected + " Selected");
|
mode.setTitle(numOfSelected + " Selected");
|
||||||
}
|
}
|
||||||
//sparseBooleanArray = bookmarksList.getCheckedItemPositions();
|
|
||||||
//adapter.setSparse(sparseBooleanArray);
|
|
||||||
//adapter.notifyDataSetChanged();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
@ -73,6 +75,7 @@ public class BookmarksActivity extends AppCompatActivity
|
|||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menu_bookmarks_delete:
|
case R.id.menu_bookmarks_delete:
|
||||||
deleteSelectedItems();
|
deleteSelectedItems();
|
||||||
|
popDeleteBookmarksSnackbar();
|
||||||
mode.finish();
|
mode.finish();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -87,8 +90,24 @@ public class BookmarksActivity extends AppCompatActivity
|
|||||||
bookmarksList.setOnItemClickListener(this);
|
bookmarksList.setOnItemClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void popDeleteBookmarksSnackbar() {
|
||||||
|
Snackbar bookmarkDeleteSnackbar =
|
||||||
|
Snackbar.make(snackbarLayout, numOfSelected + " deleted", Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Undo", new View.OnClickListener() {
|
||||||
|
@Override public void onClick(View v) {
|
||||||
|
contents.clear();
|
||||||
|
contents.addAll(tempContents);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
Toast.makeText(getApplicationContext(), "Bookmarks restored", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bookmarkDeleteSnackbar.setActionTextColor(getResources().getColor(R.color.white_undo));
|
||||||
|
bookmarkDeleteSnackbar.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void deleteSelectedItems() {
|
private void deleteSelectedItems() {
|
||||||
sparseBooleanArray = bookmarksList.getCheckedItemPositions();
|
sparseBooleanArray = bookmarksList.getCheckedItemPositions();
|
||||||
|
tempContents = new ArrayList<>(contents);
|
||||||
for (int i = sparseBooleanArray.size() - 1; i >= 0; i--)
|
for (int i = sparseBooleanArray.size() - 1; i >= 0; i--)
|
||||||
contents.remove(sparseBooleanArray.keyAt(i));
|
contents.remove(sparseBooleanArray.keyAt(i));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user