aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-03-27 10:08:58 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-03-27 10:08:58 +0000
commit1cfdaf41fa7d4ce4cf7065d13667bef32c27066a (patch)
treea2b36c50cedc72479f7ee03f40503e3d7ad70c1f
parentf40b9cbde003d9c3cc0eaa0d3c4eadb072f67c4a (diff)
downloadinfinity-for-reddit-1cfdaf41fa7d4ce4cf7065d13667bef32c27066a.tar
infinity-for-reddit-1cfdaf41fa7d4ce4cf7065d13667bef32c27066a.tar.gz
infinity-for-reddit-1cfdaf41fa7d4ce4cf7065d13667bef32c27066a.tar.bz2
infinity-for-reddit-1cfdaf41fa7d4ce4cf7065d13667bef32c27066a.tar.lz
infinity-for-reddit-1cfdaf41fa7d4ce4cf7065d13667bef32c27066a.tar.xz
infinity-for-reddit-1cfdaf41fa7d4ce4cf7065d13667bef32c27066a.tar.zst
infinity-for-reddit-1cfdaf41fa7d4ce4cf7065d13667bef32c27066a.zip
Implemented share and import themes. Fixed some issues of custom theme.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java153
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CreateThemeBottomSheetFragment.java (renamed from app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SelectBaseThemeBottomSheetFragment.java)24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java2
-rw-r--r--app/src/main/res/drawable-night/ic_import_day_night_24dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_import_day_night_24dp.xml9
-rw-r--r--app/src/main/res/layout/activity_custom_theme_listing.xml1
-rw-r--r--app/src/main/res/layout/activity_rules.xml3
-rw-r--r--app/src/main/res/layout/activity_search_result.xml19
-rw-r--r--app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml3
-rw-r--r--app/src/main/res/layout/activity_subscribed_thing_listing.xml3
-rw-r--r--app/src/main/res/layout/fragment_create_theme_bottom_sheet.xml (renamed from app/src/main/res/layout/fragment_select_base_theme_bottom_sheet.xml)24
-rw-r--r--app/src/main/res/layout/item_user_custom_theme.xml12
-rw-r--r--app/src/main/res/values/strings.xml16
19 files changed, 273 insertions, 50 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
index b8fb82a4..45902fd8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
@@ -1,5 +1,7 @@
package ml.docilealligator.infinityforreddit.Activity;
+import android.content.ClipData;
+import android.content.ClipboardManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -10,6 +12,7 @@ import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -17,6 +20,9 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.snackbar.Snackbar;
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -29,18 +35,27 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.CustomThemeListingRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.AsyncTask.ChangeThemeNameAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteThemeAsyncTask;
+import ml.docilealligator.infinityforreddit.AsyncTask.GetCustomThemeAsyncTask;
+import ml.docilealligator.infinityforreddit.AsyncTask.InsertCustomThemeAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
+import ml.docilealligator.infinityforreddit.Fragment.CreateThemeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.CustomThemeOptionsBottomSheetFragment;
-import ml.docilealligator.infinityforreddit.Fragment.SelectBaseThemeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
-public class CustomThemeListingActivity extends BaseActivity implements CustomThemeOptionsBottomSheetFragment.CustomThemeOptionsBottomSheetFragmentListener {
+import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;
+public class CustomThemeListingActivity extends BaseActivity implements
+ CustomThemeOptionsBottomSheetFragment.CustomThemeOptionsBottomSheetFragmentListener,
+ CreateThemeBottomSheetFragment.SelectBaseThemeBottomSheetFragmentListener {
+
+ @BindView(R.id.coordinator_layout_custom_theme_listing_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_customize_theme_listing_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_customize_theme_listing_activity)
@@ -94,8 +109,8 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
customThemeViewModel.getAllCustomThemes().observe(this, adapter::setUserThemes);
fab.setOnClickListener(view -> {
- SelectBaseThemeBottomSheetFragment selectBaseThemeBottomSheetFragment = new SelectBaseThemeBottomSheetFragment();
- selectBaseThemeBottomSheetFragment.show(getSupportFragmentManager(), selectBaseThemeBottomSheetFragment.getTag());
+ CreateThemeBottomSheetFragment createThemeBottomSheetFragment = new CreateThemeBottomSheetFragment();
+ createThemeBottomSheetFragment.show(getSupportFragmentManager(), createThemeBottomSheetFragment.getTag());
});
}
@@ -124,10 +139,10 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
}
@Override
- public void changeName(String oldName) {
+ public void changeName(String oldThemeName) {
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_theme_name, null);
EditText themeNameEditText = dialogView.findViewById(R.id.theme_name_edit_text_edit_theme_name_dialog);
- themeNameEditText.setText(oldName);
+ themeNameEditText.setText(oldThemeName);
themeNameEditText.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
@@ -141,13 +156,9 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
if (imm != null) {
imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
}
- new ChangeThemeNameAsyncTask(redditDataRoomDatabase, oldName, themeNameEditText.getText().toString()).execute();
- })
- .setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
- if (imm != null) {
- imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
- }
+ new ChangeThemeNameAsyncTask(redditDataRoomDatabase, oldThemeName, themeNameEditText.getText().toString()).execute();
})
+ .setNegativeButton(R.string.cancel, null)
.setOnDismissListener(dialogInterface -> {
if (imm != null) {
imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
@@ -157,12 +168,31 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
}
@Override
- public void delete(String name) {
+ public void shareTheme(String themeName) {
+ new GetCustomThemeAsyncTask(redditDataRoomDatabase, themeName, customTheme -> {
+ if (customTheme != null) {
+ String jsonModel = customTheme.getJSONModel();
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ if (clipboard != null) {
+ ClipData clip = ClipData.newPlainText("simple text", jsonModel);
+ clipboard.setPrimaryClip(clip);
+ Snackbar.make(coordinatorLayout, R.string.theme_copied, Snackbar.LENGTH_SHORT).show();
+ } else {
+ Snackbar.make(coordinatorLayout, R.string.copy_theme_faied, Snackbar.LENGTH_SHORT).show();
+ }
+ } else {
+ Snackbar.make(coordinatorLayout, R.string.cannot_find_theme, Snackbar.LENGTH_SHORT).show();
+ }
+ }).execute();
+ }
+
+ @Override
+ public void delete(String themeName) {
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.delete_theme)
- .setMessage(getString(R.string.delete_theme_dialog_message, name))
+ .setMessage(getString(R.string.delete_theme_dialog_message, themeName))
.setPositiveButton(R.string.yes, (dialogInterface, i)
- -> new DeleteThemeAsyncTask(redditDataRoomDatabase, name, (isLightTheme, isDarkTheme, isAmoledTheme) -> {
+ -> new DeleteThemeAsyncTask(redditDataRoomDatabase, themeName, (isLightTheme, isDarkTheme, isAmoledTheme) -> {
if (isLightTheme) {
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(
CustomThemeWrapper.getIndigo(CustomThemeListingActivity.this), lightThemeSharedPreferences);
@@ -187,8 +217,101 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
EventBus.getDefault().unregister(this);
}
+ public void shareTheme(CustomTheme customTheme) {
+ if (customTheme != null) {
+ String jsonModel = customTheme.getJSONModel();
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ if (clipboard != null) {
+ ClipData clip = ClipData.newPlainText("simple text", jsonModel);
+ clipboard.setPrimaryClip(clip);
+ Snackbar.make(coordinatorLayout, R.string.theme_copied, Snackbar.LENGTH_SHORT).show();
+ } else {
+ Snackbar.make(coordinatorLayout, R.string.copy_theme_faied, Snackbar.LENGTH_SHORT).show();
+ }
+ } else {
+ Snackbar.make(coordinatorLayout, R.string.cannot_find_theme, Snackbar.LENGTH_SHORT).show();
+ }
+ }
+
@Subscribe
public void onRecreateActivityEvent(RecreateActivityEvent recreateActivityEvent) {
recreate();
}
+
+ @Override
+ public void importTheme() {
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ if (clipboard != null) {
+ // If it does contain data, decide if you can handle the data.
+ if (!clipboard.hasPrimaryClip()) {
+ Snackbar.make(coordinatorLayout, R.string.no_data_in_clipboard, Snackbar.LENGTH_SHORT).show();
+ } else if (clipboard.getPrimaryClipDescription() != null &&
+ !clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) {
+ // since the clipboard has data but it is not plain text
+ Snackbar.make(coordinatorLayout, R.string.no_data_in_clipboard, Snackbar.LENGTH_SHORT).show();
+ } else if (clipboard.getPrimaryClip() != null){
+ ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
+ String json = item.getText().toString();
+ try {
+ CustomTheme customTheme = new Gson().fromJson(json, CustomTheme.class);
+ checkDuplicateAndImportTheme(customTheme, true);
+ } catch (JsonSyntaxException e) {
+ Snackbar.make(coordinatorLayout, R.string.parse_theme_failed, Snackbar.LENGTH_SHORT).show();
+ }
+ }
+ }
+ }
+
+ private void checkDuplicateAndImportTheme(CustomTheme customTheme, boolean checkDuplicate) {
+ new InsertCustomThemeAsyncTask(redditDataRoomDatabase, lightThemeSharedPreferences,
+ darkThemeSharedPreferences, amoledThemeSharedPreferences, customTheme, checkDuplicate,
+ new InsertCustomThemeAsyncTask.InsertCustomThemeAsyncTaskListener() {
+ @Override
+ public void success() {
+ Snackbar.make(coordinatorLayout, R.string.import_theme_success, Snackbar.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void duplicate() {
+ new MaterialAlertDialogBuilder(CustomThemeListingActivity.this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.duplicate_theme_name_dialog_title)
+ .setMessage(getString(R.string.duplicate_theme_name_dialog_message, customTheme.name))
+ .setPositiveButton(R.string.rename, (dialogInterface, i)
+ -> {
+ View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_theme_name, null);
+ EditText themeNameEditText = dialogView.findViewById(R.id.theme_name_edit_text_edit_theme_name_dialog);
+ themeNameEditText.setText(customTheme.name);
+ themeNameEditText.requestFocus();
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
+ new MaterialAlertDialogBuilder(CustomThemeListingActivity.this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.edit_theme_name)
+ .setView(dialogView)
+ .setPositiveButton(R.string.ok, (editTextDialogInterface, i1)
+ -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
+ }
+ if (!themeNameEditText.getText().toString().equals("")) {
+ customTheme.name = themeNameEditText.getText().toString();
+ }
+ checkDuplicateAndImportTheme(customTheme, true);
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .setOnDismissListener(editTextDialogInterface -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
+ }
+ })
+ .show();
+ })
+ .setNegativeButton(R.string.override, (dialogInterface, i) -> {
+ checkDuplicateAndImportTheme(customTheme, false);
+ })
+ .show();
+ }
+ }).execute();
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java
index e4847ac4..07730b0c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java
@@ -198,7 +198,8 @@ public class CustomizeThemeActivity extends BaseActivity {
}
CustomTheme customTheme = CustomTheme.convertSettingsItemsToCustomTheme(customThemeSettingsItems, themeName);
new InsertCustomThemeAsyncTask(redditDataRoomDatabase, lightThemeSharedPreferences,
- darkThemeSharedPreferences, amoledThemeSharedPreferences, customTheme, () -> {
+ darkThemeSharedPreferences, amoledThemeSharedPreferences, customTheme,
+ false, () -> {
Toast.makeText(CustomizeThemeActivity.this, R.string.saved, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new RecreateActivityEvent());
finish();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java
index 525564b8..3addc094 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java
@@ -18,6 +18,7 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.CustomThemeListingActivity;
import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme;
import ml.docilealligator.infinityforreddit.Fragment.CustomThemeOptionsBottomSheetFragment;
@@ -90,7 +91,7 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
activity.startActivity(intent);
});
((UserCustomThemeViewHolder) holder).shareImageView.setOnClickListener(view -> {
-
+ ((CustomThemeListingActivity) activity).shareTheme(customTheme);
});
((UserCustomThemeViewHolder) holder).itemView.setOnClickListener(view -> {
CustomThemeOptionsBottomSheetFragment customThemeOptionsBottomSheetFragment = new CustomThemeOptionsBottomSheetFragment();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
index 5477ecbe..0eba4b1d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
@@ -13,22 +13,27 @@ public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
private SharedPreferences darkThemeSharedPreferences;
private SharedPreferences amoledThemeSharedPreferences;
private CustomTheme customTheme;
+ private boolean checkDuplicate;
private InsertCustomThemeAsyncTaskListener insertCustomThemeAsyncTaskListener;
+ private boolean isDuplicate = false;
public interface InsertCustomThemeAsyncTaskListener {
void success();
+ default void duplicate() {}
}
public InsertCustomThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase,
SharedPreferences lightThemeSharedPreferences,
SharedPreferences darkThemeSharedPreferences,
- SharedPreferences amoledThemeSharedPreferences, CustomTheme customTheme,
+ SharedPreferences amoledThemeSharedPreferences,
+ CustomTheme customTheme, boolean checkDuplicate,
InsertCustomThemeAsyncTaskListener insertCustomThemeAsyncTaskListener) {
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.lightThemeSharedPreferences = lightThemeSharedPreferences;
this.darkThemeSharedPreferences = darkThemeSharedPreferences;
this.amoledThemeSharedPreferences = amoledThemeSharedPreferences;
this.customTheme = customTheme;
+ this.checkDuplicate = checkDuplicate;
this.insertCustomThemeAsyncTaskListener = insertCustomThemeAsyncTaskListener;
}
@@ -46,6 +51,12 @@ public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
}
+ if (checkDuplicate) {
+ if (redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name) != null) {
+ isDuplicate = true;
+ return null;
+ }
+ }
redditDataRoomDatabase.customThemeDao().insert(customTheme);
return null;
}
@@ -53,6 +64,10 @@ public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
- insertCustomThemeAsyncTaskListener.success();
+ if (isDuplicate) {
+ insertCustomThemeAsyncTaskListener.duplicate();
+ } else {
+ insertCustomThemeAsyncTaskListener.success();
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java
index 65409086..c05e79e0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java
@@ -5,6 +5,8 @@ import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
+import com.google.gson.Gson;
+
import java.util.ArrayList;
@Entity(tableName = "custom_themes")
@@ -150,10 +152,17 @@ public class CustomTheme {
@ColumnInfo(name = "is_change_status_bar_icon_color_after_toolbar_collapsed_in_immersive_interface")
public boolean isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface;
+ public CustomTheme() {}
+
public CustomTheme(@NonNull String name) {
this.name = name;
}
+ public String getJSONModel() {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+
public static CustomTheme convertSettingsItemsToCustomTheme(ArrayList<CustomThemeSettingsItem> customThemeSettingsItems, String themeName) {
CustomTheme customTheme = new CustomTheme(themeName);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java
index 96bb671d..f53f6c09 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java
@@ -98,7 +98,7 @@ public class CopyTextBottomSheetFragment extends RoundedBottomSheetDialogFragmen
clipboard.setPrimaryClip(clip);
Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show();
} else {
- Toast.makeText(activity, R.string.copy_failed, Toast.LENGTH_SHORT).show();
+ Toast.makeText(activity, R.string.copy_link_failed, Toast.LENGTH_SHORT).show();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SelectBaseThemeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CreateThemeBottomSheetFragment.java
index 81df06c5..d92286ae 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SelectBaseThemeBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CreateThemeBottomSheetFragment.java
@@ -22,25 +22,37 @@ import ml.docilealligator.infinityforreddit.R;
/**
* A simple {@link Fragment} subclass.
*/
-public class SelectBaseThemeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
+public class CreateThemeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
- @BindView(R.id.light_theme_text_view_select_base_theme_bottom_sheet_fragment)
+ @BindView(R.id.import_theme_text_view_create_theme_bottom_sheet_fragment)
+ TextView importTextView;
+ @BindView(R.id.light_theme_text_view_create_theme_bottom_sheet_fragment)
TextView lightThemeTextView;
- @BindView(R.id.dark_theme_text_view_select_base_theme_bottom_sheet_fragment)
+ @BindView(R.id.dark_theme_text_view_create_theme_bottom_sheet_fragment)
TextView darkThemeTextView;
- @BindView(R.id.amoled_theme_text_view_select_base_theme_bottom_sheet_fragment)
+ @BindView(R.id.amoled_theme_text_view_create_theme_bottom_sheet_fragment)
TextView amoledThemeTextView;
private Activity activity;
- public SelectBaseThemeBottomSheetFragment() {
+
+ public interface SelectBaseThemeBottomSheetFragmentListener {
+ void importTheme();
+ }
+
+ public CreateThemeBottomSheetFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_select_base_theme_bottom_sheet, container, false);
+ View rootView = inflater.inflate(R.layout.fragment_create_theme_bottom_sheet, container, false);
ButterKnife.bind(this, rootView);
+ importTextView.setOnClickListener(view -> {
+ ((SelectBaseThemeBottomSheetFragmentListener) activity).importTheme();
+ dismiss();
+ });
+
lightThemeTextView.setOnClickListener(view -> {
Intent intent = new Intent(activity, CustomizeThemeActivity.class);
intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java
index 7657bba9..5529a599 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java
@@ -7,8 +7,6 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -16,7 +14,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
-import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -47,8 +44,9 @@ public class CustomThemeOptionsBottomSheetFragment extends RoundedBottomSheetDia
}
public interface CustomThemeOptionsBottomSheetFragmentListener {
- void changeName(String oldName);
- void delete(String name);
+ void changeName(String oldThemeName);
+ void shareTheme(String themeName);
+ void delete(String themeName);
}
@Override
@@ -68,6 +66,7 @@ public class CustomThemeOptionsBottomSheetFragment extends RoundedBottomSheetDia
});
shareThemeTextView.setOnClickListener(view -> {
+ ((CustomThemeOptionsBottomSheetFragmentListener) activity).shareTheme(themeName);
dismiss();
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java
index d3c54782..4a2ed929 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java
@@ -130,7 +130,7 @@ public class ShareLinkBottomSheetFragment extends RoundedBottomSheetDialogFragme
clipboard.setPrimaryClip(clip);
Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show();
} else {
- Toast.makeText(activity, R.string.copy_failed, Toast.LENGTH_SHORT).show();
+ Toast.makeText(activity, R.string.copy_link_failed, Toast.LENGTH_SHORT).show();
}
}
diff --git a/app/src/main/res/drawable-night/ic_import_day_night_24dp.xml b/app/src/main/res/drawable-night/ic_import_day_night_24dp.xml
new file mode 100644
index 00000000..eb39e3f3
--- /dev/null
+++ b/app/src/main/res/drawable-night/ic_import_day_night_24dp.xml
@@ -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,5v6h1.17L12,13.17 9.83,11L11,11L11,5h2m2,-2L9,3v6L5,9l7,7 7,-7h-4L15,3zM19,18L5,18v2h14v-2z"
+ android:fillColor="#FFFFFF"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_import_day_night_24dp.xml b/app/src/main/res/drawable/ic_import_day_night_24dp.xml
new file mode 100644
index 00000000..ad852174
--- /dev/null
+++ b/app/src/main/res/drawable/ic_import_day_night_24dp.xml
@@ -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,5v6h1.17L12,13.17 9.83,11L11,11L11,5h2m2,-2L9,3v6L5,9l7,7 7,-7h-4L15,3zM19,18L5,18v2h14v-2z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/app/src/main/res/layout/activity_custom_theme_listing.xml b/app/src/main/res/layout/activity_custom_theme_listing.xml
index 37b8f878..5b35b48c 100644
--- a/app/src/main/res/layout/activity_custom_theme_listing.xml
+++ b/app/src/main/res/layout/activity_custom_theme_listing.xml
@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:id="@+id/coordinator_layout_custom_theme_listing_activity"
tools:context=".Activity.CustomThemeListingActivity">
<com.google.android.material.appbar.AppBarLayout
diff --git a/app/src/main/res/layout/activity_rules.xml b/app/src/main/res/layout/activity_rules.xml
index 36d057db..91f35cf2 100644
--- a/app/src/main/res/layout/activity_rules.xml
+++ b/app/src/main/res/layout/activity_rules.xml
@@ -27,7 +27,8 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
- app:popupTheme="@style/AppTheme.PopupOverlay" />
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:navigationIcon="?attr/homeAsUpIndicator" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
diff --git a/app/src/main/res/layout/activity_search_result.xml b/app/src/main/res/layout/activity_search_result.xml
index c4b132c7..63c8212e 100644
--- a/app/src/main/res/layout/activity_search_result.xml
+++ b/app/src/main/res/layout/activity_search_result.xml
@@ -14,12 +14,21 @@
android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay">
- <androidx.appcompat.widget.Toolbar
- android:id="@+id/toolbar_search_result_activity"
+ <com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- app:popupTheme="@style/AppTheme.PopupOverlay"
- app:navigationIcon="?attr/homeAsUpIndicator" />
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:titleEnabled="false"
+ app:toolbarId="@+id/toolbar_search_result_activity">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar_search_result_activity"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:navigationIcon="?attr/homeAsUpIndicator" />
+
+ </com.google.android.material.appbar.CollapsingToolbarLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout_search_result_activity"
diff --git a/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml b/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml
index ee0ae427..d552fb84 100644
--- a/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml
+++ b/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml
@@ -28,7 +28,8 @@
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
- app:popupTheme="@style/AppTheme.PopupOverlay" />
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:navigationIcon="?attr/homeAsUpIndicator" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
diff --git a/app/src/main/res/layout/activity_subscribed_thing_listing.xml b/app/src/main/res/layout/activity_subscribed_thing_listing.xml
index 183a0b61..460b1ba6 100644
--- a/app/src/main/res/layout/activity_subscribed_thing_listing.xml
+++ b/app/src/main/res/layout/activity_subscribed_thing_listing.xml
@@ -28,7 +28,8 @@
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
- app:popupTheme="@style/AppTheme.PopupOverlay" />
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:navigationIcon="?attr/homeAsUpIndicator" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
diff --git a/app/src/main/res/layout/fragment_select_base_theme_bottom_sheet.xml b/app/src/main/res/layout/fragment_create_theme_bottom_sheet.xml
index d0adbd83..c5ac6fda 100644
--- a/app/src/main/res/layout/fragment_select_base_theme_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_create_theme_bottom_sheet.xml
@@ -11,7 +11,25 @@
android:orientation="vertical">
<TextView
- android:id="@+id/light_theme_text_view_select_base_theme_bottom_sheet_fragment"
+ android:id="@+id/import_theme_text_view_create_theme_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/import_theme"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:drawableStart="@drawable/ic_import_day_night_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/light_theme_text_view_create_theme_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
@@ -29,7 +47,7 @@
android:background="?attr/selectableItemBackground" />
<TextView
- android:id="@+id/dark_theme_text_view_select_base_theme_bottom_sheet_fragment"
+ android:id="@+id/dark_theme_text_view_create_theme_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
@@ -47,7 +65,7 @@
android:background="?attr/selectableItemBackground" />
<TextView
- android:id="@+id/amoled_theme_text_view_select_base_theme_bottom_sheet_fragment"
+ android:id="@+id/amoled_theme_text_view_create_theme_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
diff --git a/app/src/main/res/layout/item_user_custom_theme.xml b/app/src/main/res/layout/item_user_custom_theme.xml
index 55891961..e8c4dc65 100644
--- a/app/src/main/res/layout/item_user_custom_theme.xml
+++ b/app/src/main/res/layout/item_user_custom_theme.xml
@@ -24,21 +24,21 @@
android:textColor="?attr/primaryTextColor" />
<ImageView
- android:id="@+id/add_image_view_item_user_custom_theme"
+ android:id="@+id/share_image_view_item_user_custom_theme"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
- android:layout_marginStart="32dp"
- android:src="@drawable/ic_add_day_night_24dp"
+ android:layout_marginStart="16dp"
+ android:src="@drawable/ic_share_24dp"
android:background="?attr/selectableItemBackgroundBorderless" />
<ImageView
- android:id="@+id/share_image_view_item_user_custom_theme"
+ android:id="@+id/add_image_view_item_user_custom_theme"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
- android:layout_marginStart="16dp"
- android:src="@drawable/ic_share_24dp"
+ android:layout_marginStart="32dp"
+ android:src="@drawable/ic_add_day_night_24dp"
android:background="?attr/selectableItemBackgroundBorderless" />
</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 22b971ff..a28dfd34 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -431,7 +431,7 @@
<string name="copy_link">Copy Link</string>
<string name="copy_success">Copied</string>
- <string name="copy_failed">Cannot copy the link</string>
+ <string name="copy_link_failed">Cannot copy the link</string>
<string name="copy_text">Copy</string>
<string name="copy_all">Copy All</string>
<string name="copy_markdown">Copy Markdown</string>
@@ -620,6 +620,20 @@
<string name="delete_theme_dialog_message">Are you sure to delete %1$s?</string>
<string name="share_theme">Share Theme</string>
<string name="change_theme_name">Change Name</string>
+ <string name="theme_copied">Copied! Paste and share it to other people.</string>
+ <string name="copy_theme_faied">Cannot copy the theme configuration</string>
+ <string name="cannot_find_theme">Cannot find this theme</string>
+ <string name="import_theme">Import Theme</string>
+ <string name="no_data_in_clipboard">Cannot find data in clipboard</string>
+ <string name="import_theme_success">Import theme successful</string>
+ <string name="parse_theme_failed">Parse Theme Failed</string>
+ <string name="share_theme_to_subreddit_dialog_title">Share it to r/Infinity_For_Reddit?</string>
+ <string name="share_theme_to_subreddit_dialog_message">The theme configuration is copied!
+ Do you want to share it to r/Infinity so that other people can use it?</string>
+ <string name="duplicate_theme_name_dialog_title">Duplicate Theme Found</string>
+ <string name="duplicate_theme_name_dialog_message">A theme in the database is also called %1$s. Do you want to change the name of this imported theme?</string>
+ <string name="rename">Rename</string>
+ <string name="override">Override</string>
<string name="color_picker">Color Picker</string>
<string name="invalid_color">Invalid Color</string>