Compare commits
4 Commits
f569e1f702
...
2a0b898bf3
Author | SHA1 | Date |
---|---|---|
akaessens | 2a0b898bf3 | |
akaessens | 43458af11c | |
akaessens | 2a67c74f57 | |
akaessens | 8f8d0d07a8 |
|
@ -2,9 +2,7 @@ name: Android CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
@ -13,9 +11,9 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: set up JDK 1.8
|
- uses: actions/setup-java@v2
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
with:
|
||||||
java-version: 1.8
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
|
|
|
@ -34,7 +34,7 @@ dependencies {
|
||||||
implementation "androidx.webkit:webkit:1.4.0"
|
implementation "androidx.webkit:webkit:1.4.0"
|
||||||
|
|
||||||
// JSON save/restore shared preference
|
// JSON save/restore shared preference
|
||||||
implementation 'com.google.code.gson:gson:2.8.5'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
|
|
||||||
// Theme
|
// Theme
|
||||||
implementation 'com.google.android.material:material:1.4.0'
|
implementation 'com.google.android.material:material:1.4.0'
|
||||||
|
@ -46,8 +46,8 @@ dependencies {
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
|
|
||||||
// animations and transformations
|
// animations and transformations
|
||||||
implementation 'jp.wasabeef:picasso-transformations:2.2.1'
|
implementation 'jp.wasabeef:picasso-transformations:2.4.0'
|
||||||
implementation 'jp.wasabeef:recyclerview-animators:3.0.0'
|
implementation 'jp.wasabeef:recyclerview-animators:4.0.2'
|
||||||
// tests
|
// tests
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
|
|
|
@ -12,6 +12,8 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AutoCompleteTextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.view.menu.MenuBuilder;
|
import androidx.appcompat.view.menu.MenuBuilder;
|
||||||
|
@ -23,13 +25,13 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
||||||
import com.google.android.material.textfield.TextInputEditText;
|
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -40,7 +42,7 @@ import static com.akdev.nofbeventscraper.FbEvent.createEventList;
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
protected ExtendedFloatingActionButton paste_button;
|
protected ExtendedFloatingActionButton paste_button;
|
||||||
protected TextInputEditText edit_text_uri_input;
|
protected AutoCompleteTextView edit_text_uri_input;
|
||||||
protected TextInputLayout layout_uri_input;
|
protected TextInputLayout layout_uri_input;
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,6 +51,28 @@ public class MainActivity extends AppCompatActivity {
|
||||||
EventAdapter adapter;
|
EventAdapter adapter;
|
||||||
LinearLayoutManager linear_layout_manager;
|
LinearLayoutManager linear_layout_manager;
|
||||||
|
|
||||||
|
List<String> history;
|
||||||
|
ArrayAdapter<String> history_adapter;
|
||||||
|
|
||||||
|
|
||||||
|
private List<String> getHistory() {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String json = prefs.getString("history", "");
|
||||||
|
|
||||||
|
Type history_type = new TypeToken<List<String>>() {
|
||||||
|
}.getType();
|
||||||
|
List<String> list = gson.fromJson(json, history_type);
|
||||||
|
|
||||||
|
if (list == null) {
|
||||||
|
list = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<FbEvent> getSavedEvents() {
|
private List<FbEvent> getSavedEvents() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
@ -81,6 +105,12 @@ public class MainActivity extends AppCompatActivity {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getHistory().isEmpty()) {
|
||||||
|
history.clear();
|
||||||
|
history_adapter.clear();
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Intent from IntentReceiver - read only once
|
* Intent from IntentReceiver - read only once
|
||||||
*/
|
*/
|
||||||
|
@ -106,6 +136,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(events);
|
String json = gson.toJson(events);
|
||||||
prefs_edit.putString("events", json);
|
prefs_edit.putString("events", json);
|
||||||
|
|
||||||
|
json = gson.toJson(history);
|
||||||
|
prefs_edit.putString("history", json);
|
||||||
prefs_edit.apply();
|
prefs_edit.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +165,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
linear_layout_manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
|
linear_layout_manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
|
||||||
recycler_view.setLayoutManager(linear_layout_manager);
|
recycler_view.setLayoutManager(linear_layout_manager);
|
||||||
|
|
||||||
|
// restore history
|
||||||
|
this.history = getHistory();
|
||||||
|
history_adapter = new ArrayAdapter<>(this, android.R.layout.simple_expandable_list_item_1, history);
|
||||||
|
|
||||||
recycler_view.setItemAnimator(new FadeInAnimator());
|
recycler_view.setItemAnimator(new FadeInAnimator());
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,6 +234,14 @@ public class MainActivity extends AppCompatActivity {
|
||||||
};
|
};
|
||||||
layout_uri_input.setErrorIconOnClickListener(listener);
|
layout_uri_input.setErrorIconOnClickListener(listener);
|
||||||
layout_uri_input.setEndIconOnClickListener(listener);
|
layout_uri_input.setEndIconOnClickListener(listener);
|
||||||
|
edit_text_uri_input.setAdapter(history_adapter);
|
||||||
|
|
||||||
|
layout_uri_input.setStartIconOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
edit_text_uri_input.showDropDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -235,6 +280,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
scraper = new FbScraper(new WeakReference<>(this), url);
|
scraper = new FbScraper(new WeakReference<>(this), url);
|
||||||
|
|
||||||
scraper.run();
|
scraper.run();
|
||||||
|
|
||||||
|
history_adapter.insert(url, 0);
|
||||||
|
history.add(0, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,16 +43,20 @@ public class SettingsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
final SharedPreferences prefs = preference.getSharedPreferences();
|
final SharedPreferences prefs = preference.getSharedPreferences();
|
||||||
|
|
||||||
final String undo = prefs.getString("events", "");
|
final String events = prefs.getString("events", "");
|
||||||
prefs.edit().remove("events").apply();
|
prefs.edit().remove("events").apply();
|
||||||
|
|
||||||
|
final String history = prefs.getString("history", "");
|
||||||
|
prefs.edit().remove("history").apply();
|
||||||
|
|
||||||
Snackbar.make(getActivity().findViewById(android.R.id.content),
|
Snackbar.make(getActivity().findViewById(android.R.id.content),
|
||||||
getString(R.string.preferences_event_snackbar), Snackbar.LENGTH_SHORT)
|
getString(R.string.preferences_event_snackbar), Snackbar.LENGTH_SHORT)
|
||||||
.setAction(R.string.undo, new View.OnClickListener() {
|
.setAction(R.string.undo, new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
prefs.edit().putString("events", undo).apply();
|
prefs.edit().putString("events", events).apply();
|
||||||
|
prefs.edit().putString("history", history).apply();
|
||||||
}
|
}
|
||||||
}).show();
|
}).show();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.25,2.52 0.77,-1.28 -3.52,-2.09L13.5,8z"
|
||||||
|
android:fillColor="#000000"/>
|
||||||
|
</vector>
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/layout_uri_input"
|
android:id="@+id/layout_uri_input"
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
|
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
|
@ -26,9 +26,10 @@
|
||||||
app:endIconMode="clear_text"
|
app:endIconMode="clear_text"
|
||||||
app:errorIconDrawable="@drawable/ic_backspace_black"
|
app:errorIconDrawable="@drawable/ic_backspace_black"
|
||||||
app:helperText="@string/helper_add_link"
|
app:helperText="@string/helper_add_link"
|
||||||
app:helperTextEnabled="true">
|
app:helperTextEnabled="true"
|
||||||
|
app:startIconDrawable="@drawable/ic_history_black">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.MaterialAutoCompleteTextView
|
||||||
android:id="@+id/edit_text_uri_input"
|
android:id="@+id/edit_text_uri_input"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -4,8 +4,7 @@ buildscript {
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:4.1.3'
|
||||||
|
@ -18,8 +17,7 @@ buildscript {
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
|
||||||
distributionSha256Sum=23e7d37e9bb4f8dabb8a3ea7fdee9dd0428b9b1a71d298aefd65b11dccea220f
|
distributionSha256Sum=bf8b869948901d422e9bb7d1fa61da6a6e19411baa7ad6ee929073df85d6365d
|
||||||
|
|
Loading…
Reference in New Issue