Skip to content
This repository was archived by the owner on Jul 22, 2021. It is now read-only.

Commit d34f4f1

Browse files
Moved popup menu items into a new settings page
Signed-off-by: sunilpaulmathew <sunil.kde@gmail.com>
1 parent 069ce07 commit d34f4f1

34 files changed

+772
-1112
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<activity android:name=".activities.ApplyScriptActivity" />
3131
<activity android:name=".activities.CreateScriptActivity" />
3232
<activity android:name=".activities.FilePickerActivity" />
33-
<activity android:name=".activities.LicenceActivity" />
33+
<activity android:name=".activities.SettingsActivity" />
3434

3535
<provider
3636
android:name="androidx.core.content.FileProvider"

app/src/main/assets/gpl.html

Lines changed: 0 additions & 696 deletions
This file was deleted.

app/src/main/java/com/smartpack/scriptmanager/MainActivity.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
2626
import com.google.android.material.floatingactionbutton.FloatingActionButton;
2727
import com.smartpack.scriptmanager.activities.AboutActivity;
28-
import com.smartpack.scriptmanager.utils.Billing;
28+
import com.smartpack.scriptmanager.activities.SettingsActivity;
2929
import com.smartpack.scriptmanager.utils.Scripts;
3030
import com.smartpack.scriptmanager.utils.Utils;
3131

