Skip to content

Commit 0db5dbe

Browse files
committed
owo
1 parent e0d8aa6 commit 0db5dbe

File tree

65 files changed

+2216
-730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2216
-730
lines changed

.idea/gradle.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
applicationId "ru.fazziclay.opentoday"
1010
minSdk 26
1111
targetSdk 32
12-
versionCode 52
13-
versionName "0.9.3 (build 52)"
12+
versionCode 54
13+
versionName "0.9.4 (build 54)"
1414

1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616
}

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
android:theme="@style/Theme.OpenToday">
1717

1818
<!-- Activities -->
19-
<activity android:name=".ui.activity.MainActivity"
19+
<activity android:name=".ui.activity.PreMainActivity"
2020
android:exported="true">
2121
<intent-filter>
2222
<action android:name="android.intent.action.MAIN" />
@@ -30,8 +30,12 @@
3030
</intent-filter>
3131
</activity>
3232
<activity android:name=".ui.activity.OpenSourceLicenseActivity" android:exported="false" />
33+
<activity android:name=".ui.activity.MainActivity" android:exported="false" />
3334

3435
<activity android:name=".debug.TestItemViewGenerator" android:exported="false" />
36+
<activity android:name=".debug.TestItemStorageDrawer" android:exported="false" />
37+
<activity android:name=".debug.TestActivityFragment" android:exported="false" />
38+
<activity android:name=".debug.TestItemManager" android:exported="false" />
3539
<activity android:name=".ui.activity.CrashReportActivity" android:exported="true">
3640
<intent-filter>
3741
<action android:name="android.intent.action.MAIN" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ru.fazziclay.opentoday.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Target;
5+
6+
import ru.fazziclay.opentoday.app.items.item.Item;
7+
8+
@Target(ElementType.METHOD)
9+
public @interface ForItem {
10+
Class<? extends Item>[] key();
11+
}

app/src/main/java/ru/fazziclay/opentoday/app/App.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import ru.fazziclay.opentoday.app.receiver.ItemsTickReceiver;
2727
import ru.fazziclay.opentoday.app.receiver.QuickNoteReceiver;
2828
import ru.fazziclay.opentoday.app.settings.SettingsManager;
29+
import ru.fazziclay.opentoday.debug.TestActivityFragment;
30+
import ru.fazziclay.opentoday.debug.TestItemManager;
31+
import ru.fazziclay.opentoday.debug.TestItemStorageDrawer;
2932
import ru.fazziclay.opentoday.debug.TestItemViewGenerator;
3033
import ru.fazziclay.opentoday.ui.activity.CrashReportActivity;
3134
import ru.fazziclay.opentoday.util.DebugUtil;
@@ -34,7 +37,7 @@
3437
@SuppressWarnings("PointlessBooleanExpression") // for debug variables
3538
public class App extends Application {
3639
// Application
37-
public static final int APPLICATION_DATA_VERSION = 5;
40+
public static final int APPLICATION_DATA_VERSION = 6;
3841
public static final String VERSION_NAME = BuildConfig.VERSION_NAME;
3942
public static final int VERSION_CODE = BuildConfig.VERSION_CODE;
4043
public static final String APPLICATION_ID = BuildConfig.APPLICATION_ID;
@@ -49,7 +52,7 @@ public class App extends Application {
4952
public static final boolean DEBUG_TICK_NOTIFICATION = (DEBUG & false);
5053
public static final int DEBUG_MAIN_ACTIVITY_START_SLEEP = (DEBUG & false) ? 6000 : 0;
5154
public static final int DEBUG_APP_START_SLEEP = (DEBUG & false) ? 1000 : 0;
52-
public static Class<? extends Activity> DEBUG_MAIN_ACTIVITY = (DEBUG & false) ? TestItemViewGenerator.class : null;
55+
public static Class<? extends Activity> DEBUG_MAIN_ACTIVITY = (DEBUG & false) ? TestActivityFragment.class : null;
5356
public static final boolean DEBUG_TEST_EXCEPTION_ONCREATE_MAINACTIVITY = (DEBUG && false);
5457

5558
private static Thread.UncaughtExceptionHandler defaultHandler;
@@ -156,7 +159,7 @@ public static void crash(Context context, CrashReport crashReport, boolean sendT
156159
.setBigContentTitle(context.getString(R.string.crash_notification_big_title))
157160
.setSummaryText(context.getString(R.string.crash_notification_big_summary)))
158161
.setPriority(NotificationCompat.PRIORITY_MAX)
159-
.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, CrashReportActivity.class).putExtra("path", file.getAbsolutePath()), flag))
162+
.setContentIntent(PendingIntent.getActivity(context, 0, CrashReportActivity.createLaunchIntent(context, file.getAbsolutePath()), flag))
160163
.setAutoCancel(true)
161164
.build());
162165

app/src/main/java/ru/fazziclay/opentoday/app/datafixer/DataFixer.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
import org.json.JSONObject;
1010

1111
import java.io.File;
12+
import java.util.UUID;
1213

1314
import ru.fazziclay.javaneoutil.FileUtil;
15+
import ru.fazziclay.opentoday.app.App;
1416

1517
public class DataFixer {
1618
private final Context context;
@@ -84,13 +86,56 @@ public void fixToCurrentVersion() {
8486
isUpdated = true;
8587
}
8688

89+
if (dataVersion == 5) {
90+
fix5versionTo6();
91+
dataVersion = 6;
92+
isUpdated = true;
93+
}
94+
8795
Log.d("DataFixer", "latest dataVersion = " + dataVersion);
8896
if (isUpdated) {
8997
File logFile = new File(context.getExternalCacheDir(), "data-fixer/logs/" + System.currentTimeMillis() + ".txt");
9098
FileUtil.setText(logFile, logs.toString());
9199
}
92100
}
93101

