aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml')
-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
9 files changed, 192 insertions, 32 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();
}
}