Refactoring

pull/206/head
M66B 3 years ago
parent 58bcffd7ff
commit e2ac96de45

@ -145,16 +145,6 @@
<action android:name="${applicationId}.REFRESH" /> <action android:name="${applicationId}.REFRESH" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity> </activity>
<activity <activity
@ -198,9 +188,19 @@
<activity <activity
android:name=".ActivityView" android:name=".ActivityView"
android:exported="false" android:exported="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:parentActivityName=".ActivityMain" /> android:parentActivityName=".ActivityMain">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity>
<activity <activity
android:name=".ActivitySearch" android:name=".ActivitySearch"

@ -144,16 +144,6 @@
<action android:name="${applicationId}.REFRESH" /> <action android:name="${applicationId}.REFRESH" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity> </activity>
<activity <activity
@ -197,9 +187,19 @@
<activity <activity
android:name=".ActivityView" android:name=".ActivityView"
android:exported="false" android:exported="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:parentActivityName=".ActivityMain" /> android:parentActivityName=".ActivityMain">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity>
<activity <activity
android:name=".ActivitySearch" android:name=".ActivitySearch"

@ -144,16 +144,6 @@
<action android:name="${applicationId}.REFRESH" /> <action android:name="${applicationId}.REFRESH" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity> </activity>
<activity <activity
@ -197,9 +187,19 @@
<activity <activity
android:name=".ActivityView" android:name=".ActivityView"
android:exported="false" android:exported="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:parentActivityName=".ActivityMain" /> android:parentActivityName=".ActivityMain">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity>
<activity <activity
android:name=".ActivitySearch" android:name=".ActivitySearch"

@ -144,16 +144,6 @@
<action android:name="${applicationId}.REFRESH" /> <action android:name="${applicationId}.REFRESH" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity> </activity>
<activity <activity
@ -197,9 +187,19 @@
<activity <activity
android:name=".ActivityView" android:name=".ActivityView"
android:exported="false" android:exported="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:parentActivityName=".ActivityMain" /> android:parentActivityName=".ActivityMain">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity>
<activity <activity
android:name=".ActivitySearch" android:name=".ActivitySearch"

@ -51,61 +51,6 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
return; return;
} }
Intent intent = getIntent();
Uri data = (intent == null ? null : intent.getData());
if (data != null &&
"message".equals(data.getScheme()) &&
BuildConfig.APPLICATION_ID.equals(data.getHost())) {
super.onCreate(savedInstanceState);
Bundle args = new Bundle();
args.putParcelable("data", data);
new SimpleTask<EntityMessage>() {
@Override
protected EntityMessage onExecute(Context context, Bundle args) {
Uri data = args.getParcelable("data");
String path = data.getPath();
if (path == null)
return null;
String[] parts = path.split("/");
if (parts.length < 1)
return null;
long id = Long.parseLong(parts[1]);
DB db = DB.getInstance(context);
return db.message().getMessage(id);
}
@Override
protected void onExecuted(Bundle args, EntityMessage message) {
finish();
if (message == null)
return;
Intent thread = new Intent(ActivityMain.this, ActivityView.class);
thread.setAction("thread:" + message.id);
thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
thread.putExtra("account", message.account);
thread.putExtra("folder", message.folder);
thread.putExtra("thread", message.thread);
thread.putExtra("filter_archive", true);
thread.putExtra("pinned", true);
thread.putExtra("msgid", message.msgid);
startActivity(thread);
}
@Override
protected void onException(Bundle args, Throwable ex) {
// Ignored
}
}.execute(this, args, "message:linked");
return;
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean eula = prefs.getBoolean("eula", false); boolean eula = prefs.getBoolean("eula", false);
boolean sync_on_launch = prefs.getBoolean("sync_on_launch", false); boolean sync_on_launch = prefs.getBoolean("sync_on_launch", false);

@ -1455,6 +1455,54 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
ServiceUI.sync(this, null); ServiceUI.sync(this, null);
} }
Uri data = intent.getData();
if (data != null &&
"message".equals(data.getScheme()) &&
BuildConfig.APPLICATION_ID.equals(data.getHost())) {
Bundle args = new Bundle();
args.putParcelable("data", data);
new SimpleTask<EntityMessage>() {
@Override
protected EntityMessage onExecute(Context context, Bundle args) {
Uri data = args.getParcelable("data");
String path = data.getPath();
if (path == null)
return null;
String[] parts = path.split("/");
if (parts.length < 1)
return null;
long id = Long.parseLong(parts[1]);
DB db = DB.getInstance(context);
return db.message().getMessage(id);
}
@Override
protected void onExecuted(Bundle args, EntityMessage message) {
if (message == null)
return;
Intent thread = new Intent();
thread.setAction("thread:" + message.id);
thread.putExtra("account", message.account);
thread.putExtra("folder", message.folder);
thread.putExtra("thread", message.thread);
thread.putExtra("filter_archive", true);
thread.putExtra("pinned", true);
thread.putExtra("msgid", message.msgid);
onViewThread(intent);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getSupportFragmentManager(), ex);
}
}.execute(this, args, "message:linked");
return;
}
String action = intent.getAction(); String action = intent.getAction();
if (action != null) { if (action != null) {
if (action.startsWith("unified")) { if (action.startsWith("unified")) {

@ -145,16 +145,6 @@
<action android:name="${applicationId}.REFRESH" /> <action android:name="${applicationId}.REFRESH" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity> </activity>
<activity <activity
@ -198,9 +188,19 @@
<activity <activity
android:name=".ActivityView" android:name=".ActivityView"
android:exported="false" android:exported="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:parentActivityName=".ActivityMain" /> android:parentActivityName=".ActivityMain">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="message" />
<data android:host="${applicationId}" />
</intent-filter>
</activity>
<activity <activity
android:name=".ActivitySearch" android:name=".ActivitySearch"

Loading…
Cancel
Save