@@ -53,10 +53,12 @@ protected void onCreate(Bundle savedInstanceState) {
5353
Scripts.mRecyclerView = findViewById(R.id.recycler_view);
5454
AppCompatImageButton mSettings = findViewById(R.id.settings_icon);
5555
FloatingActionButton mFab = findViewById(R.id.fab);
56-
AppCompatImageButton mDonate = findViewById(R.id.donate_icon);
5756
AppCompatImageButton mInfo = findViewById(R.id.info_icon);
5857

59-
mSettings.setOnClickListener(v -> Utils.settingsMenu(mSettings, this));
58+
mSettings.setOnClickListener(v -> {
59+
Intent settingsMenu = new Intent(this, SettingsActivity.class);
60+
startActivity(settingsMenu);
61+
});
6062

6163
mFab.setOnClickListener(v -> {
6264
if (!Utils.checkWriteStoragePermission(this)) {
@@ -68,8 +70,6 @@ protected void onCreate(Bundle savedInstanceState) {
6870
Utils.fabMenu(mFab, this);
6971
});
7072

71-
mDonate.setOnClickListener(v -> Billing.showDonateOption(this));
72-
7373
mInfo.setOnClickListener(v -> {
7474
Intent aboutView = new Intent(this, AboutActivity.class);
7575
startActivity(aboutView);

app/src/main/java/com/smartpack/scriptmanager/activities/AboutActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4141
MaterialTextView mAppTitle = findViewById(R.id.app_title);
4242
MaterialTextView mChangeLog = findViewById(R.id.changelog);
4343

44-
boolean isProUser = Utils.getBoolean("support_received", false, this) || !Utils.isNotDonated(this);
4544
mDeveloper.setOnClickListener(v -> Utils.launchUrl("https://github.com/sunilpaulmathew", this));
46-
mAppTitle.setText(getString(R.string.app_name) + (isProUser ? " Pro " : " ") + BuildConfig.VERSION_NAME);
45+
mAppTitle.setText(getString(R.string.app_name) + (Utils.isProUser(this) ? " Pro " : " ") + BuildConfig.VERSION_NAME);
4746
String change_log = null;
4847
try {
4948
change_log = new JSONObject(Objects.requireNonNull(Utils.readAssetFile(

app/src/main/java/com/smartpack/scriptmanager/activities/LicenceActivity.java

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
* Copyright (C) 2021-2022 sunilpaulmathew <sunil.kde@gmail.com>
3+
*
4+
* This file is part of Script Manager, an app to create, import, edit
5+
* and easily execute any properly formatted shell scripts.
6+
*
7+
*/
8+
9+
package com.smartpack.scriptmanager.activities;
10+
11+
import android.annotation.SuppressLint;
12+
import android.content.Intent;
13+
import android.graphics.Color;
14+
import android.net.Uri;
15+
import android.os.Bundle;
16+
import android.provider.Settings;
17+
import android.widget.LinearLayout;
18+
19+
import androidx.annotation.Nullable;
20+
import androidx.appcompat.app.AppCompatActivity;
21+
import androidx.appcompat.widget.AppCompatImageButton;
22+
import androidx.recyclerview.widget.DividerItemDecoration;
23+
import androidx.recyclerview.widget.LinearLayoutManager;
24+
import androidx.recyclerview.widget.RecyclerView;
25+
26+
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
27+
import com.google.android.material.textview.MaterialTextView;
28+
import com.smartpack.scriptmanager.BuildConfig;
29+
import com.smartpack.scriptmanager.R;
30+
import com.smartpack.scriptmanager.adapters.RecycleViewSettingsAdapter;
31+
import com.smartpack.scriptmanager.utils.AppSettings;
32+
import com.smartpack.scriptmanager.utils.Billing;
33+
import com.smartpack.scriptmanager.utils.RecycleViewItem;
34+
import com.smartpack.scriptmanager.utils.Utils;
35+
36+
import java.util.ArrayList;
37+
38+
/*
39+
* Created by sunilpaulmathew <sunil.kde@gmail.com> on February 13, 2020
40+
*/
41+
public class SettingsActivity extends AppCompatActivity {
42+
43+
private ArrayList <RecycleViewItem> mData = new ArrayList<>();
44+
45+
@SuppressLint({"SetTextI18n", "UseCompatLoadingForDrawables"})
46+
@Override
47+
protected void onCreate(@Nullable Bundle savedInstanceState) {
48+
super.onCreate(savedInstanceState);
49+
setContentView(R.layout.activity_settings);
50+
51+
AppCompatImageButton mBack = findViewById(R.id.back_button);
52+
LinearLayout mAppInfo = findViewById(R.id.app_info);
53+
MaterialTextView mAppTitle = findViewById(R.id.title);
54+
MaterialTextView mAppDescription = findViewById(R.id.description);
55+
RecyclerView mRecyclerView = findViewById(R.id.recycler_view);
56+
57+
mAppTitle.setText(getString(R.string.app_name) + (Utils.isProUser(this) ? " Pro " : " ") + BuildConfig.VERSION_NAME);
58+
mAppTitle.setTextColor(Utils.isDarkTheme(this) ? Color.WHITE : Color.BLACK);
59+
mAppDescription.setText(BuildConfig.APPLICATION_ID);
60+
61+
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
62+
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
63+
RecycleViewSettingsAdapter mRecycleViewAdapter = new RecycleViewSettingsAdapter(mData);
64+
mRecyclerView.setAdapter(mRecycleViewAdapter);
65+
66+
mAppInfo.setOnClickListener(v -> {
67+
Intent settings = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
68+
settings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
69+
Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null);
70+
settings.setData(uri);
71+
startActivity(settings);
72+
finish();
73+
});
74+
75+
mData.add(new RecycleViewItem(getString(R.string.language), AppSettings.getLanguage(this), getResources().getDrawable(R.drawable.ic_language), null));
76+
mData.add(new RecycleViewItem(getString(R.string.file_picker), getString(Utils.getBoolean("use_file_picker", true, this) ? R.string.file_picker_inbuilt
77+
: R.string.file_picker_external), getResources().getDrawable(R.drawable.ic_folder), null));
78+
mData.add(new RecycleViewItem(getString(R.string.dark_theme), AppSettings.getAppThemeDescription(this), getResources().getDrawable(R.drawable.ic_theme), null));
79+
mData.add(new RecycleViewItem(getString(R.string.source_code), getString(R.string.source_code_summary), getResources().getDrawable(
80+
R.drawable.ic_github), "https://github.com/SmartPack/ScriptManager"));
81+
mData.add(new RecycleViewItem(getString(R.string.support_group), getString(R.string.support_group_summary), getResources().getDrawable(R.drawable.ic_support),
82+
"https://t.me/smartpack_kmanager"));
83+
mData.add(new RecycleViewItem(getString(R.string.report_issue), getString(R.string.report_issue_summary), getResources().getDrawable(R.drawable.ic_issue),
84+
"https://github.com/SmartPack/ScriptManager/issues/new/choose"));
85+
mData.add(new RecycleViewItem(getString(R.string.support_development), null, getResources().getDrawable(R.drawable.ic_donate), null));
86+
mData.add(new RecycleViewItem(getString(R.string.more_apps), getString(R.string.more_apps_summary), getResources().getDrawable(
87+
R.drawable.ic_playstore), "https://play.google.com/store/apps/dev?id=5836199813143882901"));
88+
mData.add(new RecycleViewItem(getString(R.string.translations), getString(R.string.translations_summary), getResources().getDrawable(
89+
R.drawable.ic_translate), "https://poeditor.com/join/project?hash=w47nhsNDL7"));
90+
mData.add(new RecycleViewItem(getString(R.string.share_app), getString(R.string.share_app_Summary), getResources().getDrawable(R.drawable.ic_share), null));
91+
mData.add(new RecycleViewItem(getString(R.string.rate_us), getString(R.string.rate_us_Summary), getResources().getDrawable(R.drawable.ic_rate),
92+
"https://play.google.com/store/apps/details?id=com.smartpack.scriptmanager"));
93+
mData.add(new RecycleViewItem(getString(R.string.licence), null, getResources().getDrawable(R.drawable.ic_licence),
94+
"https://www.gnu.org/licenses/gpl-3.0-standalone.html"));
95+
96+
mRecycleViewAdapter.setOnItemClickListener((position, v) -> {
97+
if (mData.get(position).getUrl() != null) {
98+
Utils.launchUrl(mData.get(position).getUrl(), this);
99+
} else if (position == 0) {
100+
AppSettings.setLanguage(this);
101+
} else if (position == 1) {
102+
new MaterialAlertDialogBuilder(this).setItems(getResources().getStringArray(
103+
R.array.file_picker), (dialogInterface, i) -> {
104+
switch (i) {
105+
case 0:
106+
Utils.saveBoolean("use_file_picker", true, this);
107+
mData.set(position, new RecycleViewItem(getString(R.string.file_picker), getString(R.string.file_picker_inbuilt),
108+
getResources().getDrawable(R.drawable.ic_folder), null));
109+
mRecycleViewAdapter.notifyItemChanged(position);
110+
break;
111+
case 1:
112+
Utils.saveBoolean("use_file_picker", false, this);
113+
mData.set(position, new RecycleViewItem(getString(R.string.file_picker), getString(R.string.file_picker_external),
114+
getResources().getDrawable(R.drawable.ic_folder), null));
115+
mRecycleViewAdapter.notifyItemChanged(position);
116+
break;
117+
}
118+
}).setOnDismissListener(dialogInterface -> {
119+
}).show();
120+
} else if (position == 2) {
121+
AppSettings.setAppTheme(this);
122+
} else if (position == 6) {
123+
Billing.showDonateOption(this);
124+
} else if (position == 9) {
125+
Intent share_app = new Intent();
126+
share_app.setAction(Intent.ACTION_SEND);
127+
share_app.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
128+
share_app.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_message_app, BuildConfig.VERSION_NAME));
129+
share_app.setType("text/plain");
130+
Intent shareIntent = Intent.createChooser(share_app, getString(R.string.share_with));
131+
startActivity(shareIntent);
132+
}
133+
});
134+
135+
mBack.setOnClickListener(v -> onBackPressed());
136+
}
137+
138+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright (C) 2021-2022 sunilpaulmathew <sunil.kde@gmail.com>
3+
*
4+
* This file is part of Script Manager, an app to create, import, edit
5+
* and easily execute any properly formatted shell scripts.
6+
*
7+
*/
8+
9+
package com.smartpack.scriptmanager.adapters;
10+
11+
import android.graphics.Color;
12+
import android.view.LayoutInflater;
13+
import android.view.View;
14+
import android.view.ViewGroup;
15+
16+
import androidx.annotation.NonNull;
17+
import androidx.appcompat.widget.AppCompatImageView;
18+
import androidx.recyclerview.widget.RecyclerView;
19+
20+
import com.google.android.material.textview.MaterialTextView;
21+
import com.smartpack.scriptmanager.R;
22+
import com.smartpack.scriptmanager.utils.RecycleViewItem;
23+
import com.smartpack.scriptmanager.utils.Utils;
24+
25+
import java.util.ArrayList;
26+
27+
/*
28+
* Created by sunilpaulmathew <sunil.kde@gmail.com> on February 13, 2020
29+
*/
30+
31+
public class RecycleViewSettingsAdapter extends RecyclerView.Adapter<RecycleViewSettingsAdapter.ViewHolder> {
32+
33+
private ArrayList<RecycleViewItem> data;
34+
35+
private static ClickListener mClickListener;
36+
37+
public RecycleViewSettingsAdapter(ArrayList<RecycleViewItem> data) {
38+
this.data = data;
39+
}
40+
41+
@NonNull
42+
@Override
43+
public RecycleViewSettingsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
44+
View rowItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycle_view_settings, parent, false);
45+
return new RecycleViewSettingsAdapter.ViewHolder(rowItem);
46+
}
47+
48+
@Override
49+
public void onBindViewHolder(@NonNull RecycleViewSettingsAdapter.ViewHolder holder, int position) {
50+
if (this.data.get(position).getTitle() != null) {
51+
holder.mTitle.setText(this.data.get(position).getTitle());
52+
holder.mTitle.setTextColor(Utils.isDarkTheme(holder.mTitle.getContext()) ? Color.WHITE : Color.BLACK);
53+
}
54+
if (this.data.get(position).getDescription() != null) {
55+
holder.mDescription.setText(this.data.get(position).getDescription());
56+
holder.mDescription.setVisibility(View.VISIBLE);
57+
holder.mDescription.setTextColor(Utils.isDarkTheme(holder.mTitle.getContext()) ? Color.WHITE : Color.BLACK);
58+
}
59+
if (this.data.get(position).getIcon() != null) {
60+
holder.mIcon.setImageDrawable(this.data.get(position).getIcon());
61+
holder.mIcon.setVisibility(View.VISIBLE);
62+
if (position != 8 && !Utils.isDarkTheme(holder.mIcon.getContext())) {
63+
holder.mIcon.setColorFilter(Color.BLACK);
64+
}
65+
}
66+
}
67+
68+
@Override
69+
public int getItemCount() {
70+
return this.data.size();
71+
}
72+
73+
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
74+
private AppCompatImageView mIcon;
75+
private MaterialTextView mTitle;
76+
private MaterialTextView mDescription;
77+
78+
public ViewHolder(View view) {
79+
super(view);
80+
view.setOnClickListener(this);
81+
this.mIcon = view.findViewById(R.id.icon);
82+
this.mTitle = view.findViewById(R.id.title);
83+
this.mDescription = view.findViewById(R.id.description);
84+
}
85+
86+
@Override
87+
public void onClick(View view) {
88+
mClickListener.onItemClick(getAdapterPosition(), view);
89+
}
90+
}
91+
92+
public void setOnItemClickListener(ClickListener clickListener) {
93+
RecycleViewSettingsAdapter.mClickListener = clickListener;
94+
}
95+
96+
public interface ClickListener {
97+
void onItemClick(int position, View v);
98+
}
99+
100+
}

0 commit comments

Comments
 (0)