some fixes

This commit is contained in:
tom79 2019-12-08 13:57:56 +01:00
parent d40d923f81
commit fbdc245205
5 changed files with 44 additions and 31 deletions

View File

@ -160,13 +160,19 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
AutoCompleteTextView instance_list = dialogView.findViewById(R.id.search_instance);
//Manage download of attachments
RadioGroup radioGroup = dialogView.findViewById(R.id.set_attachment_group);
radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
if( checkedId == R.id.twitter_accounts){
instance_list.setHint(R.string.list_of_twitter_accounts);
}else {
instance_list.setHint(R.string.instance);
}
});
instance_list.setFilters(new InputFilter[]{new InputFilter.LengthFilter(60)});
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String instanceName = instance_list.getText().toString().trim();
String instanceName = instance_list.getText().toString().trim().replace("@","");
new Thread(new Runnable() {
@Override
public void run() {
@ -196,6 +202,8 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "MISSKEY");
} else if (radioGroup.getCheckedRadioButtonId() == R.id.gnu_instance) {
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "GNU");
}else if (radioGroup.getCheckedRadioButtonId() == R.id.twitter_accounts) {
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "NITTER");
}
if (timelines != null && adapter != null) {
List<RemoteInstance> instance = new InstancesDAO(ReorderTimelinesActivity.this, db).getInstanceByName(instanceName);

View File

@ -114,23 +114,22 @@ public class LiveNotificationDelayedService extends Service {
}
}
}
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
myIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setShowWhen(false)
.setContentIntent(pendingIntent)
.setContentTitle(getString(R.string.top_notification))
.setSmallIcon(getNotificationIcon(getApplicationContext()))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
startForeground(1, notification);
if (totalAccount > 0) {
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
myIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setShowWhen(false)
.setContentIntent(pendingIntent)
.setContentTitle(getString(R.string.top_notification))
.setSmallIcon(getNotificationIcon(getApplicationContext()))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
startForeground(1, notification);
startStream();
} else {
stopSelf();

View File

@ -137,21 +137,20 @@ public class LiveNotificationService extends Service implements NetworkStateRece
}
}
}
if (totalAccount > 0) {
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
myIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(getString(R.string.top_notification))
.setContentIntent(pendingIntent)
.setSmallIcon(getNotificationIcon(getApplicationContext()))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
myIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(getString(R.string.top_notification))
.setContentIntent(pendingIntent)
.setSmallIcon(getNotificationIcon(getApplicationContext()))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
startForeground(1, notification);
} else {
startForeground(1, notification);
if (totalAccount == 0) {
stopSelf();
}
}

View File

@ -48,5 +48,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/gnu_instance" />
<RadioButton
android:id="@+id/twitter_accounts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/twitter_accounts" />
</RadioGroup>
</LinearLayout>

View File

@ -1205,4 +1205,6 @@
<string name="action_trends">Trends</string>
<string name="trending_now">Trending now</string>
<string name="talking_about">%d people talking</string>
<string name="twitter_accounts">Twitter accounts</string>
<string name="list_of_twitter_accounts">Twitter usernames space separated</string>
</resources>