102+
private void fix5versionTo6() {
103+
// DO NOT EDIT!
104+
final File itemsDataFile = new File(context.getExternalFilesDir(""), "item_data.json");
105+
106+
try {
107+
JSONObject oldJson = new JSONObject(FileUtil.getText(itemsDataFile));
108+
JSONObject newJson = new JSONObject();
109+
110+
JSONObject mainTab = new JSONObject();
111+
mainTab.put("id", UUID.randomUUID());
112+
mainTab.put("name", "My Items");
113+
114+
if (oldJson.has("items")) {
115+
JSONArray items = oldJson.getJSONArray("items");
116+
mainTab.put("items", items);
117+
118+
} else {
119+
mainTab.put("items", new JSONArray());
120+
log("[5to6] ! items key not found");
121+
}
122+
123+
JSONArray newJsonTabs = new JSONArray();
124+
newJsonTabs.put(mainTab);
125+
newJson.put("tabs", newJsonTabs);
126+
127+
log("[5to6] write to file");
128+
FileUtil.setText(itemsDataFile, newJson.toString(2));
129+
log("[5to6] write to file: DONE");
130+
131+
132+
log("[5to6] done");
133+
} catch (Exception e) {
134+
log("[5to6] exception", e);
135+
App.exception(context, e);
136+
}
137+
}
138+
94139
private void fix4versionTo5() {
95140
try {
96141
File from = new File(context.getExternalFilesDir(""), "item_data.json");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package ru.fazziclay.opentoday.app.items;
2+
3+
import ru.fazziclay.opentoday.app.items.callback.OnCurrentItemStorageUpdate;
4+
import ru.fazziclay.opentoday.app.items.item.Item;
5+
import ru.fazziclay.opentoday.callback.CallbackStorage;
6+
7+
public interface CurrentItemStorage {
8+
Item getCurrentItem();
9+
CallbackStorage<OnCurrentItemStorageUpdate> getOnCurrentItemStorageUpdateCallbacks();
10+
}

app/src/main/java/ru/fazziclay/opentoday/app/items/DataTransferPacket.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import ru.fazziclay.opentoday.app.items.item.Item;
77

8+
@Deprecated
89
public class DataTransferPacket {
910
public List<Item> items = new ArrayList<>();
1011
}

app/src/main/java/ru/fazziclay/opentoday/app/items/ImportWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public String finalExport() throws Exception {
2626
.put("importVersion", importVersion);
2727

2828

29-
jsonObject.put("items", ItemIEManager.exportItemList(items));
29+
jsonObject.put("items", ItemIEUtil.exportItemList(items));
3030

3131
return "--OPENTODAY-IMPORT-START--\n" + importVersion + "\n" + Base64.getEncoder().encodeToString(jsonObject.toString().getBytes(StandardCharsets.UTF_8)) + "\n--OPENTODAY-IMPORT-END--";
3232
}
@@ -50,7 +50,7 @@ public static ImportWrapper finalImport(String content) throws Exception {
5050
throw new Exception("Version not compatible");
5151
}
5252

53-
return new ImportWrapper(ItemIEManager.importItemList(jsonObject.getJSONArray("items")));
53+
return new ImportWrapper(ItemIEUtil.importItemList(jsonObject.getJSONArray("items")));
5454
}
5555

5656

app/src/main/java/ru/fazziclay/opentoday/app/items/ItemIEManager.java renamed to app/src/main/java/ru/fazziclay/opentoday/app/items/ItemIEUtil.java

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,13 @@
33
import org.json.JSONArray;
44
import org.json.JSONObject;
55

6-
import java.io.File;
76
import java.util.ArrayList;
87
import java.util.List;
98

10-
import ru.fazziclay.javaneoutil.FileUtil;
119
import ru.fazziclay.opentoday.app.items.item.Item;
1210

13-
public class ItemIEManager {
11+
public class ItemIEUtil {
1412
private static final String KEY_ITEMTYPE = "itemType";
15-
private static final int JSON_INTENT_SPACES = 2;
16-
17-
private final File saveFile;
18-
19-
public ItemIEManager(File saveFile) {
20-
this.saveFile = saveFile;
21-
}
22-
23-
public DataTransferPacket loadFromFile() {
24-
if (!FileUtil.isExist(saveFile)) {
25-
return null;
26-
}
27-
try {
28-
JSONObject root = new JSONObject(FileUtil.getText(saveFile, "{}"));
29-
JSONArray jsonItems = root.optJSONArray("items");
30-
if (jsonItems == null) jsonItems = new JSONArray();
31-
32-
DataTransferPacket dataTransferPacket = new DataTransferPacket();
33-
dataTransferPacket.items = importItemList(jsonItems);
34-
return dataTransferPacket;
35-
36-
} catch (Exception e) {
37-
throw new RuntimeException("Load exception", e);
38-
}
39-
}
40-
41-
public void saveToFile(DataTransferPacket dataTransferPacket) {
42-
try {
43-
JSONObject root = new JSONObject();
44-
JSONArray jsonItems = exportItemList(dataTransferPacket.items);
45-
root.put("items", jsonItems);
46-
47-
FileUtil.setText(saveFile, root.toString(JSON_INTENT_SPACES));
48-
49-
} catch (Exception e) {
50-
throw new RuntimeException("Save exception", e);
51-
}
52-
}
5313

5414
public static JSONArray exportItemList(List<Item> items) throws Exception {
5515
JSONArray o = new JSONArray();

0 commit comments

Comments
 (0)